From d3454b7326591c1232eb69c2b3d0340d7e3b366c Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 13 一月 2026 09:58:24 +0800
Subject: [PATCH] fix: 巡检格式问题

---
 src/pages/outbound/materialOutbound.vue |  167 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 116 insertions(+), 51 deletions(-)

diff --git a/src/pages/outbound/materialOutbound.vue b/src/pages/outbound/materialOutbound.vue
index 10d58b7..bee43d1 100644
--- a/src/pages/outbound/materialOutbound.vue
+++ b/src/pages/outbound/materialOutbound.vue
@@ -30,7 +30,7 @@
                 <text class="value">{{ currentMaterial.materialspec || "-" }}</text>
               </view>
               <view class="info-line">
-                <text class="label">寰呰揣鏁伴噺锛�</text>
+                <text class="label">寰呭彂璐ф暟閲忥細</text>
                 <text class="value">{{ currentMaterial.shippedQuantity || 0 }} 鍚�</text>
               </view>
             </view>
@@ -152,57 +152,110 @@
       return;
     }
 
-    // 瑙f瀽鎵爜鏁版嵁锛岀幇鍦ㄤ簩缁寸爜鍙寘鍚玦d
-    let scanData;
-    try {
-      scanData = JSON.parse(scanCode);
-    } catch (e) {
-      toast.error("浜岀淮鐮佹牸寮忛敊璇�");
-      return;
+    // 鍘绘帀棣栧熬绌烘牸
+    const scanText = String(scanCode).trim();
+
+    // 鍒ゆ柇鏄惁涓� JSON 鏍煎紡锛堢粸绾跨瓑鍘熸湁浜岀淮鐮侊級
+    const isJsonCode = scanText.startsWith("{") || scanText.startsWith("[");
+
+    let tagData: any = null;
+    let outPutId: string | number | undefined;
+    let monofilamentNumber: string | undefined;
+    let needContractCheck = false; // 鏄惁闇�瑕佽繘琛屽悎鍚屽彿鏍¢獙锛堝彧瀵圭粸绾匡級
+
+    if (isJsonCode) {
+      // ===== 缁炵嚎绛夊師鏈変簩缁寸爜閫昏緫锛圝SON锛� =====
+      let scanData;
+      try {
+        scanData = JSON.parse(scanText);
+      } catch (e) {
+        toast.error("浜岀淮鐮佹牸寮忛敊璇�");
+        return;
+      }
+
+      outPutId = scanData.id;
+
+      if (!outPutId) {
+        toast.error("浜岀淮鐮佹牸寮忛敊璇紝缂哄皯id淇℃伅");
+        return;
+      }
+
+      // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堟牴鎹� id 鍒ゆ柇锛�
+      const exists = goodsList.value.some((item) => {
+        const itemId = item.id;
+        return itemId && itemId === outPutId && itemId !== "-";
+      });
+
+      if (exists) {
+        toast.error("璇ユ潯鐮佸凡瀛樺湪锛岃鍕块噸澶嶆壂鐮�");
+        return;
+      }
+
+      // 璋冪敤鎺ュ彛鑾峰彇缁炵嚎/鎷変笣璇︾粏淇℃伅锛堝惈鍑哄簱鐘舵�侊級
+      const { data } = await OutboundApi.getTagByIdAll({
+        outPutId: outPutId,
+      });
+
+      const list = data || [];
+      if (!list.length) {
+        toast.error("鏈煡璇㈠埌鏉$爜淇℃伅");
+        return;
+      }
+
+      tagData = list[0];
+      needContractCheck = true; // 鍙湁缁炵嚎闇�瑕佸仛鍚堝悓鍙锋牎楠�
+    } else {
+      // ===== 鍗曚笣鎷変笣浜岀淮鐮侀�昏緫锛堢函瀛楃涓诧級 =====
+      // 绀轰緥锛歓D7z30202616101201#[@]01,桅5.6,-,750826011001001,600.6
+      // 闇�瑕佹彁鍙栦互 75 寮�澶寸殑鍗曚笣鍙�
+      const parts = scanText.split(/[,\s]/).filter((p) => !!p);
+      monofilamentNumber = parts.find((p) => p.startsWith("75"));
+
+      if (!monofilamentNumber) {
+        toast.error("浜岀淮鐮佹牸寮忛敊璇紝鏈壘鍒板崟涓濆彿");
+        return;
+      }
+
+      // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堟牴鎹崟涓濆彿鍒ゆ柇锛�
+      const exists = goodsList.value.some((item) => {
+        const itemMono = item.monofilamentNumber;
+        return itemMono && itemMono === monofilamentNumber && itemMono !== "-";
+      });
+
+      if (exists) {
+        toast.error("璇ユ潯鐮佸凡瀛樺湪锛岃鍕块噸澶嶆壂鐮�");
+        return;
+      }
+
+      // 璋冪敤鎷変笣鎺ュ彛锛欸ET /mes/app/getTagByLsMonofilamentNumber?monofilamentNumber=xxxx
+      const { data } = await OutboundApi.getTagByLsMonofilamentNumber({
+        monofilamentNumber,
+      });
+
+      const list = Array.isArray(data) ? data : data ? [data] : [];
+      if (!list.length) {
+        toast.error("鏈煡璇㈠埌鏉$爜淇℃伅");
+        return;
+      }
+
+      tagData = list[0];
+      outPutId = tagData?.id || monofilamentNumber;
+      // 鎷変笣涓嶅仛鍚堝悓鍙锋牎楠�
     }
 
-    const outPutId = scanData.id;
-
-    if (!outPutId) {
-      toast.error("浜岀淮鐮佹牸寮忛敊璇紝缂哄皯id淇℃伅");
-      return;
-    }
-
-    // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堟牴鎹甶d鍒ゆ柇锛�
-    const exists = goodsList.value.some((item) => {
-      const itemId = item.id;
-      return itemId && itemId === outPutId && itemId !== "-";
-    });
-
-    if (exists) {
-      toast.error("璇ユ潯鐮佸凡瀛樺湪锛岃鍕块噸澶嶆壂鐮�");
-      return;
-    }
-
-    // 璋冪敤鎺ュ彛鑾峰彇缁炵嚎/鎷変笣璇︾粏淇℃伅锛堝惈鍑哄簱鐘舵�侊級
-    const { data } = await OutboundApi.getTagByIdAll({
-      outPutId: outPutId,
-    });
-
-    const list = data || [];
-    if (!list.length) {
-      toast.error("鏈煡璇㈠埌鏉$爜淇℃伅");
-      return;
-    }
-
-    const tagData = list[0];
-
-    // 宸插嚭搴撴牎楠�
+    // 宸插嚭搴撴牎楠岋紙缁炵嚎 / 鎷変笣 閫氱敤锛�
     if (tagData?.state === "宸插嚭搴�") {
       toast.error("璇ユ潯鐮佸凡鍑哄簱锛屾棤娉曢噸澶嶅嚭搴�");
       return;
     }
 
-    // 鍚堝悓鍙锋牎楠岋細妫�鏌ユ壂鐮佺殑鍚堝悓鍙锋槸鍚︾瓑浜庡彂璐у崟鐨剉srccode
-    const scannedContractNo = tagData?.contractno || "";
-    if (scannedContractNo && vsrccode.value && scannedContractNo !== vsrccode.value) {
-      toast.error(`鍚堝悓鍙�"${scannedContractNo}"涓庡綋鍓嶅彂璐у崟涓�"${vsrccode.value}"涓嶅尮閰峘);
-      return;
+    // 鍚堝悓鍙锋牎楠岋細鍙缁炵嚎锛圝SON 鍦烘櫙锛夎繘琛屾牎楠�
+    if (needContractCheck) {
+      const scannedContractNo = tagData?.contractno || "";
+      if (scannedContractNo && vsrccode.value && scannedContractNo !== vsrccode.value) {
+        toast.error(`鍚堝悓鍙�"${scannedContractNo}"涓庡綋鍓嶅彂璐у崟涓�"${vsrccode.value}"涓嶅尮閰峘);
+        return;
+      }
     }
 
     // 鎻愬彇鏁版嵁瀛楁锛堟牴鎹帴鍙h繑鍥炵殑鏁版嵁缁撴瀯锛�
@@ -214,6 +267,7 @@
         tagData?.monofilamentNumber ||
         tagData?.systemno ||
         tagData?.systemNo ||
+        monofilamentNumber ||
         "-",
       model: tagData?.model || "-",
       weight: tagData?.actuallylength || tagData?.actuallyLength || tagData?.weight || "-",
@@ -227,7 +281,7 @@
       productuser: tagData?.productuser || "",
       // 淇濈暀鍘熷鏁版嵁
       rawData: tagData,
-      scanCode: scanCode,
+      scanCode: scanText,
     };
 
     // 娣诲姞鍒板垪琛�
@@ -364,15 +418,26 @@
   uni.$on("scanMaterial", getScanCode);
 };
 
+// 瀹夊叏瑙g爜锛堝吋瀹瑰凡瑙g爜鎴栨湭缂栫爜鐨勬儏鍐碉級
+const safeDecode = (val: any) => {
+  if (typeof val !== "string") return val || "";
+  try {
+    // 濡傛灉鏄紪鐮佽繃鐨勶紙鍖呭惈 %锛夛紝decode 涓�娆★紱鍚﹀垯鐩存帴杩斿洖
+    return val.includes("%") ? decodeURIComponent(val) : val;
+  } catch (e) {
+    return val;
+  }
+};
+
 onLoad((options: any) => {
   // 浠庤矾鐢卞弬鏁颁腑鑾峰彇鐗╂枡鍩烘湰淇℃伅銆佸嚭搴撳崟淇℃伅鍜� vsrccode
   currentMaterial.value = {
-    materialname: options.materialname || "-",
-    materialspec: options.materialspec || "-",
+    materialname: safeDecode(options.materialname || "-"),
+    materialspec: safeDecode(options.materialspec || "-"),
     shippedQuantity: Number(options.shippedQuantity || 0),
-    cdeliveryid: options.cdeliveryid || "",
-    cdeliverybid: options.cdeliverybid || "",
-    materialcode: options.materialcode || "",
+    cdeliveryid: safeDecode(options.cdeliveryid || ""),
+    cdeliverybid: safeDecode(options.cdeliverybid || ""),
+    materialcode: safeDecode(options.materialcode || ""),
   };
   vsrccode.value = options.vsrccode || "";
 });

--
Gitblit v1.9.3