From f2e14fbd69737ca7717835fcc4e02c0f01de10d4 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期一, 02 二月 2026 10:12:42 +0800
Subject: [PATCH] fix: 修复扫码时code参数格式不一致导致的解析错误
---
src/pages/production/twist/receive/monofil.vue | 90 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 85 insertions(+), 5 deletions(-)
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index 9456e8e..23ffec7 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,10 +128,46 @@
toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
return;
}
- const { data } = await TwistApi.getScarn({
- outPutId: JSON.parse(code.code).id,
- twistId: currentLayer.twistId,
- });
+
+ // 瑙f瀽鎵爜鏁版嵁锛氬彲鑳藉寘鍚� id(outPutId) 鎴� monofilamentNumber
+ let scanCode = code.code || code;
+ const scanData = JSON.parse(scanCode);
+ const outPutId = scanData.id;
+ const monofilamentNumber = scanData.monofilamentNumber;
+
+ 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 exists = currentLayer.strandedWireDish?.some(
@@ -155,6 +196,7 @@
}
} catch (error) {
toast.error("浜岀淮鐮佸紓甯革紝璇锋洿鎹簩缁寸爜锛�");
+ console.log(error);
}
};
@@ -333,6 +375,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