From 97382f1512389bbd505d101c460d79b972a2d06f Mon Sep 17 00:00:00 2001
From: zhangdi <1104545947@qq.com>
Date: Mon, 30 Mar 2026 17:33:59 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E6=A8=A1=E6=9D=BF=E6=A0=B7?=
=?UTF-8?q?=E5=BC=8F=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/addTemplateDialog.vue | 74 ++++++++++++++-----
1 file changed, 56 insertions(+), 18 deletions(-)
diff --git a/src/views/processManagement/components/addTemplateDialog.vue b/src/views/processManagement/components/addTemplateDialog.vue
index 79b8338..4b4a6c3 100644
--- a/src/views/processManagement/components/addTemplateDialog.vue
+++ b/src/views/processManagement/components/addTemplateDialog.vue
@@ -96,8 +96,10 @@
@node-click="handleNodeClick"
:default-expand-all="true"
:expand-on-click-node="false"
- highlight-current-row
- :current-row-key="currentRowId"
+ highlight-current
+ :current-node-key="currentRowId"
+ ref="treeRef"
+ node-key="id"
/>
@@ -367,8 +369,8 @@ export default {
},
data() {
return {
- currentRowId: '',
-
+ currentRowId: 'root',
+ treeNodes: {},
treeData: [],
defaultProps: {
label: data => {
@@ -378,13 +380,13 @@ export default {
}
// 工序节点:显示 processName
if (data.processName) {
- return data.processName;
+ return data.processNo + '-' + data.processName;
}
// 项目节点:显示 projectCode
if (data.projectCode !== undefined) {
- return `${data.projectName}`;
+ return `${data.trialNo}-${data.projectName}`;
}
- return '未知节点';
+ return '工序';
},
children: data => {
// 父节点 → 工序列表
@@ -507,12 +509,18 @@ export default {
{
label: '工序列表',
processList: this.ruleForm.tableData,
+ id: 'root',
},
];
// 默认选中第一个子节点
+ // 默认选中根节点
this.$nextTick(() => {
- if (this.ruleForm.tableData.length > 0) {
- this.ruleForm.tableData = this.treeData[0].processList;
+ this.currentRowId = 'root';
+ this.activeName = '1';
+ this.treeLeave = 1;
+ // 使用 setCurrentKey 方法选中节点
+ if (this.$refs.treeRef) {
+ this.$refs.treeRef.setCurrentKey('root', false);
}
});
});
@@ -554,16 +562,31 @@ export default {
// 组织树点击
handleNodeClick(data) {
- if (data.label && data.processList) {
+ console.log(89898989, data);
+ this.treeNodes = data;
+
+ // if (data.label && data.processList) {
+ // // 点击父节点 "工序列表"
+ // this.activeName = '1';
+ // this.treeLeave = 1; // ← 关键修正
+ // // this.ruleForm.tableData = [];
+ // } else if (data.processName && data.modelProjectList) {
+ // // 点击具体工序
+ // this.activeName = '2'; // 保持工序 Tab
+ // this.treeLeave = 2; // ← 关键修正
+ // this.ruleForm.tableData2 = data.modelProjectList;
+ // }
+ if (data.id === 'root' || (data.label && data.processList)) {
// 点击父节点 "工序列表"
this.activeName = '1';
- this.treeLeave = 1; // ← 关键修正
- // this.ruleForm.tableData = [];
+ this.treeLeave = 1;
+ this.currentRowId = data.id || 'root';
} else if (data.processName && data.modelProjectList) {
// 点击具体工序
- this.activeName = '2'; // 保持工序 Tab
- this.treeLeave = 2; // ← 关键修正
+ this.activeName = '2';
+ this.treeLeave = 2;
this.ruleForm.tableData2 = data.modelProjectList;
+ this.currentRowId = data.id;
}
},
// 右侧tab切换
@@ -615,7 +638,17 @@ export default {
item.ppsId = item.ppsId + '';
item.caId = item.caId + '';
});
- this.treeData = [{ label: '工序列表', processList: res.data.data.proDetailVOList }];
+ this.treeData = [{ label: '工序列表', processList: this.ruleForm.tableData, id: 'root' }];
+ // 默认选中根节点
+ this.$nextTick(() => {
+ this.currentRowId = 'root';
+ this.activeName = '1';
+ this.treeLeave = 1;
+ // 使用 setCurrentKey 方法选中节点
+ if (this.$refs.treeRef) {
+ this.$refs.treeRef.setCurrentKey('root', false);
+ }
+ });
});
},
getDictionary() {
@@ -648,10 +681,11 @@ export default {
});
}
if (this.activeName == '2') {
+ console.log(98989898);
this.ruleForm.tableData2.push({
_tempId: this.tempId, // 临时唯一标识
id: null,
- trialNo: this.getProcessNo(this.ruleForm.tableData2),
+ trialNo: this.treeNodes.processNo + '-' + this.getProcessNo(this.ruleForm.tableData2),
});
}
},
@@ -771,7 +805,7 @@ export default {
message: '操作成功!',
});
this.$emit('closeDialog');
- this.getDetail();
+ // this.getDetail();
})
.catch(err => {
this.formLoading = false;
@@ -785,7 +819,7 @@ export default {
type: 'success',
message: '操作成功!',
});
- this.$emit('closeDialog');
+ // this.$emit('closeDialog');
this.getDetail();
})
.catch(err => {
@@ -845,6 +879,10 @@ export default {
padding: 0 !important;
line-height: 50px !important;
}
+:deep(.el-table__header th.el-table__cell) {
+ height: 36px !important; /* 设置你想要的高度 */
+ line-height: 36px !important;
+}
.process-box {
display: flex;
flex-direction: row;