From 2b2fa317c30ee2de7a8b6f5fc964532031adea66 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期日, 20 九月 2026 13:48:54 +0800
Subject: [PATCH] fix: 优化报告功能

---
 src/views/business/inspectionTask/components/InspectionWord.vue |  243 ++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 191 insertions(+), 52 deletions(-)

diff --git a/src/views/business/inspectionTask/components/InspectionWord.vue b/src/views/business/inspectionTask/components/InspectionWord.vue
index 189de42..d9ff99f 100644
--- a/src/views/business/inspectionTask/components/InspectionWord.vue
+++ b/src/views/business/inspectionTask/components/InspectionWord.vue
@@ -26,6 +26,48 @@
             </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 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>
+          <el-form :inline="true" :model="currentOtherForm" class="form-inline template-panel__conclusion--divided"
+            size="small" label-width="84px">
+            <el-form-item label="妫�楠岀粨璁�:">
+              <el-radio-group v-model="currentOtherForm.insResult" :disabled="state != 2"
+                @change="m => subOtherForm(m, 'insResult')">
+                <el-radio :label="1">鍚堟牸</el-radio>
+                <el-radio :label="0">涓嶅悎鏍�</el-radio>
+              </el-radio-group>
+            </el-form-item>
+          </el-form>
+        </div>
         <!-- 甯歌妫�楠屽師濮嬭褰� -->
         <div id="tableBox" v-loading="tableLoading" class="center-box">
           <table v-for="(item, index) in tableList" :key="index + currentTable + currentSample.id" border="1"
@@ -73,9 +115,9 @@
                       </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;`">{{ toFixed(n.v.v, n.v.ct) }}</span></template>
+                        :style="`font-family:${n.v.ff} !important;`">{{ n.v.v }}</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>
+                      <span :style="`font-family:${n.v.ff} !important;`">{{ n.v.v }}</span>
                     </template>
                     <template v-else-if="n.v.ps != undefined && n.v.ps.value === '鏍峰搧缂栧彿'">
                       <div :title="currentSample.sampleCode"
@@ -220,7 +262,8 @@
   getInsProductUnqualifiedRetest,
   search, selectUserCondition,
   submitPlan,
-  verifyPlan
+  verifyPlan,
+  write
 } from "@/api/business/inspectionTask";
 import { getUserNow, saveUnqualifiedContext } from "@/api/business/rawMaterialOrder";
 import InspectionWorker from '@/workers/InspectionWorker.worker';
@@ -340,10 +383,9 @@
       numOptions: [],
       temperatureOptions: [],
       wareTableData: [],
-      otherForm: {
-        humidity: null,
-        temperature: null,
-      },
+      // 妫�娴嬫潯浠舵寜妯℃澘 id 鍒嗙粍锛歿 [templateId]: { temperature, humidity, detectionTime, detectionPlace, deviceIds } }
+      otherForm: {},
+      deviceOptions: [],
       equipForm: {
         value0: null,
         code0: null,
@@ -418,6 +460,17 @@
     },
     action() {
       return this.javaApi + "/insOrderPlan/uploadFile";
+    },
+    // 褰撳墠妯℃澘瀵瑰簲鐨勬娴嬫潯浠�
+    currentOtherForm() {
+      return this.otherForm[this.currentTable] || {
+        temperature: null,
+        humidity: null,
+        detectionTime: null,
+        detectionPlace: null,
+        deviceIds: [],
+        insResult: null
+      }
     }
   },
   created() {
@@ -453,15 +506,24 @@
         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] : [],
+            insResult: item.insResult != null ? item.insResult : null
+          })
+        })
         if (this.typeSource == '1') {
           this.retestTag = '1'
         }
         this.getEquipOptions(1)
+        this.loadDeviceOptions()
         // 鑾峰彇褰撳墠鏍峰搧鐨勬楠岄」
         let list = await this.getCurrentProduct(this.currentSample.id, 0)
         if (list === undefined) {
@@ -515,6 +577,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()
             }
@@ -846,6 +910,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()
       }
@@ -875,6 +941,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()
       }
@@ -1174,13 +1242,6 @@
     getValue(v) {
       // 瀵归〉闈㈠睍绀烘暟鎹繘琛屽鐞�,@,浠h〃鎹㈣
       let str = v.v ? v.v : (v.v === 0 ? v.v : (v.ct && v.ct.s ? v.ct.s.length > 0 && v.ct.s[0].v.replace(new RegExp('\n', 'g'), '<br/>').replace(new RegExp('@', 'g'), '<br/>') : ''))
-      // 瀵规暟鎹繚鐣欏皬鏁扮偣杩涜澶勭悊
-      if (v.ct && v.ct.fa && v.ct.fa.includes('.') && str) {
-        let num = 0
-        let str0 = v.ct.fa.split('.')[1]
-        num = str0.length
-        str = Number(str).toFixed(num)
-      }
       if (v.v && typeof v.v == 'string' && v.v.includes('@')) {
         str = v.v.replace(new RegExp('@', 'g'), '<br/>')
       }
@@ -1210,15 +1271,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) {
@@ -1278,6 +1348,16 @@
         })
       }
     },
+    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 => {
         this.userId = res.data.id
@@ -1287,13 +1367,23 @@
     upInsReview(e) {
       if (e == 1) {
         // 閫氳繃
+        // 姣忎釜妯℃澘閮借鏈夌粨璁猴紱鍏ㄩ儴鍚堟牸鎵嶇畻鏁村崟鍚堟牸
+        const insResults = this.tableLists.map(
+          item => (this.otherForm[item.templateId] || {}).insResult
+        )
+        const missingIndex = insResults.findIndex(result => result !== 0 && result !== 1)
+        if (missingIndex > -1) {
+          this.$message.error(`璇烽�夋嫨銆�${this.tableLists[missingIndex].templateName}銆嶇殑妫�楠岀粨璁篳)
+          return
+        }
         this.reviewLoading = true;
         verifyPlan({
           orderId: this.orderId,
           type: 1,
           laboratory: this.sonLaboratory,
           tell: null,
-          userId: this.checkUser
+          userId: this.checkUser,
+          insResult: insResults.every(result => result === 1) ? 1 : 0
         }).then(res => {
           if (res.code === 200) {
             this.$message.success("鎿嶄綔鎴愬姛")
@@ -1332,17 +1422,55 @@
         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: [],
+          insResult: null
+        })
+      }
+    },
+    // 淇濆瓨褰撳墠妯℃澘鐨勬娴嬫潯浠�
+    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 (!form.deviceIds || form.deviceIds.length === 0) {
+          missing.push(`璇烽�夋嫨銆�${m.templateName}銆嶇殑璁惧`)
+        }
+      })
+      if (missing.length > 0) {
+        this.$message.error(missing[0])
         return
       }
       this.submitLoading = true;
@@ -1604,26 +1732,6 @@
       }).catch(error => {
 
       })
-    },
-    /**
-     * 灏嗘暟鍊紇淇濈暀ct.fa涓�'##'鍚庣殑鎸囧畾灏忔暟浣嶆暟锛屽苟杩斿洖鏍煎紡鍖栧悗鐨勫瓧绗︿覆銆�
-     *
-     * @param v 瑕佹牸寮忓寲鐨勬暟鍊�
-     * @param ct 鍖呭惈鏍煎紡鍖栭厤缃殑瀵硅薄
-     * @param ct.fa 鏍煎紡鍖栭厤缃瓧绗︿覆锛岃嫢鍖呭惈'##'鍒欐寜鐓у叾鍚庣殑鍐呭纭畾灏忔暟浣嶆暟
-     * @returns 鏍煎紡鍖栧悗鐨勫瓧绗︿覆鎴栧師濮嬫暟鍊硷紙鑻ラ厤缃笉绗﹀悎瑕佹眰锛�
-     */
-    toFixed(v, ct) {
-      if (v && ct && ct.fa) {
-        if (ct.fa.includes('.')) {
-          let num = ct.fa.slice(4).length
-          return Number(v).toFixed(num)
-        } else {
-          return v
-        }
-      } else {
-        return v
-      }
     }
   }
 }
@@ -1672,6 +1780,37 @@
   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;
+}
+
+.template-panel__conclusion--divided {
+  border-top: 1px dashed #e4e7ed;
+  padding-top: 12px;
+}
+
 .center {
   width: calc(100% - 40px);
   /* max-height: 580px; */

--
Gitblit v1.9.3