瀏覽代碼

优化质检工单合格率计算逻辑,新增selectResult方法实现抽检模式下的自动更新

yusheng 9 月之前
父節點
當前提交
e4d9ecea15
共有 2 個文件被更改,包括 23 次插入4 次删除
  1. 13 4
      src/views/inspectionWork/components/baseInfo.vue
  2. 10 0
      src/views/inspectionWork/edit.vue

+ 13 - 4
src/views/inspectionWork/components/baseInfo.vue

@@ -233,6 +233,7 @@
               placeholder="请选择"
               style="width: 100%"
               :disabled="showArrange == '0'"
+              @change="selectResult"
             >
               <el-option label="合格" :value="1" />
               <el-option label="不合格" :value="2" />
@@ -515,8 +516,8 @@
           this.form[val].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
       },
       // *** 计算合格数 不合格数
-      quantityCalculation(e,noSetSampleList) {
-        console.log(this.form,'执行没有');
+      quantityCalculation(e, noSetSampleList) {
+        console.log(this.form, '执行没有');
         // return
         // return
         let qualifiedNumber = this.form.qualifiedNumber - 0;
@@ -543,7 +544,11 @@
         let failureRate = ((noQualifiedNumber / total) * 100).toFixed(2);
         this.form.qualificationRate = passRate + '%';
         this.form.noQualificationRate = failureRate + '%';
-         if (this.form.qualityMode == 1 && this.form.isUnpack == 2&&!noSetSampleList) {
+        if (
+          this.form.qualityMode == 1 &&
+          this.form.isUnpack == 2 &&
+          !noSetSampleList
+        ) {
           this.$emit('quantityCalculation', qualifiedNumber);
         }
         return true;
@@ -703,8 +708,12 @@
           this.$emit('table2');
         }
       },
+      //抽检需要重新计算
       selectResult() {
-        this.$emit('quantityAssignment');
+        console.log(this.form.qualityMode,'this.form.qualityMode')
+        if (this.form.qualityMode == 2) {
+          this.$emit('quantityAssignment');
+        }
       }
     }
   };

+ 10 - 0
src/views/inspectionWork/edit.vue

@@ -431,6 +431,16 @@
         }
         this.$set(this.form, 'qualifiedNumber', qualifiedNumber);
         this.$set(this.form, 'noQualifiedNumber', noQualifiedNumber);
+        this.$set(
+          this.form,
+          'qualificationRate',
+          ((qualifiedNumber / total) * 100).toFixed(2)
+        );
+        this.$set(
+          this.form,
+          'noQualificationRate',
+          ((noQualifiedNumber / total) * 100).toFixed(2)
+        );
       },
       //切换检验方式
       changeModel(val, flag) {