Explorar el Código

优化质检工单合格数计算逻辑,新增样品清单自动更新功能

yusheng hace 9 meses
padre
commit
f0cedb6617

+ 7 - 3
src/views/inspectionWork/components/baseInfo.vue

@@ -517,7 +517,9 @@
       },
       // *** 计算合格数 不合格数
       quantityCalculation(e) {
-        console.log('执行没有');
+        console.log(this.form,'执行没有');
+        // return
+        // return
         let qualifiedNumber = this.form.qualifiedNumber - 0;
         let noQualifiedNumber = this.form.noQualifiedNumber - 0;
         let total = this.form.total - 0;
@@ -537,12 +539,14 @@
         if (e == 'noQualifiedNumber') {
           qualifiedNumber = total - this.form.noQualifiedNumber;
         }
-        console.log(qualifiedNumber, 'qualifiedNumber');
-        console.log(noQualifiedNumber, 'noQualifiedNumber');
+
         let passRate = ((qualifiedNumber / total) * 100).toFixed(2);
         let failureRate = ((noQualifiedNumber / total) * 100).toFixed(2);
         this.form.qualificationRate = passRate + '%';
         this.form.noQualificationRate = failureRate + '%';
+         if (this.form.qualityMode == 1 && this.form.isUnpack == 2) {
+          this.$emit('quantityCalculation', qualifiedNumber);
+        }
         return true;
       },
       deepCopy(obj, hash = new WeakMap()) {

+ 21 - 0
src/views/inspectionWork/components/newQualityContentTabs.vue

@@ -812,6 +812,7 @@
         // return this.sampleList?.slice(start, end);
         return this.sampleList;
       },
+
       // 分页后的质检方案列表
       paginatedSchemeList() {
         // const { currentPage, pageSize } = this.schemePagination;
@@ -844,6 +845,26 @@
       });
     },
     methods: {
+      //合格数量变化设置样品清单 全减并且不拆包才执行
+      setSampleList(val, total) {
+        this.$set(this.sampleList[0], 'measureQuantity', val);
+        let weight = this.form.totalWeight / total;
+
+        let arr = [];
+        for (let i = 0; i < total - val; i++) {
+          let data = JSON.parse(JSON.stringify(this.sampleList[0]));
+          data['measureQuantity'] = 1;
+          data['qualityResults'] = 2;
+          data['id'] = '';
+          data['weight'] = parseFloat(weight).toFixed(2);
+          arr.push(data);
+        }
+        this.$set(this.sampleList[0], 'weight',parseFloat(val*weight).toFixed(2));
+
+        this.sampleList = [this.sampleList[0], ...arr];
+        this.$emit('sampleListChange', this.sampleList);
+
+      },
       async datasource({ page, limit, where }) {
         console.log('执行33');
         const res = await queryQualityInventory({

+ 17 - 1
src/views/inspectionWork/edit.vue

@@ -28,6 +28,7 @@
         @changeNumber="changeNumber"
         @quantityAssignment="quantityAssignment"
         @changeInspectionStandardsModel="changeInspectionStandardsModel"
+        @quantityCalculation="quantityCalculation"
       ></base-info>
       <header-title title="样品信息"></header-title>
       <el-form label-width="110px">
@@ -110,6 +111,7 @@
         @getConditionType="getConditionType"
         @countQualityResults="countQualityResults"
         @setSchemeList="setSchemeList"
+        @sampleListChange="sampleListChange"
       />
     </el-card>
 
@@ -293,6 +295,10 @@
       }
     },
     methods: {
+      //合格与不合格数变化处理逻辑
+      quantityCalculation(val) {
+        this.$refs.tabsRef.setSampleList(val, this.form.total);
+      },
       setInspectionResults(list) {
         this.$nextTick(() => {
           let qualityResults = this.form.qualityResults;
@@ -1254,8 +1260,12 @@
           this.schemeList.toolList
         );
       },
+      sampleListChange(sampleList) {
+        this.sampleList = sampleList;
+      },
       inputWeight(row, index) {
         // 计算所有样本的总重量
+        console.log(this.sampleList);
         const pNum = this.sampleList.reduce((sum, item) => {
           return sum + Number(item.weight || 0);
         }, 0);
@@ -1417,6 +1427,12 @@
         });
         if (index != null) {
           this.$set(this.sampleList, index, list[0]);
+          // this.$set(this.sampleList, index, list[0]);
+          if (this.form.qualityMode == 1 && this.form.isUnpack == 2) {
+            this.activeName = '2';
+            this.countQualityResults();
+            return;
+          }
         } else {
           // this.$set(this.sampleList, null, list);
           this.sampleList = list;
@@ -1425,8 +1441,8 @@
         this.activeName = '2';
         // *** 选完批量质检调用
         // this.countQualityResults();
-        console.log('质检没有 2');
         this.$refs.baseInfoRefs.quantityCalculation('noQualifiedNumber');
+        console.log('质检没有 2');
       },
       // 批量质检
       batchQuality(index, row, type) {