This commit is contained in:
Taric Xin
2022-02-22 16:43:14 +08:00
parent 6285aa085c
commit 212be1e066
9 changed files with 78 additions and 2005 deletions

View File

@ -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);
});
}