From 825542817911686a382121f4db91202511275346 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 06 八月 2024 19:21:41 +0800
Subject: [PATCH] 检验下单-检验项要求值和要求描述校验

---
 src/components/do/b1-ins-order/add.vue |  104 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 96 insertions(+), 8 deletions(-)

diff --git a/src/components/do/b1-ins-order/add.vue b/src/components/do/b1-ins-order/add.vue
index 82d2257..bd9e8e6 100644
--- a/src/components/do/b1-ins-order/add.vue
+++ b/src/components/do/b1-ins-order/add.vue
@@ -475,7 +475,7 @@
             <template slot-scope="scope">
               <el-input size="small" placeholder="瑕佹眰鍊�" v-model="scope.row.ask" clearable type="textarea"
                 :autosize="{ minRows: 1, maxRows: 3}" @change="e=>requestChange(e,scope.row,'ask')"
-                v-if="active==1&&isAskOnlyRead"></el-input>
+                v-if="active==1&&isAskOnlyRead&&/[0-9]/.test(scope.row.ask)"></el-input>
               <span v-else>
                 <!-- <template v-if="(scope.row.ask.indexOf('D')>-1
                 ||scope.row.ask.indexOf('W')>-1
@@ -783,7 +783,7 @@
           prop="value"
           label="璇嗗埆绗﹀��">
           <template slot-scope="scope">
-            <el-input v-model="scope.row.value" placeholder="璇疯緭鍏�" size="small"></el-input>
+            <el-input v-model="scope.row.value" placeholder="璇疯緭鍏�" @input="inputValueHandler(scope.row,scope.$index)" size="small"></el-input>
           </template>
         </el-table-column>
       </el-table>
@@ -929,6 +929,7 @@
     },
     data() {
       return {
+        sampleSelectionList: [],//鏍峰搧琛ㄦ牸閫変腑鏁版嵁
         editTable:[],
         template: null,
         templates: [],
@@ -1172,6 +1173,21 @@
       }
     },
     methods: {
+      //鐗规畩鍊煎~鍐欏鐞�
+      inputValueHandler(row,index){
+        if(row){
+          const nextIndex = index+1
+          for (let i = nextIndex; i < this.editTable.length; i++) {
+            const element = this.editTable[i];
+            if(element.model==row.model){
+              this.editTable[i].value = row.value
+            }else{
+              break;
+            }
+          }
+        }
+
+      },
       spliceData () {
         if (!this.circulateForm.entrustNum || !this.circulateForm.entrustTime || !this.circulateForm.entrustPoint || this.opticalProjectList.length === 0 || this.temperatureData.length === 0) {
           this.$message.error('璇峰~鍐欏畬鏁存暟鎹�')
@@ -1556,10 +1572,38 @@
               isHaveBushing = false
             }
           })
-          // console.log('isHaveBushing===', isHaveBushing)
+          //杩囨护妫�娴嬮」锛氬幓闄ょ壒娈婇」(bsm=1),
+          let filterProductList = this.productListSelected.filter(ele=>ele.bsm==0&&/[0-9]/.test(ele.ask)).filter(ele=>{
+              if(select[1].indexOf('閫氫俊')>=0 && ['鍏夌紗','鍏夌氦'].includes(select[2])){
+                return !['娓╁害寰幆','鍏夌氦鎺ュご鎹熻��'].includes(ele.inspectionItem)
+              }
+              return true
+          }).filter(ele=>{
+              if(select[1].indexOf('鐢靛姏')>=0){
+                return !['娓╁崌璇曢獙','鐑惊鐜�'].includes(ele.inspectionItem)
+              }
+              return true
+          })
+          //鏍¢獙妫�楠岄」鐨勮姹傚�煎拰瑕佹眰鎻忚堪
+          const isTrue = this.checkRequiredValueAndRemark(filterProductList)
+          if(!isTrue){
+            this.$message.error('妫�楠岄」鐨勮姹傚�间笌瑕佹眰鎻忚堪涓嶅尮閰嶏紝 璇锋鏌�')
+            return
+          }
+
+          console.log('isHaveBushing===', this.totalArr)
+          // inspectionItem
+          let spcialItem = this.totalArr.find(a => a.state == 1 && a.inspectionItem.includes('鏉惧绠�'))
+          console.log('isHaveBushing===', isHaveBushing)
           if (productListSelected && select[2] === '鍏夌紗' && isHaveBushing === false) {
             this.$message.error('鍏夌紗娓╁害寰幆椤圭洰蹇呴』杩涜鍏夌氦閰嶇疆')
-
+            this.$refs.sampleTable.setCurrentRow(this.currentMethod, true)
+            this.rowClick(this.currentMethod)
+            this.sampleIds = [this.currentMethod.id]
+            this.openConfig()
+            return
+          }else if(spcialItem&& isHaveBushing === false){
+            this.$message.error('鏉惧绠¢」鐩繀椤昏繘琛屽厜绾ら厤缃�')
             this.$refs.sampleTable.setCurrentRow(this.currentMethod, true)
             this.rowClick(this.currentMethod)
             this.sampleIds = [this.currentMethod.id]
@@ -1589,6 +1633,46 @@
             this.saveMethod(sampleList)
           }
         }
+      },
+      checkRequiredValueAndRemark(data){
+        let isTrue = true
+        try{
+          data.forEach(ele=>{
+            if(['鈮�','鈮�','>','<','='].includes(ele.ask[0])){
+              const askVal = ele.ask.substring(1,ele.ask.length)
+              if(isNaN(askVal) || ele.tell.indexOf(askVal)<0){
+                isTrue = false
+              }
+            }
+            if(ele.ask.indexOf('-')>0 && ele.ask.length>1){
+              const splits = ele.ask.split('-')
+              if(splits.length==2 && !isNaN(splits[0]) && !isNaN(splits[1])){
+                let min = Math.min(...splits)
+                let max = Math.max(...splits)
+                if(ele.tell.indexOf('卤')<0&&ele.tell!=ele.ask){
+                  isTrue = false
+                }else if(ele.tell.indexOf('卤')>0&&ele.tell!=ele.ask){
+                  let splitNums = ele.tell.split('卤')
+                  if(splitNums.length<2){
+                    isTrue = false
+                  }else{
+                    let minTell = Number(splitNums[0])-Number(splitNums[1])
+                    let maxTell = Number(splitNums[0])+Number(splitNums[1])
+                    if(minTell!=min || maxTell!=max){
+                      isTrue = false
+                    }
+                  }
+                }
+              }else{
+                isTrue = false
+              }
+            }
+          })
+        }catch(error){
+          console.log(error);
+          isTrue = false
+        }
+        return isTrue
       },
       save0(){
         if(this.editTable.every(m=>m.value)){
@@ -1805,7 +1889,6 @@
       },
       saveMethod(sampleList){
         this.saveLoad = true
-        console.log(333333,sampleList)
         this.$axios.post(this.$api.insOrder.addInsOrder, {
           str: JSON.stringify({
             insOrder: this.addObj,
@@ -1939,8 +2022,8 @@
         })
       },
       getProNum() {
-        this.sampleList.forEach((m, i) => {
-          Vue.set(this.sampleList[i], 'proNum', m.insProduct.filter(a => a.state == 1).length)
+        this.sampleSelectionList.forEach((m, i) => {
+          Vue.set(this.sampleSelectionList[i], 'proNum', m.insProduct.filter(a => a.state == 1).length)
         })
         this.$refs.sampleTable.doLayout()
       },
@@ -2073,6 +2156,7 @@
         val.forEach(a => {
           this.sampleIds.push(a.id)
         })
+        this.sampleSelectionList = val
       },
       delSample() {
         this.sampleIds.forEach(a => {
@@ -2104,7 +2188,11 @@
         this.sampleId = row.id
         if (this.active !== 1) {
           this.sampleIds = []
-          this.sampleIds.push(row.id)
+          this.sampleSelectionList.forEach(ele=>{
+            if(ele.id == row.id){
+              this.sampleIds.push(row.id)
+            }
+          })
         }
         this.productList = row.insProduct
         this.productList0 = JSON.parse(JSON.stringify(this.productList))

--
Gitblit v1.9.3