From a6a4092ce1899bd020bc15cff43f0977c87e6be8 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期五, 15 九月 2023 16:20:25 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.22:9001/r/mom-before

---
 src/components/view/rawInsDetail.vue |  134 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 104 insertions(+), 30 deletions(-)

diff --git a/src/components/view/rawInsDetail.vue b/src/components/view/rawInsDetail.vue
index 93ad190..a028670 100644
--- a/src/components/view/rawInsDetail.vue
+++ b/src/components/view/rawInsDetail.vue
@@ -12,7 +12,7 @@
             >鎻� 浜�</el-button
           >
           <el-button
-            icon="el-icon-download"
+            icon="el-icon-back"
             @click="
               () => {
                 goBack();
@@ -51,7 +51,7 @@
               <el-input
                 v-if="detailId !== null"
                 :disabled="detailId !== null"
-                v-model="detailInfo.rname"
+                v-model="detailInfo.name"
               ></el-input>
               <el-input
                 v-else
@@ -64,7 +64,7 @@
               <el-input
                 v-if="detailId !== null"
                 :disabled="detailId !== null"
-                v-model="detailInfo.rcode"
+                v-model="detailInfo.code"
               ></el-input>
               <el-input
                 v-else
@@ -118,7 +118,7 @@
           <el-col :span="7">
             <el-form-item label="渚涘簲鍟嗗悕绉�:">
               <el-input
-                :placeholder="detailId !== null ? '' : '璇疯緭鍏ユ楠屾暟閲�'"
+                :placeholder="detailId !== null ? '' : '璇疯緭鍏ヤ緵搴斿晢鍚嶇О'"
                 :disabled="detailId !== null"
                 v-model="detailInfo.supplier"
               ></el-input>
@@ -190,9 +190,11 @@
             <el-input v-else v-model="scope.row.rpUnit" disabled></el-input>
           </template>
         </el-table-column>
-        <el-table-column prop="required" label="鏍囧噯" min-width="150">
+        <el-table-column prop="required" label="鏍囧噯鍊�" min-width="150">
           <template slot-scope="scope">
             <el-input
+              :disabled="detailId != null"
+              @blur="assertTest(scope.row)"
               v-model="scope.row.required"
               placeholder="璇疯緭鍏ユ爣鍑嗗��"
             ></el-input>
@@ -201,6 +203,8 @@
         <el-table-column prop="internal" label="鍐呮帶鍊�" min-width="150">
           <template slot-scope="scope">
             <el-input
+              @blur="assertTest(scope.row)"
+              :disabled="detailId != null"
               v-model="scope.row.internal"
               placeholder="璇疯緭鍏ュ唴鎺у��"
             ></el-input>
@@ -272,11 +276,11 @@
       <el-table :data="conclusionTable" style="100%">
         <el-table-column prop="code" label="鐗╂枡缂栧彿"> </el-table-column>
         <el-table-column prop="name" label="鐗╂枡鍚嶇О"> </el-table-column>
-        <el-table-column prop="names" label="妫�楠屽憳">
+        <el-table-column v-if="detailId != null" prop="uName" label="妫�楠屽憳">
           <template slot-scope="scope">
             <span
-              v-for="item in scope.row.names"
-              :key="item && item.userName"
+              v-for="item in scope.row.uName"
+              :key="item && item.uName"
               :style="{ marginRight: '8px' }"
               >{{ item }}</span
             >
@@ -348,6 +352,7 @@
 </template>
 
 <script>
+import { triggerRef } from "vue";
 import RawIns from "./raw-ins.vue";
 export default {
   components: { RawIns },
@@ -357,9 +362,8 @@
     this.detailInfo = {};
     if (this.detailId) {
       this.getDetailInfo();
-    } else {
-      this.getOptions();
     }
+    this.getOptions();
   },
   mounted() {},
   computed: {
@@ -367,8 +371,8 @@
       const conclusion = {};
       conclusion.name = this.detailInfo.name;
       conclusion.code = this.detailInfo.code;
-      conclusion.names = [
-        ...new Set(this.projectTable.map(item => item.userName))
+      conclusion.uName = [
+        ...new Set(this.projectTable.map(item => item.uName))
       ];
       if (
         this.projectTable.filter(item => item.testState === null).length ===
@@ -382,6 +386,7 @@
       } else {
         conclusion.testState = 1;
       }
+      console.log([conclusion]);
       return [conclusion];
     }
   },
@@ -409,7 +414,10 @@
         label: "name"
       },
       nodeData: "", // node鐐瑰嚮淇濆瓨褰撳墠鐐瑰嚮鏁版嵁
-      clickSelectSaveIndex: "" // 鐐瑰嚮閫夋嫨瀛樺偍鍒楄〃绱㈠紩
+      clickSelectDevice: {
+        index: "", // 鐐瑰嚮閫夋嫨瀛樺偍褰撳墠琛岀储寮�
+        rpId: "" // 鐐瑰嚮閫夋嫨瀛樺偍褰撳墠琛岄」鐩甀d
+      }
     };
   },
   watch: {
@@ -418,6 +426,23 @@
     }
   },
   methods: {
+    assertTest(row){
+      let fuArr=['>', '<', '=']
+      if(!fuArr.includes(row.required[0])){
+        this.$message({
+                    message: "鏍囧噯鍊糩"+row.required+"]鏍煎紡棣栦綅搴斿寘鍚�>,<鎴栬��=",
+                    type: 'warning'
+                });
+                return
+      }
+      if(!fuArr.includes(row.internal[0])){
+        this.$message({
+                    message: "鍐呮帶鍊糩"+row.internal+"]鏍煎紡棣栦綅搴斿寘鍚�>,<鎴栬��=",
+                    type: 'warning'
+                });
+                return
+      }
+    },
     // 璁惧鏍戣繃婊ゆ悳绱�
     filterNode(value, data) {
       if (!value) return true;
@@ -434,7 +459,12 @@
           this.detailInfo = res.data;
           this.projectTable = res.data.children;
           this.projectTable.forEach(i => {
-            i.testValueList = i.testValue.split(",");
+            // 瑙e喅閲嶆柊璧嬪�兼棤娉曠紪杈戞搷浣�
+            if (i.testValue == null) {
+              this.$set(i, "testValueList", []);
+            } else {
+              this.$set(i, "testValueList", i.testValue.split(","));
+            }
             // 鍙栨渶闀跨殑鍒楄〃鏁�
             if (i.testValueList.length > this.empiricalValueAdd) {
               this.empiricalValueAdd = i.testValueList.length;
@@ -445,19 +475,45 @@
     },
     // 鏂板妫�楠屽崟
     async addNewRawInspect() {
+      //TODO:
+      console.log(this.projectTable);
+      if(this.projectTable.length>0){
+        let filterTable= this.projectTable.filter(item=>{
+        return item.required===''||item.internal===''||
+        item.required===null||item.internal===null||item.name===''
+        })
+        if(filterTable.length>0) {
+          this.$message({
+                    message: "椤圭洰鍚嶇О锛屾爣鍑嗗�煎拰鍐呮帶鍊间笉鑳戒负绌猴紒",
+                    type: 'warning'
+                });
+          return
+        }
+      }
       this.projectTable.forEach(i => {
         // 灏嗗垪琛ㄨ浆鎹负瀛楃涓�
         i.testValue = i.testValueList.join(",");
       });
       this.detailInfo.rawInsProducts = this.projectTable;
-      const res = await this.$axios.post(
+      this.$axios.post(
         this.$api.url.addRawInspects,
         { ...this.detailInfo },
         { headers: { "Content-Type": "application/json" } }
-      );
-      this.detailId = res.data;
-      this.getDetailInfo();
-      this.$message.success(res.message);
+      ).then(res=>{
+        console.log(res);
+        if(res.code=="201"){
+          this.$message({
+                    message: res.message,
+                    type: 'warning'
+                });
+         return
+        }else{
+          // this.detailId = res.data;
+          // this.getDetailInfo();
+          // // this.$message.success(res.message);
+          // this.goBack();
+        }
+      });
     },
 
     // 淇敼椤圭洰鐨勬娴嬪�兼敼鍙樼粨璁�
@@ -465,8 +521,8 @@
       if (this.detailId !== null) {
         const res = await this.$axios.post(this.$api.url.updaterawInsProduct, {
           DevId: row.deviceId,
-          rpId: this.detailId,
-          testValue: row.testValueList[index]
+          rpId: row.rpId,
+          testValue: row.testValueList.join(",")
         });
         this.$message.success("鎻愪氦鎴愬姛");
         this.getDetailInfo(); //閲嶆柊鍒锋柊淇℃伅鏁版嵁
@@ -475,9 +531,11 @@
     async submitSave() {
       const res = await this.$axios.post(
         this.$api.url.updateRawInspectsById + `${this.detailId}`
-      );
-      this.$message.success("鎻愪氦鎴愬姛");
-      this.getDetailInfo();
+      ).then(res=>{
+        this.$message.success("鎻愪氦鎴愬姛");
+        this.getDetailInfo();
+        this.goBack()
+聽 聽 聽 });
     },
     // 鑾峰彇璁惧鏍戝唴瀹�
     getOptions() {
@@ -494,6 +552,7 @@
         name: "",
         required: "",
         textValue: "",
+        testState:null,
         testValueList: [],
         unit: ""
       };
@@ -510,15 +569,30 @@
     // 鐐瑰嚮琛ㄦ牸閫夋嫨瑙﹀彂
     clickTableSelect(scope) {
       this.centerDialogVisible = true;
-      this.clickSelectSaveIndex = scope.$index;
+      this.clickSelectDevice.index = scope.$index;
+      this.clickSelectDevice.rpId = scope.row.rpId;
     },
     // 鐐瑰嚮鏍戦噷闈㈢殑纭畾
     clickNodeSure() {
-      this.projectTable[this.clickSelectSaveIndex].deviceId = this.nodeData.id;
-      this.projectTable[
-        this.clickSelectSaveIndex
-      ].deviceName = this.nodeData.name;
-      this.centerDialogVisible = false;
+      if (this.detailId == null) {
+        this.projectTable[
+          this.clickSelectDevice.index
+        ].deviceId = this.nodeData.id;
+        this.projectTable[
+          this.clickSelectDevice.index
+        ].deviceName = this.nodeData.name;
+        this.centerDialogVisible = false;
+      } else {
+        this.$axios
+          .post(this.$api.url.updateDevByRpId, {
+            rpId: this.clickSelectDevice.rpId,
+            devId: this.nodeData.id
+          })
+          .then(res => {
+            this.getDetailInfo();
+            this.centerDialogVisible = false;
+          });
+      }
     },
     // 鍒犻櫎妫�楠屽�煎垪
     clickDeleteInspectionColumn() {

--
Gitblit v1.9.3