From 025e5c58bfaeee5721b726fc2b960208d7540348 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 18 九月 2026 14:15:21 +0800
Subject: [PATCH] 新疆——新聚lims 1.按钮限制放开 2.检验单详情温湿度、检测时间、检测地方校验必填

---
 src/workers/InspectionWorker.worker.js |  111 +++++++++++++++++++------------------------------------
 1 files changed, 39 insertions(+), 72 deletions(-)

diff --git a/src/workers/InspectionWorker.worker.js b/src/workers/InspectionWorker.worker.js
index f838022..119d3ce 100644
--- a/src/workers/InspectionWorker.worker.js
+++ b/src/workers/InspectionWorker.worker.js
@@ -37,6 +37,9 @@
 let sourceInsItemId = null;
 // 褰撳墠娑堟伅鐗堟湰銆俉orker 鍗曠嚎绋嬩覆琛屽鐞嗘秷鎭紝渚涢�掑綊鍏紡璁$畻瀹屾垚鍚庡洖浼犵粰涓荤嚎绋嬨��
 let currentRevision = null;
+// 鏈杈撳叆鏄惁寰�鍗曞厓鏍煎啓鍏ヨ繃璁$畻缁撴灉銆傞摼寮忓叕寮忓彧鏈夋渶澶栧眰浼氬洖浼犱繚瀛橈紝
+// 鐢ㄥ畠鍦ㄦ渶澶栧眰鍒ゆ柇璁$畻鐨勪腑闂村�兼槸鍚︿篃闇�瑕佽惤搴撱��
+let hasComputedWrite = false;
 
 /**
  * 鐢熸垚妯℃澘缁撴瀯绛惧悕
@@ -141,7 +144,8 @@
   comparisonList = JSON.parse(JSON.stringify(data.comparisonList));
   currentSample = JSON.parse(JSON.stringify(data.currentSample));
   PROJECT = data.PROJECT;
-  // 鎵ц璁$畻鏂规硶
+  // 鎵ц璁$畻鏂规硶銆傛瘡娆¤緭鍏ラ噸缃爣璁帮紝鐢辨湰娆¤皟鐢ㄦ爤鐨勬渶澶栧眰鍐冲畾鏄惁鍥炰紶淇濆瓨
+  hasComputedWrite = false;
   changeInput("", code);
 };
 
@@ -172,6 +176,18 @@
 }
 
 /**
+ * 鑾峰彇绾崟鍏冩牸寮曠敤鍏紡鐨勫潗鏍囧悕锛屼緥濡� =F4銆�=$F$4銆�
+ * 绾紩鐢ㄥ簲鐩存帴澶嶅埗鍘熷�硷紝閬垮厤鎶娾�滃瑙傗�濈瓑涓枃鏂囨湰閫佸叆鏁板�艰绠椼��
+ */
+function getDirectReferenceName(f) {
+  if (typeof f !== "string") {
+    return null;
+  }
+  const matched = f.trim().match(/^=\s*\$?([A-Za-z]{1,3})\$?(\d{1,7})\s*$/);
+  return matched ? `${matched[1].toUpperCase()}${matched[2]}` : null;
+}
+
+/**
  * 鎸夋楠岄」id鍙栧綋鍓嶆牱鍝佷笅鐨勬楠岄」淇℃伅,鍙栦笉鍒版椂杩斿洖绌哄璞�,閬垮厤鍏紡璁$畻鍥犵己椤逛腑鏂�
  *
  * @param id 妫�楠岄」id
@@ -197,7 +213,7 @@
   return !(typeof r === "number" && isNaN(r));
 }
 
-function changeInput(m, code) {
+function changeInput(m, code, isComputed) {
   let str = code.split("-");
   let r = str[1]; //褰撳墠琛�
   let c = str[2]; //褰撳墠鍒�
@@ -211,8 +227,6 @@
       break;
     }
   }
-  let isToExponential = ""; //鏄惁涓虹瀛﹁鏁版硶
-  let list2 = []; //涓�涓暟缁勶紝閲岄潰淇濆瓨鏈夊綋鍓嶆楠岄」鐨勬墍鏈夊弬鏁板��
   let isPoint = ""; //鏄惁涓哄皬鏁扮偣
   let inputType = null;
   let currentInsItemId = "";
@@ -246,7 +260,6 @@
                     break;
                   }
                 }
-                list2.push(c.v.v);
                 // 缁勮鍙傛暟鐨勫璞¢泦鍚堝苟璧嬪�硷紝鍒楀{A3:12,B4:15}
                 if (
                   (getInspectionValueType(item.i) == 1 ||
@@ -273,7 +286,11 @@
         // 濡傛灉鏄嚱鏁版柟娉曪紝鍒欐墽琛屾鏂规硶
         let comResult = ""; //鍒濆鍖栬绠楃粨鏋�
         try {
-          if (
+          const directReferenceName = getDirectReferenceName(item.v.f);
+          if (directReferenceName && Object.prototype.hasOwnProperty.call(comValue, directReferenceName)) {
+            // =F4 杩欑被鍏紡鏃㈠彲鑳藉紩鐢ㄦ暟瀛楋紝涔熷彲鑳藉紩鐢ㄤ腑鏂囨枃鏈紝鐩存帴淇濈暀婧愬�笺��
+            comResult = comValue[directReferenceName];
+          } else if (
             getInspectionValueType(item.i) == 1 ||
             isNumericFormula(item.v.f)
           ) {
@@ -321,22 +338,7 @@
             }
             // 鏍规嵁杈撳叆鐨勬暟鍊硷紝杩涜璁$畻
             comResult = compute(item.v.f.replace(/=/g, " "), comValue, isPoint);
-            // 妫�楠岄」涓哄瘑搴︽椂锛屾牴鎹姹傚�肩殑灏忔暟浣嶆敼鍙樻渶缁堝�肩殑灏忔暟浣�
-            if (inspectionItem == "瀵嗗害") {
-              const str = "" + tell;
-              const indexOfDecimal = str.indexOf(".");
-              if (indexOfDecimal > -1) {
-                const length = str.length - indexOfDecimal - 1;
-                comResult = comResult.toFixed(length);
-              }
-            } else if (
-              inspectionItemClass == "澶栨姢濂楁満姊扮墿鐞嗘�ц兘" &&
-              inspectionItem == "鍦↖RM 902鐭跨墿娌逛腑娴告场鍚�" &&
-              (inspectionItemSubclass == "鏂浼搁暱鐜囧彉鍖栫巼" ||
-                inspectionItemSubclass == "鎶楀紶寮哄害鍙樺寲鐜�")
-            ) {
-              comResult = Math.round(comResult).toFixed(0);
-            } else if (
+            if (
               typeof comResult == "string" &&
               (comResult.includes("鏂") || comResult.includes("鑴嗗寲"))
             ) {
@@ -364,15 +366,6 @@
             }
             if (isHaveSymbol) {
               comResult = symbol + comResult;
-            }
-            let list3 = list2.map((item) => item + "");
-            // 鍒ゆ柇濉殑妫�楠屽�兼槸鍚︿负绉戝璁℃暟娉曪紝濡傛灉涓虹瀛﹁鏁版硶锛屽垯杩涜杞寲
-            isToExponential = list3.some(
-              (val) => val.includes("e+") || val.includes("e-")
-            );
-            if (isToExponential) {
-              let num2 = new Big(comResult);
-              comResult = num2.toExponential(1);
             }
           } else {
             // 濡傛灉妫�楠屽�肩被鍨嬫槸鏂囨湰杈撳叆妗嗐�佷笅鎷夋
@@ -412,45 +405,8 @@
               // 鍒ゆ柇褰撳墠琛屾槸鍚︿负褰撳墠妫�楠岄」鎵�鍦ㄨ锛屽鏋滀负褰撳墠琛岋紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪��
               for (var b in a) {
                 if (a[b].c == item.c) {
-                  try {
-                    if (comResult == 0) {
-                      // 鍒ゆ柇璁$畻缁撴灉鏄惁涓�0锛屽鏋滀负0锛屽垯缁欒〃鏍兼暟鎹祴鍊间负0
-                      a[b].v.v = 0;
-                    } else if (
-                      a[b].v.ct &&
-                      a[b].v.ct.fa &&
-                      typeof a[b].v.ct.fa == "string" &&
-                      a[b].v.ct.fa.includes(".")
-                    ) {
-                      // 鍒ゆ柇褰撳墠鍗曞厓鏍兼槸鍚︿繚鐣欏皬鏁扮偣锛屽鏋滀负淇濈暀灏忔暟鐐癸紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�间负淇濈暀灏忔暟鐐癸紝杩欎釜鏄牴鎹ā鏉块厤缃皬鏁扮偣鏉ョ殑
-                      let num = 0;
-                      let str = a[b].v.ct.fa.split(".")[1];
-                      num = str.length;
-                      a[b].v.v = comResult
-                        ? Number(comResult).toFixed(num)
-                        : comResult;
-                    } else if (
-                      typeof comResult == "string" &&
-                      (comResult.includes("e+") || comResult.includes("e-"))
-                    ) {
-                      // 鍒ゆ柇璁$畻缁撴灉鏄惁涓虹瀛﹁鏁版硶锛屽鏋滀负绉戝璁℃暟娉曪紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�间负绉戝璁℃暟娉�
-                      a[b].v.v = comResult;
-                    } else {
-                      const inspectionItem = findInsItem(item.i).inspectionItem;
-                      // 鍒ゆ柇璁$畻缁撴灉鏄惁涓烘暟瀛楋紝濡傛灉涓烘暟瀛楋紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�间负鏁板瓧
-                      if (inspectionItem == "閾滅嚎鐢甸樆鐜囅�20鏈�澶у��") {
-                        let val = parseFloat(Number(comResult).toFixed(5));
-                        a[b].v.v = isNaN(val) ? comResult : val;
-                      } else {
-                        let val = parseFloat(Number(comResult).toFixed(3));
-                        a[b].v.v = isNaN(val) ? comResult : val;
-                      }
-                    }
-                  } catch (error) {
-                    // 濡傛灉浠ヤ笂鍒ゆ柇閮戒笉鏀寔锛屽垯鐩存帴璧嬪��
-                    a[b].v.v = comResult;
-                    console.log("error---", error);
-                  }
+                  a[b].v.v = comResult;
+                  hasComputedWrite = true;
                   break;
                 }
               }
@@ -459,7 +415,9 @@
           // 濡傛灉姝よ绠楃粨鏋滄墍灞炲崟鍏冩牸锛屽悓鏃朵篃鏄彟涓�涓猠xcel鍑芥暟鐨勫弬鏁帮紝閭d箞灏遍渶瑕侀�掑綊杩涜璁$畻
           // 鍙湁绠楀嚭鏈夋晥缁撴灉鎵嶇户缁悜涓嬫父鍏紡浼犻��,閬垮厤鎶婄┖鍊�/NaN 浼犳煋缁欏叾瀹冨崟鍏冩牸
           if (isValidComputedResult(comResult)) {
-            changeInput(comResult, `${id}-${item.r}-${item.c}-${pId}`); //鏀瑰彉鏈�缁堝��
+            // 鏍囪涓鸿绠楀眰锛氬畠鍙兘鏄笅娓稿叕寮忕殑鍙傛暟(isSave 浼氳缃垚 false)锛屼絾鑷韩涔熸槸缁撴灉锛�
+            // 淇濆瓨浜ょ粰鏈�澶栧眰缁熶竴鍥炰紶锛屼腑闂村�间笉浼氳婕忔帀锛屼篃涓嶄細姣忎竴绾ч兘鍙戜竴娆′繚瀛樿姹�
+            changeInput(comResult, `${id}-${item.r}-${item.c}-${pId}`, true); //鏀瑰彉鏈�缁堝��
           }
           currentInsItemId = item.i;
         } catch (error) {
@@ -467,7 +425,10 @@
         }
     }
   });
-  if (index === -1 || (inputType === undefined && isSave === "true")) {
+  if (
+    !isComputed &&
+    (hasComputedWrite || index === -1 || (inputType === undefined && isSave === "true"))
+  ) {
     // 璧嬪�间紶閫掑埌涓荤嚎绋嬬殑鏁版嵁锛宮ethod锛歴aveInsContext琛ㄧず姝ゆ秷鎭渶瑕佷繚瀛樻暟鎹�
     result = {
       method: "saveInsContext",
@@ -1213,6 +1174,12 @@
           return "鏂鑴嗗寲";
         }
       }
+      // 鍙傛暟浠e叆鍚庡惈涓枃鏃�(濡傛楠屽�煎~浜�"鍧囧寑"),涓嶈兘鍐嶅綋鍏紡 eval 鈥斺��
+      // eval("鍧囧寑") 浼氭姏 ReferenceError,琚灞� catch 鍚炴帀鍚庤繑鍥� undefined,
+      // 璇ュ崟鍏冩牸鐨勭粨鏋滄棦涓嶅啓鍥炰篃涓嶅悜涓嬫父鍏紡浼犻��,鏁存潯璁$畻閾炬柇鍦ㄨ繖閲�
+      if (/[涓�-榫/.test(str)) {
+        return str.trim();
+      }
       // 璁$畻甯歌鐨�
       const value = eval(str);
       // 闄ら浂绛夐潪鏈夐檺缁撴灉涓嶅啓鍥炲崟鍏冩牸(涓� Excel 鐨� #DIV/0! 涓�鑷�:涓嶅嚭鍊�)

--
Gitblit v1.9.3