Bläddra i källkod

fix(发票管理): 修复发票金额分配逻辑并启用表单验证

liujt 4 månader sedan
förälder
incheckning
aa52f7ea1b

+ 9 - 9
src/views/financialManage/invoiceManage/components/collectionPlanDialog.vue

@@ -552,7 +552,7 @@
           this.enterprisePage = [];
           this.enterprisePage.push(...res.list);
           this.searchForm.initiatorId = this.enterprisePage[0].id;
-          // this.reload(this.searchForm);
+          this.reload(this.searchForm);
         });
       },
       getEnterprise(val) {
@@ -617,14 +617,14 @@
         //   this.$message.warning('先款后票的计划需要付款后再开票!');
         //   return
         // }
-        // if(invoiceStatus.includes(2)) {
-        //   this.$message.warning('请选择未开票的计划!');
-        //   return
-        // }
-        // if(this.selection.length == 0 || new Set(customerIds).size != 1 || new Set(initiatorIds).size != 1) {
-        //   this.$message.warning('请选择相同客户和销售方的计划!');
-        //   return
-        // }
+        if(invoiceStatus.includes(2)) {
+          this.$message.warning('请选择未开票的计划!');
+          return
+        }
+        if(this.selection.length == 0 || new Set(customerIds).size != 1 || new Set(initiatorIds).size != 1) {
+          this.$message.warning('请选择相同客户和销售方的计划!');
+          return
+        }
 
         this.$emit('getPlanData', this.selection)
         this.handleClose()

+ 28 - 24
src/views/financialManage/invoiceManage/components/tableInfoNew.vue

@@ -336,7 +336,7 @@
       // this.tableForm = this.form;
     },
     methods: {
-      convertToArrayFormat(data) {
+      convertToArrayFormat(data, type) {
           const result = [];
           Object.keys(data.productMap).forEach(key => {
             console.log('key!!!', key);
@@ -352,31 +352,35 @@
                 amountTotalPrice: amountTotalPrice,
                 defaultAmountTotalPrice: defaultAmountTotalPrice,
                 ...detail,
-                invoiceAmount: '',
+                invoiceAmount: detail.invoiceAmount || 0,
               });
             });
           });
+
+          if(type == 'setValue') {
+            // Allocate defaultAmountTotalPrice to invoiceAmount for each key group
+            const uniqueKeys = [...new Set(result.map(item => item.key))];
+            uniqueKeys.forEach(key => {
+              const sameKeyItems = result.filter(item => item.key === key);
+              if (sameKeyItems.length > 0) {
+                const defaultAmountTotalPrice = parseFloat(sameKeyItems[0].defaultAmountTotalPrice) || 0;
+                let remainingTotal = defaultAmountTotalPrice;
+                
+                sameKeyItems.forEach(item => {
+                  if (remainingTotal <= 0) {
+                    item.invoiceAmount = 0;
+                  } else {
+                    const unInvoiceAmount = parseFloat(item.unInvoiceAmount) || 0;
+                    const allocateAmount = Math.min(remainingTotal, unInvoiceAmount);
+                    item.invoiceAmount = allocateAmount.toFixed(2);
+                    remainingTotal -= allocateAmount;
+                  }
+                });
+              }
+            });
+          }
+          
           
-          // Allocate defaultAmountTotalPrice to invoiceAmount for each key group
-          const uniqueKeys = [...new Set(result.map(item => item.key))];
-          uniqueKeys.forEach(key => {
-            const sameKeyItems = result.filter(item => item.key === key);
-            if (sameKeyItems.length > 0) {
-              const defaultAmountTotalPrice = parseFloat(sameKeyItems[0].defaultAmountTotalPrice) || 0;
-              let remainingTotal = defaultAmountTotalPrice;
-              
-              sameKeyItems.forEach(item => {
-                if (remainingTotal <= 0) {
-                  item.invoiceAmount = 0;
-                } else {
-                  const unInvoiceAmount = parseFloat(item.unInvoiceAmount) || 0;
-                  const allocateAmount = Math.min(remainingTotal, unInvoiceAmount);
-                  item.invoiceAmount = allocateAmount.toFixed(2);
-                  remainingTotal -= allocateAmount;
-                }
-              });
-            }
-          });
           
           return result;
       },
@@ -432,14 +436,14 @@
       putValue(data) {
         let tempData = JSON.parse(JSON.stringify(data));
         console.log('tableInfoNew putValue', tempData);
-        tempData.detailList = this.convertToArrayFormat(tempData);
+        tempData.detailList = this.convertToArrayFormat(tempData, 'putValue');
         console.log('data.detailList', data.detailList);
         this.tableForm = tempData;
         console.log('tableInfoNew putValue~~~', this.tableForm);
       },
       setValue(data) {
         let tempData = JSON.parse(JSON.stringify(data));
-        tempData.detailList = this.convertToArrayFormat(tempData);
+        tempData.detailList = this.convertToArrayFormat(tempData, 'setValue');
         console.log('tempData.detailList', tempData.detailList);
         this.tableForm = tempData;
       },