Sfoglia il codice sorgente

修改首件两检的判断

695593266@qq.com 5 mesi fa
parent
commit
f8fde6331a

+ 72 - 44
src/views/produce/components/qualityInspection/components/selfInspectionReporting.vue

@@ -203,6 +203,14 @@
         :selection.sync="selection"
         style="width: 100%"
       >
+        <template v-slot:toolbar>
+          <el-button
+            type="primary"
+            @click="addInspection"
+            v-if="form.items.length == 0"
+            >选择质检方案</el-button
+          >
+        </template>
         <template v-slot:status="{ row }">
           <el-tag v-if="row.status == 0">待自检</el-tag>
           <el-tag v-if="row.status == 1">请托中</el-tag>
@@ -341,6 +349,11 @@
       <el-button type="primary" @click="saveSelf(1)">提交</el-button>
       <el-button type="primary" @click="saveSelf(2)">保存</el-button>
     </span>
+
+    <inspectionTemplatePop
+      ref="inspectionTemplateRef"
+      @changeSel="changeSel"
+    ></inspectionTemplatePop>
   </ele-modal>
 </template>
 
@@ -348,11 +361,14 @@
   import {
     getDetail,
     selfInspectionReport,
-    specialInspectionReport
+    specialInspectionReport,
+    addInspectionsTerm
   } from '@/api/produce/qualityInspection.js';
   import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import inspectionTemplatePop from '@/views/produce/components/bom/qualityTesting/inspectionTemplate.vue';
+  import { getTemplateById } from '@/api/produce/bom.js';
   export default {
-    components: { deptSelect },
+    components: { deptSelect, inspectionTemplatePop },
     data() {
       return {
         visible: false,
@@ -364,7 +380,8 @@
           toolingQualifiedValid: 1,
           measuringToolValid: 1,
           ncProgramValid: 1,
-          materialSemiFinishedValid: 1
+          materialSemiFinishedValid: 1,
+          items: []
         },
         rules: {
           firstArticleCode: [
@@ -539,23 +556,6 @@
         });
       },
 
-      // applyStatus(actionType) {
-      //   if (actionType !== 1) return;
-
-      //   const statusMap = {
-      //     1: { form: 2, item: 2 },
-      //     2: { form: 3, item: 3 }
-      //   };
-
-      //   const config = statusMap[this.type];
-      //   if (!config) return;
-
-      //   this.form.status = config.form;
-      //   this.form.items.forEach((item) => {
-      //     item.status = config.item;
-      //   });
-      // },
-
       applyStatus(actionType) {
         if (actionType !== 1) return;
 
@@ -577,37 +577,60 @@
 
         const { resultField, itemStatus, formStatus } = config;
 
+        const allPass = this.form.items.every((item) => item[resultField] == 1);
+
+        if (!allPass) return;
+
         this.form.items.forEach((item) => {
-          if (item[resultField] === 1) {
-            item.status = itemStatus;
-          }
+          item.status = itemStatus;
         });
 
-        const allPass = this.form.items.every(
-          (item) => item[resultField] === 1
-        );
+        this.form.status = formStatus;
 
-        if (allPass) {
-          this.form.status = formStatus;
-        }
+        // this.form.items.forEach((item) => {
+        //   if (item[resultField] == 1) {
+        //     item.status = itemStatus;
+        //   }
+        // });
+
+        // const allPass = this.form.items.every(
+        //   (item) => item[resultField] == 1
+        // );
+
+        // if (allPass) {
+        //   this.form.status = formStatus;
+        // }
+      },
+
+      addInspection() {
+        this.$refs.inspectionTemplateRef.open('first');
+      },
+
+      async changeSel({ id }) {
+        const { data } = await getTemplateById(id);
+
+        data.inspectionItemVOList.forEach((item) => {
+          item.qualitySchemeTemplateCode = data.qualitySchemeTemplateCode;
+          item.qualitySchemeTemplateName = data.qualitySchemeTemplateName;
+        });
+
+        this.isAdd = true;
+        await this.addInspectionsTerm(data.inspectionItemVOList);
       },
 
-      // validateCheckResult() {
-      //   const map = {
-      //     1: ['selfCheckResult', '请填写完整自检结果后再提交'],
-      //     2: ['specialCheckResult', '请填写完整专检结果后再提交']
-      //   };
+      async addInspectionsTerm(items) {
+        const payload = this.buildInspectionPayload(items);
+        const res = await addInspectionsTerm(payload);
 
-      //   const config = map[this.type];
-      //   if (!config) return true;
+        this.form = res;
+      },
 
-      //   const [field, msg] = config;
-      //   if (this.form.items.some((item) => !item[field])) {
-      //     this.$message.warning(msg);
-      //     return false;
-      //   }
-      //   return true;
-      // },
+      buildInspectionPayload(items) {
+        return {
+          ...this.item,
+          items
+        };
+      },
 
       validateCheckResult() {
         const map = {
@@ -669,7 +692,12 @@
             data[item.key] = 1;
           }
         });
-        this.form = { ...data };
+        // this.form = { ...data };
+        this.form = {
+          ...this.form,
+          ...data,
+          items: data.items || []
+        };
       }
     }
   };

+ 0 - 3
src/views/produce/components/qualityInspection/components/selfInspectionRequest.vue

@@ -376,9 +376,6 @@
         const res = await addInspectionsTerm(payload);
 
         this.list = res.items;
-
-        
-
       },
 
       deepCopy(obj, hash = new WeakMap()) {