From 35ad48f83f7aca5f36c111c0daaf61966dac1a5c Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 04 九月 2026 16:29:40 +0800
Subject: [PATCH] feat(inspection): 集成 Luckysheet 并优化检验任务功能 - 优化设备名称和编码的同步更新机制

---
 public/index.html                                |    5 +
 src/views/business/inspectionTask/inspection.vue |  133 ++++++++++++++++++++++++++++----------------
 2 files changed, 87 insertions(+), 51 deletions(-)

diff --git a/public/index.html b/public/index.html
index 745aa41..79f9cb1 100644
--- a/public/index.html
+++ b/public/index.html
@@ -230,12 +230,13 @@
         <div class="load_title">姝e湪鍔犺浇绯荤粺璧勬簮锛岃鑰愬績绛夊緟</div>
       </div>
     </div>
+    <!-- Luckysheet 蹇呴』鍏堜簬鑷姩娉ㄥ叆鐨� Vue 搴旂敤鑴氭湰鍔犺浇 -->
+    <script src="<%= BASE_URL %>luckysheet/plugins/js/plugin.js"></script>
+    <script src="<%= BASE_URL %>luckysheet/luckysheet.umd.js"></script>
   </body>
   <script
     type="text/javascript"
     src="http://192.168.21.53:9001/web-apps/apps/api/documents/api.js"
   ></script>
-  <script src="<%= BASE_URL %>luckysheet/plugins/js/plugin.js"></script>
-  <script src="<%= BASE_URL %>luckysheet/luckysheet.umd.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.16.105/pdf.min.js"></script>
 </html>
diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue
index 796b098..1bb499c 100644
--- a/src/views/business/inspectionTask/inspection.vue
+++ b/src/views/business/inspectionTask/inspection.vue
@@ -310,7 +310,7 @@
                     <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
+                      <el-select v-model="n.v.v" :disabled="state > 1" class="table_input" filterable multiple clearable
                         placeholder="璁惧" remote @change="(val) => changeEquip(val, n)"
                         @visible-change="(e) => getEquipOptions(e, n.i)">
                         <el-option v-for="item in equipOptions" :key="item.value" :label="item.label"
@@ -1913,6 +1913,24 @@
     handleTableData() {
       this.excelMethodList = []; //excel鍑芥暟鍒楄〃
       this.widthList = this.tableList[0].style.columnlen; //椤甸潰瀹藉害--鏍规嵁妯℃澘鏉ョ殑
+      // 瀵圭収鎺ュ彛杩斿洖鐨勬楠岄」妯℃澘 ID 涓庨〉闈㈠疄闄呭弬涓庡尮閰嶇殑妯℃澘 ID銆�
+      this.tableList.forEach((template) => {
+        console.log("[templateId鏍稿]", {
+          sampleId: this.currentSample.id,
+          currentTable: this.currentTable,
+          templateName: template.templateName,
+        });
+        console.table(this.currentSample.insProduct.map((product) => ({
+          妫�楠岄」ID: product.id,
+          妫�楠岄」: product.inspectionItem,
+          妫�楠屽瓙椤�: product.inspectionItemSubclass,
+          "妫�楠岄」templateId锛堟帴鍙h繑鍥烇級": product.templateId,
+          妫�楠岄」ID绫诲瀷: typeof product.templateId,
+          "褰撳墠妯℃澘templateId": template.templateId,
+          妯℃澘ID绫诲瀷: typeof template.templateId,
+          "鏄惁涓�鑷达紙涓ユ牸姣旇緝锛�": product.templateId === template.templateId,
+        })));
+      });
       // 鏈寰幆涓昏鍋氶〉闈㈡覆鏌撳眰闈㈢殑澶勭悊--鍗曞厓鏍煎悎骞堕澶勭悊
       this.tableList.forEach((a) => {
         let mcList = a.template.filter(
@@ -2117,6 +2135,37 @@
                 count2++;
               }
               if (count2 == this.currentSample.insProduct.length) {
+                console.warn("[妯℃澘琛屾湭鍖归厤] 鍗冲皢闅愯棌璇ヨ", {
+                  sampleId: this.currentSample.id,
+                  templateId: a.templateId,
+                  templateName: a.templateName,
+                  妯℃澘琛屽彿: b.r + 1,
+                  妯℃澘鎷兼帴鍚嶇О: str,
+                  妯℃澘鏍囪鍗曞厓鏍�: a.template
+                    .filter((cell) => cell.r === b.r && cell.v.ps != undefined)
+                    .map((cell) => ({
+                      鍒楀彿: cell.c + 1,
+                      鏍囪: cell.v.ps.value,
+                      鏂囧瓧: cell.v.v,
+                    })),
+                });
+                console.table(this.currentSample.insProduct
+                  .filter((product) => product.templateId === a.templateId)
+                  .map((product) => {
+                    const name = [product.inspectionItemClass, product.inspectionItem,
+                      product.inspectionItemSubclass]
+                      .map((value) => value == null ? "" : value.replace(/\s*/g, ""))
+                      .join("");
+                    return {
+                      妫�楠岄」ID: product.id,
+                      妫�楠岄」鍒嗙被: product.inspectionItemClass,
+                      妫�楠岄」: product.inspectionItem,
+                      妫�楠屽瓙椤�: product.inspectionItemSubclass,
+                      鎺ュ彛鎷兼帴鍚嶇О: name,
+                      妯℃澘鎷兼帴鍚嶇О: str,
+                      鍚嶇О鏄惁涓�鑷�: name === str,
+                    };
+                  }));
                 dels.add(b.r);
               }
             }
@@ -2281,9 +2330,11 @@
       });
       // 鏈寰幆涓昏鏄椤甸潰鍙婂悗绔紶鍙傝繘琛屽垵濮嬪寲璧嬪��
       this.currentSample.insProduct.forEach(async (a) => {
+        // 灏氭棤妫�楠岀粨鏋滄椂锛屼繚鐣欏墠闈㈠垵濮嬪寲鐨勭┖鍊笺��
+        const savedResult = a.insProductResult || {};
         try {
           // 璁$畻鍊艰祴鍊�
-          let comValue = JSON.parse(a.insProductResult.comValue);
+          let comValue = JSON.parse(savedResult.comValue || "[]");
           for (var i = 0; i < comValue.length; i++) {
             if (
               this.param[a.id].comValue.find(
@@ -2308,7 +2359,7 @@
         } catch (e) { }
         try {
           // 妫�楠屽�艰祴鍊�
-          let insValue = JSON.parse(a.insProductResult.insValue);
+          let insValue = JSON.parse(savedResult.insValue || "[]");
           for (let i = 0; i < insValue.length; i++) {
             if (
               this.param[a.id].insValue.find(
@@ -2333,7 +2384,7 @@
         } catch (e) { }
         try {
           // 璁惧缂栧彿璧嬪��
-          let equipValue = JSON.parse(a.insProductResult.equipValue);
+          let equipValue = JSON.parse(savedResult.equipValue || "[]");
           for (let i = 0; i < equipValue.length; i++) {
             // 鏅�氳澶囪祴鍊�
             this.param[a.id].equipValue[i].v.v = equipValue[i].v;
@@ -2341,7 +2392,7 @@
         } catch (e) { }
         try {
           // 璁惧鍚嶇О璧嬪��
-          let equipName = JSON.parse(a.insProductResult.equipName);
+          let equipName = JSON.parse(savedResult.equipName || "[]");
           for (let i = 0; i < equipName.length; i++) {
             equipName[i].v !== "" &&
               equipName[i].v.map((val) => {
@@ -2934,53 +2985,37 @@
       }
     },
     // 璁惧鏀瑰彉
-    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 itemParam = this.param[n.i];
+      if (!itemParam) {
+        this.$message.error("璁惧鏈叧鑱旀楠岄」锛岃鍒锋柊椤甸潰鍚庨噸璇�");
+        return;
+      }
+      const selectedDevices = Array.isArray(val) ? [...val] : [];
+      const deviceCodes = selectedDevices.join("锛�");
+      this.$set(n.v, "v", selectedDevices);
+      // 鍚嶇О涓庣紪鐮佸崟鍏冩牸鍙兘鏁伴噺涓嶅悓锛屽垎鍒洿鏂帮紝閬垮厤涓嬫爣瓒婄晫涓柇淇濆瓨銆�
+      (itemParam.equipName || []).forEach((cell) => {
+        this.$set(cell.v, "v", [...selectedDevices]);
+      });
+      (itemParam.equipValue || []).forEach((cell) => {
+        this.$set(cell.v, "v", deviceCodes);
+      });
+      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];
-          }
-        }
-        // 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(n.i);
     },
     getAuthorizedPerson() {
       selectUserCondition({ type: 1 }).then((res) => {

--
Gitblit v1.9.3