diff --git a/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.ts b/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.ts index a01cade2..1db86b54 100644 --- a/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.ts +++ b/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.ts @@ -158,6 +158,7 @@ export class MenuTreeComponent implements OnInit, OnChanges { auths.push(origin.id); const authsSet = new Set(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 {