Pārlūkot izejas kodu

表格合计功能优化:支持多字段合计及单位自定义,完善库存表格合计显示

yusheng 9 mēneši atpakaļ
vecāks
revīzija
2de8a2b2b6

+ 7 - 4
src/utils/util.js

@@ -47,7 +47,7 @@ export function copyObj(obj) {
   return newobj;
 }
 //合计费用
-export function getSummaries(param,key) {
+export function getSummaries(param,key,unit) {
   const { columns, data } = param;
   const sums = [];
   columns.forEach((column, index) => {
@@ -55,8 +55,11 @@ export function getSummaries(param,key) {
       sums[index] = '合计';
       return;
     }
-    if (column.property == key) {
-      const values = data.map((item) => Number(item['cost']));
+
+    if (key.includes(column.property)) {
+      const values = data.map((item) => Number(item[column.property]));
+          console.log(values)
+
       if (!values.every((value) => isNaN(value))) {
         sums[index] = values.reduce((prev, curr) => {
           const value = Number(curr);
@@ -66,7 +69,7 @@ export function getSummaries(param,key) {
             return prev;
           }
         }, 0);
-        sums[index] += ' ';
+        sums[index] += ' '+unit+'';
       } else {
         sums[index] = '';
       }

+ 1 - 1
src/views/marketManagem/components/companyList.vue

@@ -209,7 +209,7 @@ export default {
   mounted() {},
   methods: {
     getSummaries(param) {
-      return getSummaries(param, 'cost');
+      return getSummaries(param, ['cost'],'元');
     },
     //删除任务信息数据
     handleDelInfo(index) {

+ 2 - 1
src/views/marketManagem/components/conferenceList.vue

@@ -279,7 +279,8 @@ export default {
   mounted() {},
   methods: {
     getSummaries(param) {
-      return getSummaries(param, 'cost');
+           return getSummaries(param, ['cost'],'元');
+
     },
     //删除任务信息数据
     handleDelInfo(index) {

+ 2 - 1
src/views/marketManagem/components/mealList.vue

@@ -292,7 +292,8 @@ export default {
   mounted() {},
   methods: {
     getSummaries(param) {
-      return getSummaries(param, 'cost');
+           return getSummaries(param, ['cost'],'元');
+
     },
     //删除任务信息数据
     handleDelInfo(index) {

+ 2 - 1
src/views/marketManagem/components/putUpList.vue

@@ -225,7 +225,8 @@ export default {
   mounted() {},
   methods: {
     getSummaries(param) {
-      return getSummaries(param, 'cost');
+         return getSummaries(param, ['cost'],'元');
+
     },
     //删除任务信息数据
     handleDelInfo(index) {

+ 2 - 1
src/views/marketManagem/components/souvenirList.vue

@@ -273,7 +273,8 @@ export default {
   mounted() {},
   methods: {
     getSummaries(param) {
-      return getSummaries(param, 'cost');
+               return getSummaries(param, ['cost'],'元');
+
     },
     //删除任务信息数据
     handleDelInfo(index) {

+ 2 - 1
src/views/marketManagem/components/taskInfoTable.vue

@@ -357,7 +357,8 @@
 
     methods: {
       getSummaries(param) {
-        return getSummaries(param, 'cost');
+             return getSummaries(param, ['cost'],'元');
+
       },
       //新增任务信息数据
       handleAddInfo() {

+ 2 - 1
src/views/marketManagem/components/visitList.vue

@@ -277,7 +277,8 @@ export default {
   mounted() {},
   methods: {
     getSummaries(param) {
-      return getSummaries(param, 'cost');
+            return getSummaries(param, ['cost'],'元');
+
     },
     //删除任务信息数据
     handleDelInfo(index) {

+ 16 - 5
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -8,7 +8,10 @@
       class="time-form"
       @columns-change="handleColumnChange"
       :cache-key="cacheKeyUrl"
-      :maxHeight="350"
+      height="350"
+      full-height="calc(100vh - 76px)"
+      show-summary
+      :summary-method="getSummaries"
     >
       <!-- 表头工具栏 -->
       <template v-slot:toolbar>
@@ -307,7 +310,7 @@
             placeholder="请输入"
             type="number"
             :min="0"
-            @input="changeCount(scope.row, scope.$index)"
+            @input="changeCount(scope.row, scope.$index,false)"
           >
           </el-input>
         </el-form-item>
@@ -442,6 +445,7 @@
   import { levelList } from '@/enum/dict.js';
   import { changeCount } from '@/BIZComponents/setProduct.js';
   import { parameterGetByCode } from '@/api/main/index.js';
+  import { getSummaries } from '@/utils/util.js';
 
   export default {
     mixins: [dictMixins, getDynamicsColumns, tabMixins],
@@ -560,7 +564,7 @@
       columns() {
         return [
           {
-            width: 45,
+            width: 60,
             type: 'index',
             columnKey: 'index',
             align: 'center',
@@ -960,6 +964,13 @@
         this.$store.state.user.info.clientEnvironmentId;
     },
     methods: {
+      getSummaries(param) {
+        return getSummaries(
+          param,
+          ['saleCount', 'blockCount', 'totalCount'],
+          ' '
+        );
+      },
       downloadFile(file) {
         getFile({ objectName: file.storePath }, file.name);
       },
@@ -1059,7 +1070,7 @@
         );
       },
       //改变数量
-      changeCount(row, index, isBlockCount) {
+      changeCount(row, index, isBlockCount=true) {
         this.$set(
           this.form,
           'datasource[' + index + ']',
@@ -1190,7 +1201,7 @@
               (Number(row.blockCount) * modelLong * modeWide * modeHight) /
               1000000;
             row.saleCount = row.totalCount;
-            this.changeCount(row, index, true);
+            this.changeCount(row, index, false);
           }
         }
       },

+ 15 - 6
src/views/saleManage/saleOrder/invoice/components/inventoryTableDetails.vue

@@ -7,7 +7,10 @@
     row-key="id"
     @columns-change="handleColumnChange"
     :cache-key="cacheKeyUrl"
-    :maxHeight="350"
+    height="350"
+    full-height="calc(100vh - 76px)"
+    show-summary
+    :summary-method="getSummaries"
   >
     <template v-slot:technicalDrawings="{ row }">
       <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
@@ -35,6 +38,7 @@
   import getDynamicsColumns from '@/mixins/getDynamicsColumns';
   import { reviewStatusEnum, lbjtList } from '@/enum/dict';
   import { levelList } from '@/enum/dict.js';
+  import { getSummaries } from '@/utils/util.js';
 
   export default {
     mixins: [dictMixins, tabMixins, getDynamicsColumns],
@@ -60,7 +64,7 @@
         let columnsVersion = this.columnsVersion;
         return [
           {
-            width: 45,
+            width: 60,
             type: 'index',
             columnKey: 'index',
             align: 'center',
@@ -127,16 +131,14 @@
             prop: 'modelKey',
             label: '机型',
             showOverflowTooltip: true,
-            align: 'center',
-
+            align: 'center'
           },
           {
             minWidth: 120,
             prop: 'colorKey',
             showOverflowTooltip: true,
             label: '颜色',
-            align: 'center',
-
+            align: 'center'
           },
           {
             minWidth: 160,
@@ -417,6 +419,13 @@
       }
     },
     methods: {
+      getSummaries(param) {
+        return getSummaries(
+          param,
+          ['saleCount', 'blockCount', 'totalCount'],
+          ' '
+        );
+      },
       //修改回显
       putTableValue(data) {
         console.log(data, 'data');