<el-tree
:props="{class: customNodeClass}"
:data="treeData"
node-key="id"
show-checkbox
ref="classesTree"
:check-strictly="true"
@check="treeCheckChange"
:filter-node-method="filterNode"
/>
onMounted(() => {
queryClassesTree();
});
const queryClassesTree = async () => {
service({
url: `/common/getTree`,
method: 'post',
}).then((res) => {
let data: [] = markLastLeaf(res.data);
treeData.splice(0, treeData.length, ...data);
});
};
const markLastLeaf = (arr: any) => {
// 标记是否是树末位子节点
return arr.map((v: any) => {
const item: Item = { id: v.id, label: v.name, level: '', children: [] };
if (!v.children || v.children.length === 0) {
item.level = 'last';
} else {
item.children = markLastLeaf([...v.children]);
}
return item;
});
};
const customNodeClass: any = (data: Item, node: Node) => {
if (!data.level) {
return 'is-penultimate'
}
return ''
}
:deep(.is-penultimate>.yxt-tree-node__content .yxt-checkbox){
display: none !important;
}
07-29
4604
11-04
4462