From 049fda473cc178917a02f3a174dfd08a84b0cb8d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 17 九月 2026 10:52:28 +0800
Subject: [PATCH] 新疆——新聚lims 1.每个检验项都要有一个选择检测时间的地方,跟温湿度放在一起,还有检测地点,设备也要单独绑定检验项,最后导出模版再总结到一起 2.产品名称改为检测依据、加一个样品名称手输 3.下单时原始记录模板可以从标准库绑定的模板进行删减

---
 src/views/business/inspectionTask/components/InspectionWord.vue | 1023 ++++++++++++++++++++------------------------------------
 1 files changed, 369 insertions(+), 654 deletions(-)

diff --git a/src/views/business/inspectionTask/components/InspectionWord.vue b/src/views/business/inspectionTask/components/InspectionWord.vue
index 8e10e5c..666c720 100644
--- a/src/views/business/inspectionTask/components/InspectionWord.vue
+++ b/src/views/business/inspectionTask/components/InspectionWord.vue
@@ -17,14 +17,46 @@
             </el-radio-group>
           </div>
           <div style="display: flex;align-items: center;">
-            <span v-if="typeSource == '1'">&nbsp;&nbsp;澶嶆祴娆℃暟锛�</span>
-            <el-select v-if="typeSource == '1'" v-model="retestTag" placeholder="璇烽�夋嫨" size="small"
+            <span>&nbsp;&nbsp;澶嶆祴娆℃暟锛�</span>
+            <el-select v-model="retestTag" placeholder="璇烽�夋嫨" size="small"
               @change="m => handleChangeCableTag(currentSample.id, 4, 'cableTag', m)">
               <el-option v-for="item in unPassNumList" :key="item.retestTag" :label="item.retestTag"
                 :value="item.retestTag">
               </el-option>
             </el-select>
           </div>
+        </div>
+        <div class="template-panel">
+          <el-form :inline="true" :model="currentOtherForm" class="form-inline" size="small" label-width="84px">
+            <el-form-item label="娓╁害:">
+              <el-input v-model="currentOtherForm.temperature" :disabled="state > 1" placeholder="" size="small"
+                style="width: 90px" @change="m => subOtherForm(m, 'temperature')"></el-input>
+              <span class="template-panel__unit">鈩�</span>
+            </el-form-item>
+            <el-form-item label="婀垮害:">
+              <el-input v-model="currentOtherForm.humidity" :disabled="state > 1" placeholder="" size="small"
+                style="width: 90px" @change="m => subOtherForm(m, 'humidity')"></el-input>
+              <span class="template-panel__unit">%RH</span>
+            </el-form-item>
+            <el-form-item label="妫�娴嬫椂闂�:">
+              <el-date-picker v-model="currentOtherForm.detectionTime" :disabled="state > 1" type="date"
+                value-format="yyyy-MM-dd" placeholder="璇烽�夋嫨鏃ユ湡" size="small" style="width: 160px"
+                @change="m => subOtherForm(m, 'detectionTime')"></el-date-picker>
+            </el-form-item>
+            <el-form-item label="妫�娴嬪湴鐐�:">
+              <el-input v-model="currentOtherForm.detectionPlace" :disabled="state > 1" clearable
+                placeholder="璇疯緭鍏ユ娴嬪湴鐐�" size="small" style="width: 200px"
+                @change="m => subOtherForm(m, 'detectionPlace')"></el-input>
+            </el-form-item>
+            <el-form-item v-if="isDirectTemplateOrder()" label="璁惧:">
+              <el-select v-model="currentOtherForm.deviceIds" :disabled="state != 1" multiple filterable clearable
+                size="small" placeholder="璇烽�夋嫨璁惧" style="width: 360px"
+                @change="m => subOtherForm(m, 'deviceIds')">
+                <el-option v-for="device in deviceOptions" :key="device.id" :label="device.label"
+                  :value="device.id" />
+              </el-select>
+            </el-form-item>
+          </el-form>
         </div>
         <!-- 甯歌妫�楠屽師濮嬭褰� -->
         <div id="tableBox" v-loading="tableLoading" class="center-box">
@@ -33,16 +65,17 @@
             <tbody>
               <tr v-for="(m, i) in item.arr" :key="i">
                 <td v-for="(n, j) in m" v-if="n.v.mc == undefined || Object.keys(n.v.mc).length === 4"
-                  :id='item.templateId + "-" + n.i + "-" + n.r + "-" + n.c' :key="j" :colspan="n.v.mc && n.v.mc.cs ? n.v.mc.cs : 1"
-                  :rowspan="n.v.mc && n.v.mc.rs ? n.v.mc.rs : 1"
+                  :id='item.templateId + "-" + n.i + "-" + n.r + "-" + n.c' :key="j"
+                  :colspan="n.v.mc && n.v.mc.cs ? n.v.mc.cs : 1" :rowspan="n.v.mc && n.v.mc.rs ? n.v.mc.rs : 1"
                   :style="`background:${n.v.bg ? n.v.bg : ''};color:${n.v.fc};font-size:${n.v.fs}px;width:${handleWidth(n)}px !important;height:${item.style.rowlen[n.r]}px;font-wight:${n.v.bl ? 'bold' : ''};`">
                   <div :class="`content-h-${n.v.ht} content-v-${n.v.vt}`"
                     :style="`width:${handleWidth(n)}px !important;min-height:${item.style.rowlen[n.r]}px;`"
                     class="content">
                     <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" :key="'abc-' + '000' + index + '000' + i + '000' + j"
-                        v-model="n.v.v"
+                      <el-input
+                        v-if="getInspectionValueType(n.i) == 1 || (getInspectionValueType(n.i) != 2 && getInspectionValueType(n.i) != 4)"
+                        :key="'abc-' + '000' + index + '000' + i + '000' + j" v-model="n.v.v"
                         :disabled="(getInspectionItemType(n.i) == 1 && !dataAcquisitionEidtAble) || (n.u != userId && n.u != undefined && n.u != '')"
                         class="table_input"
                         @change="m => changeInput(m, `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType')"
@@ -61,34 +94,6 @@
                       <span v-else-if="getInspectionValueType(n.i) == 4"
                         :style="`font-family:${n.v.ff} !important;`">/</span>
                     </template>
-                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '缁撹'">
-                      <el-select
-                        v-if="(getInspectionValueType(n.i) == 2 || getInspectionValueType(n.i) == 5) && state == 1 && PROJECT == '瑁呭鐢电紗'"
-                        v-model="n.v.v" class="table_input"
-                        @change="m => changeInput(m, `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType')">
-                        <el-option :value="1" label="鍚堟牸"></el-option>
-                        <el-option :value="0" label="涓嶅悎鏍�"></el-option>
-                        <el-option :value="3" label="涓嶅垽瀹�"></el-option>
-                        <el-option :value="2" label="寰呭畾"></el-option>
-                      </el-select>
-                      <template v-if="state > 1">
-                        <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">鍚堟牸</span>
-                        <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">涓嶅悎鏍�</span>
-                        <span v-else-if="n.v.v === 3"
-                          :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">涓嶅垽瀹�</span>
-                        <span v-else :style="`font-family:${n.v.ff} !important;`">寰呭畾</span>
-                      </template>
-                      <template v-if="getInspectionValueType(n.i) != 2 && state == 1">
-                        <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">鍚堟牸</span>
-                        <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">涓嶅悎鏍�</span>
-                        <span v-else-if="n.v.v === 3"
-                          :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">涓嶅垽瀹�</span>
-                        <span v-else :style="`font-family:${n.v.ff} !important;`">寰呭畾</span>
-                      </template>
-                    </template>
-                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '璁惧缂栫爜' && state == 1">
-                      <span>{{ n.v.v }}</span>
-                    </template>
                     <template v-else-if="n.v.ps != undefined && n.v.ps.value === '璁惧鍚嶇О'">
                       <el-select v-model="n.v.v" :disabled="state > 1" class="table_input" filterable multiple
                         placeholder="璁惧" remote @change="(val) => changeEquip(val, n)"
@@ -98,9 +103,6 @@
                           {{ item.label + '--' + item.value }}
                         </el-option>
                       </el-select>
-                    </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>
                     </template>
                     <template v-else-if="n.v.ps != undefined && n.v.ps.value === '璁$畻鍊�' && state == 1"><span
                         :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) }}</span></template>
@@ -125,7 +127,8 @@
                     </template>
                     <template v-else-if="n.v.ps != undefined && n.v.ps.value === '濂楃'">
                       <div style="display: flex;flex-wrap: nowrap;align-items: center;">
-                        <div :style="`font-family:${n.v.ff} !important;`">{{ currentBushing ? currentBushing.color : '' }}
+                        <div :style="`font-family:${n.v.ff} !important;`">{{ currentBushing ? currentBushing.color : ''
+                          }}
                         </div>
                       </div>
                     </template>
@@ -249,11 +252,14 @@
   getInsProductUnqualifiedRetest,
   search, selectUserCondition,
   submitPlan,
-  verifyPlan
+  verifyPlan,
+  write
 } from "@/api/business/inspectionTask";
 import { getUserNow, saveUnqualifiedContext } from "@/api/business/rawMaterialOrder";
+import InspectionWorker from '@/workers/InspectionWorker.worker';
+import DataWorker from '@/workers/DataWorker.worker';
 export default {
-  props: ['sonLaboratory', 'orderId', 'state', 'inspectorList', 'typeSource', 'unPassCheck', 'rawMaterialTag'],
+  props: ['sonLaboratory', 'orderId', 'state', 'inspectorList', 'typeSource', 'unPassCheck', 'rawMaterialTag','cableTag', 'repetitionTag'],
   components: {
     AddUnPass,
     UnPassDialog
@@ -367,10 +373,9 @@
       numOptions: [],
       temperatureOptions: [],
       wareTableData: [],
-      otherForm: {
-        humidity: null,
-        temperature: null,
-      },
+      // 妫�娴嬫潯浠舵寜妯℃澘 id 鍒嗙粍锛歿 [templateId]: { temperature, humidity, detectionTime, detectionPlace, deviceIds } }
+      otherForm: {},
+      deviceOptions: [],
       equipForm: {
         value0: null,
         code0: null,
@@ -426,7 +431,7 @@
       getDataTypeId: '',
       getDataType: null,
       unPassDialog: false, // 涓嶅悎鏍煎鐞嗗脊妗�
-      retestTag: '', // 澶嶆祴娆℃暟
+      retestTag: '1', // 澶嶆祴娆℃暟
       addCheck: false, // 鎸囧畾瀹℃牳浜哄憳寮规
       checkUser: '',
       type: '',
@@ -445,6 +450,16 @@
     },
     action() {
       return this.javaApi + "/insOrderPlan/uploadFile";
+    },
+    // 褰撳墠妯℃澘瀵瑰簲鐨勬娴嬫潯浠�
+    currentOtherForm() {
+      return this.otherForm[this.currentTable] || {
+        temperature: null,
+        humidity: null,
+        detectionTime: null,
+        detectionPlace: null,
+        deviceIds: []
+      }
     }
   },
   created() {
@@ -480,15 +495,25 @@
         this.sampleProduct = res.data.sampleProduct
         this.currentSample = this.HaveJson(this.sampleProduct[0])
         let insProduct = this.HaveJson(this.currentSample.insProduct)
-        // 娓╁害銆佹箍搴﹁祴鍊�
-        this.otherForm = {
-          temperature: this.insOrder.temperature ? this.insOrder.temperature : null,
-          humidity: this.insOrder.humidity ? this.insOrder.humidity : null,
-        }
+        // 妫�娴嬫潯浠惰祴鍊硷細鎸夋ā鏉� id 鍒嗙粍鍥炴樉
+        this.otherForm = {}
+        const conditionList = this.insOrder.templateConditions || []
+        conditionList.forEach(item => {
+          this.$set(this.otherForm, item.templateId, {
+            temperature: item.temperature != null ? item.temperature : null,
+            humidity: item.humidity != null ? item.humidity : null,
+            detectionTime: item.detectionTime != null ? item.detectionTime : null,
+            detectionPlace: item.detectionPlace != null ? item.detectionPlace : null,
+            deviceIds: Array.isArray(item.deviceIds) ? [...item.deviceIds] : []
+          })
+        })
         if (this.typeSource == '1') {
           this.retestTag = '1'
         }
         this.getEquipOptions(1)
+        if (this.sonLaboratory === '鏂拌仛') {
+          this.loadDeviceOptions()
+        }
         // 鑾峰彇褰撳墠鏍峰搧鐨勬楠岄」
         let list = await this.getCurrentProduct(this.currentSample.id, 0)
         if (list === undefined) {
@@ -497,23 +522,10 @@
           return
         }
         this.currentSample.insProduct = this.HaveJson(list)
-        // 鍒濆鍖栦紶閫掑埌鍚庣鐨勫弬鏁�
+        // 鍒濆鍖栦紶閫掑埌鍚庣鐨勫弬鏁�,鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(r-c)鈥濆瓨
         this.param = {}
         this.changeType = 0;
-        this.currentSample.insProduct.forEach(a => {
-          // 鏄惁涓烘垚鍝佺數缂嗕笅鐨勬澗濂楃椤圭洰锛屼笉鏄垯鎵ц鍒濆鍖�
-          if (this.handleCasing(a.inspectionItem)) {
-            this.param[a.id] = {
-              insValue: [],
-              comValue: [],
-              resValue: null,
-              equipValue: [],
-              equipName: [],
-              insResult: null
-            }
-          }
-        })
-        await this.determineWhetherToCollectData()//鏄惁闇�瑕佹暟閲�
+        // await this.determineWhetherToCollectData()//鏄惁闇�瑕佹暟閲�
         if (this.currentSample.index == undefined) this.currentSample['index'] = 1
         let bushing = this.currentSample.bushing
         this.getTableLists();//澶勭悊妯℃澘鍒楄〃淇℃伅
@@ -532,19 +544,7 @@
           if (m.templateId == val1) {
             let list = await this.getCurrentProduct(this.currentSample.id, 0)
             this.currentSample.insProduct = this.HaveJson(list)//璧嬪�煎綋鍓嶆牱鍝佺殑妫�楠岄」
-            this.param = {}//鍒濆鍖栦紶鍒板悗绔殑鍙傛暟
-            this.currentSample.insProduct.forEach((a, j) => {
-              if (this.handleCasing(a.inspectionItem)) {
-                this.param[a.id] = {
-                  insValue: [],
-                  comValue: [],
-                  resValue: null,
-                  equipValue: [],
-                  equipName: [],
-                  insResult: null
-                }
-              }
-            })
+            this.param = {}//鍒濆鍖栦紶鍒板悗绔殑鍙傛暟,鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(r-c)鈥濆瓨
             // 鍘婚噸妯℃澘锛岃繑鍥炴湁鍑犱釜妯℃澘
             const mySet1 = new Set();
             this.tableLists = this.currentSample.insProduct.filter(m => {
@@ -567,6 +567,8 @@
             if (this.tableLists && this.tableLists.length > 0) {
               this.tableList = null;
               this.tableList = this.tableLists.filter(m => m.templateId == val1)
+              // 妯℃澘闆嗗悎鍙兘鍙樺寲锛岃ˉ榻愭俯搴︺�佹箍搴︽Ы浣�
+              this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
               // 瀵规ā鏉胯繘琛屽鐞�
               this.handleTableData()
             }
@@ -577,47 +579,7 @@
     // 鐗规畩妫�楠岄」--鐩戝惉璁惧淇℃伅鏀瑰彉
     equipForm: {
       deep: true,
-      handler(val) {
-        if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '娓╁害寰幆妫�楠屽師濮嬭褰�' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('鐑惊鐜�') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('娓╁崌璇曢獙')) && this.equipOptions && this.equipOptions.length > 0) {
-          // 鍒濆鍖栬澶囦俊鎭�
-          this.param[this.currentSample.insProduct[0].id].equipValue = []
-          this.param[this.currentSample.insProduct[0].id].equipName = []
-          if (this.equipForm.code0) {
-            // 璧嬪�肩涓�涓澶囩殑淇℃伅
-            this.equipForm.value0 = this.equipOptions.find(m => m.value == this.equipForm.code0).label
-            this.param[this.currentSample.insProduct[0].id].equipValue.push({
-              i: this.currentSample.insProduct[0].id,
-              v: {
-                v: this.equipForm.code0
-              }
-            })
-            this.param[this.currentSample.insProduct[0].id].equipName.push({
-              i: this.currentSample.insProduct[0].id,
-              v: {
-                v: this.equipForm.value0
-              }
-            })
-          }
-          if (this.equipForm.code1) {
-            // 璧嬪�肩浜屼釜璁惧鐨勪俊鎭�
-            this.equipForm.value1 = this.equipOptions.find(m => m.value == this.equipForm.code1).label
-            this.param[this.currentSample.insProduct[0].id].equipValue.push({
-              i: this.currentSample.insProduct[0].id,
-              v: {
-                v: this.equipForm.code1
-              }
-            })
-            this.param[this.currentSample.insProduct[0].id].equipName.push({
-              i: this.currentSample.insProduct[0].id,
-              v: {
-                v: this.equipForm.value1
-              }
-            })
-          }
-          // 淇濆瓨鏁版嵁
-          this.saveInsContext()
-        }
-      }
+      handler(val) { },
     },
   },
   beforeDestroy() {
@@ -816,12 +778,12 @@
         this.stopWorker(); // 纭繚涔嬪墠鐨� Worker 宸插仠姝�
       }
       // 鍒涘缓 Worker 瀹炰緥
-      this.worker = new Worker('/static/js/worker.js');
+      this.worker = new InspectionWorker();
       if (this.worker0) {
         this.stopWorker(); // 纭繚涔嬪墠鐨� Worker 宸插仠姝�
       }
       // 鍒涘缓 Worker 瀹炰緥
-      this.worker0 = new Worker('/static/js/worker0.js');
+      this.worker0 = new DataWorker();
     },
     // 鍋滄澶氱嚎绋�
     stopWorker() {
@@ -845,8 +807,11 @@
         laboratory: this.sonLaboratory,
         retestTag: this.retestTag,
         rawMaterialTag: this.rawMaterialTag,
+        repetitionTag: this.repetitionTag,
+        cableTag: this.cableTag,
       }
-      let res = getInsProductUnqualifiedRetest(params)
+      let res = await getInsProductUnqualifiedRetest(params)
+      console.log('res---', res)
       if (res.code === 200 && res.data.length > 0) {
         this.tableLoading = false;
         this.scrollInit()
@@ -878,16 +843,6 @@
         let list = await this.getCurrentProduct(m, type, cableTag)
         if (list.length > 0) {
           this.param = {}
-          list.forEach(a => {
-            this.param[a.id] = {
-              insValue: [],
-              comValue: [],
-              resValue: null,
-              equipValue: [],
-              equipName: [],
-              insResult: null
-            }
-          })
           this.getTableLists0(list)
           this.worker.postMessage(JSON.stringify({
             type: 'saveData',
@@ -945,6 +900,8 @@
         this.tableList = null;
         this.tableList = [this.tableLists[0]]
         this.currentTable = this.tableLists[0].templateId;
+        // 琛ラ綈姣忎釜妯℃澘鐨勬俯搴︺�佹箍搴︽Ы浣�
+        this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
         // 澶勭悊椤甸潰鍒楄〃鏁版嵁
         this.handleTableData()
       }
@@ -974,6 +931,8 @@
         this.tableList = [this.tableLists[0]]
         this.currentTable = this.tableLists[0].templateId;
         this.currentSample.insProduct = this.HaveJson(list)
+        // 琛ラ綈姣忎釜妯℃澘鐨勬俯搴︺�佹箍搴︽Ы浣�
+        this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
         // 澶勭悊椤甸潰鍒楄〃鏁版嵁
         this.handleTableData()
       }
@@ -1068,129 +1027,19 @@
           count++
         })
       })
-      // 鏈寰幆涓昏鏄帶鍒跺悎骞�,浠ュ強鎺у埗妫�楠岄」淇℃伅鏄惁灞曠ず鍑烘潵,浠ヤ究鍚庣画妫�楠�
+      // 鎸夊悗绔笅鍙戠殑鈥滄ā鏉縄D + 妯℃澘琛屽彿鈥濈洿鎺ョ粦瀹氭楠岄」锛屼笉鍋氬悕绉版瘮瀵癸紝涓嶉殣钘忎换浣曡
       this.tableList.forEach(a => {
-        let dels = new Set()//闇�瑕佸垹闄ょ殑琛�
-        let ids = []//鎵�鏈夋楠岄」鐨刬d
-        let set3 = new Set()
-        a.template.forEach(b => {
-          let size1 = set3.size
-          let size2 = set3.add(b.r).size
-          if (size1 < size2) {
-            let str = ''
-            let str2 = ''
-            let unit2 = ''
-            let count4 = 0
-            let isThree = 0
-            a.template.forEach(c => {
-              // 鑾峰彇鍒� 妫�楠岄」鍒嗙被+妫�楠岄」+妫�楠屽瓙椤圭殑鎷兼帴,濡傛灉妯℃澘閲岀殑淇℃伅璺熸帴鍙h繑鍥炵殑妫�楠岄」淇℃伅鑳藉鍖归厤鍒欏睍绀哄嚭鏉�
-              if (b.r === c.r) {
-                if (c.v.ps != undefined && c.v.ps.value === '妫�楠岄」鍒嗙被' && count4 === 0) {
-                  // 涓夌骇鍒嗙被
-                  isThree = 1
-                } else if (c.v.ps != undefined && c.v.ps.value === '妫�楠岄」' && count4 === 0) {
-                  // 浜岀骇鍒嗙被
-                  isThree = 0
-                }
-                if (isThree == 0) {
-                  if (c.v.ps != undefined && c.v.ps.value === '妫�楠岄」') {
-                    if (count4 === 0) {
-                      str += c.v.v
-                      count4 += 1
-                    }
-                  } else if (c.v.ps != undefined && c.v.ps.value === '妫�楠屽瓙椤�') {
-                    if (count4 === 1) {
-                      str += c.v.v
-                      count4 += 1
-                    }
-                  }
-                } else if (isThree == 1) {
-                  if (c.v.ps != undefined && c.v.ps.value === '妫�楠岄」鍒嗙被') {
-                    if (count4 === 0) {
-                      str += c.v.v
-                      count4 += 1
-                    }
-                  } else if (c.v.ps != undefined && c.v.ps.value === '妫�楠岄」') {
-                    if (count4 === 1) {
-                      str += c.v.v
-                      count4 += 1
-                    }
-                  } else if (c.v.ps != undefined && c.v.ps.value === '妫�楠屽瓙椤�') {
-                    if (count4 === 2) {
-                      str += c.v.v
-                      count4 += 1
-                    }
-                  }
-                }
-                if (str === '鏈烘鎬ц兘骞叉�佹媺浼稿己搴�(绾靛悜)') {
-                  if (c.v.ps != undefined && c.v.ps.value === '鍗曚綅') {
-                    str2 = str + c.v.v
-                    unit2 = c.v.v
-
-                  }
-                }
-              }
-            })
-            if (str != '') {
-              let count2 = 0
-              for (let i in this.currentSample.insProduct) {
-                let inspectionItemClass = this.currentSample.insProduct[i].inspectionItemClass == null || this.currentSample.insProduct[i].inspectionItemClass == undefined ? '' : this.currentSample.insProduct[i].inspectionItemClass
-                let inspectionItem = this.currentSample.insProduct[i].inspectionItem == null || this.currentSample.insProduct[i].inspectionItem == undefined ? '' : this.currentSample.insProduct[i].inspectionItem
-                let inspectionItemSubclass = this.currentSample.insProduct[i].inspectionItemSubclass == null || this.currentSample.insProduct[i].inspectionItemSubclass == undefined ? '' : this.currentSample.insProduct[i].inspectionItemSubclass
-                if (inspectionItemSubclass === '骞叉�佹媺浼稿己搴�(绾靛悜)') {
-                  // 妫�楠屽瓙椤逛负'骞叉�佹媺浼稿己搴�(绾靛悜)'鏃讹紝妯$増閲屾槸涓や釜璁$畻鍊煎搴旂浉鍚岀殑妫�楠屽�煎苟涓旇绠楁柟寮忎笉鍚岋紝瑕佹牴鎹浉鍚岀殑'鍗曚綅'鍋氱壒娈婄殑娓叉煋
-                  const unit = this.currentSample.insProduct[i].unit
-                  if ((this.currentSample.insProduct[i].templateId === a.templateId && inspectionItemClass + inspectionItem + inspectionItemSubclass + unit === str2) || (this.currentSample.insProduct[i].templateId === a.templateId && !unit2.includes('/') && inspectionItemClass + inspectionItem + inspectionItemSubclass === str)) {
-                    ids.push({
-                      r: b.r,
-                      id: this.currentSample.insProduct[i].id,
-                      product: this.currentSample.insProduct[i]
-                    })
-                    break
-                  }
-                } else {
-                  // 濡傛灉鐩哥瓑,閭d箞璇存槑鎵惧埌浜�,骞朵笖鎶奿d瀛樿捣鏉�,鍚庣画妫�楠岄」涔熶細鍦ㄩ〉闈腑鏄剧ず鍑烘潵
-                  if (this.currentSample.insProduct[i].templateId === a.templateId && inspectionItemClass + inspectionItem + inspectionItemSubclass === str) {
-                    ids.push({
-                      r: b.r,
-                      id: this.currentSample.insProduct[i].id,
-                      product: this.currentSample.insProduct[i]
-                    })
-                    break
-                  }
-                }
-                count2++
-              }
-              if (count2 == this.currentSample.insProduct.length) {
-                dels.add(b.r)
-              }
+        const directProducts = this.currentSample.insProduct.filter(
+          (product) => product.templateId === a.templateId &&
+            product.templateRowIndex !== null && product.templateRowIndex !== undefined
+        );
+        directProducts.forEach((product) => {
+          a.template.forEach((cell) => {
+            if (cell.r === product.templateRowIndex) {
+              cell.i = product.id;
             }
-          }
-        })
-        // 鎿嶄綔鍒犻櫎
-        dels.forEach(del => {
-          for (let b = 0; b < a.template.length; b++) {
-            if (a.template[b].r === del) {
-              a.template.splice(b, 1)
-              b -= 1
-            }
-          }
-        })
-        // 鎿嶄綔璧嬪��--涓昏璧嬪�煎崟浣�,璇曢獙鏂规硶绛変俊鎭�
-        ids.forEach(id => {
-          for (let b = 0; b < a.template.length; b++) {
-            if (a.template[b].r === id.r) {
-              a.template[b].i = id.id
-              if (a.template[b].v.ps != undefined && a.template[b].v.ps.value === '鍗曚綅') {
-                a.template[b].v.v = id.product.unit
-              }
-              if (a.template[b].v.ps != undefined && (a.template[b].v.ps.value === '璇曢獙鏂规硶' || a.template[b].v
-                .ps.value === '妫�娴嬫柟娉�')) {
-                a.template[b].v.v = id.product.methodS
-              }
-            }
-          }
-        })
+          });
+        });
         let set2 = new Set()
         // 鍚堝苟鐨勬暟鎹鐞�,cs  rs  浠h〃鍚堝苟鐨勬暟閲�
         a.template.forEach(b => {
@@ -1217,60 +1066,24 @@
         let arrs = []
         let set = new Set()
         let count1 = 0
-        let conclusionList = []; //缁撹鍒楄〃
-        let finalList = []; //鏈�缁堝�煎垪琛�
-        // 缁撹涓庢渶缁堝�煎湪杩欓噷涓�涓�瀵瑰簲,浠ヤ笅涓や釜鍒楄〃闀垮害鑲畾鏄竴鏍风殑,濡傛灉鏈変笉涓�鏍�,閭d箞澶氬崐鏄ā鏉块厤缃緱闂
-        conclusionList = a.template.filter(n => n.v.ps != undefined && n.v.ps.value === '缁撹')//缁撹鍒楄〃
-        finalList = a.template.filter(n => n.v.ps != undefined && n.v.ps.value === '鏈�缁堝��')//鏈�缁堝�煎垪琛�
         a.template.forEach(b => {
           if (b.v.ps != undefined && b.v.ps.value === '搴忓彿' && (b.v.mc == undefined || Object.keys(b.v.mc).length === 4)) {
             // 瀵瑰簭鍙疯繘琛岃祴鍊�
             count1++
             b.v.v = count1
           }
-          if (b.v.ps != undefined && b.v.ps.value === '瑕佹眰鍊�') {
-            // 瀵硅姹傚�艰繘琛岃祴鍊�
-            b.v.v = this.getAsk(b.i)
-          }
-          // 瀵归〉闈㈢殑鍜岀粰鍚庣浼犲弬鐨勬楠屽��,璁$畻鍊�,璁惧缂栫爜,璁惧鍚嶇О,鏈�缁堝��,缁撹杩涜鍒濆鍖�
-          if (b.v.ps != undefined && typeof b.v.ps.value === 'string' && b.v.ps.value.includes('妫�楠屽��')) {
+          // 鍒濆鍖栧彲濉啓/鍙绠楀崟鍏冩牸,鍚庣画鎸夊潗鏍囧洖鏄�
+          if (
+            b.v.ps != undefined &&
+            typeof b.v.ps.value === 'string' &&
+            (b.v.ps.value.includes('妫�楠屽��') ||
+              b.v.ps.value === '璁$畻鍊�' ||
+              b.v.ps.value === '鏈�缁堝��' ||
+              b.v.ps.value === '璁惧鍚嶇О')
+          ) {
             this.$set(b.v, 'v', '')
-            // b.v.v = ''
-            b.u = ''
-            b.i && this.param[b.i] && this.param[b.i].insValue.push(b)
-          }
-          if (b.v.ps != undefined && b.v.ps.value === '璁$畻鍊�') {
-            this.$set(b.v, 'v', '')
-            // b.v.v = ''
-            b.i && this.param[b.i] && this.param[b.i].comValue.push(b)
-          }
-          if (b.v.ps != undefined && b.v.ps.value === '璁惧缂栫爜') {
-            // b.v.v = ''
-            this.$set(b.v, 'v', '')
-            b.i && this.param[b.i] && this.param[b.i].equipValue.push(b)
-          }
-          if (b.v.ps != undefined && b.v.ps.value === '璁惧鍚嶇О') {
-            this.$set(b.v, 'v', '')
-            // b.v.v = ''
-            b.i && this.param[b.i] && this.param[b.i].equipName.push(b)
-          }
-          if (b.v.ps != undefined && b.v.ps.value === '鏈�缁堝��') {
-            // b.v.v = ''
-            this.$set(b.v, 'v', '')
-            if (b.i !== undefined && this.param[b.i] && !this.param[b.i].resValue) {
-              this.param[b.i].resValue = b
-            }
-          }
-          if (b.v.ps != undefined && b.v.ps.value === '缁撹') {
-            if (b.i !== undefined && this.param[b.i] && !this.param[b.i].insResult) {
-              this.param[b.i].insResult = b
-              conclusionList.forEach((n, i) => {
-                if (n.r == b.r && n.c == b.c) {
-                  b.v.f =
-                    `(${this.comparisonList.find(j => j.value == (finalList[i].c)).label}${finalList[i].r + 1})`
-
-                }
-              })
+            if (b.v.ps.value.includes('妫�楠屽��')) {
+              b.u = ''
             }
           }
           set.add(b.r)
@@ -1280,7 +1093,8 @@
           }
         })
         // 浠ヤ笅鏄牱寮忓鐞嗛�昏緫
-        set = Array.sort(set)
+        // set = Array.sort(set)
+        set = [...set]
         set.forEach(b => {
           let arr = []
           a.template.forEach(c => {
@@ -1296,97 +1110,45 @@
           this.tableWidth += (a.style.columnlen[i] === undefined ? 100 : a.style.columnlen[i])
         }
       })
-      // 鏈寰幆涓昏鏄椤甸潰鍙婂悗绔紶鍙傝繘琛屽垵濮嬪寲璧嬪��
-      this.currentSample.insProduct.forEach(async a => {
-        try {
-          // 璁$畻鍊艰祴鍊�
-          let comValue = JSON.parse(a.insProductResult.comValue)
-          for (var i = 0; i < comValue.length; i++) {
-            this.param[a.id].comValue[i].v.v = this.toFixed(comValue[i].v, this.param[a.id].comValue[i].v.ct)
-          }
-        } catch (e) { }
-        try {
-          // 妫�楠屽�艰祴鍊�
-          let insValue = JSON.parse(a.insProductResult.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 = this.toFixed(insValue[i].v, this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).v.ct)
-              this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).u = insValue[i].u
-              // this.param[a.id].insValue[i].v.v = insValue[i].v
-              // this.param[a.id].insValue[i].u = insValue[i].u
-            }
-          }
-        } catch (e) { }
-        try {
-          // 璁惧缂栧彿璧嬪��
-          let equipValue = JSON.parse(a.insProductResult.equipValue)
-          if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '娓╁害寰幆妫�楠屽師濮嬭褰�' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('鐑惊鐜�') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('娓╁崌璇曢獙'))) {
-            // 鐗规畩椤圭洰鍒濆鍖�
-            this.param[a.id].equipValue = []
-            for (let i = 0; i < equipValue.length; i++) {
-              this.param[a.id].equipValue.push({
-                v: {
-                  v: ''
-                }
-              })
-            }
-          }
-          for (let i = 0; i < equipValue.length; i++) {
-            if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '娓╁害寰幆妫�楠屽師濮嬭褰�' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('鐑惊鐜�') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('娓╁崌璇曢獙'))) {
-              // 娓╁害寰幆璁惧璧嬪��
-              this.$set(this.equipForm, `code` + i, equipValue[i].v)
-              this.param[a.id].equipValue[i].v.v = equipValue[i].v
-            } else {
-              // 鏅�氳澶囪祴鍊�
-              this.param[a.id].equipValue[i].v.v = equipValue[i].v
-            }
-          }
-        } catch (e) { }
-        try {
-          // 璁惧鍚嶇О璧嬪��
-          let equipName = JSON.parse(a.insProductResult.equipName)
-          for (let i = 0; i < equipName.length; i++) {
-            equipName[i].v !== '' && equipName[i].v.map(val => {
-              const index = this.equipOptions.findIndex(item => item.value === val)
-              if (index > -1) {
-                // 鏍规嵁璁惧缂栫爜杞崲涓虹浉搴旂殑璁惧鍚嶇О
-                val = this.equipOptions[index].deviceName
-              }
-            })
-          }
-          if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '娓╁害寰幆妫�楠屽師濮嬭褰�' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('鐑惊鐜�') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('娓╁崌璇曢獙'))) {
-            // 璁惧鍚嶇О鍒濆鍖�
-            this.param[a.id].equipName = []
-            for (let i = 0; i < equipName.length; i++) {
-              this.param[a.id].equipName.push({
-                v: {
-                  v: ''
-                }
-              })
-            }
-          }
-          for (let i = 0; i < equipName.length; i++) {
-            if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '娓╁害寰幆妫�楠屽師濮嬭褰�' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('鐑惊鐜�') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('娓╁崌璇曢獙'))) {
-              // 娓╁害寰幆璧嬪��
-              this.$set(this.equipForm, `value` + i, equipName[i].v)
-              this.param[a.id].equipName[i].v.v = equipName[i].v
-            } else {
-              // 鏅�氳澶囧悕绉拌祴鍊�
-              this.param[a.id].equipName[i].v.v = equipName[i].v
-            }
-          }
-        } catch (e) {
-          console.log('璁惧鍚嶇О璧嬪��----', e)
-        }
-        try {
-          // 鏈�缁堝�艰祴鍊�
-          this.param[a.id].resValue.v.v = this.toFixed(a.lastValue, this.param[a.id].resValue.v.ct)
-          // 缁撹璧嬪��
-          this.param[a.id].insResult.v.v = a.insResult
-        } catch (e) { }
-      })
+      // 鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(r-c)鈥濆洖鏄惧凡淇濆瓨鐨勫��
+      this.initParamByCoordinate()
       // 瀵筫xcel鍑芥暟杩涜澶勭悊
       this.handleExcelMethod()
+    },
+    // 鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(r-c)鈥濆洖鏄惧凡淇濆瓨鐨勫��
+    initParamByCoordinate() {
+      this.param = {}
+      this.tableList.forEach(a => {
+        this.param[a.templateId] = {}
+        const product = this.currentSample.insProduct.find(m => m.templateId === a.templateId)
+        let saved = (product && (product.recordValues || product.insProductResult)) || {}
+        if (typeof saved === 'string') {
+          try {
+            saved = JSON.parse(saved)
+          } catch (e) {
+            saved = {}
+          }
+        }
+        a.template.forEach(cell => {
+          const key = `${cell.r}-${cell.c}`
+          const item = saved[key]
+          if (item === undefined || item === null) {
+            return
+          }
+          const value = typeof item === 'object' ? item.v : item
+          if (value === undefined || value === null) {
+            return
+          }
+          cell.v.v = value
+          if (typeof item === 'object' && item.u) {
+            cell.u = item.u
+          }
+          this.param[a.templateId][key] = {
+            v: value,
+            u: typeof item === 'object' ? item.u : cell.u
+          }
+        })
+      })
     },
     // 妫�楠屽�艰緭鍏ュ悗瑙﹀彂鐨勫嚱鏁�
     changeInput(m, code, n, getDataType) {
@@ -1394,9 +1156,7 @@
       if (getDataType == 'getDataType') {
         this.getDataType = 2;
       }
-      let currentInsItemId = null//褰撳墠妫�楠岄」id
       if (n) {
-        currentInsItemId = JSON.parse(JSON.stringify(n.i))
         // 瀹氫箟涓�涓嚱鏁版潵楠岃瘉鍒嗘暟鏄惁鏈夋晥
         if (typeof n.v.v == 'string') {
           function isValidFraction(fraction) {
@@ -1424,6 +1184,10 @@
           modelType: this.sampleProduct[0].model,
           currentInsItem: n
         }));
+        // 鍏堜繚瀛樹富绾跨▼涓凡缁忚緭鍏ョ殑鍘熷鍊笺�俉orker 瀹屾垚璁$畻鍚庝細鍐嶆鍏ラ槦淇濆瓨璁$畻缁撴灉銆�
+        if (n) {
+          this.saveInsContext()
+        }
       } catch (error) {
         console.log(444, error);
       }
@@ -1433,24 +1197,11 @@
         this.result = JSON.parse(event.data);
         switch (this.result.method) {
           case 'saveInsContext':
-            console.log(`output->`, 11111111111111)
             this.$nextTick(() => {
-              // this.$delete(this.tableList[0],'arr')
-              this.$set(this.tableList[0], 'arr', this.result.value.tableList[0].arr)
-              this.param = this.result.value.param
-              if (this.result.value.currentInsItem) {
-                currentInsItemId = this.result.value.currentInsItem.i
-              }
-              // 鐗规畩澶勭悊涓�涓嬬粨璁�,浼氭湁杩欑鐗规畩鎯呭喌
-              for (var i in this.param) {
-                if (this.param[i].insResult && this.param[i].insResult.v && this.param[i].insResult.v.v) {
-                  if (this.param[i].insResult.v.v == '鍚堟牸') {
-                    this.$set(this.param[i].insResult.v, 'v', 1)
-                  } else if (this.param[i].insResult.v.v == '涓嶅悎鏍�') {
-                    this.$set(this.param[i].insResult.v, 'v', 0)
-                  }
-                }
-              }
+              const resultValue = this.result.value
+              this.$set(this.tableList[0], 'arr', resultValue.tableList[0].arr)
+              this.param = resultValue.param
+              this.saveInsContext()
             })
             break;
           case 'tableList':
@@ -1458,116 +1209,16 @@
               // 鏇存柊鏁版嵁
               this.$delete(this.tableList[0], 'arr')
               this.$set(this.tableList[0], 'arr', this.result.value[0].arr)
-              // this.param = this.result.value.param
-              if (this.result.value.currentInsItem) {
-                currentInsItemId = this.result.value.currentInsItem.i
-              }
             })
-            break;
-          case 'getCurrentInsProduct':
-            // 鏇存柊椤甸潰鏁版嵁
-            this.getCurrentInsProduct(this.result.value)
             break;
         }
       };
-      // 淇濆瓨鏁版嵁
-      setTimeout(() => {
-        this.saveInsContext(currentInsItemId)
-      }, 200)
     },
     // 鏄惁闇�瑕佹暟閲�
-    async determineWhetherToCollectData() {
-      let res = determineWhetherToCollectData({ managementNumber: '' })
-      this.isGet = res.data
-    },
-    // 鏍规嵁鍚庣浼犲弬鏇存柊椤甸潰鏁版嵁   param => this.tableList[0].insProductResult
-    getCurrentInsProduct(pId) {
-      if (!this.tableList[0].insProductResult) {
-        this.tableList[0].insProductResult = {}
-      }
-      for (let m in this.param[pId]) {
-        let value = this.param[pId][m]
-        switch (m) {
-          case 'comValue':
-            // 璧嬪�艰绠楀��
-            if (value && value.length > 0) {
-              this.tableList[0].insProductResult[m] = [];
-              value.forEach((a, i) => {
-                let obj = {
-                  v: a.v.v,
-                }
-                this.tableList[0].insProductResult[m].push(obj);
-              })
-              try {
-                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
-              } catch (error) {
-                console.log(555, error);
-              }
-            }
-            break;
-          // 璧嬪�兼楠屽��
-          case 'insValue':
-            if (value && value.length > 0) {
-              this.tableList[0].insProductResult[m] = [];
-              value.forEach((a, i) => {
-                let obj = {
-                  v: a.v.v,
-                  u: a.u,
-                }
-                this.tableList[0].insProductResult[m].push(obj);
-              })
-              try {
-                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
-              } catch (error) {
-                console.log(666, error);
-              }
-            }
-            break;
-          // 璧嬪�艰澶囩紪鍙�
-          case 'equipValue':
-            if (value && value.length > 0) {
-              this.tableList[0].insProductResult[m] = [];
-              value.forEach((a, i) => {
-                let obj = {
-                  v: a.v.v,
-                }
-                this.tableList[0].insProductResult[m].push(obj);
-              })
-              try {
-                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
-              } catch (error) {
-                console.log(777, error);
-              }
-            }
-            break;
-          // 璧嬪�艰澶囧悕绉�
-          case 'equipName':
-            if (value && value.length > 0) {
-              this.tableList[0].insProductResult[m] = [];
-              value.forEach((a, i) => {
-                let obj = {
-                  v: a.v.v,
-                }
-                this.tableList[0].insProductResult[m].push(obj);
-              })
-              try {
-                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
-              } catch (error) {
-                console.log(888, error);
-              }
-            }
-            break;
-          // 璧嬪�兼渶缁堝��
-          case 'resValue':
-            this.tableList[0].lastValue = value ? value.v.v : ''
-            break;
-          // 璧嬪�肩粨璁�
-          case 'insResult':
-            this.tableList[0].insResult = value ? value.v.v : ''
-            break;
-        }
-      }
-    },
+    // async determineWhetherToCollectData() {
+    //   let res = determineWhetherToCollectData({ managementNumber: '' })
+    //   this.isGet = res.data
+    // },
     // 瀵笶XCEL鍑芥暟杩涜澶勭悊
     handleExcelMethod() {
       if (this.excelMethodList.length > 0) {
@@ -1601,14 +1252,6 @@
         }
       }
     },
-    // 鑾峰彇瑕佹眰鎻忚堪
-    getTell(id) {
-      for (var a in this.currentSample.insProduct) {
-        if (this.currentSample.insProduct[a].id == id) {
-          return this.currentSample.insProduct[a].tell
-        }
-      }
-    },
     // 鍔ㄦ�佽幏鍙栧崟鍏冩牸瀹藉害
     handleWidth(n) {
       let sum = 0;
@@ -1625,15 +1268,24 @@
     // 瀵硅緭鍏ュ�艰繘琛屾牸寮忔牎楠�
     handleInput(n) {
       try {
-        n.v.v = n.v.v.replace(/[^\d.^e>\-/+]/g, '');
-        n.v.v = n.v.v.replace(/\.{2,}/g, "."); //鍙繚鐣欑涓�涓�. 娓呴櫎澶氫綑鐨�
-        n.v.v = n.v.v.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
-        n.v.v = n.v.v.replace(/\/{2,}/g, "/"); //鍙繚鐣欑涓�涓�/娓呴櫎澶氫綑鐨�
-        n.v.v = n.v.v.replace("/", "$#$").replace(/\//g, "").replace("$#$", "/");
+        const v = n.v.v;
+        // 鑳藉姏鑼冨洿宸插簾寮�,妫�楠屽�肩被鍨嬩笉鍐嶄綔涓哄垽鏂緷鎹�傛暣涓插彧鐢辩畻寮忓瓧绗︾粍鎴愭椂鎵嶈鑼冨寲鏍煎紡,
+        // 鍑虹幇涓枃绛夊叾瀹冨瓧绗﹀嵆鎸夋枃鏈鐞嗗師鏍蜂繚鐣�,鍚﹀垯鏂囧瓧浼氳閫愬瓧鍒犳帀
+        if (typeof v !== "string" || /[^\d.^e>锛炩墺鈮�<锛滄柇瑁傝剢鍖朶-/+]/.test(v)) {
+          return;
+        }
+        n.v.v = v
+          .replace(/\.{2,}/g, ".") //鍙繚鐣欑涓�涓�. 娓呴櫎澶氫綑鐨�
+          .replace(".", "$#$")
+          .replace(/\./g, "")
+          .replace("$#$", ".")
+          .replace(/\/{2,}/g, "/") //鍙繚鐣欑涓�涓�/娓呴櫎澶氫綑鐨�
+          .replace("/", "$#$")
+          .replace(/\//g, "")
+          .replace("$#$", "/");
       } catch (error) {
         console.log(error);
       }
-
     },
     getInspectionItemType(id) {
       for (var a in this.currentSample.insProduct) {
@@ -1642,26 +1294,22 @@
         }
       }
     },
-    // 鑾峰彇瑕佹眰鍊�
-    getAsk(id) {
-      for (var a in this.currentSample.insProduct) {
-        if (this.currentSample.insProduct[a].id == id) {
-          return this.currentSample.insProduct[a].ask
-        }
-      }
-    },
     getSystemValue(n) {
       let code = null
       try {
-        this.param[n.i].equipValue.forEach(a => {
-          if (a.r === n.r) {
-            if (a.v.v == null || a.v.v == '') {
-              this.$message.error('璇峰厛閫夋嫨閲囬泦鐨勮澶�')
-              return
-            } else {
-              code = a.v.v
-            }
-          }
+        this.tableList.forEach(table => {
+          (table.arr || []).forEach(row => {
+            row.forEach(cell => {
+              if (cell.i == n.i && cell.r === n.r && cell.v.ps && cell.v.ps.value === '璁惧缂栫爜') {
+                if (cell.v.v == null || cell.v.v == '') {
+                  this.$message.error('璇峰厛閫夋嫨閲囬泦鐨勮澶�')
+                  return
+                } else {
+                  code = cell.v.v
+                }
+              }
+            })
+          })
         })
       } catch (e) {
         // console.log(e);
@@ -1696,6 +1344,21 @@
           console.error(error)
         })
       }
+    },
+    // 鏂拌仛鐩存帴缁戝畾妯℃澘鐨勫崟鎹紝璁惧鎸夋ā鏉块�夋嫨
+    isDirectTemplateOrder() {
+      return this.sonLaboratory === '鏂拌仛' && this.currentSample &&
+        (this.currentSample.insProduct || []).some(product => product.templateRowIndex != null)
+    },
+    loadDeviceOptions() {
+      search({ status: 0 }).then(res => {
+        this.deviceOptions = (res.data || []).map(device => ({
+          id: device.id,
+          label: `${device.deviceName}--${device.managementNumber}`
+        }))
+      }).catch(error => {
+        console.error(error)
+      })
     },
     getUserInfo() {
       getUserNow().then(res => {
@@ -1751,17 +1414,54 @@
         this.$message.error('鏈緭鍏ヤ笉閫氳繃鍘熷洜')
       }
     },
+    // 淇濊瘉妯℃澘鐨勬娴嬫潯浠舵Ы浣嶅瓨鍦�
+    ensureOtherForm(templateId) {
+      if (templateId == null) return
+      if (!this.otherForm[templateId]) {
+        this.$set(this.otherForm, templateId, {
+          temperature: null,
+          humidity: null,
+          detectionTime: null,
+          detectionPlace: null,
+          deviceIds: []
+        })
+      }
+    },
+    // 淇濆瓨褰撳墠妯℃澘鐨勬娴嬫潯浠�
+    subOtherForm(m, type) {
+      const payload = {
+        id: this.insOrder.id,
+        templateId: this.currentTable
+      }
+      if (type === 'deviceIds') {
+        payload.deviceIds = Array.isArray(m) ? [...m] : []
+      } else if (type === 'detectionTime' || type === 'detectionPlace') {
+        payload[type] = m === '' || m == null ? null : m
+      } else {
+        payload[type] = Number(m)
+      }
+      write(payload).then(res => {
+        this.$message.success("淇濆瓨鎴愬姛")
+      })
+    },
     submit() {
       if (this.verifyUser === null || this.verifyUser === '') {
         this.$message.error("璇锋寚瀹氬鏍镐汉鍛�")
         return
       }
-      if (!this.otherForm.humidity) {
-        this.$message.error("璇疯緭鍏ユ箍搴�")
-        return
-      }
-      if (!this.otherForm.temperature) {
-        this.$message.error("璇疯緭鍏ユ俯搴�")
+      const missing = []
+      this.tableLists.forEach(m => {
+        const form = this.otherForm[m.templateId] || {}
+        if (!form.temperature) missing.push(`璇峰~鍐欍��${m.templateName}銆嶇殑娓╁害`)
+        if (!form.humidity) missing.push(`璇峰~鍐欍��${m.templateName}銆嶇殑婀垮害`)
+        if (!form.detectionTime) missing.push(`璇烽�夋嫨銆�${m.templateName}銆嶇殑妫�娴嬫椂闂碻)
+        if (!form.detectionPlace) missing.push(`璇峰~鍐欍��${m.templateName}銆嶇殑妫�娴嬪湴鐐筦)
+        if (this.isDirectTemplateOrder() && (!form.deviceIds || form.deviceIds.length === 0)) {
+          missing.push(`璇烽�夋嫨銆�${m.templateName}銆嶇殑璁惧`)
+        }
+      })
+      if (missing.length > 0) {
+        this.$message.error(missing[0])
         return
       }
       this.submitLoading = true;
@@ -1770,13 +1470,14 @@
         laboratory: this.sonLaboratory,
       }).then(res => {
         if (res.code === 200) {
-          if (!res.data || res.data.length == 0) {
+          if (!res.data || res.data.errorMsg.length == 0) {
             this.submitLoading = true;
             submitPlan({
               orderId: this.orderId,
               laboratory: this.sonLaboratory,
               verifyUser: this.verifyUser,
-              entrustCode: this.insOrder.entrustCode
+              entrustCode: this.insOrder.entrustCode,
+              registerInsResults: false,
             }).then(res => {
               if (res.code === 200) {
                 this.$message.success("鎿嶄綔鎴愬姛")
@@ -1791,12 +1492,12 @@
           } else {
             let newData = []
             const h = this.$createElement
-            for (let i in res.data) {
-              const lastChar = res.data[i].slice(-1);
+            for (let i in res.data.errorMsg) {
+              const lastChar = res.data.errorMsg[i].slice(-1);
               if (lastChar == '-') {
-                res.data[i] = res.data[i].slice(0, -1);
+                res.data.errorMsg[i] = res.data.errorMsg[i].slice(0, -1);
               }
-              newData.push(h('p', { style: 'font-size: 14px;color: red;' }, (Number(i) + 1) + '銆�' + res.data[i]))
+              newData.push(h('p', { style: 'font-size: 14px;color: red;' }, (Number(i) + 1) + '銆�' + res.data.errorMsg[i]))
             }
             newData.push(h('p', { style: 'font-size: 16px;color:#000;margin-top:12px;overflow-y: auto;max-height:80vh' }, '浠ヤ笂椤圭洰涓嶅悎鏍硷紝纭畾鎻愪氦锛�'))
             this.$confirm('鎻愮ず', {
@@ -1810,7 +1511,8 @@
               submitPlan({
                 orderId: this.orderId,
                 laboratory: this.sonLaboratory,
-                verifyUser: this.verifyUser
+                verifyUser: this.verifyUser,
+                registerInsResults: false,
               }).then(res => {
                 if (res.code === 200) {
                   this.$message.success("鎿嶄綔鎴愬姛")
@@ -1831,94 +1533,100 @@
       })
       return
     },
-    // 缁熶竴鍦ㄨ繖閲屼繚瀛樻暟鎹�
-    saveInsContext(currentInsItemId) {
-      try {
-        if (this.param) {
-          let param = null
-          if (currentInsItemId) {
-            param = { [currentInsItemId]: this.param[currentInsItemId] }
-          } else {
-            param = this.param
+    // 鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(r-c)鈥濅粠褰撳墠妯℃澘蹇収鍑哄緟淇濆瓨鍙傛暟
+    buildParam() {
+      const param = {}
+      this.tableList.forEach(a => {
+        param[a.templateId] = {}
+        a.template.forEach(cell => {
+          const isEditable =
+            cell.v.ps != undefined &&
+            typeof cell.v.ps.value === 'string' &&
+            (cell.v.ps.value.includes('妫�楠屽��') ||
+              cell.v.ps.value === '璁$畻鍊�' ||
+              cell.v.ps.value === '鏈�缁堝��' ||
+              cell.v.ps.value === '璁惧鍚嶇О')
+          if (!isEditable) {
+            return
           }
-          saveUnqualifiedContext({
-            param: JSON.stringify(param),
-            currentTable: this.currentTable,
-            sampleId: this.currentSample.id
-          }).then(res => {
-            this.$message.success('宸蹭繚瀛�')
-          })
-          // 鍚� Worker 鍙戦�佹秷鎭紝寮�濮嬪鐞嗛�昏緫
-          this.worker.postMessage(JSON.stringify({
-            modelType: this.sampleProduct[0].model,
-            type: 'saveData',
-            tableList: this.tableList,
-            param: this.param,
-            currentTable: this.currentTable
-          }));
+          if (
+            cell.v.ps.value.includes('妫�楠屽��') &&
+            (cell.v.v === '' || cell.v.v === null || cell.v.v === undefined)
+          ) {
+            return
+          }
+          param[a.templateId][`${cell.r}-${cell.c}`] = {
+            v: cell.v.v,
+            u: cell.u
+          }
+        })
+      })
+      return param
+    },
+    // 缁熶竴鍦ㄨ繖閲屼繚瀛樻暟鎹�
+    saveInsContext() {
+      try {
+        if (!this.param) {
+          return
         }
+        const param = this.buildParam()
+        this.param = param
+        let isNoTestValue = ''
+        this.tableList.forEach(a => {
+          a.template.forEach(cell => {
+            if (
+              cell.v.ps != undefined &&
+              typeof cell.v.ps.value === 'string' &&
+              cell.v.ps.value.includes('妫�楠屽��') &&
+              (cell.v.v === '' || cell.v.v === null || cell.v.v === undefined)
+            ) {
+              isNoTestValue = 1
+            }
+          })
+        })
+        saveUnqualifiedContext({
+          param: JSON.stringify(param),
+          currentTable: this.currentTable,
+          sampleId: this.currentSample.id,
+          isNoTestValue: isNoTestValue
+        }).then(res => {
+          this.$message.success('宸蹭繚瀛�')
+        })
+        // 鍚� Worker 鍙戦�佹秷鎭紝寮�濮嬪鐞嗛�昏緫
+        this.worker.postMessage(JSON.stringify({
+          modelType: this.sampleProduct[0].model,
+          type: 'saveData',
+          tableList: this.tableList,
+          param: this.param,
+          currentTable: this.currentTable
+        }));
       } catch (error) {
         console.log(999, error);
       }
     },
     // 璁惧鏀瑰彉
-    changeEquip(val, n, v) {
-      try {
-        // this.$set(n.v,'v',val)
-        this.tableList[0].arr.forEach((item, index) => {
-          item.forEach((m, i) => {
-            if (this.param[m.i]) {
-              this.param[m.i].state = 1
+    changeEquip(val, n) {
+      const selectedDevices = Array.isArray(val) ? [...val] : []
+      const deviceCodes = selectedDevices.join('锛�')
+      this.$set(n.v, 'v', selectedDevices)
+      this.tableList.forEach(table => {
+        (table.arr || []).forEach(row => {
+          row.forEach(cell => {
+            if (cell.i == n.i && cell.v.ps) {
+              if (cell.v.ps.value === '璁惧鍚嶇О') {
+                this.$set(cell.v, 'v', [...selectedDevices])
+              } else if (cell.v.ps.value === '璁惧缂栫爜') {
+                this.$set(cell.v, 'v', deviceCodes)
+              }
             }
-            // if(m.i==n.i&&m.v.ps&&m.v.ps.value=='璁惧鍚嶇О'&&v){
-            //   this.$set(m.v,'v',v)
-            // }
           })
         })
-        for (let i in this.param) {
-          if (this.param[i].state != 1) {
-            delete this.param[i]
-          }
-        }
-        // if(val&&v){
-        //   for (let i1 in this.param[n.i].equipName) {
-        //     if (this.param[n.i].equipName[i1].i === n.i && this.param[n.i].equipName[i1].r === n.r) {
-        //       this.$delete(this.param[n.i].equipValue[i1].v,'v')
-        //       this.$set(this.param[n.i].equipValue[i1].v,'v',val)
-        //       this.$delete(this.param[n.i].equipName[i1].v,'v')
-        //       this.$set(this.param[n.i].equipName[i1].v,'v',v)
-        //     }
-        //   }
-        // }
-        // this.equipOptions涓鸿澶囧悕绉颁笅鎷夋閫夐」鏁版嵁
-        for (let i1 in this.param[n.i].equipName) {
-          if (this.param[n.i].equipName[i1].i === n.i && this.param[n.i].equipName[i1].r === n.r) {
-            this.$delete(this.param[n.i].equipValue[i1].v, 'v')
-            // 灏嗘暟缁勮祴鍊肩粰璁惧缂栫爜
-            this.$set(this.param[n.i].equipValue[i1].v, 'v', val.join('锛�'))
-            this.$delete(this.param[n.i].equipName[i1].v, 'v')
-            // 灏嗘暟缁勮祴鍊肩粰璁惧缂栫爜
-            this.$set(this.param[n.i].equipName[i1].v, 'v', val)
-            this.tableList[0].arr.forEach((item, index) => {
-              item.forEach((m) => {
-                if (m.i == n.i && m.v.ps && m.v.ps.value == '璁惧缂栫爜') {
-                  this.$set(m.v, 'v', val.join('锛�'))
-                }
-                if (m.i == n.i && m.v.ps && m.v.ps.value == '璁惧鍚嶇О') {
-                  this.$set(m.v, 'v', val)
-                }
-              })
-            })
-          }
-        }
-        // 淇濆瓨鏁版嵁
-        this.saveInsContext(n.i)
-      } catch (e) {
-        console.log('changeEquip----', e)
-      }
+      })
+      // 閫夋嫨銆佺Щ闄ゃ�佹竻绌哄潎鐢� change 浜嬩欢瑙﹀彂锛岀珛鍗充繚瀛樸��
+      this.saveInsContext()
     },
     getAuthorizedPerson() {
-      selectUserCondition({ type: 0 }).then((res) => {
+      selectUserCondition({ type: 1 }).then((res) => {
         let data = [];
         res.data.forEach((a) => {
           data.push({
@@ -1970,16 +1678,6 @@
       this.param = {}
       this.fiberOptic = []
       this.currentFiberOptic = null;
-      this.currentFiberOpticTape.productList.forEach(a => {
-        this.param[a.id] = {
-          insValue: [],
-          comValue: [],
-          resValue: null,
-          equipValue: [],
-          equipName: [],
-          insResult: null
-        }
-      })
       this.fiberOpticTapeVisible = false;
       let list = await this.getCurrentProduct(this.currentFiberOpticTape.id, 1)
       this.getTableLists0(list)
@@ -1999,16 +1697,7 @@
       }
       this.currentKey2 = index
       this.currentFiberOptic = this.HaveJson(this.fiberOptic[index - 1])
-      this.currentFiberOptic.productList.forEach(a => {
-        this.param[a.id] = {
-          insValue: [],
-          comValue: [],
-          resValue: null,
-          equipValue: [],
-          equipName: [],
-          insResult: null
-        }
-      })
+      this.param = {}
       let list = await this.getCurrentProduct(this.currentFiberOptic.id, 2)
       this.getTableLists0(list)
     },
@@ -2102,6 +1791,32 @@
   text-align: left;
 }
 
+/* 褰撳墠妫�楠屾ā鏉跨殑妫�娴嬫潯浠� */
+.template-panel {
+  background-color: #f8f9fb;
+  border: 1px solid #ebeef5;
+  border-radius: 3px;
+  padding: 16px 16px 4px;
+  margin-top: 12px;
+  text-align: left;
+}
+
+/* form-item 鐢� inline-flex 淇濊瘉 label 涓庢帶浠跺悓琛岋紝涓嶄緷璧栬鐩掑搴︽帹绠� */
+.template-panel>>>.el-form-item {
+  display: inline-flex;
+  align-items: center;
+  margin-bottom: 12px;
+}
+
+.template-panel>>>.el-form-item__label {
+  flex: none;
+}
+
+.template-panel__unit {
+  margin-left: 4px;
+  color: #606266;
+}
+
 .center {
   width: calc(100% - 40px);
   /* max-height: 580px; */
@@ -2188,7 +1903,7 @@
 }
 
 .content-h-2 {
-  justify-content: end;
+  justify-content: flex-end;
 }
 
 .content-v-0 {

--
Gitblit v1.9.3