From b7b7b53debb680d528864dc6be30277f766ae2e3 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 23 一月 2026 14:34:57 +0800
Subject: [PATCH] fix: 产品结构详情限制最外层只能选一个当前产品不能多个
---
src/views/productionManagement/productStructure/Detail/index.vue | 147 ++++++++++++------------------------------------
1 files changed, 37 insertions(+), 110 deletions(-)
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 7e9e176..cdb32ae 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -57,7 +57,7 @@
</el-form-item>
</template>
</el-table-column>
- <el-table-column prop="processId"
+ <el-table-column prop="processName"
label="娑堣�楀伐搴�">
<template #default="{ row, $index }">
<el-form-item v-if="dataValue.isEdit"
@@ -178,6 +178,7 @@
const ProductSelectDialog = defineAsyncComponent(
() => import("@/views/basicData/product/ProductSelectDialog.vue")
);
+ const emit = defineEmits(["update:router"]);
const form = ref();
const route = useRoute();
@@ -233,15 +234,18 @@
if (isOrderPage.value) {
// 璁㈠崟鎯呭喌锛氫娇鐢ㄨ鍗曠殑浜у搧缁撴瀯鎺ュ彛
const { data } = await listProcessBom({ orderId: routeOrderId.value });
- dataValue.dataList = data || [];
+ dataValue.dataList = (data as any) || [];
} else {
// 闈炶鍗曟儏鍐碉細浣跨敤鍘熸潵鐨勬帴鍙�
const { data } = await queryList(routeId.value);
- dataValue.dataList = data || [];
+ dataValue.dataList = (data as any) || [];
// 涓烘墍鏈夐」鍙婂叾瀛愰」璁剧疆name灞炴��
const setNameRecursively = items => {
items.forEach(item => {
item.tempId = item.id;
+ item.processName =
+ dataValue.processOptions.find(option => option.id === item.processId)
+ ?.name || "";
if (item.children && item.children.length > 0) {
setNameRecursively(item.children);
}
@@ -249,109 +253,12 @@
};
setNameRecursively(dataValue.dataList);
console.log(dataValue.dataList, "dataValue.dataList");
-
- // dataValue.dataList = [
- // {
- // id: 30,
- // productModelId: 220,
- // processId: 42,
- // unitQuantity: 0.0,
- // demandedQuantity: 0.0,
- // unit: "30",
- // tenantId: 100,
- // bomId: 5,
- // processName: "娴嬭瘯1",
- // productName: "1111",
- // productId: 264,
- // model: "1112233",
- // productStructureList: null,
- // children: [
- // {
- // id: 300,
- // productModelId: 220,
- // processId: 42,
- // unitQuantity: 0.0,
- // demandedQuantity: 0.0,
- // unit: "300",
- // tenantId: 100,
- // bomId: 5,
- // processName: "娴嬭瘯1",
- // productName: "1111",
- // productId: 264,
- // model: "1112233",
- // productStructureList: null,
- // children: [
- // {
- // id: 3000,
- // productModelId: 220,
- // processId: 42,
- // unitQuantity: 0.0,
- // demandedQuantity: 0.0,
- // unit: "3000",
- // tenantId: 100,
- // bomId: 5,
- // processName: "娴嬭瘯1",
- // productName: "1111",
- // productId: 264,
- // model: "1112233",
- // productStructureList: null,
- // },
- // {
- // id: 3200,
- // productModelId: 221,
- // processId: 43,
- // unitQuantity: 0.0,
- // demandedQuantity: 0.0,
- // unit: "3200",
- // tenantId: 100,
- // bomId: 5,
- // processName: "娴嬭瘯2",
- // productName: "xxx",
- // productId: 266,
- // model: "xxx",
- // productStructureList: null,
- // },
- // ],
- // },
- // {
- // id: 320,
- // productModelId: 221,
- // processId: 43,
- // unitQuantity: 0.0,
- // demandedQuantity: 0.0,
- // unit: "320",
- // tenantId: 100,
- // bomId: 5,
- // processName: "娴嬭瘯2",
- // productName: "xxx",
- // productId: 266,
- // model: "xxx",
- // productStructureList: null,
- // },
- // ],
- // },
- // {
- // id: 32,
- // productModelId: 221,
- // processId: 43,
- // unitQuantity: 0.0,
- // demandedQuantity: 0.0,
- // unit: "32",
- // tenantId: 100,
- // bomId: 5,
- // processName: "娴嬭瘯2",
- // productName: "xxx",
- // productId: 266,
- // model: "xxx",
- // productStructureList: null,
- // },
- // ];
}
};
const fetchProcessOptions = async () => {
- const { data } = await list(routeId.value);
- dataValue.processOptions = data;
+ const { data } = await list();
+ dataValue.processOptions = data as any;
};
const handleProduct = row => {
@@ -359,6 +266,16 @@
ElMessage.error("鍙兘閫夋嫨涓�涓骇鍝�");
}
const productData = row[0];
+
+ // 鏍¢獙锛氫笉鑳藉湪鏈�澶栧眰閫夋嫨璺熷綋鍓嶄骇鍝佷竴鏍风殑浜у搧
+ const isTopLevel = dataValue.dataList.some(item => item.tempId === dataValue.currentRowName);
+ if (isTopLevel) {
+ if (productData.productName === tableData[0].productName &&
+ productData.model === tableData[0].model) {
+ ElMessage.warning("涓嶈兘鍦ㄦ渶澶栧眰閫夋嫨璺熷綋鍓嶄骇鍝佷竴鏍风殑浜у搧");
+ return;
+ }
+ }
// dataValue.dataList[dataValue.currentRowIndex].productName =
// row[0].productName;
// dataValue.dataList[dataValue.currentRowIndex].model = row[0].model;
@@ -476,9 +393,11 @@
model: undefined,
productModelId: undefined,
processId: "",
+ processName: "",
unitQuantity: 0,
demandedQuantity: 0,
unit: "",
+ children: [],
tempId: new Date().getTime(),
});
};
@@ -516,6 +435,9 @@
const addItem2 = tempId => {
dataValue.dataList.map(item => {
if (item.tempId === tempId) {
+ if (!item.children) {
+ item.children = [];
+ }
item.children.push({
parentId: item.id || "",
parentTempId: item.tempId || "",
@@ -524,6 +446,7 @@
model: undefined,
productModelId: undefined,
processId: "",
+ processName: "",
unitQuantity: 0,
demandedQuantity: 0,
unit: "",
@@ -539,7 +462,9 @@
const addchildItem = (item, tempId) => {
if (item.tempId === tempId) {
console.log(item, "item");
-
+ if (!item.children) {
+ item.children = [];
+ }
item.children.push({
parentId: item.id || "",
parentTempId: item.tempId || "",
@@ -580,21 +505,23 @@
const cancelEdit = () => {
dataValue.isEdit = false;
- dataValue.dataList = dataValue.dataList.filter(item => item.id !== undefined);
+ // dataValue.dataList = dataValue.dataList.filter(item => item.id !== undefined);
+ fetchData();
};
- onMounted(() => {
+ onMounted(async () => {
// 浠庤矾鐢卞弬鏁板洖鏄炬暟鎹�
- tableData[0].productName = routeProductName.value;
- tableData[0].model = routeProductModelName.value;
- tableData[0].bomNo = routeBomNo.value;
+ tableData[0].productName = routeProductName.value as string;
+ tableData[0].model = routeProductModelName.value as string;
+ tableData[0].bomNo = routeBomNo.value as string;
// 璁㈠崟鎯呭喌涓嬬鐢ㄧ紪杈�
if (isOrderPage.value) {
dataValue.isEdit = false;
}
- fetchData();
- fetchProcessOptions();
+ // 鍏堝姞杞藉伐搴忛�夐」锛屽啀鍔犺浇鏁版嵁锛岀‘淇漞l-select鑳藉姝g‘鍥炴樉
+ await fetchProcessOptions();
+ await fetchData();
});
</script>
\ No newline at end of file
--
Gitblit v1.9.3