From ab87478ba941f90cd60252cf4d34aa585dc1a63f Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期一, 22 七月 2024 18:29:10 +0800
Subject: [PATCH] 设备数采配置 调整

---
 src/components/do/b1-inspect-order-plan/Inspection.vue |  133 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 100 insertions(+), 33 deletions(-)

diff --git a/src/components/do/b1-inspect-order-plan/Inspection.vue b/src/components/do/b1-inspect-order-plan/Inspection.vue
index 1d3b6c3..b27d4eb 100644
--- a/src/components/do/b1-inspect-order-plan/Inspection.vue
+++ b/src/components/do/b1-inspect-order-plan/Inspection.vue
@@ -209,9 +209,6 @@
   <div v-loading="loading" class="inspection">
     <el-row class="title">
       <el-col :span="12" style="padding-left: 20px;text-align: left;">妫�楠屽崟璇︽儏
-        <!-- <span style="color: #3A7BFA;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;鏍峰搧</span>
-        <span v-if="currentFiberOpticTape" style="color: #3A7BFA;"> - 鍏夌氦甯�</span>
-        <span v-if="currentFiberOptic" style="color: #3A7BFA;"> - 鍏夌氦</span> -->
       </el-col>
       <el-col :span="12" style="text-align: right;">
         <!-- <el-button size="small" type="primary" @click="fiberOpticVisible=true" v-if="fiberOptic.length>0">鍏夌氦鍒囨崲</el-button>
@@ -277,10 +274,6 @@
               <el-tag :type="item.state==1?'success':'danger'" style="float: right;margin-top: 5px;" size="small">{{ item.state==1?'宸叉':'鏈' }}</el-tag>
             </el-option>
           </el-select>
-          <!-- <el-radio-group v-model="currentTab" size="small" v-if="fibers.length>0" @input="m=>handleChange(m,1)">
-            <el-radio-button :label="item.id" v-for="(item,index) in fibers" :key="index"
-              size="small">{{ item.code }}</el-radio-button>
-          </el-radio-group> -->
           <span v-if="fiber.length>0">&nbsp;&nbsp;鍏夌氦锛�</span>
           <el-select v-model="currentTab" placeholder="璇烽�夋嫨" @change="m=>handleChange(m,2)" v-if="fiber.length>0" size="small">
             <el-option
@@ -292,10 +285,6 @@
               <el-tag :type="item.state==1?'success':'danger'" style="float: right;margin-top: 5px;" size="small">{{ item.state==1?'宸叉':'鏈' }}</el-tag>
             </el-option>
           </el-select>
-          <!-- <el-radio-group v-model="currentTab" size="small" v-if="fiber.length>0" @input="m=>handleChange(m,2)">
-            <el-radio-button :label="item.id" v-for="(item,index) in fiber" :key="index"
-              size="small">{{ item.bushColor+'-'+item.color }}</el-radio-button>
-          </el-radio-group> -->
           <el-form :inline="true" :model="otherForm" class="form-inline" label-width="50px" style="padding-top: 0;padding-left: 10px;" v-if="PROJECT=='妫�娴嬩腑蹇�'">
             <el-form-item label="娓╁害:" style="margin-bottom: 0;">
               <el-input v-model="otherForm.temperature" size="small" placeholder="" style="width: 90px;" @change="m=>subOtherForm(m,'temperature')"></el-input>
@@ -306,7 +295,8 @@
               <span style="margin-left: 4px;">%</span>
             </el-form-item>
           </el-form>
-          <el-button type="primary" size="small">缂栬緫鏁伴噰</el-button>
+          <el-button type="primary" size="small" v-if="dataAcquisitionEidt>0&&PROJECT=='妫�娴嬩腑蹇�'" @click="getDataAcquisitionDevice" :loading="dataAcquisitionLoading">鏁版嵁閲囬泦</el-button>
+          <el-button :type="dataAcquisitionEidtAble?'':'primary'" size="small" v-if="dataAcquisitionEidt>0&&PROJECT=='妫�娴嬩腑蹇�'" @click="dataAcquisitionEidtAble=!dataAcquisitionEidtAble">{{dataAcquisitionEidtAble?'鍏抽棴缂栬緫':'缂栬緫鏁伴噰'}}</el-button>
         </div>
       </div>
       <div class="center-box" id="nav" v-loading="tableLoading" v-if="!tableLists.find(m=>m.templateId==currentTable)||tableLists.find(m=>m.templateId==currentTable).templateName!='娓╁害寰幆妫�楠屽師濮嬭褰�'">
@@ -321,11 +311,11 @@
                   :style="`width:${handleWidth(n)}px !important;min-height:${item.style.rowlen[n.r]}px;`">
                   <template v-if="n.v.ps!=undefined && typeof n.v.ps.value ==='string'&& n.v.ps.value.includes('妫�楠屽��') && state==1">
                     <el-input v-if="getInspectionValueType(n.i) == 1" class="table_input" v-model="n.v.v"
-                              :disabled="getInspectionItemType(n.i) == 1 || (n.u != userId && n.u != undefined && n.u != '')"
+                              :disabled="(getInspectionItemType(n.i) == 1 && !dataAcquisitionEidtAble )|| (n.u != userId && n.u != undefined && n.u != '')"
                               @input="handleInput(n)"
                               @change="m=>changeInput(m,`${item.templateId}-${n.r}-${n.c}-${n.i}`, n)" @mousewheel.native.prevent :key="'abc-'+'000'+index+'000'+i+'000'+j">
-                      <el-button slot="append" type="primary" icon="el-icon-edit" size="mini"
-                        v-if="getInspectionItemType(n.i) == 1" @click="getSystemValue(n)"></el-button>
+                      <!-- <el-button slot="append" type="primary" icon="el-icon-edit" size="mini"
+                        v-if="getInspectionItemType(n.i) == 1" @click="getSystemValue(n)"></el-button> -->
                     </el-input>
                     <el-input v-else-if="getInspectionValueType(n.i) == 2" class="table_input" type="textarea"
                       v-model="n.v.v"
@@ -357,7 +347,7 @@
                       <el-option v-for="item in equipOptions" :key="item.value" :label="item.value" :value="item.value">
                       </el-option>
                     </el-select>
-                    <el-button type="primary" icon="el-icon-document-copy" size="small" circle title="鏁伴噰" v-if="n.isItADataAcquisitionDevice&&PROJECT=='妫�娴嬩腑蹇�'" @click="getDataAcquisitionDevice(n.v.v)"></el-button>
+                    <!-- <el-button type="primary" icon="el-icon-document-copy" size="small" circle title="鏁伴噰" v-if="n.isItADataAcquisitionDevice&&PROJECT=='妫�娴嬩腑蹇�'" @click="getDataAcquisitionDevice(n.v.v)"></el-button> -->
                   </template>
                   <template v-else-if="n.v.ps!=undefined && n.v.ps.value==='瑕佹眰鍊�' && state==1">
                     <span :style="`font-family:${n.v.ff} !important;`">{{getTell(n.i)}}</span>
@@ -696,6 +686,7 @@
   import ValueTable from '../../tool/value-table.vue'
   import file from '../../../util/file'
   import excelFunction from '../../../util/excelFountion'
+import { number } from 'echarts'
   export default {
     props: ['sonLaboratory', 'orderId', 'state'],
     components: {
@@ -849,8 +840,11 @@
         },
         result: null,
         worker: null,
-        dataAcquisitionBtn:{},
-        wareLength:[]
+        wareLength:[],
+        dataAcquisitionInfo:{},
+        dataAcquisitionEidt:0,
+        dataAcquisitionEidtAble:false,
+        dataAcquisitionLoading:false
       }
     },
     computed: {
@@ -875,6 +869,7 @@
       this.getAuthorizedPerson()
       this.scrollInit()
       this.getPower()
+      this.startWorker()
     },
     watch: {
       id(val) {
@@ -988,6 +983,21 @@
             this.saveInsContext()
           }
         }
+      },
+      param:{
+        deep:true,
+        handler(val){
+          this.dataAcquisitionEidt = 0
+          if(val){
+            for (let key in val) {
+              val[key].equipValue.forEach(m=>{
+                if(m.isItADataAcquisitionDevice){
+                  this.dataAcquisitionEidt++
+                }
+              })
+            }
+          }
+        }
       }
     },
     beforeDestroy() {
@@ -995,9 +1005,48 @@
       this.stopWorker();
     },
     methods: {
-      getDataAcquisitionDevice(managementNumber){
-        this.$axios.get(this.$api.deviceScope.dataCollection+'?managementNumber='+managementNumber+'&entrustCode='+this.insOrder.entrustCode+'&sampleCode='+this.currentSample.sampleCode).then(res=>{
-          console.log(111,res)
+      getDataAcquisitionDevice(){
+        this.dataAcquisitionLoading = true
+        this.$axios.get(this.$api.deviceScope.dataCollection+'?entrustCode='+this.insOrder.entrustCode+'&sampleCode='+this.currentSample.sampleCode + '&id=' + this.currentSample.id).then(res=>{
+          this.dataAcquisitionLoading = false
+          if(res.code!=200){
+            return
+          }
+          this.dataAcquisitionInfo = res.data
+          let list = this.tableList[0].arr
+          list.forEach((item,index)=>{
+            item.forEach(m=>{
+              if(m.v.ps&&(m.v.ps.value=='妫�楠屽瓙椤�'||m.v.ps.value=='妫�楠岄」')){
+                if(this.dataAcquisitionInfo[m.v.m]){
+                  let num = 0;
+                  list[index].forEach(n=>{
+                    if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
+                      num++
+                    }
+                  })
+                  list[index].forEach((n,i)=>{
+                    if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
+                      if(n.v.ps.value.includes(this.dataAcquisitionInfo.frequency)&&!n.v.ps.value.includes(this.dataAcquisitionInfo.frequency+'0')){
+                        setTimeout(()=>{
+                          this.$delete(n.v,'v')
+                          this.$set(n.v,'v',this.dataAcquisitionInfo[m.v.m])
+                          this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
+                        },1000)
+                      }else if(Number(this.dataAcquisitionInfo.frequency)>num){
+                        if(n.v.ps.value.includes(num)){
+                          setTimeout(()=>{
+                            this.$delete(n.v,'v')
+                            this.$set(n.v,'v',this.dataAcquisitionInfo[m.v.m])
+                            this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
+                          },1000)
+                        }
+                      }
+                    }
+                  })
+                }
+              }
+            })
+          })
         })
       },
       startWorker() {
@@ -1207,7 +1256,6 @@
             }
             arr2.push(obj)
           })
-          console.log(arr2)
           this.wareTableData = arr2
         })
         this.getEquipOptions(true,this.currentSample.insProduct[0].id)
@@ -1727,7 +1775,6 @@
           } catch (e) {}
           try {
             let insValue = JSON.parse(a.insProductResult.insValue)
-            console.log(2222,insValue)
             for (let i = 0; i < insValue.length; i++) {
               if(this.param[a.id].insValue.find(m=>m.c==insValue[i].c&&m.r==insValue[i].r)){
                 this.param[a.id].insValue.find(m=>m.c==insValue[i].c&&m.r==insValue[i].r).v.v = insValue[i].v
@@ -1748,8 +1795,19 @@
                 if(equipValue[i].v){
                   let isItADataAcquisitionDevice = await this.determineWhetherToCollectData(equipValue[i].v)
                   this.param[a.id].equipValue[i].isItADataAcquisitionDevice = isItADataAcquisitionDevice
+
                 }else{
                   this.param[a.id].equipValue[i].isItADataAcquisitionDevice = false
+                }
+                this.dataAcquisitionEidt = 0
+                if(this.param){
+                  for (let key in this.param) {
+                    this.param[key].equipValue.forEach(m=>{
+                      if(m.isItADataAcquisitionDevice){
+                        this.dataAcquisitionEidt++
+                      }
+                    })
+                  }
                 }
               }
             }
@@ -1788,8 +1846,6 @@
             n.v.v = n.v.v.replace('/', '')
           }
         }
-        this.startWorker()
-
         // 鍚� Worker 鍙戦�佹秷鎭紝寮�濮嬪鐞嗛�昏緫
         this.worker.postMessage(JSON.stringify({
           code: code,
@@ -1807,7 +1863,8 @@
           switch (this.result.method){
             case 'saveInsContext':
               this.$nextTick(()=>{
-                this.tableList = this.result.value.tableList
+                this.$delete(this.tableList[0],'arr')
+                this.$set(this.tableList[0],'arr',this.result.value.tableList[0].arr)
                 this.param = this.result.value.param
                 for (var i in this.param){
                   if(this.param[i].insResult&&this.param[i].insResult.v&&this.param[i].insResult.v.v){
@@ -1818,22 +1875,19 @@
                     }
                   }
                 }
-                console.log(2222,this.param)
                 this.saveInsContext()
               })
               break;
             case 'tableList':
               this.$nextTick(()=>{
-                this.tableList = this.result.value
+                this.$delete(this.tableList[0],'arr')
+                this.$set(this.tableList[0],'arr',this.result.value[0].arr)
               })
               break;
             case 'getCurrentInsProduct':
               this.getCurrentInsProduct(this.result.value)
               break;
           }
-          // if(this.result.method=='saveInsContext'){
-          //   this.stopWorker(); // 澶勭悊瀹屾垚鍚庡仠姝� Worker
-          // }
         };
       },
       async determineWhetherToCollectData(managementNumber){
@@ -2122,7 +2176,9 @@
               this.$axios.post(this.$api.insOrderPlan.submitPlan, {
                 orderId: this.orderId,
                 laboratory: this.sonLaboratory,
-                verifyUser: this.verifyUser
+                verifyUser: this.verifyUser,
+                entrustCode: this.insOrder.entrustCode,
+                sampleCode: this.currentSample.sampleCode
               }).then(res => {
                 if (res.code === 200) {
                   this.$message.success("鎿嶄綔鎴愬姛")
@@ -2143,7 +2199,7 @@
                 }
                 newData.push(h('p', {style: 'font-size: 14px;color: red;'}, (Number(i)+1)+'銆�'+res.data[i]))
               }
-              newData.push(h('p',  { style: 'font-size: 16px;color:#000;margin-top:12px' },'浠ヤ笂椤圭洰涓嶅悎鏍硷紝纭畾鎻愪氦锛�'))
+              newData.push(h('p',  { style: 'font-size: 16px;color:#000;margin-top:12px;overflow-y: auto;max-height:80vh' },'浠ヤ笂椤圭洰涓嶅悎鏍硷紝纭畾鎻愪氦锛�'))
               this.$confirm('鎻愮ず',{
                 title:'鎻愮ず',
                 message: h('div', null, newData),
@@ -2175,6 +2231,7 @@
         return
       },
       saveInsContext() {
+        // console.log(1111,this.param)
         if(this.param){
           this.$axios.post(this.$api.insOrderPlan.saveInsContext, {
             param: JSON.stringify(this.param)
@@ -2199,6 +2256,16 @@
             }
           }
         }
+        this.dataAcquisitionEidt = 0
+        if(this.param){
+          for (let key in this.param) {
+            this.param[key].equipValue.forEach(m=>{
+              if(m.isItADataAcquisitionDevice){
+                this.dataAcquisitionEidt++
+              }
+            })
+          }
+        }
         this.saveInsContext()
       },
       getAuthorizedPerson() {

--
Gitblit v1.9.3