This commit is contained in:
Taric Xin
2022-04-27 16:35:11 +08:00
parent 5760a69695
commit 88ea143bad

View File

@ -158,6 +158,7 @@ export class MenuTreeComponent implements OnInit, OnChanges {
auths.push(origin.id);
const authsSet = new Set<string>(auths);
this.authorityAssistId = [...Array.from(authsSet)];
this.recursionAddParantNode(node);
} else {
data.forEach(auth => this._apiAuthSet.delete(auth.functionButtonId));
this._NodeAuthMap.delete(origin.id);
@ -243,9 +244,29 @@ export class MenuTreeComponent implements OnInit, OnChanges {
private recursionDeleteParantNode(node: NzTreeNode) {
this.authorityAssistId = this.authorityAssistId.filter(auth => auth !== node.origin.id);
if (node.parentNode) {
if (!node.parentNode.children.find(node => node.isChecked) && node.parentNode.origin.level !== 0) {
this._NodeAuthMap.delete(node.parentNode.origin.id);
}
this.recursionDeleteParantNode(node.parentNode);
}
}
/**
* 向上递归添加父节点到源数据
* 清理勾选数据
*
* @param node
*/
private recursionAddParantNode(node: NzTreeNode) {
this._NodeAuthMap.set(node.origin.id, {
authorityId: node.origin.id,
buttonAuthorityIds: [],
isUpdateAuthority: 1
});
if (node.parentNode) {
this.recursionAddParantNode(node.parentNode);
}
}
}
export interface AuthorityIdVO {