Merge branch 'develop'
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
<nz-card [nzLoading]="loadingInfo" [nzBordered]="false">
|
||||
<se-container se-container="1">
|
||||
<se label="接口权限" required [labelWidth]="120">
|
||||
<app-menu-tree #menu (changeData)="getData($event)" [type]="'edit'"
|
||||
[roleId]="params.id" [appId]="params.appId" [isAuthorityIdDTOList]="roleInfoData.authority || []"
|
||||
[authorityAssistId]="roleInfoData.authorityAssistId || []" (changeIF)="changeIF($event)">
|
||||
<app-menu-tree #menu (changeData)="getData($event)" [appId]="params.appId"
|
||||
[isAuthorityIdDTOList]="roleInfoData.authority || []"
|
||||
[authorityAssistId]="roleInfoData.authorityAssistId || []">
|
||||
</app-menu-tree>
|
||||
</se>
|
||||
</se-container>
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
<div *ngIf="origin.buttonInfoList && origin.buttonInfoList.length">
|
||||
<label style="width: 100%" nz-checkbox [ngModel]="_apiAuthSet.has(item.functionButtonId)"
|
||||
*ngFor="let item of origin.buttonInfoList"
|
||||
(ngModelChange)="addAuthority($event,origin,node, item)" [disabled]="source === 'onlyAuth'">{{
|
||||
(ngModelChange)="butCheckedAction($event,origin,node, item)"
|
||||
[disabled]="source === 'onlyAuth'">{{
|
||||
item.permissionsName }}</label>
|
||||
</div>
|
||||
<nz-empty nzNotFoundImage="simple" *ngIf="!origin.buttonInfoList || origin.buttonInfoList.length === 0">
|
||||
|
||||
@ -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<any>();
|
||||
|
||||
_apiAuthSet = new Set<string>();
|
||||
_NodeAuthMap = new Map<string, { authorityId: string; buttonAuthorityIds: string[]; isUpdateAuthority: 0 | 1 }>();
|
||||
_apiAuthSet = new Set<string>(); // 操作权限全数据源
|
||||
_NodeAuthMap = new Map<string, AuthorityIdVO>(); // 树权限数据源
|
||||
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<string>(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<string>(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;
|
||||
}
|
||||
|
||||
@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user