From f7f25f593a731ea71e307257f5cec3ba562dacda Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 04 十二月 2025 11:10:39 +0800
Subject: [PATCH] fix: 杆领用,型号选择下拉框
---
src/pages/production/wire/report/wire.vue | 140 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 129 insertions(+), 11 deletions(-)
diff --git a/src/pages/production/wire/report/wire.vue b/src/pages/production/wire/report/wire.vue
index fd3935b..7814947 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>
@@ -147,11 +150,12 @@
label-width="100px"
placeholder="璇疯緭鍏ラ鐢ㄦ潌鍙�"
/>
- <wd-input
+ <wd-picker
v-model="newParentData.poleModel"
label="鏉嗗瀷鍙�"
label-width="100px"
- placeholder="璇疯緭鍏ユ潌鍨嬪彿"
+ :columns="poleModelOptions"
+ placeholder="璇烽�夋嫨鏉嗗瀷鍙�"
/>
<wd-input
v-model="newParentData.polePackageNumber"
@@ -192,6 +196,9 @@
/>
</wd-popup>
+ <!-- 鎵爜缁勪欢 -->
+ <Scan ref="scanRef" emitName="scanRodBag" />
+
<wd-toast />
</view>
</template>
@@ -207,6 +214,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();
@@ -221,6 +229,10 @@
// 渚涘簲鍟嗛�夐」
const supplierOptions = ref<any[]>([]);
+// 瑙勬牸鍨嬪彿閫夐」
+const poleModelOptions = ref<any[]>([]);
+// 鐖剁骇鐗╂枡缂栫爜
+const materialCode = ref<string>("");
// 鐖剁骇寮规鐩稿叧
const parentDialogVisible = ref(false);
@@ -242,14 +254,34 @@
poleNumber: "",
});
+// 鎵爜缁勪欢鐩稿叧
+const scanRef = ref();
+
// 鑾峰彇璇︽儏鏁版嵁
const getDetailData = async (id: string) => {
try {
const { data } = await WireDetailApi.getWireDetailById({ id });
model.value = data.model;
oneLength.value = data.oneLength;
+ await loadPoleModelOptions();
} catch (error) {
console.error("鑾峰彇璇︽儏澶辫触:", error);
+ }
+};
+
+// 鍔犺浇瑙勬牸鍨嬪彿鍒楄〃
+const loadPoleModelOptions = async () => {
+ try {
+ const { code, data } = await WireApi.getMaterialByParentCode("003001");
+ if (code == 200 && Array.isArray(data)) {
+ poleModelOptions.value = data.map((item: any) => ({
+ label: item.specificationModel || "",
+ value: item.specificationModel || "",
+ }));
+ }
+ } catch (error) {
+ console.error("鍔犺浇瑙勬牸鍨嬪彿鍒楄〃澶辫触:", error);
+ toast.error("鍔犺浇瑙勬牸鍨嬪彿鍒楄〃澶辫触");
}
};
@@ -325,15 +357,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 +535,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 +682,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