This commit is contained in:
sjl
2025-03-11 14:16:21 +08:00
parent 341b8df5a9
commit 9af98b034f
4 changed files with 44 additions and 11 deletions

View File

@@ -286,6 +286,7 @@ const second = ref(0)
const emit = defineEmits(['update:activeName','update:activeIndex','update:startDisabeld','update:pauseDisabled'])
watch(()=>props.formControl.scriptId,()=>{
console.log("切换脚本",props.formControl.scriptId);
if(props.formControl.scriptId!=''){
getTree()
}
@@ -303,6 +304,19 @@ const getTree = () => {
}).then(res => {
if (res.code === 'A0000') {
treeData.value = res.data
// 为 treeData 及其子节点添加 id
let idCounter = 0;
const addIdToTree = (nodes: any[]) => {
nodes.forEach(node => {
node.id = idCounter++; // 为每个节点添加唯一的 id
if (node.children && node.children.length > 0) {
addIdToTree(node.children); // 递归为子节点添加 id
}
});
};
addIdToTree(treeData.value);
// 添加tab子项
props.options.forEach((k: any, i: number) => {
@@ -312,6 +326,7 @@ const getTree = () => {
item.children.forEach((s: any) => {
k.children.forEach((P: any) => {
if (P.code == s.scriptTypeCode) {
tabData.value[i].children.push({
label: P.label,
value: P.code,
@@ -336,6 +351,8 @@ const getTree = () => {
tabChange()
}
})
}
@@ -376,7 +393,7 @@ const tabChange = () => {
const inquireTable = () => {
const sortOrder = ['Ua', 'Ia', 'Ub', 'Ib', 'Uc', 'Ic']
dlsDetails({
scriptId: '9ff96807cf8c7524587982ed8baa8b57',
scriptId: props.formControl.scriptId,
scriptType: activeName.value,
scriptSubType: childActiveName.value
}).then((res: any) => {
@@ -393,7 +410,7 @@ const inquireTable = () => {
}
})
console.log('treeData',treeData.value)
}

View File

@@ -1,6 +1,6 @@
<template>
<el-tree
node-key="scriptName"
node-key="id"
default-expand-all
:data="props.treeData"
:props="defaultProps"
@@ -44,7 +44,7 @@ const childActiveName = ref('')
const activeIndex = ref()
const treeRef = ref()
const handleNodeClick = (data, node) => {
console.log('handleNodeClick', props.treeData)
//console.log('handleNodeClick', props.treeData)
if(data.index!= null){
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
const parents = getParentNodes(node, [])
@@ -105,8 +105,12 @@ function findTargetCodes(data: any[], targetCodes: string[]) {
function handleCheckChange(data,isChecked) {
console.log('handleCheckChange', data,isChecked)
if(isChecked){
const checked = [data.scriptName]; // id为tree的node-key属性
const checked = [data.id]; // id为tree的node-key属性
treeRef.value?.setCheckedKeys(checked);
emit('setTab', {
activeIndex:data.index
})
}
}
// // 对外映射