From 6e9a16a5aa8a5a222369cb6d9989acfe0ce7039f Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 18 十一月 2025 15:56:13 +0800
Subject: [PATCH] fix: 领用单丝删除功能

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

diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index ebf1542..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>
@@ -345,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