From 377b8900389fa8aa33834b830bac0967f9fec8e2 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 14 四月 2026 17:40:34 +0800
Subject: [PATCH] 中兴实强 1.bom加一个引用功能, 2.工艺路线需要修改,bom不必填,选了bom就带入bom信息
---
src/views/productionManagement/productStructure/Detail/index.vue | 63 +++++++++++++++++++++++++++----
1 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 6734830..f1ebf08 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -121,12 +121,17 @@
</el-table-column>
<el-table-column label="鎿嶄綔"
fixed="right"
- width="200">
+ width="260">
<template #default="{ row, $index }">
- <el-button v-if="dataValue.isEdit && !dataValue.dataList.some(item => (item as any).tempId === row.tempId)"
+ <el-button v-if="dataValue.isEdit"
type="danger"
text
@click="removeItem(row.tempId)">鍒犻櫎
+ </el-button>
+ <el-button v-if="dataValue.isEdit"
+ type="primary"
+ text
+ @click="quoteItem(row.tempId)">寮曠敤
</el-button>
<el-button v-if="dataValue.isEdit"
type="primary"
@@ -221,7 +226,6 @@
]);
const openDialog = (tempId: any) => {
- console.log(tempId, "tempId");
dataValue.currentRowName = tempId;
dataValue.showProductDialog = true;
};
@@ -236,14 +240,15 @@
const { data } = await queryList(routeId.value);
dataValue.dataList = (data as any) || [];
// 涓烘墍鏈夐」鍙婂叾瀛愰」璁剧疆name灞炴��
- const setNameRecursively = (items: any[]) => {
+ const setNameRecursively = (items: any[], parent: any = null) => {
items.forEach((item: any) => {
item.tempId = item.id;
+ item.parentTempId = parent?.tempId || "";
item.processName =
dataValue.processOptions.find(option => option.id === item.processId)
?.name || "";
if (item.children && item.children.length > 0) {
- setNameRecursively(item.children);
+ setNameRecursively(item.children, item);
}
});
};
@@ -426,6 +431,48 @@
}
});
};
+ const createTempId = () => new Date().getTime() + Math.floor(Math.random() * 1000);
+ const cloneItem = (item: any, parentTempId = "", parentId = item.parentId || "") => {
+ const tempId = createTempId();
+ return {
+ ...item,
+ id: undefined,
+ parentId,
+ tempId,
+ parentTempId,
+ children: [],
+ };
+ };
+ const quoteItem = (tempId: string) => {
+ const topIndex = dataValue.dataList.findIndex(item => item.tempId === tempId);
+ if (topIndex !== -1) {
+ const currentItem = dataValue.dataList[topIndex];
+ dataValue.dataList.splice(
+ topIndex + 1,
+ 0,
+ cloneItem(currentItem, currentItem.parentTempId || "")
+ );
+ return;
+ }
+
+ const quoteChildItem = (items: any[], currentTempId: string) => {
+ for (let i = 0; i < items.length; i++) {
+ const item = items[i];
+ if (item.tempId === currentTempId) {
+ items.splice(i + 1, 0, cloneItem(item, item.parentTempId || ""));
+ return true;
+ }
+ if (item.children && item.children.length > 0) {
+ if (quoteChildItem(item.children, currentTempId)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ quoteChildItem(dataValue.dataList, tempId);
+ };
const addItem2 = tempId => {
dataValue.dataList.map(item => {
if (item.tempId === tempId) {
@@ -441,7 +488,7 @@
productModelId: undefined,
processId: "",
processName: "",
- unitQuantity: 0,
+ unitQuantity: 1,
demandedQuantity: 0,
unit: "",
children: [],
@@ -467,7 +514,7 @@
model: undefined,
productModelId: undefined,
processId: "",
- unitQuantity: 0,
+ unitQuantity: 1,
demandedQuantity: 0,
children: [],
unit: "",
@@ -518,4 +565,4 @@
await fetchProcessOptions();
await fetchData();
});
-</script>
\ No newline at end of file
+</script>
--
Gitblit v1.9.3