From e3bf21045fc29371449c7e888d786370dc962ae1 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 07 九月 2026 15:42:09 +0800
Subject: [PATCH] feat(inspection): 优化检验数据保存逻辑

---
 src/views/business/inspectionView/index.vue |   54 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/src/views/business/inspectionView/index.vue b/src/views/business/inspectionView/index.vue
index bba64e6..09e38b9 100644
--- a/src/views/business/inspectionView/index.vue
+++ b/src/views/business/inspectionView/index.vue
@@ -2224,20 +2224,19 @@
 
       // 鐩戝惉 Worker 杩斿洖鐨勭粨鏋�
       this.worker.onmessage = (event) => {
-        this.result = JSON.parse(event.data);
-        switch (this.result.method) {
+        const workerResult = JSON.parse(event.data);
+        this.result = workerResult;
+        switch (workerResult.method) {
           case "saveInsContext":
             this.$nextTick(() => {
+              const resultValue = workerResult.value;
               // this.$delete(this.tableList[0],'arr')
               this.$set(
                 this.tableList[0],
                 "arr",
-                this.result.value.tableList[0].arr
+                resultValue.tableList[0].arr
               );
-              this.param = this.result.value.param;
-              if (this.result.value.currentInsItemId) {
-                currentInsItemId = this.result.value.currentInsItemId;
-              }
+              this.param = resultValue.param;
               // 鐗规畩澶勭悊涓�涓嬬粨璁�,浼氭湁杩欑鐗规畩鎯呭喌
               for (var i in this.param) {
                 if (
@@ -2252,23 +2251,28 @@
                   }
                 }
               }
-              this.saveInsContext(currentInsItemId);
+              const sourceInsItemId =
+                resultValue.sourceInsItemId != null &&
+                  resultValue.sourceInsItemId !== ""
+                  ? resultValue.sourceInsItemId
+                  : currentInsItemId;
+              this.saveInsContext([
+                sourceInsItemId,
+                resultValue.currentInsItemId,
+              ]);
             });
             break;
           case "tableList":
             this.$nextTick(() => {
               // 鏇存柊鏁版嵁
               this.$delete(this.tableList[0], "arr");
-              this.$set(this.tableList[0], "arr", this.result.value[0].arr);
+              this.$set(this.tableList[0], "arr", workerResult.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);
+            this.getCurrentInsProduct(workerResult.value);
             break;
         }
       };
@@ -2674,14 +2678,26 @@
       return;
     },
     // 缁熶竴鍦ㄨ繖閲屼繚瀛樻暟鎹�
-    saveInsContext(currentInsItemId) {
+    saveInsContext(currentInsItemIds) {
       try {
         if (this.param) {
-          let param = null;
-          if (currentInsItemId) {
-            param = { [currentInsItemId]: this.param[currentInsItemId] };
-          } else {
-            param = this.param;
+          const ids = (Array.isArray(currentInsItemIds)
+            ? currentInsItemIds
+            : [currentInsItemIds]
+          )
+            .filter((id) => id != null && id !== "")
+            .map((id) => String(id));
+          let param = this.param;
+          if (ids.length > 0) {
+            param = {};
+            [...new Set(ids)].forEach((id) => {
+              if (this.param[id]) {
+                param[id] = this.param[id];
+              }
+            });
+            if (Object.keys(param).length === 0) {
+              return;
+            }
           }
           saveInsContext({
             param: JSON.stringify(param),

--
Gitblit v1.9.3