From 6c2a0e8132eb77429e26518c0f4dbec50036d018 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 30 一月 2026 11:45:56 +0800
Subject: [PATCH] fix: 扫码接口变更

---
 src/pages/outbound/materialOutbound.vue        |   75 +++++++++++++++---------
 src/api/product/twist.ts                       |    9 +++
 src/api/product/outbound.ts                    |    8 +-
 src/pages/production/twist/receive/monofil.vue |   55 +++++++++++-------
 4 files changed, 92 insertions(+), 55 deletions(-)

diff --git a/src/api/product/outbound.ts b/src/api/product/outbound.ts
index 7afe4b2..19a23e5 100644
--- a/src/api/product/outbound.ts
+++ b/src/api/product/outbound.ts
@@ -57,10 +57,10 @@
     });
   },
 
-  // 鎷変笣鍗曚笣浜岀淮鐮佹煡璇紙閫氳繃鍗曚笣鍙凤級
-  getTagByLsMonofilamentNumber(params: { monofilamentNumber: string }) {
-    return request<BaseResult<any[]>>({
-      url: "/app/getTagByLsMonofilamentNumber",
+  // 鎷変笣鍗曚笣浜岀淮鐮佹煡璇紙閫氳繃鍗曚笣鍙凤紝杩斿洖瀵硅薄锛�
+  getTagByMonofilamentNumber(params: { monofilamentNumber: string }) {
+    return request<BaseResult<any>>({
+      url: "/app/getTagByMonofilamentNumber",
       method: "GET",
       data: params,
     });
diff --git a/src/api/product/twist.ts b/src/api/product/twist.ts
index 2ea641c..6541aab 100644
--- a/src/api/product/twist.ts
+++ b/src/api/product/twist.ts
@@ -29,6 +29,15 @@
     });
   },
 
+  // 鍗曚笣棰嗙敤鎵爜锛堟寜鍗曚笣缂栧彿锛�
+  getScarnTag(params: { monofilamentNumber: string; twistId: number | string }) {
+    return request<BaseResult<any>>({
+      url: "/app/scarnTag",
+      method: "GET",
+      data: params,
+    });
+  },
+
   // 鎷変笣浜岀淮鐮佹煡璇�
   getTagByIdLs(params: { outPutId: string | number }) {
     return request<BaseResult<any>>({
diff --git a/src/pages/outbound/materialOutbound.vue b/src/pages/outbound/materialOutbound.vue
index 876d241..bfc49fe 100644
--- a/src/pages/outbound/materialOutbound.vue
+++ b/src/pages/outbound/materialOutbound.vue
@@ -189,36 +189,53 @@
       }
 
       outPutId = scanData.id;
+      monofilamentNumber = scanData.monofilamentNumber;
 
-      if (!outPutId) {
-        toast.error("浜岀淮鐮佹牸寮忛敊璇紝缂哄皯id淇℃伅");
+      if (outPutId) {
+        //TODO鍏煎鐩墠宸叉墦鍗扮殑浜岀淮鐮�
+        // 鏈� id锛氭寜 id 鏌ラ噸骞惰皟 getTagByIdAll锛堣繑鍥炴暟缁勶級
+        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 if (monofilamentNumber) {
+        // 鏈� monofilamentNumber锛氭寜鍗曚笣鍙锋煡閲嶅苟璋� getTagByMonofilamentNumber锛堣繑鍥炲璞★級
+        const exists = goodsList.value.some((item) => {
+          const itemMono = item.monofilamentNumber;
+          return itemMono && itemMono === monofilamentNumber && itemMono !== "-";
+        });
+        if (exists) {
+          toast.error("璇ユ潯鐮佸凡瀛樺湪锛岃鍕块噸澶嶆壂鐮�");
+          return;
+        }
+        const { data } = await OutboundApi.getTagByMonofilamentNumber({
+          monofilamentNumber,
+        });
+        if (!data || (Array.isArray(data) && !data.length)) {
+          toast.error("鏈煡璇㈠埌鏉$爜淇℃伅");
+          return;
+        }
+        tagData = Array.isArray(data) ? data[0] : data;
+        outPutId = tagData?.id || monofilamentNumber;
+        needContractCheck = true;
+      } else {
+        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
@@ -242,10 +259,10 @@
         return;
       }
 
-      // 璋冪敤鎷変笣鎺ュ彛锛欸ET /mes/app/getTagByLsMonofilamentNumber?monofilamentNumber=xxxx
+      // 璋冪敤鎷変笣鎺ュ彛锛欸ET /mes/app/getTagByMonofilamentNumber?monofilamentNumber=xxxx
       let data;
       try {
-        const response = await OutboundApi.getTagByLsMonofilamentNumber({
+        const response = await OutboundApi.getTagByMonofilamentNumber({
           monofilamentNumber,
         });
         data = response.data;
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index de0bfc2..9592c45 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -129,33 +129,44 @@
       return;
     }
 
-    // 瑙f瀽鎵爜鏁版嵁锛岀幇鍦ㄤ簩缁寸爜鍙寘鍚玦d
+    // 瑙f瀽鎵爜鏁版嵁锛氬彲鑳藉寘鍚� id(outPutId) 鎴� monofilamentNumber
     const scanData = JSON.parse(code.code);
     const outPutId = scanData.id;
+    const monofilamentNumber = scanData.monofilamentNumber;
 
-    if (!outPutId) {
-      toast.error("浜岀淮鐮佹牸寮忛敊璇紝缂哄皯id淇℃伅");
+    let data: any;
+
+    if (outPutId) {
+      // 鏈� outPutId锛氬厛鏌ュ眰绾э紝鍐嶈皟 scarn
+      const { data: tagData } = await TwistApi.getTagByIdLs({
+        outPutId: outPutId,
+      });
+      if (tagData.layer && tagData.layer !== currentLayer.twistedLayer) {
+        toast.error(
+          `棰嗙敤灞傜骇涓嶅锛屽綋鍓嶅眰鏄細${currentLayer.twistedLayer}锛岄鐢ㄥ崟涓濆眰鏄細${tagData.layer}`
+        );
+      }
+      const res = await TwistApi.getScarn({
+        outPutId: outPutId,
+        twistId: currentLayer.twistId,
+      });
+      data = res.data;
+    } else if (monofilamentNumber) {
+      // 鏃� outPutId 鏈� monofilamentNumber锛氬彧璋� scarnTag锛岃繑鍥炲惈 layer 鐢ㄤ簬鎻愮ず
+      const res = await TwistApi.getScarnTag({
+        monofilamentNumber,
+        twistId: currentLayer.twistId,
+      });
+      data = res.data;
+      if (data.layer && data.layer !== currentLayer.twistedLayer) {
+        toast.error(
+          `棰嗙敤灞傜骇涓嶅锛屽綋鍓嶅眰鏄細${currentLayer.twistedLayer}锛岄鐢ㄥ崟涓濆眰鏄細${data.layer}`
+        );
+      }
+    } else {
+      toast.error("浜岀淮鐮佹牸寮忛敊璇紝缂哄皯id鎴栧崟涓濈紪鍙蜂俊鎭�");
       return;
     }
-
-    // 璋冪敤鎺ュ彛鑾峰彇鎷変笣璇︾粏淇℃伅
-    const { data: tagData } = await TwistApi.getTagByIdLs({
-      outPutId: outPutId,
-    });
-
-    // 鍒ゆ柇灞傜骇鏄惁鍖归厤锛堝鏋滄帴鍙h繑鍥炵殑鏁版嵁涓湁layer瀛楁锛�
-    if (tagData.layer && tagData.layer !== currentLayer.twistedLayer) {
-      toast.error(
-        `棰嗙敤灞傜骇涓嶅锛屽綋鍓嶅眰鏄細${currentLayer.twistedLayer}锛岄鐢ㄥ崟涓濆眰鏄細${tagData.layer}`
-      );
-      // return;
-    }
-
-    // 璋冪敤鍗曚笣棰嗙敤鎵爜鎺ュ彛
-    const { data } = await TwistApi.getScarn({
-      outPutId: outPutId,
-      twistId: currentLayer.twistId,
-    });
 
     // 妫�鏌ュ綋鍓嶅眰鏄惁宸插瓨鍦ㄨ鍗曚笣
     const exists = currentLayer.strandedWireDish?.some(

--
Gitblit v1.9.3