edit
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
<div class="modal-header">
|
||||
<div class="modal-title">{{ i.id === 0 ? '新增角色' : '编辑角色' }}</div>
|
||||
<div class="modal-title">{{ params.id === 0 ? '新增角色' : '编辑角色' }}</div>
|
||||
</div>
|
||||
<nz-spin *ngIf="!i" class="modal-spin"></nz-spin>
|
||||
<div *ngIf="i">
|
||||
<sf #sf [compact]="true" [ui]="ui" [schema]="schema" [button]="'none'"> </sf>
|
||||
<nz-spin *ngIf="!params" class="modal-spin"></nz-spin>
|
||||
<div *ngIf="params">
|
||||
<sf #sf [compact]="true" [ui]="{'*': { spanLabelFixed: 120, grid: { span: 24 } } }" [schema]="schema"
|
||||
[button]="'none'"> </sf>
|
||||
</div>
|
||||
<div class="box">
|
||||
<se-container se-container="1">
|
||||
<se label="角色权限" required [labelWidth]="120">
|
||||
<app-cuc-menu #menu (changeData)="getData($event)" [type]="i.id === 0 ? 'add' : 'edit'" [source]="source"
|
||||
[roleId]="i.id" [isAuthorityIdDTOList]="roleInfoData.authority || []"
|
||||
<app-cuc-menu #menu (changeData)="getData($event)" [type]="params.id === 0 ? 'add' : 'edit'" [roleId]="params.id"
|
||||
[isAuthorityIdDTOList]="roleInfoData.authority || []"
|
||||
[authorityAssistId]="roleInfoData.authorityAssistId || []">
|
||||
</app-cuc-menu>
|
||||
</se>
|
||||
@ -17,7 +18,6 @@
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button nz-button type="button" (click)="close()">{{ source === 'onlyAuth' ? '关闭' : '取消' }}</button>
|
||||
<button nz-button type="button" nzType="primary" (click)="sure()" *ngIf="source !== 'onlyAuth'"
|
||||
[disabled]="!sf?.valid">确定</button>
|
||||
<button nz-button type="button" (click)="close()">取消</button>
|
||||
<button nz-button type="button" nzType="primary" (click)="sure()">确定</button>
|
||||
</div>
|
||||
@ -18,25 +18,18 @@ export class SettingRoleEditComponent implements OnInit {
|
||||
sf!: SFComponent;
|
||||
@ViewChild('menu', { static: false })
|
||||
menu!: SettingMenuComponent;
|
||||
record: any = {};
|
||||
roleInfoData: any = {};
|
||||
authorityAssistId: any[] = [];
|
||||
appList: any[] = [];
|
||||
source = '';
|
||||
i: any;
|
||||
params: any;
|
||||
schema!: SFSchema;
|
||||
authority: any[] = [];
|
||||
roleTplData: any[] = [];
|
||||
ui!: SFUISchema;
|
||||
constructor(private modal: NzModalRef, public service: SystemService, private envSrv: EAEnvironmentService) {}
|
||||
constructor(private modal: NzModalRef, public service: SystemService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.i.id) {
|
||||
this.initSF();
|
||||
if (this.params.id) {
|
||||
this.getRoleInfo();
|
||||
}
|
||||
if (this.source === '') {
|
||||
this.initSF();
|
||||
}
|
||||
}
|
||||
initSF() {
|
||||
this.schema = {
|
||||
@ -57,7 +50,7 @@ export class SettingRoleEditComponent implements OnInit {
|
||||
default: this.roleInfoData.roleDescription,
|
||||
ui: {
|
||||
autosize: { minRows: 3 },
|
||||
hidden: this.i.lookType === 'detail',
|
||||
hidden: this.params.lookType === 'detail',
|
||||
placeholder: '请输入角色描述',
|
||||
widget: 'textarea'
|
||||
}
|
||||
@ -65,46 +58,15 @@ export class SettingRoleEditComponent implements OnInit {
|
||||
},
|
||||
required: ['roleName']
|
||||
};
|
||||
this.ui = {
|
||||
'*': {
|
||||
spanLabelFixed: 120,
|
||||
grid: { span: 24 }
|
||||
}
|
||||
};
|
||||
}
|
||||
getAppList() {
|
||||
const params = {
|
||||
pageSize: 10000,
|
||||
pageIndex: 1
|
||||
};
|
||||
return this.service.request(this.service.$api_getAppList, params).pipe(
|
||||
map(res => {
|
||||
this.appList = res;
|
||||
const versionArr: any[] = [];
|
||||
const resArr = res;
|
||||
if (resArr && resArr.length) {
|
||||
resArr.forEach((item: any) => {
|
||||
versionArr.push({
|
||||
label: item.appName,
|
||||
value: item.appId
|
||||
});
|
||||
});
|
||||
}
|
||||
return versionArr;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getRoleInfo() {
|
||||
const params = {
|
||||
id: this.i.id
|
||||
id: this.params.id
|
||||
};
|
||||
this.service.request(this.service.$api_getRoleInfo, params).subscribe(res => {
|
||||
this.service.request(this.params.infoUrl, params).subscribe(res => {
|
||||
if (res) {
|
||||
this.roleInfoData = res;
|
||||
}
|
||||
|
||||
if (this.source === '') {
|
||||
this.initSF();
|
||||
}
|
||||
});
|
||||
@ -117,6 +79,10 @@ export class SettingRoleEditComponent implements OnInit {
|
||||
this.modal.destroy();
|
||||
}
|
||||
sure() {
|
||||
if (!this.sf?.valid) {
|
||||
this.service.msgSrv.warning('校验错误');
|
||||
return;
|
||||
}
|
||||
// this.menu.washTree();
|
||||
// if (this.authorityAssistId.length === 0) {
|
||||
// this.service.msgSrv.warning('请选择权限!');
|
||||
@ -124,28 +90,20 @@ export class SettingRoleEditComponent implements OnInit {
|
||||
// }
|
||||
const auths = this.menu?.washTree();
|
||||
const params: any = {
|
||||
id: this.i.id,
|
||||
id: this.params.id,
|
||||
...this.sf.value,
|
||||
authority: auths.authority,
|
||||
authorityAssistId: auths.authorityAssistId
|
||||
};
|
||||
// if (this.sf) {
|
||||
// this.appList.forEach(item => {
|
||||
// if (item.appId === this.sf.value.appId) {
|
||||
// params.tenantId = item.tenantId;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// delete params.tplId;
|
||||
if (this.i.id === 0) {
|
||||
if (this.params.id === 0) {
|
||||
delete params.id;
|
||||
}
|
||||
if (this.i.id) {
|
||||
this.service.request(this.service.$api_update_role, params).subscribe(res => {
|
||||
if (this.params.id) {
|
||||
this.service.request(this.params.updateUrl, params).subscribe(res => {
|
||||
this.modal.close(true);
|
||||
});
|
||||
} else {
|
||||
this.service.request(this.service.$api_save_role, params).subscribe(res => {
|
||||
this.service.request(this.params.addUrl, params).subscribe(res => {
|
||||
this.modal.close(true);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user