From c13c2bb15b501c74fe4270b0ae763e5c9422ee39 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 19 十一月 2025 10:02:52 +0800
Subject: [PATCH] fix: 重构绞线报工功能

---
 src/pages/production/twist/receive/monofil.vue |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index 9456e8e..b4998fc 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -25,7 +25,12 @@
         <block v-for="item in nodeList" :key="item">
           <wd-tab :title="item.twistedLayer" :name="item.twistedLayer">
             <scroll-view class="content" scroll-y>
-              <MonofilCard v-for="(m, i) in item.strandedWireDish" :key="i" :data="m" />
+              <MonofilCard
+                v-for="(m, i) in item.strandedWireDish"
+                :key="i"
+                :data="m"
+                @delete="handleDeleteCard(item, m)"
+              />
             </scroll-view>
           </wd-tab>
         </block>
@@ -123,8 +128,20 @@
       toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
       return;
     }
+
+    // 瑙f瀽鎵爜鏁版嵁
+    const scanData = JSON.parse(code.code);
+
+    // 鍒ゆ柇灞傜骇鏄惁鍖归厤
+    if (scanData.layer && scanData.layer !== currentLayer.twistedLayer) {
+      toast.error(
+        `棰嗙敤灞傜骇涓嶅锛屽綋鍓嶅眰鏄細${currentLayer.twistedLayer}锛岄鐢ㄥ崟涓濆眰鏄細${scanData.layer}`
+      );
+      // return;
+    }
+
     const { data } = await TwistApi.getScarn({
-      outPutId: JSON.parse(code.code).id,
+      outPutId: scanData.id,
       twistId: currentLayer.twistId,
     });
 
@@ -333,6 +350,44 @@
   }
 };
 
+// 鍒犻櫎鍗$墖
+const handleDeleteCard = async (layer: any, cardData: any) => {
+  // 鏄剧ず纭鎻愮ず
+  uni.showModal({
+    title: "鎻愮ず",
+    content: "纭畾瑕佸垹闄よ鍗曚笣鍚楋紵",
+    success: async (res) => {
+      if (res.confirm) {
+        try {
+          // 濡傛灉鏈塱d锛岃皟鐢ㄦ帴鍙e垹闄�
+          if (cardData.id !== undefined && cardData.id !== null) {
+            const { code, msg } = await TwistApi.deleteStrandedWireDish(cardData.id);
+            if (code !== 200) {
+              toast.error(msg || "鍒犻櫎澶辫触");
+              return;
+            }
+          }
+
+          // 鍓嶇鐩存帴鍒犻櫎锛堟棤璁烘槸鍚︽湁id锛岄兘浠庡墠绔垹闄わ級
+          if (layer.strandedWireDish && Array.isArray(layer.strandedWireDish)) {
+            const index = layer.strandedWireDish.findIndex(
+              (item: any) => item.monofilamentNumber === cardData.monofilamentNumber
+            );
+            if (index !== -1) {
+              layer.strandedWireDish.splice(index, 1);
+              toast.success("鍒犻櫎鎴愬姛");
+              // 鍒锋柊褰撳墠灞傜殑鏁版嵁鏄剧ず
+              getList();
+            }
+          }
+        } catch (error: any) {
+          toast.error(error.msg || "鍒犻櫎澶辫触");
+        }
+      }
+    },
+  });
+};
+
 onLoad(async (options: any) => {
   // 寮�鍚箍鎾洃鍚簨浠�
   uni.$on("scanMono", getScanCode);

--
Gitblit v1.9.3