Преглед изворни кода

优化发货单详情页,添加合计费用功能及相关表格配置

yusheng пре 9 месеци
родитељ
комит
45313f9cc4
2 измењених фајлова са 60 додато и 9 уклоњено
  1. 35 0
      src/utils/util.js
  2. 25 9
      src/views/bpm/handleTask/components/saleOrder/invoice/detailDialog.vue

+ 35 - 0
src/utils/util.js

@@ -144,3 +144,38 @@ export function getMaxSameProcessIdCount(arr) {
   }
   }
   return maxCount;
   return maxCount;
 }
 }
+
+//合计费用
+export function getSummaries(param, key, unit) {
+  const { columns, data } = param;
+  const sums = [];
+  columns.forEach((column, index) => {
+    if (index === 0) {
+      sums[index] = '合计';
+      return;
+    }
+
+    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);
+          if (!isNaN(value)) {
+            return prev + curr;
+          } else {
+            return prev;
+          }
+        }, 0);
+        sums[index] += ' ' + unit + '';
+      } else {
+        sums[index] = '';
+      }
+    } else {
+      sums[index] = '';
+    }
+  });
+
+  return sums;
+}

+ 25 - 9
src/views/bpm/handleTask/components/saleOrder/invoice/detailDialog.vue

@@ -123,6 +123,8 @@
       :cache-key="cacheKeyUrl"
       :cache-key="cacheKeyUrl"
       :datasource="detailData.productList"
       :datasource="detailData.productList"
       row-key="id"
       row-key="id"
+      show-summary
+      :summary-method="getSummaries"
     >
     >
       <template v-slot:stockLedger="scope">
       <template v-slot:stockLedger="scope">
         <el-popover placement="right" width="60%" trigger="hover">
         <el-popover placement="right" width="60%" trigger="hover">
@@ -198,6 +200,7 @@
   import detailDialog from '@/views/bpm/outgoingManagement/details.vue';
   import detailDialog from '@/views/bpm/outgoingManagement/details.vue';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import { levelList } from '@/enum/dict.js';
   import { levelList } from '@/enum/dict.js';
+  import { getSummaries } from '@/utils/util.js';
 
 
   export default {
   export default {
     mixins: [dictMixins, tabMixins],
     mixins: [dictMixins, tabMixins],
@@ -209,6 +212,7 @@
     data() {
     data() {
       return {
       return {
         cacheKeyUrl: 'wt-saleManage-invoice-inventoryTableDetail',
         cacheKeyUrl: 'wt-saleManage-invoice-inventoryTableDetail',
+        columnsVersion: 0,
         activeComp: 'main',
         activeComp: 'main',
         tabOptions: [{ key: 'main', name: '发货单详情' }],
         tabOptions: [{ key: 'main', name: '发货单详情' }],
         reviewStatusEnum,
         reviewStatusEnum,
@@ -248,8 +252,14 @@
             label: '刻码',
             label: '刻码',
             align: 'center'
             align: 'center'
           }
           }
-        ],
-        columns: [
+        ]
+      };
+    },
+    computed: {
+
+      columns() {
+        let columnsVersion = this.columnsVersion;
+        return [
           {
           {
             width: 45,
             width: 45,
             type: 'index',
             type: 'index',
@@ -311,16 +321,14 @@
             prop: 'modelKey',
             prop: 'modelKey',
             label: '机型',
             label: '机型',
             showOverflowTooltip: true,
             showOverflowTooltip: true,
-            align: 'center',
-
+            align: 'center'
           },
           },
           {
           {
             minWidth: 120,
             minWidth: 120,
             prop: 'colorKey',
             prop: 'colorKey',
             showOverflowTooltip: true,
             showOverflowTooltip: true,
             label: '颜色',
             label: '颜色',
-            align: 'center',
-
+            align: 'center'
           },
           },
           {
           {
             minWidth: 160,
             minWidth: 160,
@@ -416,7 +424,7 @@
             align: 'center'
             align: 'center'
           },
           },
 
 
-          this.clientEnvironmentId == '4'
+           this.$store.state.user.info.clientEnvironmentId== '4'
             ? {
             ? {
                 width: 120,
                 width: 120,
                 prop: 'blockCount',
                 prop: 'blockCount',
@@ -591,9 +599,10 @@
             slot: 'remark',
             slot: 'remark',
             align: 'center'
             align: 'center'
           }
           }
-        ]
-      };
+        ];
+      }
     },
     },
+
     props: {
     props: {
       businessId: {
       businessId: {
         default: ''
         default: ''
@@ -616,6 +625,13 @@
       }
       }
     },
     },
     methods: {
     methods: {
+      getSummaries(param) {
+        return getSummaries(
+          param,
+          ['saleCount', 'blockCount', 'totalCount'],
+          ' '
+        );
+      },
       changeActive(item) {
       changeActive(item) {
         this.activeComp = item.key;
         this.activeComp = item.key;
         this.$emit('activeCompChange', item.key);
         this.$emit('activeCompChange', item.key);