Răsfoiți Sursa

质检报告

yusheng 3 săptămâni în urmă
părinte
comite
26e88f7b2c

+ 56 - 5
src/views/bpm/handleTask/components/qualityReportApproval/detailDialog.vue

@@ -30,6 +30,7 @@
         v-show="activeComp == 'unqualifiedList'"
         @setQualifiedNumber="setQualifiedNumber"
         :total="basicInfoData.total"
+        @setLossNumber="setLossNumber"
       ></unqualifiedProduct>
 
       <div style="margin-top: 10px" v-if="businessType?.includes('检测报告单')">
@@ -50,7 +51,7 @@
         <el-input
           v-model="basicInfoData.qualifiedNumber"
           placeholder="合格数"
-          style="width: 140px"
+          style="width: 120px"
           disabled
         ></el-input>
 
@@ -59,7 +60,35 @@
           v-model="basicInfoData.noQualifiedNumber"
           placeholder="不合格数"
           disabled
-          style="width: 140px"
+          style="width: 120px"
+        ></el-input>
+        留样数(合格):
+        <el-input
+          v-model="basicInfoData.retainedSampleQuantity"
+          placeholder=" "
+          disabled
+          style="width: 120px"
+        ></el-input>
+        留样数(不合格):
+        <el-input
+          v-model="basicInfoData.retainedSampleUnqualified"
+          placeholder=" "
+          disabled
+          style="width: 120px"
+        ></el-input>
+        消耗数(合格):
+        <el-input
+          v-model="basicInfoData.lossNumber"
+          placeholder=" "
+          disabled
+          style="width: 120px"
+        ></el-input>
+        消耗数(不合格):
+        <el-input
+          v-model="basicInfoData.lossNumberUnqualified"
+          placeholder=" "
+          disabled
+          style="width: 120px"
         ></el-input>
       </div>
     </div>
@@ -209,7 +238,29 @@
           this.fileUrl = `${url}?token=${getToken()}&id=${this.businessId}`;
         }
       },
-
+      setLossNumber({
+        lossNumber,
+        lossNumberUnqualified,
+        retainedSampleQuantity,
+        retainedSampleUnqualified
+      }) {
+        this.$set(
+          this.basicInfoData,
+          'retainedSampleQuantity',
+          retainedSampleQuantity
+        );
+        this.$set(
+          this.basicInfoData,
+          'retainedSampleUnqualified',
+          retainedSampleUnqualified
+        );
+        this.$set(this.basicInfoData, 'lossNumber', lossNumber);
+        this.$set(
+          this.basicInfoData,
+          'lossNumberUnqualified',
+          lossNumberUnqualified
+        );
+      },
       async initUnqualifiedProduct() {
         const data = await getList({
           sourceCode: this.basicInfoData.code
@@ -240,7 +291,7 @@
             this.basicInfoData.qualityResults = 4;
           }
         }
-        if (data.noQualifiedNumber == this.basicInfoData.total) {
+        if (!data.qualifiedNumber ) {
           this.basicInfoData.qualityResults = 2;
         }
         if (data.qualifiedNumber && data.noQualifiedNumber) {
@@ -256,7 +307,7 @@
           document.getElementById('conclusionInput').value;
         const params = {
           id: this.businessId,
-          type:0,
+          type: 0,
           reportTemplateId: this.form.reportTemplateId,
           reportTemplateCode: this.form.reportTemplateCode,
           reportTemplateName: this.form.reportTemplateName,

+ 98 - 13
src/views/bpm/handleTask/components/qualityReportApproval/unqualifiedProduct.vue

@@ -4,10 +4,11 @@
       <ele-pro-table
         ref="table"
         :columns="columns"
-        :datasource="poList"
+       :datasource="poList.filter((item) => item.disposalStatus != 2)"
         :selection.sync="selection"
         :needPage="false"
         row-key="id"
+        
       >
         <!-- 操作列 -->
         <template v-slot:toolbar v-if="showBtn">
@@ -284,7 +285,7 @@
               <el-input-number
                 v-model="singleQuantity"
                 :min="0"
-                :max="total"
+                :max="availableTotal"
                 style="width: 120px"
               ></el-input-number>
             </template>
@@ -449,7 +450,11 @@
         sampleList: [],
         inventoryList: [],
         oldList: [],
-        addSelection: []
+        addSelection: [],
+        retainedSampleQuantity: 0,
+        retainedSampleUnqualified: 0,
+        lossNumber: 0,
+        lossNumberUnqualified: 0
       };
     },
     computed: {
@@ -471,6 +476,14 @@
           return this.allList;
         }
       },
+      // 可用总数 = 总数 - 留样数 - 消耗数
+      availableTotal() {
+        if (!this.sampleList.length) return this.total;
+        const usedQuantity = this.sampleList
+          .filter((item) => item.disposeType == 6 || item.disposeType == 7)
+          .reduce((sum, item) => sum + (item.measureQuantity || 0), 0);
+        return this.total - usedQuantity;
+      },
       // 表格列配置
       columns() {
         const arr = [
@@ -662,19 +675,20 @@
       setQualifiedNumber() {
         let isQualifiedNumber = true;
         let noQualifiedNumber = this.poList
-          .filter((item) => item.disposeType != 5)
+          .filter((item) => item.disposeType != 5 && item.disposalStatus != 2)
           .reduce((acc, cur) => acc + cur.measureQuantity, 0);
 
         if (
           this.poList
             .filter((item) => item.disposeType == 5)
-            .reduce((acc, cur) => acc + cur.measureQuantity, 0) == this.total
+            .reduce((acc, cur) => acc + cur.measureQuantity, 0) ==
+          this.availableTotal
         ) {
           isQualifiedNumber = false;
         }
         this.$emit('setQualifiedNumber', {
           noQualifiedNumber,
-          qualifiedNumber: this.total - noQualifiedNumber,
+          qualifiedNumber: this.availableTotal - noQualifiedNumber,
           isQualifiedNumber
         });
       },
@@ -682,21 +696,39 @@
         if (qualityResults == 1) {
           this.poList = JSON.parse(JSON.stringify(this.oldList));
           this.poList = this.poList.map((item) => {
-            item.disposalStatus = 1;
-            item.disposeType = 5;
+            if (item.disposalStatus != 2) {
+              item.disposalStatus = 1;
+              item.disposeType = 5;
+            }
             return item;
           });
         }
         if (qualityResults == 4) {
-          this.poList = JSON.parse(JSON.stringify(this.inventoryList));
+          this.poList = [
+            ...JSON.parse(JSON.stringify(this.inventoryList)),
+            ...JSON.parse(
+              JSON.stringify(
+                this.oldList.filter((item) => item.disposalStatus == 2)
+              )
+            )
+          ];
           this.poList = this.poList.map((item) => {
-            item.disposalStatus = 1;
-            item.disposeType = 5;
+            if (item.disposalStatus != 2) {
+              item.disposalStatus = 1;
+              item.disposeType = 5;
+            }
             return item;
           });
         }
         if (qualityResults == 2) {
-          this.poList = JSON.parse(JSON.stringify(this.inventoryList));
+          this.poList = [
+            ...JSON.parse(JSON.stringify(this.inventoryList)),
+            ...JSON.parse(
+              JSON.stringify(
+                this.oldList.filter((item) => item.disposalStatus == 2)
+              )
+            )
+          ];
         }
         if (qualityResults == 3) {
           this.poList = JSON.parse(JSON.stringify(this.oldList));
@@ -732,7 +764,7 @@
             0
           );
         }
-        if (poListTotal + selectedTotal > this.total) {
+        if (poListTotal + selectedTotal > this.availableTotal) {
           this.$message.error('选中的计量数量之和加上已有数量不能超过总数');
           return;
         }
@@ -759,6 +791,7 @@
         const arr = await getById(this.id);
         this.oldList = JSON.parse(JSON.stringify(arr.poList));
         this.poList = arr.poList;
+        this.setQualifiedNumber();
       },
 
       //   async getRefluxTask() {
@@ -802,6 +835,7 @@
         if (res.list.length > 0) {
           this.inventoryList = res.list;
         }
+        return;
       },
 
       async queryQualitySamplContent() {
@@ -810,6 +844,57 @@
           size: 1000
         });
         this.sampleList = res.list;
+        [
+          'retainedSampleQuantity',
+          'retainedSampleUnqualified',
+          'lossNumber',
+          'lossNumberUnqualified'
+        ].forEach((key) => {
+          this[key] = 0;
+        });
+        if (this.sampleList.length > 0 && this.inventoryList.length > 0) {
+          const processedList = this.sampleList.filter(
+            (item) => item.disposeType == 6 || item.disposeType == 7
+          );
+          console.log(processedList.filter((item) => item.disposeType == 6),'qwewqe')
+          console.log(processedList.filter((item) => item.disposeType == 7),'123123')
+          processedList.forEach((sampleItem) => {
+            if (sampleItem.disposeType == 6) {
+              sampleItem.qualityResults == 2
+                ? (this.retainedSampleUnqualified += sampleItem.measureQuantity)
+                : (this.retainedSampleQuantity +=
+                    sampleItem.measureQuantity);
+            } else {
+              sampleItem.qualityResults == 2
+                ? (this.lossNumberUnqualified += sampleItem.measureQuantity)
+                : (this.lossNumber += sampleItem.measureQuantity);
+            }
+            const inventoryItem = this.inventoryList.find(
+              (item) => item.sourceId === sampleItem.sourceId
+            );
+            if (inventoryItem) {
+              inventoryItem.measureQuantity = Math.max(
+                0,
+                (inventoryItem.measureQuantity || 0) -
+                  (sampleItem.measureQuantity || 0)
+              );
+            }
+          });
+        }
+        this.$emit('setLossNumber', {
+          lossNumber: this.lossNumber,
+          lossNumberUnqualified: this.lossNumberUnqualified,
+          retainedSampleQuantity: this.retainedSampleQuantity,
+          retainedSampleUnqualified: this.retainedSampleUnqualified
+        });
+        if (this.inventoryList.length == 1 && !this.inventoryList[0].sourceId) {
+          this.inventoryList[0].measureQuantity =
+            this.inventoryList[0].measureQuantity -
+            this.lossNumber -
+            this.lossNumberUnqualified -
+            this.retainedSampleQuantity -
+            this.retainedSampleUnqualified;
+        }
       },
 
       async handleDispose() {