filterHalfCheckedKeys() {
let { orgTreeList, saveOrgMenus, } = this.state;
// 所有不需要授权的自动打勾
saveOrgMenus = uniq([...saveOrgMenus,])
console.log('saveOrgMenus=',saveOrgMenus,orgTreeList)
// 展示时要把半选的资源去掉
let filterCheckedKeys = (arr, defaultCheckedKeys) => {
console.log('defaultCheckedKeys=',defaultCheckedKeys)
forEach(arr, item => {
//当前节点有子节点先处理子节点
if (defaultCheckedKeys.includes(item.id)) {
filterCheckedKeys(item.children, defaultCheckedKeys);
}
//当前节点的子节点不是全选就去掉当前节点
if (some(item.children, item1 => !defaultCheckedKeys.includes(item1.id))) {
let index = defaultCheckedKeys.findIndex(item2 => item2 == item.id);
if (index != -1) {
defaultCheckedKeys.splice(index, 1);
}
}
});
};
filterCheckedKeys(orgTreeList, saveOrgMenus);
console.log('saveOrgMenus==2',saveOrgMenus)
retrun saveOrgMenus;
}
tree根据子节点及父节点id,获取子节点id
最新推荐文章于 2024-04-27 08:57:52 发布