From 051e5b520f0b94dd409d4fd90ea8fc350a943f9d Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期一, 14 十月 2024 16:42:31 +0800
Subject: [PATCH] 完成温湿度特殊项目

---
 src/components/do/b1-inspect-order-plan/circuit-parameters1.vue |    6 +
 src/components/do/b1-inspect-order-plan/humidity.vue            |  252 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/components/do/b1-inspect-order-plan/circuit-parameters2.vue |    6 +
 src/components/do/b1-inspect-order-plan/Inspection.vue          |   12 +
 src/assets/api/controller.js                                    |    3 
 5 files changed, 275 insertions(+), 4 deletions(-)

diff --git a/src/assets/api/controller.js b/src/assets/api/controller.js
index 59cf00d..834e395 100644
--- a/src/assets/api/controller.js
+++ b/src/assets/api/controller.js
@@ -196,7 +196,8 @@
   claimInsOrderPlan: "/insOrderPlan/claimInsOrderPlan", //璁ら妫�楠屼换鍔�
   doInsOrder: "/insOrderPlan/doInsOrder", //鎵ц妫�楠屾搷浣�
   saveInsContext: "/insOrderPlan/saveInsContext", //淇濆瓨妫�楠屽唴瀹�
-  saveInsContext2: "/insOrderPlan/saveInsContext2", //淇濆瓨妫�楠屽唴瀹�
+  saveInsContext2: "/insOrderPlan/saveInsContext2", //淇濆瓨妫�楠屽唴瀹�--鐢佃矾璇曢獙
+  saveInsContext3: "/insOrderPlan/saveInsContext3", //淇濆瓨妫�楠屽唴瀹�--娓╂箍搴︽楠�
   deleteInsContext: "/insOrderPlan/deleteInsContext", //鍒犻櫎棰戞
   deleteInsContext2: "/insOrderPlan/deleteInsContext2", //鍒犻櫎棰戠偣
   upPlanUser: "/insOrderPlan/upPlanUser", //浠诲姟浜ゆ帴
diff --git a/src/components/do/b1-inspect-order-plan/Inspection.vue b/src/components/do/b1-inspect-order-plan/Inspection.vue
index ce9beb9..178322a 100644
--- a/src/components/do/b1-inspect-order-plan/Inspection.vue
+++ b/src/components/do/b1-inspect-order-plan/Inspection.vue
@@ -260,7 +260,7 @@
       <el-col :span="12" style="padding-left: 20px;text-align: left;" :class="{noShow:noBack}">妫�楠屽崟璇︽儏
       </el-col>
       <el-col :span="12" style="text-align: right;">
-        <el-button size="small" type="primary" @click="versionDialogVisible=true" v-if="state==1">妫�楠屾ā鏉垮垏鎹�</el-button>
+        <el-button size="small" type="primary" @click="versionDialogVisible=true" v-if="state==1&&tableLists.find(m=>m.templateId==currentTable)&&tableLists.find(m=>m.templateId==currentTable).templateName.includes('鐢佃矾璇曢獙')">妫�楠屾ā鏉垮垏鎹�</el-button>
         <el-button size="small" type="primary" @click="sampleVisible=true;uploadSample()">鏍峰搧鍒囨崲</el-button>
         <el-button size="small" type="primary" @click="taskVisible=true" v-show="!isLook">浠诲姟鍒囨崲</el-button>
         <el-button size="small" type="primary" @click="handleSubmit" v-if="state==1"
@@ -347,7 +347,7 @@
         </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.includes('鐢佃矾璇曢獙'))">
+      <div class="center-box" id="nav" v-loading="tableLoading" v-if="!tableLists.find(m=>m.templateId==currentTable)||(!tableLists.find(m=>m.templateId==currentTable).templateName.includes('鐢佃矾璇曢獙')&&!tableLists.find(m=>m.templateId==currentTable).templateName.includes('娓╂箍搴﹁瘯楠�'))">
         <table border="1" class="tables" cellpadding="10" v-for="(item,index) in tableList" :key="index+currentTable+currentSample.id">
           <tbody>
             <tr v-for="(m,i) in item.arr" :key="i">
@@ -729,6 +729,10 @@
         <CircuitParameters1 v-if="currentTableState==0" :insProduct="currentSample.insProduct" :orderId="id" :sampleId="currentSample.id" :state="state" :num="currentSample.num1" :isLook="isLook" :currentNum="currentNum"></CircuitParameters1>
         <CircuitParameters2 v-if="currentTableState==1" :insProduct="currentSample.insProduct" :orderId="id" :sampleId="currentSample.id" :state="state" :num="currentSample.num1" :isLook="isLook" :currentNum="currentNum"></CircuitParameters2>
       </div>
+      <!-- 娓╂箍搴﹁瘯楠� -->
+       <div v-else-if="tableLists.find(m=>m.templateId==currentTable).templateName.includes('娓╂箍搴﹁瘯楠�')">
+        <Humidity :insProduct="currentSample.insProduct" :orderId="id" :sampleId="currentSample.id" :state="state" :isLook="isLook" :num="currentSample.num1"/>
+       </div>
       <el-upload :action="action"
       :data="{
         orderId:id
@@ -890,6 +894,7 @@
   import excelFunction from '../../../util/excelFountion'
   import CircuitParameters1 from './circuit-parameters1.vue'
   import CircuitParameters2 from './circuit-parameters2.vue'
+  import Humidity from './humidity.vue'
   import filePreview from '../../tool/file-preview.vue'
   export default {
     props: ['sonLaboratory', 'orderId', 'state','inspectorList','version','orderStateId','isLook','num1','noBack'],
@@ -898,7 +903,8 @@
       Circuit,
       CircuitParameters1,
       CircuitParameters2,
-      filePreview
+      filePreview,
+      Humidity,
     },
     data() {
       return {
diff --git a/src/components/do/b1-inspect-order-plan/circuit-parameters1.vue b/src/components/do/b1-inspect-order-plan/circuit-parameters1.vue
index 6315c9e..756c6b1 100644
--- a/src/components/do/b1-inspect-order-plan/circuit-parameters1.vue
+++ b/src/components/do/b1-inspect-order-plan/circuit-parameters1.vue
@@ -391,6 +391,12 @@
     },
     currentNum(val) {
       this.initData()
+    },
+    insProduct:{
+      deep:true,
+      handler:()=>{
+        this.initData()
+      }
     }
   },
   mounted() {
diff --git a/src/components/do/b1-inspect-order-plan/circuit-parameters2.vue b/src/components/do/b1-inspect-order-plan/circuit-parameters2.vue
index e54a0f8..84f89f5 100644
--- a/src/components/do/b1-inspect-order-plan/circuit-parameters2.vue
+++ b/src/components/do/b1-inspect-order-plan/circuit-parameters2.vue
@@ -272,6 +272,12 @@
     },
     currentNum(val) {
       this.initData()
+    },
+    insProduct:{
+      deep:true,
+      handler:()=>{
+        this.initData()
+      }
     }
   },
   mounted() {
diff --git a/src/components/do/b1-inspect-order-plan/humidity.vue b/src/components/do/b1-inspect-order-plan/humidity.vue
new file mode 100644
index 0000000..8bf256a
--- /dev/null
+++ b/src/components/do/b1-inspect-order-plan/humidity.vue
@@ -0,0 +1,252 @@
+<template>
+  <div>
+    <table border="1" cellpadding="10" class="thermal-table" style="margin-bottom: 20px;">
+      <template v-for="(item,index) in insProductList">
+        <tr>
+          <td style="font-size: 18px;font-weight: 500;background-color: #F0F1F5;padding: 10px 0;box-sizing: border-box;" colspan="6">{{ item.inspectionItemSubclass }}</td>
+        </tr>
+        <tr>
+          <td style="font-size: 16px;background-color: #F0F1F5;">瑙勬牸鍨嬪彿</td>
+          <td>{{item.model}}</td>
+          <td style="font-size: 16px;background-color: #F0F1F5;">璇曢獙鏂规硶</td>
+          <td>{{item.methodS}}</td>
+          <td style="font-size: 16px;background-color: #F0F1F5;">璁惧缂栧彿</td>
+          <td>
+            <el-select v-model="item.equipValue" placeholder="璇烽�夋嫨" size="small" :disabled="state>1" @focus="methodFocus(item)" @change="m=>handleEquip(m,item)">
+              <el-option
+                v-for="item in equipOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
+          </td>
+        </tr>
+        <tr>
+          <td style="font-size: 16px;background-color: #F0F1F5;">璇曢獙瑕佹眰</td>
+          <td colspan="3" style="text-align: left;">{{item.tell}}</td>
+          <td style="font-size: 16px;background-color: #F0F1F5;">璁惧鍚嶇О</td>
+          <td>{{ item.equipName }}</td>
+        </tr>
+        <tr>
+          <td style="font-size: 16px;background-color: #F0F1F5;">瀹為獙鍓嶆牱鍝佹鏌�</td>
+          <td colspan="2">
+            <el-select v-model="item.beforeCheck" placeholder="璇烽�夋嫨" size="small" :disabled="state>1" @change="save(item)">
+              <el-option
+                v-for="item in options"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
+          </td>
+          <td style="font-size: 16px;background-color: #F0F1F5;">瀹為獙鍚庢牱鍝佹鏌�</td>
+          <td colspan="2">
+            <el-select v-model="item.afterCheck" placeholder="璇烽�夋嫨" size="small" :disabled="state>1" @change="save(item)">
+              <el-option
+                v-for="item in options"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
+          </td>
+        </tr>
+        <tr style="background-color: #F0F1F5;">
+          <td colspan="2">鏃堕棿</td>
+          <td colspan="1">娓╁害</td>
+          <td colspan="1">婀垮害</td>
+          <td colspan="2">鎿嶄綔</td>
+        </tr>
+        <tr v-for="(m,i) in item.list" :key="i+item.id">
+          <td colspan="2">
+            <el-time-picker
+            v-model="m.time"
+            placeholder="鏃堕棿" size="small" editable format="HH:mm" value-format="HH:mm" style="width: 100%;" @change="save(item)" :disabled="state>1">
+          </el-time-picker>
+          </td>
+          <td colspan="1">
+            <el-input v-model="m.temperature" placeholder="娓╁害" size="small" @blur	="handleReplace(m,'鈩�','temperature',item)" :disabled="state>1"></el-input>
+          </td>
+          <td colspan="1">
+            <el-input v-model="m.humidity" placeholder="婀垮害" size="small" @blur	="handleReplace(m,'%rh','humidity',item)" :disabled="state>1"></el-input>
+          </td>
+          <td colspan="2">
+            <el-button icon="el-icon-minus" circle size="mini" type="danger"
+            @click="deleteList(item.list,i,item)" :disabled="state>1" style="margin: 5px;"></el-button>
+            <el-button icon="el-icon-plus" circle size="mini" type="primary" @click="addList(item.list,i)" :disabled="state>1" style="margin: 5px;"></el-button>
+          </td>
+        </tr>
+      </template>
+    </table>
+  </div>
+</template>
+
+<script>
+export default {
+  props:['insProduct','orderId','sampleId','state','isLook','num'],
+  data() {
+    return {
+      equipOptions:[],
+      insProductList:[],
+      options:[
+        {value: '瀹屽ソ', label: '瀹屽ソ'},
+        {value: '鐮存崯', label: '鐮存崯'}
+      ]
+    }
+  },
+  watch:{
+    insProduct:{
+      deep:true,
+      handler:function(newVal,oldVal){
+        this.init()
+      }
+    }
+  },
+  mounted() {
+    this.init()
+  },
+  methods: {
+    init(){
+      this.insProductList = this.HaveJson(this.insProduct)
+      this.insProductList.forEach(item=>{
+        if(!item.insProductResult){
+          // 鍒濆鍖�
+          this.$set(item,'list',[])
+          item.list.push({})
+          item.list.forEach(m=>{
+            this.$set(m,'time','')
+            this.$set(m,'temperature','')
+            this.$set(m,'humidity','')
+          })
+          this.$set(item,'equipValue','')
+          this.$set(item,'equipName','')
+          this.$set(item,'beforeCheck','')
+          this.$set(item,'afterCheck','')
+        }else{
+          // 璧嬪��
+          this.$set(item,'list',JSON.parse(item.insProductResult.insValue))
+          item.list.forEach(m=>{
+            this.$set(m,'time',m.time)
+            this.$set(m,'temperature',m.temperature)
+            this.$set(m,'humidity',m.humidity)
+          })
+          this.$set(item,'equipValue',item.insProductResult.equipValue)
+          this.$set(item,'equipName',item.insProductResult.equipName)
+          this.$set(item,'beforeCheck',item.insProductResult.beforeCheck)
+          this.$set(item,'afterCheck',item.insProductResult.afterCheck)
+        }
+      })
+    },
+    deleteList(arr,i,item){
+      if(arr.length>1){
+        arr.splice(i,1)
+        this.save(item)
+      }else{
+        this.$message({
+          type: 'warning',
+          message: '涓嶈兘鍐嶅垹闄や簡'
+        })
+      }
+    },
+    addList(arr,i){
+      arr.splice(i+1,0,{
+        time:'',
+        temperature:'',
+        humidity:''
+      })
+    },
+    async methodFocus(item){
+      this.equipOptions = await this.getEquipOptions(item)
+    },
+    // 鑾峰彇璁惧閫夐」 id:涓烘楠岄」id
+    async getEquipOptions(m) {
+      let arr = []
+      let res = await this.$axios.post(this.$api.deviceScope.selectDeviceByCategory, {
+        inspectionItem: m.inspectionItem,
+        inspectionItemSubclass: m.inspectionItemSubclass
+      })
+      if (res.code === 200 && res.data) {
+        arr = res.data.map(m => {
+          m.value = m.managementNumber
+          m.label = m.deviceName
+          return m
+        })
+      }
+      return arr
+    },
+    /**
+   * 澶勭悊璁惧淇℃伅
+   *
+   * @param {any} m - 鏂扮殑璁惧鍊�
+   * @param {Object} item - 璁惧瀵硅薄
+   */
+    handleEquip(m,item){
+      this.$delete(item, 'equipValue')
+      this.$set(item, 'equipValue', m)
+      this.$delete(item, 'equipName')
+      this.$set(item, 'equipName', this.equipOptions.find(m=>m.value==item.equipValue).label)
+      this.save(item)
+    },
+    /**
+   * 鏇挎崲鏂囨湰涓殑鎸囧畾鍗曚綅
+   *
+   * @param {Object} m - 闇�瑕佷慨鏀圭殑鏂囨湰瀵硅薄
+   * @param {string} unit - 瑕佹浛鎹㈢殑鍗曚綅
+   * @param {any} v - 鏈娇鐢ㄧ殑鍙傛暟锛堜繚鐣欎互鍖归厤鍏朵粬閲嶈浇锛�
+   * @returns {void} 鏃犺繑鍥炲��
+   */
+    handleReplace(m,unit,v,item){
+      if(m[v]&&!`${m[v]}`.includes(unit)){
+        m[v] = m[v]+unit
+      }
+      if(m[v]){
+        this.save(item)
+      }
+    },
+    save(item){
+      this.$axios.post(this.$api.insOrderPlan.saveInsContext3, {
+        insProductId:item.id,
+        insValue:JSON.stringify(item.list),
+        equipValue:item.equipValue,
+        equipName:item.equipName,
+        num:this.num,
+        beforeCheck:item.beforeCheck,
+        afterCheck:item.afterCheck,
+      }, {
+      headers: {
+        'Content-Type': 'application/json'
+      },
+      noQs:true}).then(res => {
+        if (res.code === 201) {
+          this.$message.error('淇濆瓨澶辫触')
+          return
+        }
+        this.$message.success('宸蹭繚瀛�')
+      }).catch(err => {
+        console.log(err)
+      })
+    },
+  },
+}
+</script>
+
+<style scoped>
+  .thermal-table{
+    min-width: calc(100% - 10px);
+    margin: 5px 5px 0;
+    table-layout: fixed;
+  }
+  .thermal-table td {
+    min-width: 70px;
+    text-align: center;
+    font-size: 14px;
+    word-wrap: break-word;
+    white-space: normal;
+    padding: 5px;
+  }
+  .thermal-table .el-input{
+    display: flex;
+    align-items: center;
+  }
+</style>

--
Gitblit v1.9.3