diff --git a/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html index b92286ac..b7d4e764 100644 --- a/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html +++ b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html @@ -1,9 +1,9 @@ - + diff --git a/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts index c572ee48..3e066d21 100644 --- a/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts +++ b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts @@ -47,9 +47,7 @@ export class ApiAuthModalComponent implements OnInit { close() { this.modal.destroy(); } - changeIF(value: any) { - this.changeValue = true; - } + sure() { const auths = this.menu?.washTree(); if (auths.authorityAssistId.length === 0) { diff --git a/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.html b/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.html index 46207bfb..0ad3b3a9 100644 --- a/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.html +++ b/src/app/routes/sys-setting/components/organization-management/menu-tree/menu-tree.component.html @@ -11,7 +11,8 @@
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 23688cd6..a01cade2 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 @@ -12,30 +12,25 @@ export class MenuTreeComponent implements OnInit, OnChanges { @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; origin: any = { buttonInfoList: [], dictList: [] }; node!: NzTreeNode; - authority: any[] = []; functionList: any[] = []; - @Input() type = 'edit'; @Input() source = ''; @Input() appId = this.envSrv.env.appId; - @Input() isAuthorityIdDTOList: any[] = []; - @Input() authorityAssistId: any[] = []; - @Input() roleId: any; + @Input() isAuthorityIdDTOList: AuthorityIdVO[] = []; + @Input() authorityAssistId: string[] = []; @Output() changeData = new EventEmitter(); - _apiAuthSet = new Set(); - _NodeAuthMap = new Map(); + _apiAuthSet = new Set(); // 操作权限全数据源 + _NodeAuthMap = new Map(); // 树权限数据源 constructor(public service: SystemService, private cdr: ChangeDetectorRef, private envSrv: EAEnvironmentService) {} ngOnChanges(changes: SimpleChanges): void { if (changes.isAuthorityIdDTOList) { - if (this.type === 'edit') { - this.authority = this.isAuthorityIdDTOList || []; - this.authority.forEach(auth => { - this._NodeAuthMap.set(auth.authorityId, auth); - if (auth.buttonAuthorityIds) { - auth.buttonAuthorityIds.forEach((buttonId: string) => this._apiAuthSet.add(buttonId)); - } - }); - } + // 遍历初始化树节点权限数据源 初始化操作权限数据源 + this.isAuthorityIdDTOList?.forEach(auth => { + this._NodeAuthMap.set(auth.authorityId, auth); + if (auth.buttonAuthorityIds) { + auth.buttonAuthorityIds.forEach((buttonId: string) => this._apiAuthSet.add(buttonId)); + } + }); } } @@ -54,11 +49,11 @@ export class MenuTreeComponent implements OnInit, OnChanges { }); } - addAuthority( + butCheckedAction( status: boolean, origin: { buttonInfoList: any[]; [key: string]: any }, node: NzTreeNode, - item: { checked: any; functionButtonId: string } + item: { functionButtonId: string } ) { // 更新完整操作权限数据 if (status) { @@ -103,7 +98,6 @@ export class MenuTreeComponent implements OnInit, OnChanges { clickTreeNodeAction(event: any): void { this.origin = event.node.origin; this.node = event.node; - console.log(this.node); // 叶子节点获取操作权限, 非叶子节点则展开 if (event.node.origin.isLeaf) { @@ -142,40 +136,8 @@ export class MenuTreeComponent implements OnInit, OnChanges { } } - private recursionSetNodeAuth(origin: any) { - this._NodeAuthMap.set(origin.id, { authorityId: origin.id, buttonAuthorityIds: [], isUpdateAuthority: 1 }); - let auths = [...this.authorityAssistId]; - origin.children?.forEach((node: any) => { - auths.push(node.id); - node._selected = true; - const _auth = this._NodeAuthMap.get(node.id); - this._NodeAuthMap.set(node.id, { - authorityId: node.id, - buttonAuthorityIds: _auth?.buttonAuthorityIds || [], - isUpdateAuthority: 1 - }); - if (node?.children?.length > 0) { - this.recursionSetNodeAuth(node); - } - }); - auths = [...auths, ...this.authorityAssistId]; - const authsSet = new Set(auths); - this.authorityAssistId = [...Array.from(authsSet)]; - } - - private recursionDeleteNodeAuth(origin: any) { - this._NodeAuthMap.delete(origin.id); - this.authorityAssistId = this.authorityAssistId.filter(auth => auth !== origin.id); - origin.children?.forEach((node: any) => { - this.authorityAssistId = this.authorityAssistId.filter(auth => auth !== node.id); - this._NodeAuthMap.delete(node.id); - if (node?.children?.length > 0) { - this.recursionDeleteNodeAuth(node); - } - }); - } - /** + * TODO * 根据树勾选状态更新数据源 * 1.更新操作权限点数据源 _apiAuthSet * 2.更新菜单权限数据源 _NodeAuthMap @@ -205,8 +167,6 @@ export class MenuTreeComponent implements OnInit, OnChanges { } washTree() { - // const checkedNode: any = this.nzTreeComponent.getCheckedNodeList(); - // const halfCheckedNode: any = this.nzTreeComponent.getHalfCheckedNodeList(); const authority: any[] = []; this._NodeAuthMap.forEach(nodeAuth => authority.push(nodeAuth)); const result = { @@ -235,6 +195,45 @@ export class MenuTreeComponent implements OnInit, OnChanges { }); } + /** + * 向下递归添加子节点到树权限数据源 + * + * @param origin + */ + private recursionSetNodeAuth(origin: any) { + this._NodeAuthMap.set(origin.id, { authorityId: origin.id, buttonAuthorityIds: [], isUpdateAuthority: 1 }); + let auths = [...this.authorityAssistId]; + origin.children?.forEach((node: any) => { + auths.push(node.id); + // 标记为 通过父级勾选关联导致勾选。防止父级勾选导致更新了源数据 + node._selected = true; + const _auth = this._NodeAuthMap.get(node.id); + this._NodeAuthMap.set(node.id, { + authorityId: node.id, + buttonAuthorityIds: _auth?.buttonAuthorityIds || [], + isUpdateAuthority: 1 + }); + if (node?.children?.length > 0) { + this.recursionSetNodeAuth(node); + } + }); + auths = [...auths, ...this.authorityAssistId]; + const authsSet = new Set(auths); + this.authorityAssistId = [...Array.from(authsSet)]; + } + + private recursionDeleteNodeAuth(origin: any) { + this._NodeAuthMap.delete(origin.id); + this.authorityAssistId = this.authorityAssistId.filter(auth => auth !== origin.id); + origin.children?.forEach((node: any) => { + this.authorityAssistId = this.authorityAssistId.filter(auth => auth !== node.id); + this._NodeAuthMap.delete(node.id); + if (node?.children?.length > 0) { + this.recursionDeleteNodeAuth(node); + } + }); + } + /** * 向上递归取消父节点勾选 * 清理勾选数据 @@ -248,3 +247,10 @@ export class MenuTreeComponent implements OnInit, OnChanges { } } } + +export interface AuthorityIdVO { + authorityId: string; + buttonAuthorityIds: string[]; + dataAuthority?: { dictId: number; dictItemId: number; itemKey: string }[]; + isUpdateAuthority?: 0 | 1; +} diff --git a/src/app/routes/ticket-management/components/invoice-requested/invoice-requested-detail/invoice-requested-detail.component.ts b/src/app/routes/ticket-management/components/invoice-requested/invoice-requested-detail/invoice-requested-detail.component.ts index a8f18617..901d2adb 100644 --- a/src/app/routes/ticket-management/components/invoice-requested/invoice-requested-detail/invoice-requested-detail.component.ts +++ b/src/app/routes/ticket-management/components/invoice-requested/invoice-requested-detail/invoice-requested-detail.component.ts @@ -247,7 +247,7 @@ export class InvoiceRequestedDetailComponent implements OnInit { enum: [ { label: '全部', value: '' }, { label: '整车', value: '1' }, - { label: '大宗', value: '2' } + { label: '大宗', value: '2' }, ], ui: { widget: 'select', @@ -305,7 +305,7 @@ export class InvoiceRequestedDetailComponent implements OnInit { { title: '订单完成日期', index: 'billfinTime', type: 'date', width: 150 }, { title: '开票状态', index: 'vatappStsLabel', width: 100 }, { title: '所属项目', index: 'projectIdName', width: 140 }, - { title: '订单类型', index: 'billType', width: 100, type: 'enum', enum: { 1: '整车', 2: '大宗' } }, + { title: '订单类型', index: 'billTypeLabel', width: 100,}, { title: '装货地', index: 'loadingfrom', width: 220 }, { title: '卸货地', index: 'loadingto', width: 220 }, { title: '货物信息', index: 'goodsinfo', width: 150 },