|
@ -1,6 +1,6 @@ |
|
|
import { PermItemDTO, UserRoleDTO } from "@admin/app/dtos/user.dto"; |
|
|
import { PermItemDTO, UserRoleDTO } from "@admin/app/dtos/user.dto"; |
|
|
import { ApiService } from "@admin/app/services"; |
|
|
import { ApiService } from "@admin/app/services"; |
|
|
import { Component, Input, OnChanges, SimpleChanges } from "@angular/core"; |
|
|
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from "@angular/core"; |
|
|
import { ActivatedRoute } from "@angular/router"; |
|
|
import { ActivatedRoute } from "@angular/router"; |
|
|
import { AnyObject } from "@cdk/types"; |
|
|
import { AnyObject } from "@cdk/types"; |
|
|
import { NzMessageService } from "ng-zorro-antd/message"; |
|
|
import { NzMessageService } from "ng-zorro-antd/message"; |
|
@ -18,6 +18,8 @@ export class RolePermissionComponent implements OnChanges { |
|
|
|
|
|
|
|
|
@Input() role!: UserRoleDTO; |
|
|
@Input() role!: UserRoleDTO; |
|
|
|
|
|
|
|
|
|
|
|
@Output() onReload = new EventEmitter(); |
|
|
|
|
|
|
|
|
loading = false; |
|
|
loading = false; |
|
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges): void { |
|
|
ngOnChanges(changes: SimpleChanges): void { |
|
@ -36,10 +38,7 @@ export class RolePermissionComponent implements OnChanges { |
|
|
} |
|
|
} |
|
|
if (changes["role"]?.currentValue) { |
|
|
if (changes["role"]?.currentValue) { |
|
|
const role: UserRoleDTO = changes["role"].currentValue; |
|
|
const role: UserRoleDTO = changes["role"].currentValue; |
|
|
let perms: number[] = []; |
|
|
let perms: number[] = role.roleItems ?? []; |
|
|
try { |
|
|
|
|
|
perms = JSON.parse(role.roleItems); |
|
|
|
|
|
} catch (error) {} |
|
|
|
|
|
this.hasPermissions.clear(); |
|
|
this.hasPermissions.clear(); |
|
|
perms.forEach((p) => { |
|
|
perms.forEach((p) => { |
|
|
this.hasPermissions.add(p); |
|
|
this.hasPermissions.add(p); |
|
@ -77,6 +76,7 @@ export class RolePermissionComponent implements OnChanges { |
|
|
) |
|
|
) |
|
|
.subscribe((res) => { |
|
|
.subscribe((res) => { |
|
|
this.msg.success(res.desc); |
|
|
this.msg.success(res.desc); |
|
|
|
|
|
this.onReload.emit(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|