作者:李纯皓_922 | 来源:互联网 | 2024-09-25 15:39
机构懒加载,选人时候,如果该机构下面没人,就取消加载并且不显示箭头
checkable
:load-data="onloadData"
@check="onCheck"
:tree-data="treeData"
:replace-fields="replaceFields"
:loadedKeys="loadedKeys"
:expandedKeys="expandedKeys"
@expand="onExpand"
>
//异步加载数据
onloadData(treeNode) {
return new Promise((resolve,reject)=>{
let taskId = treeNode.dataRef.id;
if (treeNode.dataRef.meta == 1) {
taskId = taskId ? taskId.substr(2, taskId.length) : "";
console.log(‘treeNode.dataRef.children‘, treeNode);
commonApi.subOrgAndUserTreeNode(taskId).then((data) => {
if (data.length > 1) {
treeNode.dataRef.children.splice(0,treeNode.dataRef.children.length)
treeNode.dataRef.children = data;
this.treeData = [...this.treeData];
} else {
treeNode.dataRef.isLeaf = true;
this.treeData = [...this.treeData];
}
}).finally(() => { resolve() });
} else {
resolve();
return;
}
})