
機構懶加載,選人時候,如果該機構下面沒人,就取消加載並且不顯示箭頭
<a-tree
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;
}
})
