From 7cf708376b46741dbee847e59c64a8e11ad088c5 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 15 十月 2025 13:27:58 +0800
Subject: [PATCH] fix: 绞线的钢芯领用取消关联
---
src/api/product/twist.ts | 9 +
src/pages/production/components/ProductionCard.vue | 4
src/pages/production/twist/receive/monofil.vue | 202 ++++++++++++++++++++++++++++
src/pages/production/twist/receive/steelCore/edit.vue | 42 +++++
src/pages/production/twist/components/MonofilCard.vue | 4
src/pages/production/twist/receive/steelCore/index.vue | 34 ++++
src/pages/production/twist/receive/steelCore/form.vue | 89 ++++++++++++
7 files changed, 367 insertions(+), 17 deletions(-)
diff --git a/src/api/product/twist.ts b/src/api/product/twist.ts
index 5bca559..d39d753 100644
--- a/src/api/product/twist.ts
+++ b/src/api/product/twist.ts
@@ -53,6 +53,15 @@
data: params,
});
},
+
+ // 鏍规嵁鍗曚笣缂栧彿鏌ヨ
+ selectByMonofilamentNumber(params: { monofilamentNumber: string }) {
+ return request<BaseResult<any>>({
+ url: "/strandedWire/selectByMonofilamentNumber",
+ method: "GET",
+ data: params,
+ });
+ },
};
export default TwistApi;
diff --git a/src/pages/production/components/ProductionCard.vue b/src/pages/production/components/ProductionCard.vue
index d691c8c..f5a9a84 100644
--- a/src/pages/production/components/ProductionCard.vue
+++ b/src/pages/production/components/ProductionCard.vue
@@ -1,8 +1,8 @@
<template>
<wd-row>
<wd-col v-for="(item, index) in data" :key="index" :span="item.span ?? 12" class="my-1">
- <view class="flex justify-between w-full h-[20px]">
- <view class="text-[#646874] pl-1">{{ item.label }}</view>
+ <view class="flex w-full h-[20px]">
+ <view class="text-[#646874] pl-1 mr-3">{{ item.label }}</view>
<view class="font-medium pr-1" :style="{ color: item.color ?? color }">
{{ value[item.prop] }} {{ value[item.unitProp] }} {{ item.unit }}
</view>
diff --git a/src/pages/production/twist/components/MonofilCard.vue b/src/pages/production/twist/components/MonofilCard.vue
index ba6c943..68268d5 100644
--- a/src/pages/production/twist/components/MonofilCard.vue
+++ b/src/pages/production/twist/components/MonofilCard.vue
@@ -2,8 +2,8 @@
<wd-card>
<wd-cell-group :border="true">
<wd-cell title="鍗曚笣缂栧彿" :value="data.monofilamentNumber" />
- <wd-cell title="鐞嗚闀垮害" :value="data.amount + ' (M)'" />
- <wd-cell title="鐢熶骇闀垮害" :value="data.actuallyLength + ' (M)'" />
+ <wd-cell title="鐞嗚闀垮害" :value="data.amount + ' (m)'" />
+ <wd-cell title="鐢熶骇闀垮害" :value="data.actuallyLength + ' (m)'" />
<wd-cell title="閲嶉噺" :value="data.actuallyWeight + ' (kg)'" />
</wd-cell-group>
</wd-card>
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index 87cc830..7f66e3d 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -11,16 +11,22 @@
<CardTitle title="鍗曚笣棰嗙敤" :hideAction="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="openManualInput"
+ ></wd-button>
</template>
</CardTitle>
</template>
<!-- <MonofilCard v-for="(item, index) in cardList" :key="index" :data="item" /> -->
- <wd-tabs v-model="tab" slidable="always">
+ <wd-tabs v-model="tab" slidable="always" class="tabs-container">
<block v-for="item in nodeList" :key="item">
<wd-tab :title="item.twistedLayer" :name="item.twistedLayer">
- <view class="content">
+ <scroll-view class="content" scroll-y>
<MonofilCard v-for="(m, i) in item.strandedWireDish" :key="i" :data="m" />
- </view>
+ </scroll-view>
</wd-tab>
</block>
</wd-tabs>
@@ -38,6 +44,32 @@
:nodeList="nodeList"
@confirm="handleConfirmSave"
/>
+
+ <!-- 鎵嬪姩杈撳叆璐ㄩ噺杩芥函鍙峰脊妗� -->
+ <wd-popup v-model="showManualInput" position="center" :close-on-click-modal="false">
+ <view class="manual-input-modal">
+ <view class="modal-header">
+ <text class="title">鎵嬪姩棰嗙敤鍗曚笣</text>
+ <wd-icon name="close" @click="closeManualInput" />
+ </view>
+ <view class="modal-content">
+ <view class="input-label">鍗曚笣缂栧彿</view>
+ <wd-input
+ v-model="manualOutPutId"
+ placeholder="璇疯緭鍏ュ崟涓濈紪鍙�"
+ clearable
+ @clear="manualOutPutId = ''"
+ />
+ </view>
+ <view class="modal-footer">
+ <wd-button @click="closeManualInput" type="default">鍙栨秷</wd-button>
+ <wd-button type="primary" @click="handleManualConfirm" custom-class="confirm-btn">
+ 纭畾
+ </wd-button>
+ </view>
+ </view>
+ </wd-popup>
+
<wd-toast />
</view>
</template>
@@ -61,6 +93,8 @@
const toast = useToast();
const tab = ref("");
const showStatisticsModal = ref(false);
+const showManualInput = ref(false);
+const manualOutPutId = ref("");
// 鐩戝惉鏍囩鍒囨崲
watch(tab, () => {
@@ -122,6 +156,76 @@
const openScan = () => {
scanRef.value.triggerScan();
+};
+
+// 鎵撳紑鎵嬪姩杈撳叆寮规
+const openManualInput = () => {
+ // 妫�鏌ユ槸鍚﹀凡閫夋嫨鏍囩
+ if (!tab.value) {
+ toast.error("璇峰厛閫夋嫨涓�涓眰");
+ return;
+ }
+ showManualInput.value = true;
+};
+
+// 鍏抽棴鎵嬪姩杈撳叆寮规
+const closeManualInput = () => {
+ showManualInput.value = false;
+ manualOutPutId.value = "";
+};
+
+// 鎵嬪姩杈撳叆纭
+const handleManualConfirm = async () => {
+ if (!manualOutPutId.value.trim()) {
+ toast.error("璇疯緭鍏ヨ川閲忚拷婧彿");
+ return;
+ }
+
+ try {
+ const { data } = await TwistApi.selectByMonofilamentNumber({
+ monofilamentNumber: manualOutPutId.value.trim(),
+ });
+
+ // 鎵惧埌褰撳墠閫変腑鐨勫眰
+ const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
+ if (!currentLayer) {
+ toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
+ return;
+ }
+
+ // 妫�鏌ュ綋鍓嶅眰鏄惁宸插瓨鍦ㄨ鍗曚笣
+ const exists = currentLayer.strandedWireDish?.some(
+ (item: any) => item.monofilamentNumber === data.monofilamentNumber
+ );
+
+ if (!exists) {
+ const { id, outPutId, wireId, oneLength, ...rest } = data;
+ const newItem = {
+ wireId: paramsId.value,
+ outputId: id,
+ amount: oneLength,
+ ongLength: oneLength,
+ ...rest,
+ };
+
+ // 娣诲姞鍒板綋鍓嶅眰鐨� strandedWireDish 涓�
+ if (!currentLayer.strandedWireDish) {
+ currentLayer.strandedWireDish = [];
+ }
+ currentLayer.strandedWireDish.push(newItem);
+
+ // 鍒锋柊褰撳墠灞傜殑鏁版嵁鏄剧ず
+ getList();
+
+ // 鍏抽棴寮规骞舵竻绌鸿緭鍏�
+ closeManualInput();
+ toast.success("娣诲姞鎴愬姛");
+ } else {
+ toast.error("璇ュ崟涓濆凡棰嗙敤锛岃鍕块噸澶嶆坊鍔�");
+ }
+ } catch (error: any) {
+ toast.error(error.msg || "鏌ヨ澶辫触");
+ }
};
const getList = async () => {
@@ -245,20 +349,112 @@
.list_box {
height: calc(100vh - 100px);
background: #f3f9f8;
+ display: flex;
+ flex-direction: column;
}
+
+// 鎵嬪姩杈撳叆寮规鏍峰紡
+.manual-input-modal {
+ width: 320px;
+ background: #fff;
+ border-radius: 12px;
+ overflow: hidden;
+
+ .modal-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 16px 20px;
+ border-bottom: 1px solid #f0f0f0;
+
+ .title {
+ font-size: 18px;
+ font-weight: 600;
+ color: #333;
+ }
+ }
+
+ .modal-content {
+ padding: 20px;
+
+ .input-label {
+ font-size: 14px;
+ color: #333;
+ margin-bottom: 8px;
+ font-weight: 500;
+ }
+ }
+
+ .modal-footer {
+ display: flex;
+ gap: 12px;
+ padding: 16px 20px;
+ border-top: 1px solid #f0f0f0;
+ }
+}
+
+:deep(.manual-input-modal .confirm-btn) {
+ background-color: #0d867f !important;
+ border-color: #0d867f !important;
+
+ .wd-button__content {
+ color: #fff !important;
+ }
+}
+
+// tab瀹瑰櫒鏍峰紡
+.tabs-container {
+ height: calc(100vh - 200px);
+ display: flex;
+ flex-direction: column;
+}
+
+.content {
+ height: calc(100vh - 280px);
+ width: 100%;
+}
+
:deep(.wd-button__content) {
color: #0d867f;
}
:deep(.zp-paging-container) {
background: transparent !important;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
}
:deep(.zp-paging-container-content) {
background: transparent !important;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
}
:deep(.wd-tabs) {
background: transparent !important;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
}
:deep(.wd-tabs__nav) {
margin-bottom: 10px;
+ flex-shrink: 0;
+ position: sticky;
+ top: 0;
+ z-index: 10;
+ background: #f3f9f8;
+}
+:deep(.wd-tabs__content) {
+ flex: 1;
+ overflow: visible;
+}
+:deep(.wd-tab__pane) {
+ height: 100%;
+}
+:deep(.zp-paging-container-top) {
+ flex-shrink: 0;
+}
+:deep(.zp-paging-container-bottom) {
+ flex-shrink: 0;
}
</style>
diff --git a/src/pages/production/twist/receive/steelCore/edit.vue b/src/pages/production/twist/receive/steelCore/edit.vue
index 269154d..fb7ae58 100644
--- a/src/pages/production/twist/receive/steelCore/edit.vue
+++ b/src/pages/production/twist/receive/steelCore/edit.vue
@@ -1,7 +1,7 @@
<template>
<view>
- <CardTitle title="缁炵嚎鐩樺叿棰嗙敤" :hideAction="false" />
- <SteelCoreForm class="mx-4" />
+ <CardTitle title="缁炵嚎閽㈣姱棰嗙敤" :hideAction="false" />
+ <SteelCoreForm ref="formRef" class="mx-4" />
<view class="footer">
<wd-button
class="submit_btn"
@@ -15,12 +15,48 @@
</wd-button>
</view>
</view>
+ <wd-toast />
</template>
<script lang="ts" setup>
import CardTitle from "@/components/card-title/index.vue";
import SteelCoreForm from "./form.vue";
+import { useToast } from "wot-design-uni";
+import { onLoad, onUnload } from "@dcloudio/uni-app";
-const handleSubmit = () => {};
+const formRef = ref();
+const toast = useToast();
+
+const handleSubmit = async () => {
+ const success = await formRef.value.submitEdit();
+ if (success) {
+ setTimeout(() => {
+ uni.navigateBack();
+ }, 500);
+ }
+};
+
+// 鎺ユ敹鍒楄〃椤典紶閫掔殑鏁版嵁
+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);
+ }
+ }
+};
+
+onLoad((options: any) => {
+ // 鐩戝惉鏁版嵁浼犻�掍簨浠�
+ uni.$on("steelCoreEditData", receiveEditData);
+});
+
+onUnload(() => {
+ // 椤甸潰鍗歌浇鏃剁Щ闄ょ洃鍚�
+ uni.$off("steelCoreEditData", receiveEditData);
+});
</script>
<style lang="scss" scoped>
.footer {
diff --git a/src/pages/production/twist/receive/steelCore/form.vue b/src/pages/production/twist/receive/steelCore/form.vue
index d0e4c2c..c4185ec 100644
--- a/src/pages/production/twist/receive/steelCore/form.vue
+++ b/src/pages/production/twist/receive/steelCore/form.vue
@@ -26,10 +26,18 @@
placeholder="璇疯緭鍏ラ暱搴�"
/>
<wd-input
- v-model="model.manufacturers"
+ v-model="model.weight"
+ label="閲嶉噺"
+ label-width="100px"
+ prop="weight"
+ clearable
+ placeholder="璇疯緭鍏ラ噸閲�"
+ />
+ <wd-input
+ v-model="model.supplier"
label="鍘傚"
label-width="100px"
- prop="manufacturers"
+ prop="supplier"
clearable
placeholder="璇疯緭鍏ュ巶瀹�"
/>
@@ -44,15 +52,19 @@
const emits = defineEmits(["refresh"]);
const paramsId = ref();
+const editId = ref(); // 缂栬緫鏃剁殑ID
+const allListData = ref<any[]>([]); // 瀛樺偍瀹屾暣鍒楄〃鏁版嵁
const toast = useToast();
const { form: model } = useFormData({
model: undefined, // 瑙勬牸鍨嬪彿
monofilamentNumber: undefined, // 鏍峰搧缂栧彿
amount: undefined, // 鏁伴噺
- manufacturers: undefined, // 鍘傚
+ weight: undefined, // 閲嶉噺
+ supplier: undefined, // 鍘傚
type: "閽㈣姱",
});
+// 鏂板鎻愪氦
const submit = async () => {
const { code } = await TwistApi.addStrandedWireDish([
{
@@ -65,6 +77,73 @@
emits("refresh");
return true;
}
+ return false;
+};
+
+// 缂栬緫鎻愪氦锛堜篃璧版柊澧炴帴鍙o紝鎻愪氦鏁翠釜鍒楄〃锛�
+const submitEdit = async () => {
+ if (!editId.value) {
+ toast.error("缂哄皯璁板綍ID");
+ return false;
+ }
+
+ console.log("submitEdit - 缂栬緫鍓嶇殑鍒楄〃:", allListData.value);
+ console.log("submitEdit - 褰撳墠琛ㄥ崟鏁版嵁:", model);
+ console.log("submitEdit - 缂栬緫鐨処D:", editId.value);
+
+ // 鏇存柊鍒楄〃涓搴旂殑鏁版嵁椤�
+ const updatedList = allListData.value.map((item) => {
+ if (item.id === editId.value) {
+ // 淇濈暀鍘熸湁鏁版嵁锛岀劧鍚庢洿鏂颁慨鏀圭殑瀛楁
+ const updatedItem = {
+ ...item, // 鍏堜繚鐣欏師鏈夌殑鎵�鏈夋暟鎹�
+ model: model.model,
+ monofilamentNumber: model.monofilamentNumber,
+ amount: model.amount,
+ weight: model.weight,
+ supplier: model.supplier,
+ type: model.type,
+ };
+ console.log("submitEdit - 鏇存柊鍚庣殑椤�:", updatedItem);
+ return updatedItem;
+ }
+ return item;
+ });
+
+ console.log("submitEdit - 鎻愪氦鐨勫畬鏁村垪琛�:", updatedList);
+
+ // 鎻愪氦鏁翠釜鍒楄〃
+ const { code } = await TwistApi.addStrandedWireDish(updatedList);
+
+ if (code == 200) {
+ toast.success("鏇存柊鎴愬姛");
+ return true;
+ }
+ return false;
+};
+
+// 璁剧疆琛ㄥ崟鏁版嵁锛堢敤浜庣紪杈戞椂鍥炴樉锛�
+const setFormData = (list: any[], currentEditId: number) => {
+ // 瀹夊叏妫�鏌ワ細纭繚list鏄暟缁�
+ if (!Array.isArray(list)) {
+ console.error("setFormData: list 鍙傛暟涓嶆槸鏁扮粍", list);
+ return;
+ }
+
+ // 瀛樺偍瀹屾暣鍒楄〃鏁版嵁
+ allListData.value = list;
+ editId.value = currentEditId;
+
+ // 鎵惧埌褰撳墠缂栬緫椤瑰苟鍥炴樉鍒拌〃鍗�
+ const currentItem = list.find((item) => item.id === currentEditId);
+ if (currentItem) {
+ model.model = currentItem.model;
+ model.monofilamentNumber = currentItem.monofilamentNumber;
+ model.amount = currentItem.amount;
+ model.weight = currentItem.weight;
+ model.supplier = currentItem.supplier;
+ model.type = currentItem.type || "閽㈣姱";
+ }
};
onLoad((options: any) => {
@@ -73,12 +152,12 @@
defineExpose({
submit,
+ submitEdit,
+ setFormData,
});
</script>
<style lang="scss" scoped>
-.form_box {
-}
.submit_btn {
position: absolute;
bottom: 0;
diff --git a/src/pages/production/twist/receive/steelCore/index.vue b/src/pages/production/twist/receive/steelCore/index.vue
index 21b8d6f..a0f40cd 100644
--- a/src/pages/production/twist/receive/steelCore/index.vue
+++ b/src/pages/production/twist/receive/steelCore/index.vue
@@ -39,7 +39,7 @@
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, onShow } from "@dcloudio/uni-app";
import ManageApi from "@/api/product/manage";
import zPaging from "@/components/z-paging/z-paging.vue";
@@ -51,6 +51,7 @@
visible: false,
});
const cardList = ref<any[]>([]);
+const needRefresh = ref(false); // 鏍囪鏄惁闇�瑕佸埛鏂�
const cardAttr = ref<any[]>([
{
@@ -63,6 +64,11 @@
unitProp: "unit",
},
{
+ label: "閲嶉噺",
+ prop: "weight",
+ unitProp: "weightUnit",
+ },
+ {
label: "鍘傚",
prop: "supplier",
span: 16,
@@ -70,8 +76,21 @@
]);
const toEdit = (id: number) => {
+ needRefresh.value = true; // 鏍囪闇�瑕佸埛鏂�
+
+ // 纭繚 cardList 鏄暟缁�
+ const listData = Array.isArray(cardList.value) ? cardList.value : [];
+ console.log("toEdit - 浼犻�掔殑鍒楄〃鏁版嵁:", listData, "缂栬緫ID:", id);
+
uni.navigateTo({
url: `/pages/production/twist/receive/steelCore/edit?id=${id}`,
+ success: () => {
+ // 椤甸潰璺宠浆鎴愬姛鍚庡彂閫佷簨浠朵紶閫掑畬鏁村垪琛ㄦ暟鎹拰褰撳墠缂栬緫ID
+ uni.$emit("steelCoreEditData", {
+ list: listData,
+ editId: id,
+ });
+ },
});
};
@@ -80,7 +99,10 @@
};
const submit = async () => {
- dialog.visible = !(await steelCoreRef.value.submit());
+ const success = await steelCoreRef.value.submit();
+ if (success) {
+ dialog.visible = false;
+ }
};
const cancel = () => {
@@ -105,6 +127,14 @@
onLoad((options: any) => {
paramsId.value = options.id;
});
+
+onShow(() => {
+ // 浠庣紪杈戦〉杩斿洖鏃跺埛鏂板垪琛�
+ if (needRefresh.value) {
+ reloadList();
+ needRefresh.value = false;
+ }
+});
</script>
<style lang="scss" scoped>
--
Gitblit v1.9.3