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 | 163 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 149 insertions(+), 14 deletions(-)
diff --git a/src/pages/production/wire/report/wire.vue b/src/pages/production/wire/report/wire.vue
index e391316..15e8fd9 100644
--- a/src/pages/production/wire/report/wire.vue
+++ b/src/pages/production/wire/report/wire.vue
@@ -116,10 +116,17 @@
</view>
<template #footer>
- <view class="flex justify-start">
- <wd-button plain size="small" type="primary" @click="openChildDialog(item)">
+ <view class="flex justify-start gap-2">
+ <wd-button
+ plain
+ size="small"
+ type="primary"
+ @click="openChildDialog(item)"
+ style="margin-right: 10px"
+ >
鎶ュ伐绠$悊
</wd-button>
+ <wd-button plain size="small" @click="() => toSelfInspect(item)">鑷</wd-button>
</view>
</template>
</wd-card>
@@ -130,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>
@@ -151,13 +161,14 @@
label="鏉嗗寘鍙�"
label-width="100px"
placeholder="璇疯緭鍏ユ潌鍖呭彿"
+ type="number"
/>
<wd-input
v-model="newParentData.poleWeight"
label="鏉嗛噸(kg)"
label-width="100px"
- type="number"
placeholder="璇疯緭鍏ユ潌閲�"
+ type="number"
/>
<wd-picker
v-model="newParentData.supplier"
@@ -169,7 +180,7 @@
</wd-cell-group>
</view>
<view class="dialog-footer">
- <wd-button plain @click="closeParentDialog">鍙栨秷</wd-button>
+ <wd-button plain @click="closeParentDialog" style="margin-right: 10px">鍙栨秷</wd-button>
<wd-button type="primary" class="ml-2" @click="handleSaveNewParent">淇濆瓨</wd-button>
</view>
</view>
@@ -183,6 +194,9 @@
@close="handleDrawClose"
/>
</wd-popup>
+
+ <!-- 鎵爜缁勪欢 -->
+ <Scan ref="scanRef" emitName="scanRodBag" />
<wd-toast />
</view>
@@ -199,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();
@@ -233,6 +248,9 @@
wireId: "",
poleNumber: "",
});
+
+// 鎵爜缁勪欢鐩稿叧
+const scanRef = ref();
// 鑾峰彇璇︽儏鏁版嵁
const getDetailData = async (id: string) => {
@@ -317,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,
};
@@ -490,18 +506,107 @@
drawFormRef.visible = false;
};
+// 璺宠浆鍒拌嚜妫�椤甸潰
+const toSelfInspect = (row: any) => {
+ uni.navigateTo({
+ url: `/pages/production/wire/selfInspect/index?wireId=${paramsId.value}&poleModel=${row.poleModel || ""}&poleNumber=${row.poleNumber || ""}`,
+ });
+};
+
+// 鎵撳紑鎵爜
+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>
<style lang="scss" scoped>
.list {
min-height: calc(100vh - 30px);
- padding: 12px;
+ padding: 12px 4px;
background: #f3f9f8;
:deep() {
@@ -543,6 +648,36 @@
border-radius: 12px 12px 0 0;
}
+.dialog-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 16px;
+ border-bottom: 1px solid #e6e6e6;
+ position: sticky;
+ top: 0;
+ background: #fff;
+ z-index: 10;
+}
+
+.dialog-header-actions {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.dialog-title {
+ font-size: 16px;
+ color: #333;
+ font-weight: 500;
+}
+
+.close-icon {
+ font-size: 20px;
+ color: #999;
+ padding: 4px;
+}
+
.dialog-content {
flex: 1;
overflow-y: auto;
--
Gitblit v1.9.3