Pārlūkot izejas kodu

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-eom into dev

xieyong 1 mēnesi atpakaļ
vecāks
revīzija
e7f91f4163

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

@@ -1863,9 +1863,19 @@
       validateForm(callback) {
         //开始表单校验
         this.$refs.form.validate((valid, obj) => {
-          // 找出所有发货数量超过订单剩余数量的产品
-          const exceededItems = this.form.datasource.filter(
-            (item) => Number(item.totalCount) > item.notGenerateSendCount
+          // 同一订单产品可能拆成多条发货明细,删除明细后只按当前有效行汇总校验。
+          const groups = this.form.datasource.reduce((result, item) => {
+            const key = item.orderProductId
+              ? `order:${item.orderProductId}`
+              : `product:${item.productCode}|${item.batchNo || ''}|${item.colorKey || ''}|${item.modelType || ''}`;
+            const group = result[key] || { totalCount: 0, remainingCount: Number(item.notGenerateSendCount) || 0, productCode: item.productCode };
+            group.totalCount += Number(item.totalCount) || 0;
+            group.remainingCount = Math.max(group.remainingCount, Number(item.notGenerateSendCount) || 0);
+            result[key] = group;
+            return result;
+          }, {});
+          const exceededItems = Object.values(groups).filter(
+            (item) => item.totalCount > item.remainingCount
           );
           // 退货单退货不校验数量,实物赔偿无法计算
           if (
@@ -1878,9 +1888,8 @@
               .map((item) => item.productCode)
               .join('、');
             this.$message.warning(`${productNames} 的发货数量大于订单剩余数量`);
-            if (this.isTotalCount == 1) {
-              callback(false);
-            }
+            callback(false);
+            return;
           }
           if (obj) {
             let messages = Object.keys(obj).map((key) => obj[key][0]);