Просмотр исходного кода

fix(inspectionProjectReport): 添加损耗数同步逻辑,确保合格/不合格数一致性

xieyong 1 неделя назад
Родитель
Сommit
5879b6b44d
1 измененных файлов с 27 добавлено и 0 удалено
  1. 27 0
      src/views/inspectionWork/components/inspectionProjectReport.vue

+ 27 - 0
src/views/inspectionWork/components/inspectionProjectReport.vue

@@ -825,6 +825,22 @@
         // this.initData();
       },
 
+      //当 qms_defaultDisposalType 为 true 时,损耗数自动同步合格/不合格数
+      syncLossNumber(row, index) {
+        if (!this.qms_defaultDisposalType) return;
+        this.$set(
+          this.tableData[index],
+          'lossNumber',
+          Number(row.qualifiedQuantity) || 0
+        );
+        this.$set(
+          this.tableData[index],
+          'lossNumberUnqualified',
+          Number(row.noQualifiedQuantity) || 0
+        );
+        this.initData();
+      },
+
       async open({ workData, row, list }, type, pageName) {
         this.tableData = [];
         this.pageName = pageName;
@@ -884,6 +900,13 @@
           // }
         }
 
+        //当 qms_defaultDisposalType 为 true 时,初始化时同步损耗数
+        if (this.qms_defaultDisposalType) {
+          this.tableData.forEach((item, index) => {
+            this.syncLossNumber(item, index);
+          });
+        }
+
         this.visible = true;
       },
       handleOneKeyQualified() {
@@ -978,6 +1001,8 @@
           if (type == 'noQualifiedQuantity' && item[type] > 0) {
             this.$set(this.tableData[index], 'qualityResults', 2);
           }
+          //当 qms_defaultDisposalType 为 true 时,损耗数自动同步合格/不合格数
+          this.syncLossNumber(item, index);
         }
         //损耗数
         if (type == 'lossNumber' || type == 'lossNumberUnqualified') {
@@ -1016,6 +1041,8 @@
             this.isQualifiedQuantity(row, index, 'noQualifiedQuantity');
           }
         }
+        //当 qms_defaultDisposalType 为 true 时,损耗数自动同步合格/不合格数
+        this.syncLossNumber(row, index);
       }
     },
     watch: {