From 527b5009256cbf4a30a4f154d0c1b7dbeb11472f Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 28 十一月 2025 16:41:28 +0800
Subject: [PATCH] fix: 铝杆扫码领用。
---
src/pages/production/wire/report/wire.vue | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
src/manifest.json | 2
2 files changed, 106 insertions(+), 10 deletions(-)
diff --git a/src/manifest.json b/src/manifest.json
index 515033e..b701d72 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -2,7 +2,7 @@
"name" : "绾跨紗涓婃姤",
"appid" : "__UNI__F64E0A4",
"description" : "",
- "versionName" : "1.0.20",
+ "versionName" : "1.0.22",
"versionCode" : "100",
"transformPx" : false,
/* 5+App鐗规湁鐩稿叧 */
diff --git a/src/pages/production/wire/report/wire.vue b/src/pages/production/wire/report/wire.vue
index fd3935b..15e8fd9 100644
--- a/src/pages/production/wire/report/wire.vue
+++ b/src/pages/production/wire/report/wire.vue
@@ -137,7 +137,10 @@
<view class="parent-dialog">
<view class="dialog-header">
<text class="dialog-title">鏂板鏉嗗寘</text>
- <wd-icon name="close" class="close-icon" @click="closeParentDialog"></wd-icon>
+ <view class="dialog-header-actions">
+ <wd-button type="icon" icon="scan" color="#0D867F" @click="openScan"></wd-button>
+ <wd-icon name="close" class="close-icon" @click="closeParentDialog"></wd-icon>
+ </view>
</view>
<view class="dialog-content">
<wd-cell-group>
@@ -192,6 +195,9 @@
/>
</wd-popup>
+ <!-- 鎵爜缁勪欢 -->
+ <Scan ref="scanRef" emitName="scanRodBag" />
+
<wd-toast />
</view>
</template>
@@ -207,6 +213,7 @@
import { getTeamId } from "@/utils/cache";
import { useUserStore } from "@/store/modules/user";
import WireDetailApi from "@/api/product/wire";
+import Scan from "@/components/scan/index.vue";
const toast = useToast();
const userStore = useUserStore();
@@ -241,6 +248,9 @@
wireId: "",
poleNumber: "",
});
+
+// 鎵爜缁勪欢鐩稿叧
+const scanRef = ref();
// 鑾峰彇璇︽儏鏁版嵁
const getDetailData = async (id: string) => {
@@ -325,15 +335,13 @@
// 鏂板鐖剁骇鏁版嵁 - 鎵撳紑寮规
const handleAddParent = () => {
- const lastParent = parentDataList.value[0];
-
- // 鍒濆鍖栨柊鏁版嵁锛屽鏋滄湁鏈�鍚庝竴鏉℃暟鎹紝浣跨敤鍏跺�间綔涓洪粯璁ゅ��
+ // 娓呯┖鎵�鏈夋暟鎹�
newParentData.value = {
- poleNumber: lastParent?.poleNumber || "",
- poleModel: lastParent?.poleModel || "",
- polePackageNumber: lastParent?.polePackageNumber || "",
- poleWeight: lastParent?.poleWeight || null,
- supplier: lastParent?.supplier || "",
+ poleNumber: "",
+ poleModel: "",
+ polePackageNumber: "",
+ poleWeight: undefined,
+ supplier: "",
isConsumed: 1,
};
@@ -505,11 +513,93 @@
});
};
+// 鎵撳紑鎵爜
+const openScan = () => {
+ if (scanRef.value) {
+ scanRef.value.triggerScan();
+ } else {
+ toast.error("鎵爜缁勪欢鏈垵濮嬪寲");
+ }
+};
+
+// 澶勭悊鎵爜缁撴灉
+const getScanCode = (code: any) => {
+ try {
+ console.log("鎵爜缁撴灉:", code.code);
+
+ let scanData: any = {};
+
+ // 灏濊瘯瑙f瀽 JSON 鏍煎紡
+ try {
+ scanData = JSON.parse(code.code);
+ } catch (e) {
+ // 濡傛灉涓嶆槸 JSON锛屽皾璇曟寜閫楀彿鍒嗗壊
+ const arr = code.code.split(",");
+ if (arr.length >= 5) {
+ // 鏍规嵁 wireForm.vue 鐨勬牸寮忥細arr[2] 鏄潌鍨嬪彿锛宎rr[3] 鏄鐢ㄦ潌鍙凤紝arr[4] 鏄潌閲�
+ scanData = {
+ poleModel: arr[2],
+ poleNumber: arr[3],
+ poleWeight: arr[4],
+ };
+ } else {
+ // 濡傛灉鏍煎紡涓嶅尮閰嶏紝灏濊瘯鍏朵粬瑙f瀽鏂瑰紡
+ // 鍙兘鏄悎鏍艰瘉浜岀淮鐮侊紝鍖呭惈鐐夋鍙枫�佺墝鍙枫�佽鏍笺�佸噣閲嶇瓑淇℃伅
+ // 鏍规嵁鍚堟牸璇佷俊鎭紝灏濊瘯鎻愬彇鍏抽敭瀛楁
+ const codeStr = code.code;
+
+ // 灏濊瘯鎻愬彇鐐夋鍙凤紙鏍煎紡锛氭暟瀛�-鏁板瓧-鏁板瓧锛�
+ const batchMatch = codeStr.match(/(\d{6,}-\d{3,}-\d{3,})/);
+ if (batchMatch) {
+ scanData.poleNumber = batchMatch[1]; // 鐐夋鍙蜂綔涓洪鐢ㄦ潌鍙�
+ }
+
+ // 灏濊瘯鎻愬彇鐗屽彿锛圓6绛夛級
+ const brandMatch = codeStr.match(/鐗屽彿[锛�:]\s*([A-Z]\d+)/i) || codeStr.match(/([A-Z]\d+)/);
+ if (brandMatch) {
+ scanData.poleModel = brandMatch[1]; // 鐗屽彿浣滀负鏉嗗瀷鍙�
+ }
+
+ // 灏濊瘯鎻愬彇鍑�閲嶏紙鏁板瓧+KG锛�
+ const weightMatch =
+ codeStr.match(/鍑�閲峓锛�:]\s*(\d+(?:\.\d+)?)\s*KG/i) ||
+ codeStr.match(/(\d+(?:\.\d+)?)\s*KG/i);
+ if (weightMatch) {
+ scanData.poleWeight = parseFloat(weightMatch[1]);
+ }
+ }
+ }
+
+ // 鍙~鍏呬笁涓瓧娈碉細棰嗙敤鏉嗗彿銆佹潌鍨嬪彿銆佹潌閲�(kg)
+ if (scanData.poleNumber) {
+ newParentData.value.poleNumber = scanData.poleNumber;
+ }
+ if (scanData.poleModel) {
+ newParentData.value.poleModel = scanData.poleModel;
+ }
+ if (scanData.poleWeight) {
+ newParentData.value.poleWeight = parseFloat(scanData.poleWeight);
+ }
+
+ toast.success("鎵爜鎴愬姛锛屽凡濉厖淇℃伅");
+ } catch (error) {
+ console.error("瑙f瀽鎵爜鏁版嵁澶辫触:", error);
+ toast.error("浜岀淮鐮佹牸寮忛敊璇紝璇锋鏌ヤ簩缁寸爜");
+ }
+};
+
onLoad(async (options: any) => {
paramsId.value = options.id;
await getDetailData(options.id);
await loadSupplierDict();
await getData();
+ // 寮�鍚壂鐮佺洃鍚簨浠�
+ uni.$on("scanRodBag", getScanCode);
+});
+
+onUnload(() => {
+ // 鍙栨秷鎵爜鐩戝惉浜嬩欢
+ uni.$off("scanRodBag", getScanCode);
});
</script>
@@ -570,6 +660,12 @@
z-index: 10;
}
+.dialog-header-actions {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
.dialog-title {
font-size: 16px;
color: #333;
--
Gitblit v1.9.3