From 646135b9c54d6ccf5d47af30bf208bdfe5005017 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 09 十二月 2025 10:31:44 +0800
Subject: [PATCH] fix: 二维码内容简化,只传一个id。根据id查询详细信息。
---
src/pages/production/twist/components/StatisticsModal.vue | 4
src/api/product/twist.ts | 9 +
src/api/product/outbound.ts | 9 +
src/pages/production/twist/receive/monofil.vue | 22 ++
src/manifest.json | 2
src/pages/index/index.vue | 12 +-
src/pages/outbound/index.vue | 256 +++++++++++++++--------------------------
7 files changed, 139 insertions(+), 175 deletions(-)
diff --git a/src/api/product/outbound.ts b/src/api/product/outbound.ts
index 9f46c06..30059a7 100644
--- a/src/api/product/outbound.ts
+++ b/src/api/product/outbound.ts
@@ -10,6 +10,15 @@
data: data,
});
},
+
+ // 缁炵嚎浜岀淮鐮佹煡璇�
+ getTagByIdJx(params: { outPutId: string | number }) {
+ return request<BaseResult<any>>({
+ url: "/app/getTagByIdJx",
+ method: "GET",
+ data: params,
+ });
+ },
};
export default OutboundApi;
diff --git a/src/api/product/twist.ts b/src/api/product/twist.ts
index ef914da..2ea641c 100644
--- a/src/api/product/twist.ts
+++ b/src/api/product/twist.ts
@@ -29,6 +29,15 @@
});
},
+ // 鎷変笣浜岀淮鐮佹煡璇�
+ getTagByIdLs(params: { outPutId: string | number }) {
+ return request<BaseResult<any>>({
+ url: "/app/getTagByIdLs",
+ method: "GET",
+ data: params,
+ });
+ },
+
addStrandedWireDish(data: any) {
return request<BaseResult<any>>({
url: "/app/addStrandedWireDish",
diff --git a/src/manifest.json b/src/manifest.json
index b701d72..3e6766c 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -2,7 +2,7 @@
"name" : "绾跨紗涓婃姤",
"appid" : "__UNI__F64E0A4",
"description" : "",
- "versionName" : "1.0.22",
+ "versionName" : "1.0.24",
"versionCode" : "100",
"transformPx" : false,
/* 5+App鐗规湁鐩稿叧 */
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 111981c..5de2d23 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -201,12 +201,12 @@
url: "/pages/routingInspection/index",
show: false,
},
- // {
- // icon: "/static/icons/log.png",
- // title: "鍑哄簱",
- // url: "/pages/outbound/index",
- // show: true,
- // },
+ {
+ icon: "/static/icons/log.png",
+ title: "鍑哄簱",
+ url: "/pages/outbound/index",
+ show: true,
+ },
]);
// 鍔犺浇璁块棶缁熻鏁版嵁
diff --git a/src/pages/outbound/index.vue b/src/pages/outbound/index.vue
index a3a435c..ec42661 100644
--- a/src/pages/outbound/index.vue
+++ b/src/pages/outbound/index.vue
@@ -25,6 +25,18 @@
<text class="outbound_item_value">{{ item.model || "-" }}</text>
</view>
<view class="outbound_item_row">
+ <text class="outbound_item_label">閲嶉噺锛�</text>
+ <text class="outbound_item_value">{{ item.weight || "-" }} kg</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">鍘傚锛�</text>
+ <text class="outbound_item_value">{{ item.clienteleName || "-" }}</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">娈甸暱锛�</text>
+ <text class="outbound_item_value">{{ item.actuallyLength || "-" }} M</text>
+ </view>
+ <view class="outbound_item_row">
<text class="outbound_item_label">鐢熶骇鏃ユ湡锛�</text>
<text class="outbound_item_value">{{ item.productionDate || "-" }}</text>
</view>
@@ -68,170 +80,92 @@
return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
};
-// 瑙f瀽鎵爜鍐呭
-const parseScanCode = (scanCode: string) => {
- try {
- // 绗竴娆¤В鏋愶細瑙f瀽澶栧眰JSON
- const outerParsed = JSON.parse(scanCode);
-
- // 濡傛灉澶栧眰鏈� code 瀛楁锛屼笖鏄瓧绗︿覆锛岄渶瑕佸啀娆¤В鏋�
- let innerData = null;
- if (outerParsed.code && typeof outerParsed.code === "string") {
- try {
- const innerParsed = JSON.parse(outerParsed.code);
-
- // 鏌ユ壘鎵�鏈夋暟瀛梜ey锛堝 "12480"锛夛紝杩欎釜鏁板瓧key灏辨槸id
- const keys = Object.keys(innerParsed);
- // 鎵惧埌鎵�鏈夋暟瀛梜ey锛屾帓闄� "code" 瀛楁
- const numberKeys = keys.filter((key) => !isNaN(Number(key)) && key !== "code");
-
- if (numberKeys.length > 0) {
- // 鍙栫涓�涓暟瀛梜ey锛堣繖涓氨鏄痠d锛�
- const dataKey = numberKeys[0];
- const idValue = Number(dataKey); // 鏁板瓧key灏辨槸id鍊�
- // 鎻愬彇鏁板瓧key瀵瑰簲鐨勬暟鎹璞�
- const extractedData = innerParsed[dataKey];
- if (extractedData) {
- innerData = { ...extractedData }; // 澶嶅埗鏁版嵁瀵硅薄
- // 纭繚鏁版嵁瀵硅薄涓湁id瀛楁锛屽鏋滄病鏈夊垯浣跨敤鏁板瓧key浣滀负id
- if (!innerData.id) {
- innerData.id = idValue;
- }
- }
- } else {
- // 濡傛灉娌℃湁鏁板瓧key锛屽皾璇曠洿鎺ヤ娇鐢ㄥ璞★紙鎺掗櫎 code 瀛楁锛�
- const { code, ...rest } = innerParsed;
- if (Object.keys(rest).length > 0) {
- innerData = rest;
- }
- }
- } catch (e) {
- console.error("鍐呭眰JSON瑙f瀽澶辫触:", e);
- }
- } else {
- // 濡傛灉娌℃湁 code 瀛楁锛岀洿鎺ヤ娇鐢ㄥ灞傛暟鎹�
- innerData = outerParsed;
- }
-
- // 濡傛灉 innerData 浠嶇劧涓虹┖锛屽皾璇曠洿鎺ヨВ鏋�
- if (!innerData) {
- innerData = outerParsed;
- }
-
- // 濡傛灉 innerData 浠嶇劧鍖呭惈鏁板瓧key缁撴瀯锛堝 { "12480": {...}, "code": "..." }锛夛紝闇�瑕佸啀娆℃彁鍙�
- if (innerData && typeof innerData === "object" && !innerData.id && !innerData.contractno) {
- const keys = Object.keys(innerData);
- const numberKeys = keys.filter((key) => !isNaN(Number(key)) && key !== "code");
- if (numberKeys.length > 0) {
- const dataKey = numberKeys[0];
- const extractedData = innerData[dataKey];
- if (extractedData) {
- innerData = { ...extractedData };
- }
- }
- }
-
- // 鎻愬彇鏁版嵁瀛楁锛堟牴鎹簩缁寸爜瀹為檯瀛楁鍚嶇粺涓�锛�
- const data = {
- id: innerData?.id,
- contractNo: innerData?.contractno,
- batchNo: innerData?.monofilamentnumber,
- model: innerData?.model,
- weight: innerData?.actuallyweight,
- productionDate: innerData?.producttime,
- projectId: innerData?.projectid,
- // 淇濈暀鍘熷鏁版嵁锛堜繚瀛樻彁鍙栧悗鐨勬暟鎹璞★級
- rawData: innerData,
- scanCode: scanCode,
- };
-
- // 濡傛灉鎵爜鏁版嵁涓湁 projectId锛屼繚瀛樺畠
- if (data.projectId && !projectId.value) {
- projectId.value = data.projectId;
- }
-
- return data;
- } catch (error) {
- console.error("JSON瑙f瀽澶辫触:", error);
- // 濡傛灉涓嶆槸JSON锛屽皾璇曟寜閫楀彿鍒嗗壊锛堝彲鑳芥槸CSV鏍煎紡锛�
- const parts = scanCode.split(",");
- if (parts.length >= 5) {
- return {
- id: parts[0] || "-", // 鍋囪绗竴涓槸id
- contractNo: parts[1] || "-",
- batchNo: parts[2] || "-",
- model: parts[3] || "-",
- weight: parts[4] || "-",
- productionDate: parts[5] || "-",
- projectId: projectId.value || "-",
- scanCode: scanCode,
- };
- }
- // 濡傛灉閮芥棤娉曡В鏋愶紝杩斿洖鍘熷瀛楃涓�
- return {
- id: scanCode, // 浣跨敤鍘熷瀛楃涓蹭綔涓篿d
- contractNo: scanCode,
- batchNo: "-",
- model: "-",
- weight: "-",
- productionDate: "-",
- projectId: projectId.value || "-",
- scanCode: scanCode,
- };
- }
-};
-
// 鎵爜鍥炶皟
-const getScanCode = (code: any) => {
- // 濡傛灉 code 鏄璞′笖鏈� code 瀛楁锛屼娇鐢� code.code锛涘惁鍒欑洿鎺ヤ娇鐢� code
- let scanCode = code.code || code;
+const getScanCode = async (code: any) => {
+ try {
+ // 濡傛灉 code 鏄璞′笖鏈� code 瀛楁锛屼娇鐢� code.code锛涘惁鍒欑洿鎺ヤ娇鐢� code
+ let scanCode = code.code || code;
- // 濡傛灉 scanCode 鏄璞★紝灏濊瘯鑾峰彇鍏� code 瀛楁
- if (typeof scanCode === "object" && scanCode.code) {
- scanCode = scanCode.code;
+ // 濡傛灉 scanCode 鏄璞★紝灏濊瘯鑾峰彇鍏� code 瀛楁
+ if (typeof scanCode === "object" && scanCode.code) {
+ scanCode = scanCode.code;
+ }
+
+ // 濡傛灉 scanCode 鏄瓧绗︿覆锛岀洿鎺ヤ娇鐢紱濡傛灉鏄璞★紝杞负瀛楃涓�
+ if (typeof scanCode !== "string") {
+ scanCode = JSON.stringify(scanCode);
+ }
+
+ if (!scanCode) {
+ toast.error("鎵爜鍐呭涓虹┖");
+ return;
+ }
+
+ // 瑙f瀽鎵爜鏁版嵁锛岀幇鍦ㄤ簩缁寸爜鍙寘鍚玦d
+ let scanData;
+ try {
+ scanData = JSON.parse(scanCode);
+ } catch (e) {
+ toast.error("浜岀淮鐮佹牸寮忛敊璇�");
+ return;
+ }
+
+ const outPutId = scanData.id;
+
+ if (!outPutId) {
+ toast.error("浜岀淮鐮佹牸寮忛敊璇紝缂哄皯id淇℃伅");
+ return;
+ }
+
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堟牴鎹甶d鍒ゆ柇锛�
+ const exists = outboundList.value.some((item) => {
+ const itemId = item.id;
+ return itemId && itemId === outPutId && itemId !== "-";
+ });
+
+ if (exists) {
+ toast.error("璇ユ潯鐮佸凡瀛樺湪锛岃鍕块噸澶嶆壂鐮�");
+ return;
+ }
+
+ // 璋冪敤鎺ュ彛鑾峰彇缁炵嚎璇︾粏淇℃伅
+ const { data: tagData } = await OutboundApi.getTagByIdJx({
+ outPutId: outPutId,
+ });
+
+ // 鎻愬彇鏁版嵁瀛楁锛堟牴鎹帴鍙h繑鍥炵殑鏁版嵁缁撴瀯锛�
+ const parsedData = {
+ id: tagData?.id || outPutId,
+ contractNo: tagData?.contractno || tagData?.contractNo || "-",
+ batchNo: tagData?.systemno || tagData?.systemNo || tagData?.batchNo || "-",
+ model: tagData?.model || "-",
+ weight: tagData?.actuallyweight || tagData?.actuallyWeight || tagData?.weight || "-",
+ clienteleName: tagData?.clientelename || tagData?.clienteleName || "-",
+ actuallyLength: tagData?.actuallylength || tagData?.actuallyLength || "-",
+ productionDate: tagData?.producttime || tagData?.productionDate || "-",
+ projectId: tagData?.projectid || tagData?.projectId || projectId.value || "",
+ // 淇濈暀鍘熷鏁版嵁
+ rawData: tagData,
+ scanCode: scanCode,
+ };
+
+ // 濡傛灉鎺ュ彛杩斿洖鐨勬暟鎹腑鏈� projectId锛屼繚瀛樺畠
+ if (parsedData.projectId && !projectId.value) {
+ projectId.value = parsedData.projectId;
+ }
+
+ // 娣诲姞鍒板垪琛�
+ const newItem = {
+ ...parsedData,
+ scanTime: formatTime(new Date()),
+ };
+
+ outboundList.value.push(newItem);
+ toast.success("鎵爜鎴愬姛");
+ } catch (error: any) {
+ console.error("鎵爜澶勭悊澶辫触:", error);
+ toast.error(error.msg || "浜岀淮鐮佸紓甯革紝璇锋洿鎹簩缁寸爜锛�");
}
-
- // 濡傛灉 scanCode 鏄瓧绗︿覆锛岀洿鎺ヤ娇鐢紱濡傛灉鏄璞★紝杞负瀛楃涓�
- if (typeof scanCode !== "string") {
- scanCode = JSON.stringify(scanCode);
- }
-
- if (!scanCode) {
- toast.error("鎵爜鍐呭涓虹┖");
- return;
- }
-
- // 瑙f瀽鎵爜鍐呭
- const parsedData = parseScanCode(scanCode);
-
- // 浣跨敤id浣滀负鍞竴鏍囪瘑
- const uniqueId = parsedData.id;
-
- // 濡傛灉娌℃湁id锛屾彁绀洪敊璇�
- if (!uniqueId || uniqueId === "-" || uniqueId === null || uniqueId === undefined) {
- toast.error("鎵爜鍐呭缂哄皯鍞竴鏍囪瘑锛屾棤娉曟坊鍔�");
- return;
- }
-
- // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堟牴鎹甶d鍒ゆ柇锛�
- const exists = outboundList.value.some((item) => {
- const itemId = item.id;
- return itemId && itemId === uniqueId && itemId !== "-";
- });
-
- if (exists) {
- toast.error("璇ユ潯鐮佸凡瀛樺湪锛岃鍕块噸澶嶆壂鐮�");
- return;
- }
-
- // 娣诲姞鍒板垪琛�
- const newItem = {
- ...parsedData,
- scanTime: formatTime(new Date()),
- };
-
- outboundList.value.push(newItem);
- toast.success("鎵爜鎴愬姛");
};
// 瑙﹀彂鎵爜
diff --git a/src/pages/production/twist/components/StatisticsModal.vue b/src/pages/production/twist/components/StatisticsModal.vue
index 49837ad..f8ea690 100644
--- a/src/pages/production/twist/components/StatisticsModal.vue
+++ b/src/pages/production/twist/components/StatisticsModal.vue
@@ -47,7 +47,7 @@
</view>
<view class="layer-details">
<text class="detail-text">閲嶉噺锛歿{ layer.weight.toFixed(2) }} kg</text>
- <text class="detail-text">闀垮害锛歿{ layer.length.toFixed(2) }} M</text>
+ <text class="detail-text"> 闀垮害锛歿{ layer.length.toFixed(2) }} M</text>
</view>
</view>
</view>
@@ -111,7 +111,7 @@
node.strandedWireDish.forEach((item: any) => {
stats[layerName].count++;
stats[layerName].weight += parseFloat(item.actuallyWeight || 0);
- stats[layerName].length += parseFloat(item.amount || 0);
+ stats[layerName].length += parseFloat(item.actuallyLength || 0);
});
}
});
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index b4998fc..de0bfc2 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -129,19 +129,31 @@
return;
}
- // 瑙f瀽鎵爜鏁版嵁
+ // 瑙f瀽鎵爜鏁版嵁锛岀幇鍦ㄤ簩缁寸爜鍙寘鍚玦d
const scanData = JSON.parse(code.code);
+ const outPutId = scanData.id;
- // 鍒ゆ柇灞傜骇鏄惁鍖归厤
- if (scanData.layer && scanData.layer !== currentLayer.twistedLayer) {
+ if (!outPutId) {
+ 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}锛岄鐢ㄥ崟涓濆眰鏄細${scanData.layer}`
+ `棰嗙敤灞傜骇涓嶅锛屽綋鍓嶅眰鏄細${currentLayer.twistedLayer}锛岄鐢ㄥ崟涓濆眰鏄細${tagData.layer}`
);
// return;
}
+ // 璋冪敤鍗曚笣棰嗙敤鎵爜鎺ュ彛
const { data } = await TwistApi.getScarn({
- outPutId: scanData.id,
+ outPutId: outPutId,
twistId: currentLayer.twistId,
});
--
Gitblit v1.9.3