From 7a77afaedc239551008b8fba42f02f85065fbe4b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 14 四月 2026 17:47:51 +0800
Subject: [PATCH] 中兴实强 1.新增工艺路线的时候产品可以多选
---
src/views/productionManagement/productStructure/Detail/index.vue | 86 ++++++++++++++++++++++++++++++++++--------
1 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 3a76e48..f1ebf08 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -115,18 +115,23 @@
<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>
<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);
}
});
};
@@ -264,15 +269,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 +400,7 @@
}
};
- const removeItem = (tempId:string) => {
+ const removeItem = (tempId: string) => {
// 鍏堝皾璇曚粠椤跺眰鍒犻櫎
const topIndex = dataValue.dataList.findIndex(item => item.tempId === tempId);
if (topIndex !== -1) {
@@ -421,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) {
@@ -436,7 +488,7 @@
productModelId: undefined,
processId: "",
processName: "",
- unitQuantity: 0,
+ unitQuantity: 1,
demandedQuantity: 0,
unit: "",
children: [],
@@ -462,7 +514,7 @@
model: undefined,
productModelId: undefined,
processId: "",
- unitQuantity: 0,
+ unitQuantity: 1,
demandedQuantity: 0,
children: [],
unit: "",
@@ -513,4 +565,4 @@
await fetchProcessOptions();
await fetchData();
});
-</script>
\ No newline at end of file
+</script>
--
Gitblit v1.9.3