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/outbound/materialOutbound.vue | 128 +++++++++++++++++++++++++++++-------------
1 files changed, 88 insertions(+), 40 deletions(-)
diff --git a/src/pages/outbound/materialOutbound.vue b/src/pages/outbound/materialOutbound.vue
index 876d241..bad1b8d 100644
--- a/src/pages/outbound/materialOutbound.vue
+++ b/src/pages/outbound/materialOutbound.vue
@@ -176,7 +176,6 @@
let tagData: any = null;
let outPutId: string | number | undefined;
let monofilamentNumber: string | undefined;
- let needContractCheck = false; // 鏄惁闇�瑕佽繘琛屽悎鍚屽彿鏍¢獙锛堝彧瀵圭粸绾匡級
if (isJsonCode) {
// ===== 缁炵嚎绛夊師鏈変簩缁寸爜閫昏緫锛圝SON锛� =====
@@ -189,36 +188,50 @@
}
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,
+ });
+ tagData = data;
+ if (!tagData) {
+ toast.error("鏈煡璇㈠埌鏉$爜淇℃伅");
+ return;
+ }
+ } 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;
+ } 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 +255,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;
@@ -259,6 +272,18 @@
if (!formattedMonofilamentNumber) {
return;
}
+
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堥拡瀵规墜鍔ㄥ鐞嗗悗鐨勫崟涓濆彿杩涜鍘婚噸锛�
+ const isDuplicate = goodsList.value.some((item) => {
+ const itemMono = item.monofilamentNumber;
+ return itemMono && itemMono === formattedMonofilamentNumber;
+ });
+
+ if (isDuplicate) {
+ toast.error(`鏉$爜"${formattedMonofilamentNumber}"宸插瓨鍦紝璇峰嬁閲嶅鎵爜`);
+ return;
+ }
+
const newItem = {
id: monofilamentNumber || "-",
contractNo: "鏈湪mes涓敓浜�",
@@ -268,7 +293,7 @@
clienteleName: "-",
actuallyLength: "-",
productionDate: "-",
- type: "",
+ type: "鎷変笣",
devicemodel: "",
state: "",
projectId: "",
@@ -293,15 +318,15 @@
toast.error("璇ユ潯鐮佸凡鍑哄簱锛屾棤娉曢噸澶嶅嚭搴�");
return;
}
-
- // 鍚堝悓鍙锋牎楠岋細鍙缁炵嚎锛圝SON 鍦烘櫙锛夎繘琛屾牎楠�
- if (needContractCheck) {
- 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繑鍥炵殑鏁版嵁缁撴瀯锛�
const parsedData = {
@@ -329,6 +354,29 @@
scanCode: scanText,
};
+ // 鍐嶆妫�鏌ユ槸鍚﹀凡瀛樺湪锛堥拡瀵规墜鍔ㄥ鐞嗗悗鐨勫崟涓濆彿杩涜鍘婚噸锛�
+ const isDuplicate = goodsList.value.some((item) => {
+ const itemMono = item.monofilamentNumber;
+ const currentMono = parsedData.monofilamentNumber;
+ return itemMono && itemMono === currentMono && itemMono !== "-";
+ });
+
+ if (isDuplicate) {
+ toast.error(`鏉$爜"${parsedData.monofilamentNumber}"宸插瓨鍦紝璇峰嬁閲嶅鎵爜`);
+ return;
+ }
+
+ // 妫�鏌ョ被鍨嬫槸鍚︿竴鑷�
+ if (goodsList.value.length > 0) {
+ const firstItemType = goodsList.value[0].type;
+ const currentType = parsedData.type;
+ // 濡傛灉绫诲瀷涓嶄竴鑷达紝鎻愮ず閿欒
+ if (firstItemType && currentType && firstItemType !== currentType) {
+ toast.error(`鐩墠鍙兘杩涜${firstItemType}鍑哄簱`);
+ return;
+ }
+ }
+
// 娣诲姞鍒板垪琛�
const newItem = {
...parsedData,
--
Gitblit v1.9.3