From b9c0cee25748ea2d5621a8ca56ceb855a9ce3700 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 17 四月 2026 16:08:01 +0800
Subject: [PATCH] fix: 修改生产模块
---
src/views/productionManagement/productStructure/Detail/index.vue | 77 ++++++++++++++++++++++++++------------
1 files changed, 52 insertions(+), 25 deletions(-)
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 3a76e48..9f8ad51 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -1,6 +1,6 @@
<template>
- <div class="app-container">
- <PageHeader content="浜у搧缁撴瀯璇︽儏">
+ <div :class="embedded ? 'embedded-container' : 'app-container'">
+ <PageHeader v-if="!embedded" content="浜у搧缁撴瀯璇︽儏">
<template #right-button>
<el-button v-if="!dataValue.isEdit && !isOrderPage"
type="primary"
@@ -115,7 +115,7 @@
<el-input v-model="row.unit"
placeholder="璇疯緭鍏ュ崟浣�"
clearable
- :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
+ :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
</el-form-item>
</template>
</el-table-column>
@@ -174,6 +174,18 @@
const ProductSelectDialog = defineAsyncComponent(
() => import("@/views/basicData/product/ProductSelectDialog.vue")
);
+ const props = defineProps({
+ embedded: {
+ type: Boolean,
+ default: false,
+ },
+ // 鏄惧紡鎸囧畾BOM涓婚敭锛堢敤浜庡祵鍏ュ埌鈥滃伐鑹鸿矾绾块」鐩�濈瓑椤甸潰鏃讹紝璺敱 query.id 涓嶆槸 bomId 鐨勬儏鍐碉級
+ bomId: {
+ type: [String, Number],
+ default: undefined,
+ },
+ });
+ const embedded = computed(() => props.embedded);
const emit = defineEmits(["update:router"]);
const form = ref();
@@ -181,7 +193,8 @@
const router = useRouter();
const routeId = computed({
get() {
- return route.query.id;
+ // 浼樺厛浣跨敤澶栭儴浼犲叆鐨� bomId锛屽叾娆′娇鐢ㄨ矾鐢辩殑 bomId锛屾渶鍚庡洖閫�鍒拌矾鐢辩殑 id锛堝吋瀹瑰師椤甸潰锛�
+ return props.bomId ?? route.query.bomId ?? route.query.id;
},
set(val) {
@@ -227,26 +240,28 @@
};
const fetchData = async () => {
+ const setNameRecursively = (items: any[]) => {
+ items.forEach((item: any) => {
+ item.tempId = item.tempId || item.id || new Date().getTime() + Math.random();
+ item.processName =
+ dataValue.processOptions.find(option => option.id === item.processId)?.name || item.processName || "";
+ if (item.children && item.children.length > 0) {
+ setNameRecursively(item.children);
+ }
+ });
+ };
+
if (isOrderPage.value) {
// 璁㈠崟鎯呭喌锛氫娇鐢ㄨ鍗曠殑浜у搧缁撴瀯鎺ュ彛
const { data } = await listProcessBom({ orderId: routeOrderId.value });
- dataValue.dataList = (data as any) || [];
+ const list = Array.isArray(data) ? data : (data as any)?.records || [];
+ dataValue.dataList = list;
+ setNameRecursively(dataValue.dataList);
} else {
// 闈炶鍗曟儏鍐碉細浣跨敤鍘熸潵鐨勬帴鍙�
const { data } = await queryList(routeId.value);
dataValue.dataList = (data as any) || [];
// 涓烘墍鏈夐」鍙婂叾瀛愰」璁剧疆name灞炴��
- const setNameRecursively = (items: any[]) => {
- items.forEach((item: any) => {
- 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);
- }
- });
- };
setNameRecursively(dataValue.dataList);
console.log(dataValue.dataList, "dataValue.dataList");
}
@@ -264,15 +279,20 @@
const productData = row[0];
// 鏈�澶栧眰缁勪欢涓紝涓庡綋鍓嶄骇鍝佺浉鍚岀殑浜у搧鍙兘鏈変竴涓�
- const isTopLevel = dataValue.dataList.some(item => (item as any).tempId === dataValue.currentRowName);
+ const isTopLevel = dataValue.dataList.some(
+ item => (item as any).tempId === dataValue.currentRowName
+ );
if (isTopLevel) {
- if (productData.productName === tableData[0].productName &&
- productData.model === tableData[0].model) {
+ if (
+ productData.productName === tableData[0].productName &&
+ productData.model === tableData[0].model
+ ) {
// 鏌ユ壘鏄惁宸茬粡鏈夊叾浠栭《灞傝宸茬粡鏄繖涓骇鍝�
- const hasOther = dataValue.dataList.some(item =>
- (item as any).tempId !== dataValue.currentRowName &&
- (item as any).productName === tableData[0].productName &&
- (item as any).model === tableData[0].model
+ const hasOther = dataValue.dataList.some(
+ item =>
+ (item as any).tempId !== dataValue.currentRowName &&
+ (item as any).productName === tableData[0].productName &&
+ (item as any).model === tableData[0].model
);
if (hasOther) {
ElMessage.warning("鏈�澶栧眰鍜屽綋鍓嶄骇鍝佷竴鏍风殑涓�绾у彧鑳芥湁涓�涓�");
@@ -390,7 +410,7 @@
}
};
- const removeItem = (tempId:string) => {
+ const removeItem = (tempId: string) => {
// 鍏堝皾璇曚粠椤跺眰鍒犻櫎
const topIndex = dataValue.dataList.findIndex(item => item.tempId === tempId);
if (topIndex !== -1) {
@@ -513,4 +533,11 @@
await fetchProcessOptions();
await fetchData();
});
-</script>
\ No newline at end of file
+</script>
+
+<style scoped>
+.embedded-container {
+ padding: 0;
+ margin: 0;
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3