Explorar el Código

feat: 更新inventoryTableDetails组件属性,启用价格和折扣总计显示

xieyong hace 1 día
padre
commit
5e0c8349fd

+ 62 - 25
src/BIZComponents/inventoryTableDetails.vue

@@ -9,7 +9,7 @@
       tool-class="ele-toolbar-form"
       class="time-form"
       @columns-change="handleColumnChange"
-    > 
+    >
       <!-- show-summary
       :summary-method="getSummaries" -->
       <template v-slot:technicalDrawings="scope">
@@ -74,7 +74,9 @@
       <template v-slot:toolbar>
         <div class="headbox">
           <div class="pricebox">
-            <span class="amount" v-if="showSummary">数量合计:{{ allQuantity }}</span>
+            <span class="amount" v-if="showSummary"
+              >数量合计:{{ allQuantity }}</span
+            >
             <span class="amount" v-if="isAllPrice">总计:{{ allPrice }}元</span>
             <span class="amount" v-if="isDiscountTotalPrice"
               >优惠后总金额:{{ form.discountTotalPrice }}元</span
@@ -92,11 +94,21 @@
   // import fileMain from '@/components/addDoc/index.vue';
   import { contactQueryByCategoryIdsAPI } from '@/api/bpm/components/supplierManage/contact';
   const dayjs = require('dayjs');
-  import { lbjtList, levelList, pricingWayList, quoteTypeOp } from '@/enum/dict.js';
+  import {
+    lbjtList,
+    levelList,
+    pricingWayList,
+    quoteTypeOp
+  } from '@/enum/dict.js';
   import timeDialog from '@/components/timeDialog/index.vue';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin.js';
   import { getSummaries } from '@/utils/util.js';
-  import { getAllQuantity } from '@/BIZComponents/setProduct.js';
+  import {
+    getAllQuantity,
+    formatPrice,
+    getAllPrice,
+    getAllDiscountPrice
+  } from '@/BIZComponents/setProduct.js';
   import { getInventoryTotalAPI } from '@/api/bpm/components/wms';
 
   export default {
@@ -262,7 +274,7 @@
               return pricingWayList.find((item) => item.id == row.pricingWay)
                 ?.name;
             }
-          },
+          }
         ];
         // 条件显示的新增字段列(仅当quoteType为2时显示)
         const additionalColumns =
@@ -372,7 +384,7 @@
             label: '裁线米段',
             align: 'center',
             slot: 'cuttingLength',
-            isNone: this.quoteType === 2,
+            isNone: this.quoteType === 2
           },
           {
             width: 120,
@@ -380,7 +392,7 @@
             label: '仓库名称',
             slot: 'warehouseName',
             align: 'center',
-            isNone: this.quoteType === 2,
+            isNone: this.quoteType === 2
           },
           {
             width: 120,
@@ -557,8 +569,10 @@
             label: '报价方式',
             align: 'center',
             formatter: (_row, _column, cellValue) => {
-              return this.quoteTypeOp.find((item) => item.value == _row.quoteWay)
-                ?.label || '';
+              return (
+                this.quoteTypeOp.find((item) => item.value == _row.quoteWay)
+                  ?.label || ''
+              );
             }
           },
           {
@@ -864,11 +878,7 @@
     },
     methods: {
       getSummaries(param) {
-        return getSummaries(
-          param,
-          ['saleCount'],
-          ' '
-        );
+        return getSummaries(param, ['saleCount'], ' ');
       },
       async getSupplierObj(productList, queryName) {
         try {
@@ -955,6 +965,13 @@
           this.getStockCount(item) - Number(item.lockQuantity || 0);
         return Number(availableCount.toFixed(4));
       },
+      pickAmount(candidates, fallback) {
+        const hit = candidates.find(
+          (v) => v !== null && v !== undefined && v !== '' && !isNaN(Number(v))
+        );
+        const num = Number(hit === undefined ? fallback : hit);
+        return isNaN(num) ? 0 : formatPrice(num);
+      },
       //修改回显
       async putTableValue(data) {
         let productList =
@@ -963,21 +980,39 @@
           [];
         if (productList) {
           this.form.datasource = productList;
-          this.allPrice =
-            data.totalAmount || data.totalPrice || data?.contractVO?.totalPrice;
-          this.allQuantity = getAllQuantity(this.form.datasource, this.countObj)  
+
+          // 总计:优先用接口返回的总金额,接口未返回时按明细行合计兜底
+          this.allPrice = this.pickAmount(
+            [data.totalAmount, data.totalPrice, data?.contractVO?.totalPrice],
+            getAllPrice(this.form.datasource)
+          );
+
+          this.allQuantity = getAllQuantity(
+            this.form.datasource,
+            this.countObj
+          );
           if (this.isDiscountTotalPrice) {
-            this.form.discountTotalPrice =
-              data.payAmount ||
-              data.discountTotalPrice ||
-              data?.contractVO?.discountTotalPrice;
+            // 优惠后总金额:接口未返回时按明细行折让合计兜底,无折让时等于总计
+            this.form.discountTotalPrice = this.pickAmount(
+              [
+                data.payAmount,
+                data.discountTotalPrice,
+                data?.contractVO?.discountTotalPrice
+              ],
+              Number(getAllDiscountPrice(this.form.datasource)) ||
+                Number(this.allPrice)
+            );
           }
           // this.setDeliveryDays();
 
           if (this.isWms) {
             let codeList = this.form.datasource
-            .filter((item) => item.productCode)
-            .map((item) => item.batchNo ? [item.productCode, item.batchNo].join(',') : item.productCode);
+              .filter((item) => item.productCode)
+              .map((item) =>
+                item.batchNo
+                  ? [item.productCode, item.batchNo].join(',')
+                  : item.productCode
+              );
             //获取仓库库存
             let inventoryTotalList = await getInventoryTotalAPI(codeList);
             this.form.datasource
@@ -985,8 +1020,10 @@
               .forEach((item, index) => {
                 let find =
                   inventoryTotalList.find(
-                                    (key) => (key.code + ',' + key.batchNo == item.productCode+','+item.batchNo)
-                                  ) || {};
+                    (key) =>
+                      key.code + ',' + key.batchNo ==
+                      item.productCode + ',' + item.batchNo
+                  ) || {};
                 this.form.datasource;
                 if (this.showStockCount) {
                   this.$set(

+ 7 - 1
src/views/bpm/handleTask/components/prepayment/detailDialog.vue

@@ -167,10 +167,16 @@
       <headerTitle title="物品清单" size="16px" style="margin-top: 20px"></headerTitle>
       <inventoryTableDetails
         ref="inventoryTableDetailsRef"
-        :isAllPrice="false"
+        :isAllPrice="true"
+        :isDiscountTotalPrice="true"
         :showSummary="true"
         :isSelected="false"
         cacheKeyUrl="eos-prepayment-inventoryTableDetails"
+        :countObj="{
+          countKey: 'totalCount',
+          unitKey: 'saleUnit',
+          unitIdKey: 'saleUnitId'
+        }"
       ></inventoryTableDetails>
 
       <!-- 付款信息 -->