From bfbea958be8afe7e0522dc19f8a468eb35a3f9b9 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 13 十一月 2025 10:29:09 +0800
Subject: [PATCH] fix: 钢芯领用添加芯线类型字段,添加扫码领用功能
---
src/pages/production/twist/receive/monofil.vue | 30 +++++--
src/pages/production/twist/receive/steelCore/edit.vue | 3
src/pages/production/twist/receive/index.vue | 6
src/pages/production/twist/receive/steelCore/index.vue | 69 ++++++++++++++++
src/pages/production/twist/receive/steelCore/form.vue | 80 +++++++++++++++++++
src/pages/production/wire/attachment/index.vue | 3
6 files changed, 170 insertions(+), 21 deletions(-)
diff --git a/src/pages/production/twist/receive/index.vue b/src/pages/production/twist/receive/index.vue
index 74275f9..d4cede7 100644
--- a/src/pages/production/twist/receive/index.vue
+++ b/src/pages/production/twist/receive/index.vue
@@ -1,16 +1,16 @@
<template>
<wd-tabs v-model="tab" auto-line-width>
<wd-tab title="鍗曚笣棰嗙敤" name="鍗曚笣棰嗙敤">
- <Monofil />
+ <Monofil v-if="tab === '鍗曚笣棰嗙敤'" />
</wd-tab>
<wd-tab title="鐩樺叿棰嗙敤" name="鐩樺叿棰嗙敤">
<view class="content">
- <Plate />
+ <Plate v-if="tab === '鐩樺叿棰嗙敤'" />
</view>
</wd-tab>
<wd-tab title="鑺嚎棰嗙敤" name="鑺嚎棰嗙敤">
<view class="content">
- <SteelCore />
+ <SteelCore v-if="tab === '鑺嚎棰嗙敤'" />
</view>
</wd-tab>
</wd-tabs>
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index 526969d..9456e8e 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -79,7 +79,7 @@
import MonofilCard from "../components/MonofilCard.vue";
import StatisticsModal from "../components/StatisticsModal.vue";
import { useToast } from "wot-design-uni";
-import { onLoad, onUnload } from "@dcloudio/uni-app";
+import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app";
import Scan from "@/components/scan/index.vue";
import ManageApi from "@/api/product/manage";
import TwistApi from "@/api/product/twist";
@@ -95,20 +95,21 @@
const showStatisticsModal = ref(false);
const showManualInput = ref(false);
const manualOutPutId = ref("");
+const isPageVisible = ref(false); // 鏍囪椤甸潰鏄惁鍙
// 鐩戝惉鏍囩鍒囨崲
watch(tab, () => {
if (tab.value) {
- console.log("tab.value:===========1", tab.value);
getList();
}
});
const getScanCode = async (code: any) => {
- console.log("鑷畾涔夋壂鎻忕殑缁撴灉鍥炶皟鍑芥暟:", code);
- // let parseData = code.trim();
- console.log("code:===========", JSON.parse(code.code));
- console.log("id:=============", JSON.parse(code.code).id);
+ // 妫�鏌ラ〉闈㈡槸鍚﹀彲瑙侊紝濡傛灉涓嶅彲瑙佸垯涓嶅鐞嗘壂鐮佹暟鎹�
+ if (!isPageVisible.value) {
+ return;
+ }
+
try {
// 妫�鏌ユ槸鍚﹀凡閫夋嫨鏍囩
if (!tab.value) {
@@ -117,13 +118,11 @@
}
// 鎵惧埌褰撳墠閫変腑鐨勫眰
- console.log("tab.value:===========2", tab.value);
const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
if (!currentLayer) {
toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
return;
}
- console.log("tab.value:===========3", currentLayer);
const { data } = await TwistApi.getScarn({
outPutId: JSON.parse(code.code).id,
twistId: currentLayer.twistId,
@@ -259,7 +258,6 @@
// 璁剧疆榛樿绗竴灞�
if (nodeList.value && nodeList.value.length > 0 && !tab.value) {
tab.value = nodeList.value[0].twistedLayer;
- console.log("璁剧疆榛樿绗竴灞�:", tab.value);
// 璁剧疆榛樿鏍囩鍚庯紝鍔犺浇绗竴灞傜殑鏁版嵁
getList();
}
@@ -344,9 +342,21 @@
getRootNumber(options.id);
// getRootNumber(118);
});
+
+onShow(() => {
+ // 椤甸潰鏄剧ず鏃舵爣璁颁负鍙
+ isPageVisible.value = true;
+});
+
+onHide(() => {
+ // 椤甸潰闅愯棌鏃舵爣璁颁负涓嶅彲瑙�
+ isPageVisible.value = false;
+});
+
onUnload(() => {
- // 寮�鍚箍鎾洃鍚簨浠�
+ // 鍙栨秷骞挎挱鐩戝惉浜嬩欢
uni.$off("scanMono", getScanCode);
+ isPageVisible.value = false;
});
</script>
diff --git a/src/pages/production/twist/receive/steelCore/edit.vue b/src/pages/production/twist/receive/steelCore/edit.vue
index c3a6b6a..cbca0fe 100644
--- a/src/pages/production/twist/receive/steelCore/edit.vue
+++ b/src/pages/production/twist/receive/steelCore/edit.vue
@@ -37,13 +37,10 @@
// 鎺ユ敹鍒楄〃椤典紶閫掔殑鏁版嵁
const receiveEditData = (data: any) => {
- console.log("receiveEditData 鎺ユ敹鍒扮殑鏁版嵁:", data);
if (data && formRef.value) {
// 纭繚 list 鍜� editId 閮藉瓨鍦�
if (data.list && data.editId) {
formRef.value.setFormData(data.list, data.editId);
- } else {
- console.error("鏁版嵁鏍煎紡閿欒:", data);
}
}
};
diff --git a/src/pages/production/twist/receive/steelCore/form.vue b/src/pages/production/twist/receive/steelCore/form.vue
index 616e48f..4561801 100644
--- a/src/pages/production/twist/receive/steelCore/form.vue
+++ b/src/pages/production/twist/receive/steelCore/form.vue
@@ -1,6 +1,16 @@
<template>
<wd-form ref="form" :model="model" class="relative form_box">
<wd-cell-group :border="true">
+ <wd-picker
+ v-model="diskMaterialValue"
+ :columns="diskMaterialOptions"
+ label="鑺嚎绫诲瀷"
+ label-width="100px"
+ prop="diskMaterial"
+ placeholder="璇烽�夋嫨鑺嚎绫诲瀷"
+ clearable
+ @confirm="handleDiskMaterialChange"
+ />
<wd-input
v-model="model.model"
label="瑙勬牸鍨嬪彿"
@@ -48,6 +58,7 @@
<script lang="ts" setup>
import useFormData from "@/hooks/useFormData";
import TwistApi from "@/api/product/twist";
+import ManageApi from "@/api/product/manage";
import { useToast } from "wot-design-uni";
const props = defineProps({
@@ -59,6 +70,10 @@
type: Object,
default: null,
},
+ wireId: {
+ type: [String, Number],
+ default: undefined,
+ },
});
const emits = defineEmits(["refresh"]);
@@ -67,6 +82,7 @@
const allListData = ref<any[]>([]); // 瀛樺偍瀹屾暣鍒楄〃鏁版嵁
const toast = useToast();
const { form: model } = useFormData({
+ diskMaterial: undefined, // 鑺嚎绫诲瀷
model: undefined, // 瑙勬牸鍨嬪彿
monofilamentNumber: undefined, // 鏍峰搧缂栧彿
amount: undefined, // 鏁伴噺
@@ -75,11 +91,45 @@
type: "閽㈣姱",
});
+// 鑺嚎绫诲瀷瀛楀吀鏁版嵁
+const diskMaterialOptions = ref<Array<{ label: string; value: string }>>([]);
+const diskMaterialValue = ref("");
+
+// 鍔犺浇鑺嚎绫诲瀷瀛楀吀鏁版嵁
+const loadDiskMaterialDict = async () => {
+ try {
+ const res = await ManageApi.dictAPI("core_wire_type");
+ if (res.data && Array.isArray(res.data)) {
+ diskMaterialOptions.value = res.data.map((item: any) => ({
+ label: item.dictLabel || "",
+ value: item.dictValue || "",
+ }));
+ }
+ } catch (error) {
+ // 鍔犺浇瀛楀吀澶辫触锛岄潤榛樺鐞�
+ }
+};
+
+// 澶勭悊鑺嚎绫诲瀷閫夋嫨
+const handleDiskMaterialChange = (val: any) => {
+ model.diskMaterial = val.value;
+};
+
+// 鐩戝惉 model.diskMaterial 鍙樺寲锛屽悓姝ラ�夋嫨鍣ㄦ樉绀�
+watch(
+ () => model.diskMaterial,
+ (newValue) => {
+ diskMaterialValue.value = newValue || "";
+ },
+ { immediate: true }
+);
+
// 鏂板鎻愪氦
const submit = async () => {
+ const currentWireId = props.wireId || paramsId.value;
const { code } = await TwistApi.addStrandedWireDish([
{
- wireId: paramsId.value,
+ wireId: currentWireId,
...model,
},
]);
@@ -107,6 +157,7 @@
// 淇濈暀鍘熸湁鏁版嵁锛岀劧鍚庢洿鏂颁慨鏀圭殑瀛楁
const updatedItem = {
...item, // 鍏堜繚鐣欏師鏈夌殑鎵�鏈夋暟鎹�
+ diskMaterial: model.diskMaterial,
model: model.model,
monofilamentNumber: model.monofilamentNumber,
amount: model.amount,
@@ -133,7 +184,6 @@
const setFormData = (list: any[], currentEditId: number) => {
// 瀹夊叏妫�鏌ワ細纭繚list鏄暟缁�
if (!Array.isArray(list)) {
- console.error("setFormData: list 鍙傛暟涓嶆槸鏁扮粍", list);
return;
}
@@ -144,12 +194,15 @@
// 鎵惧埌褰撳墠缂栬緫椤瑰苟鍥炴樉鍒拌〃鍗�
const currentItem = list.find((item) => item.id === currentEditId);
if (currentItem) {
+ model.diskMaterial = currentItem.diskMaterial;
model.model = currentItem.model;
model.monofilamentNumber = currentItem.monofilamentNumber;
model.amount = currentItem.amount;
model.weight = currentItem.weight;
model.supplier = currentItem.supplier;
model.type = currentItem.type || "閽㈣姱";
+ // 璁剧疆鑺嚎绫诲瀷鐨勫洖鏄惧��
+ diskMaterialValue.value = currentItem.diskMaterial || "";
}
};
@@ -158,12 +211,14 @@
() => props.editData,
(newData) => {
if (newData && props.mode === "edit") {
+ model.diskMaterial = newData.diskMaterial || "";
model.model = newData.model || "";
model.monofilamentNumber = newData.monofilamentNumber || "";
model.amount = newData.amount || "";
model.weight = newData.weight || "";
model.supplier = newData.supplier || "";
model.type = newData.type || "閽㈣姱";
+ diskMaterialValue.value = newData.diskMaterial || "";
}
},
{ immediate: true, deep: true }
@@ -171,16 +226,36 @@
// 閲嶇疆琛ㄥ崟鏁版嵁
const resetFormData = () => {
+ model.diskMaterial = undefined;
model.model = undefined;
model.monofilamentNumber = undefined;
model.amount = undefined;
model.weight = undefined;
model.supplier = undefined;
model.type = "閽㈣姱";
+ diskMaterialValue.value = "";
+};
+
+// 濉厖琛ㄥ崟鏁版嵁锛堢敤浜庢壂鐮佸悗鍥炴樉锛�
+const fillFormData = (data: any) => {
+ if (data) {
+ model.diskMaterial = data.diskMaterial || "";
+ model.model = data.model || "";
+ model.monofilamentNumber = data.monofilamentNumber || "";
+ model.amount = data.oneLength || data.amount || "";
+ model.weight = data.weight || "";
+ model.supplier = data.supplier || "";
+ model.type = data.type || "閽㈣姱";
+ diskMaterialValue.value = data.diskMaterial || "";
+ }
};
onLoad((options: any) => {
paramsId.value = options.id;
+});
+
+onMounted(async () => {
+ await loadDiskMaterialDict();
});
defineExpose({
@@ -188,6 +263,7 @@
submitEdit,
setFormData,
resetFormData,
+ fillFormData,
});
</script>
diff --git a/src/pages/production/twist/receive/steelCore/index.vue b/src/pages/production/twist/receive/steelCore/index.vue
index 0acc106..676f782 100644
--- a/src/pages/production/twist/receive/steelCore/index.vue
+++ b/src/pages/production/twist/receive/steelCore/index.vue
@@ -8,7 +8,12 @@
@query="getList"
>
<template #top>
- <CardTitle title="鑺嚎棰嗙敤" :hideAction="true" :full="false" @action="addReport" />
+ <CardTitle title="鑺嚎棰嗙敤" :hideAction="false" :full="false">
+ <template #action>
+ <wd-button type="icon" icon="scan" color="#0D867F" @click="openScan"></wd-button>
+ <wd-button type="icon" icon="add-circle" color="#0D867F" @click="addReport"></wd-button>
+ </template>
+ </CardTitle>
</template>
<wd-card v-for="(item, index) in cardList" :key="index" type="rectangle" custom-class="round">
<template #title>
@@ -28,7 +33,7 @@
<wd-button type="text" @click="cancelAdd">鍙栨秷</wd-button>
<wd-button type="text" @click="submitAdd">纭畾</wd-button>
</view>
- <SteelCore ref="addFormRef" mode="add" @refresh="reloadList" />
+ <SteelCore ref="addFormRef" mode="add" :wireId="paramsId" @refresh="reloadList" />
</wd-popup>
<wd-popup v-model="editDialog.visible" position="bottom" custom-class="yl-popup">
<view class="action px-3">
@@ -38,10 +43,12 @@
<SteelCore
ref="editFormRef"
mode="edit"
+ :wireId="paramsId"
:editData="editDialog.currentItem"
@refresh="reloadList"
/>
</wd-popup>
+ <Scan ref="scanRef" emitName="scanSteelCore" />
<wd-toast />
</view>
</template>
@@ -51,15 +58,19 @@
import ProductionCard from "../../../components/ProductionCard.vue";
import { useToast } from "wot-design-uni";
import SteelCore from "./form.vue";
-import { onLoad } from "@dcloudio/uni-app";
+import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app";
import ManageApi from "@/api/product/manage";
+import TwistApi from "@/api/product/twist";
import zPaging from "@/components/z-paging/z-paging.vue";
+import Scan from "@/components/scan/index.vue";
const paramsId = ref();
const pagingRef = ref();
const addFormRef = ref();
const editFormRef = ref();
+const scanRef = ref();
const toast = useToast();
+const isPageVisible = ref(false); // 鏍囪椤甸潰鏄惁鍙
const addDialog = reactive({
visible: false,
});
@@ -147,9 +158,61 @@
pagingRef.value.refresh();
};
+// 鎵爜鐩稿叧鏂规硶
+const openScan = () => {
+ scanRef.value.triggerScan();
+};
+
+const getScanCode = async (code: any) => {
+ // 妫�鏌ラ〉闈㈡槸鍚﹀彲瑙侊紝濡傛灉涓嶅彲瑙佸垯涓嶅鐞嗘壂鐮佹暟鎹�
+ if (!isPageVisible.value) {
+ return;
+ }
+
+ try {
+ const parseData = JSON.parse(code.code);
+
+ // 鎵撳紑鏂板寮规骞跺~鍏呮壂鐮佽幏鍙栫殑淇℃伅
+ addDialog.visible = true;
+
+ // 绛夊緟寮规鎵撳紑鍚庡~鍏呰〃鍗曟暟鎹�
+ // 浣跨敤鍙岄噸绛夊緟锛歯extTick + setTimeout 纭繚缁勪欢宸插畬鍏ㄦ寕杞�
+ nextTick(() => {
+ setTimeout(() => {
+ if (addFormRef.value) {
+ addFormRef.value.fillFormData(parseData);
+ toast.success("鎵爜鎴愬姛锛岃纭淇℃伅");
+ } else {
+ toast.error("琛ㄥ崟鍔犺浇澶辫触锛岃閲嶈瘯");
+ }
+ }, 200); // 寤惰繜200ms纭繚寮规鍜岀粍浠跺凡瀹屽叏娓叉煋
+ });
+ } catch (error) {
+ toast.error("浜岀淮鐮佸紓甯革紝璇锋洿鎹簩缁寸爜锛�");
+ }
+};
+
onLoad((options: any) => {
+ // 寮�鍚箍鎾洃鍚簨浠�
+ uni.$on("scanSteelCore", getScanCode);
paramsId.value = options.id;
});
+
+onShow(() => {
+ // 椤甸潰鏄剧ず鏃舵爣璁颁负鍙
+ isPageVisible.value = true;
+});
+
+onHide(() => {
+ // 椤甸潰闅愯棌鏃舵爣璁颁负涓嶅彲瑙�
+ isPageVisible.value = false;
+});
+
+onUnload(() => {
+ // 鍙栨秷骞挎挱鐩戝惉浜嬩欢
+ uni.$off("scanSteelCore", getScanCode);
+ isPageVisible.value = false;
+});
</script>
<style lang="scss" scoped>
diff --git a/src/pages/production/wire/attachment/index.vue b/src/pages/production/wire/attachment/index.vue
index ef52bfa..3c81d5c 100644
--- a/src/pages/production/wire/attachment/index.vue
+++ b/src/pages/production/wire/attachment/index.vue
@@ -523,3 +523,6 @@
+
+
+
--
Gitblit v1.9.3