Эх сурвалжийг харах

fix: 优化未开票金额计算逻辑,直接使用接口返回值,简化代码

xieyong 1 сар өмнө
parent
commit
1eff513f53

+ 2 - 21
src/views/financialManage/invoiceManage/components/addOrEditDialogNew.vue

@@ -1191,24 +1191,11 @@
         const sameKeyItems = this.form.relatedList.filter((d) => d.sourceCode === item.key);
         console.log('sameKeyItems~~~', sameKeyItems);
 
-        // 从关联物品清单中取该订单的"未开票金额"和"本次开票金额"(per-detail 字段)
-        const tableInfoRef = this.$refs.tableInfoRef;
-        let unInvoiceAmount = 0;
-        let invoiceAmount = 0;
-        if (tableInfoRef && tableInfoRef.tableForm && tableInfoRef.tableForm.detailList) {
-          const matchedDetail = tableInfoRef.tableForm.detailList.find(
-            (d) => d.key === item.key
-          );
-          if (matchedDetail) {
-            unInvoiceAmount = parseFloat(matchedDetail.unInvoiceAmount) || 0;
-            invoiceAmount = parseFloat(matchedDetail.invoiceAmount) || 0;
-          }
-        }
-
         let remainingTotal = sum;
         const lastIndex = sameKeyItems.length - 1;
 
         // 从上到下分配 sum 给相同订单号的数据,多余数量放在最后一个
+        // paymentItem.unInvoiceAmount 直接使用接口返回值,不再被关联物品清单覆盖
         sameKeyItems.forEach((paymentItem, index) => {
           if (remainingTotal <= 0) {
             paymentItem.invoiceAmount = 0;
@@ -1223,19 +1210,13 @@
           }
         });
 
-        // 来源清单的未开票金额 = 关联物品清单的未开票金额 - 本次开票金额
-        const remainingUnInvoice = (unInvoiceAmount - invoiceAmount).toFixed(2);
-        sameKeyItems.forEach((paymentItem) => {
-          this.$set(paymentItem, 'unInvoiceAmount', remainingUnInvoice);
-        });
-
         this.updateInvoiceAmount();
         console.log('分配完成后的 sameKeyItems:', sameKeyItems);
       },
 
       updatePlanPaymentAmount(item) {
         console.log('item~~~', item);
-        item.unInvoiceAmount = item.planPaymentAmount - item.invoicedAmount;
+        // unInvoiceAmount 不再本地计算,直接使用接口返回的值
         // 更新关联物品清单中的 defaultAmountTotalPrice
         const tableInfoRef = this.$refs.tableInfoRef;
         if (tableInfoRef && item.sourceCode) {