|
|
|
@ -75,20 +75,15 @@ export class RoleComponent implements OnInit {
|
|
|
|
|
nzMaskClosable: false, |
|
|
|
|
nzOnOk: async () => { |
|
|
|
|
if (instance.validateForm.valid) { |
|
|
|
|
|
|
|
|
|
await new Promise(resolve => { |
|
|
|
|
console.log('表单信息', instance.validateForm) |
|
|
|
|
let arr = [] |
|
|
|
|
instance.validateForm.value.power.forEach(element => { |
|
|
|
|
arr.push(element.name) |
|
|
|
|
}); |
|
|
|
|
let body = { |
|
|
|
|
name: instance.validateForm.value.name, |
|
|
|
|
DisplayName: instance.validateForm.value.name, |
|
|
|
|
grantedPermissions: arr |
|
|
|
|
grantedPermissions: instance.validateForm.value.power || [] |
|
|
|
|
} |
|
|
|
|
let body2=instance.validateForm.value.menus |
|
|
|
|
this.http.post('/api/services/app/Role/Create', body).subscribe((data:any) => { |
|
|
|
|
let body2 = instance.validateForm.value.menus || [] |
|
|
|
|
this.http.post('/api/services/app/Role/Create', body).subscribe((data: any) => { |
|
|
|
|
resolve(data) |
|
|
|
|
this.http.post('/api/services/app/Role/SetRoleMenus', body2, { |
|
|
|
|
params: { |
|
|
|
@ -96,14 +91,14 @@ export class RoleComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
}).subscribe(data => { |
|
|
|
|
resolve(data) |
|
|
|
|
|
|
|
|
|
// this.message.create('success', '分配成功!');
|
|
|
|
|
|
|
|
|
|
this.message.create('success', '创建成功!'); |
|
|
|
|
this.getAllRoles() |
|
|
|
|
return true |
|
|
|
|
}, err => { |
|
|
|
|
this.message.create('warning', '分配菜单错误!'); |
|
|
|
|
}) |
|
|
|
|
this.message.create('success', '创建成功!'); |
|
|
|
|
this.getAllRoles() |
|
|
|
|
return true |
|
|
|
|
}, err => { |
|
|
|
|
this.message.create('warning', '创建角色错误!'); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
@ -116,14 +111,13 @@ export class RoleComponent implements OnInit {
|
|
|
|
|
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!')); |
|
|
|
|
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
edit(item) { |
|
|
|
|
const modal = this.modal.create({ |
|
|
|
|
nzTitle: '编辑角色', |
|
|
|
|
nzContent: EditroleComponent, |
|
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
|
nzWidth: 400, |
|
|
|
|
// nzOkLoading: true,
|
|
|
|
|
nzComponentParams: { |
|
|
|
|
data: item, |
|
|
|
|
optionList: this.optionList, |
|
|
|
@ -134,33 +128,30 @@ export class RoleComponent implements OnInit {
|
|
|
|
|
if (instance.validateForm.valid) { |
|
|
|
|
await new Promise(resolve => { |
|
|
|
|
console.log('表单信息', instance.validateForm) |
|
|
|
|
let arr = [] |
|
|
|
|
instance.validateForm.value.power.forEach(element => { |
|
|
|
|
arr.push(element.name ? element.name : element) |
|
|
|
|
}); |
|
|
|
|
let body = { |
|
|
|
|
id: item.id, |
|
|
|
|
name: instance.validateForm.value.name, |
|
|
|
|
DisplayName: instance.validateForm.value.name, |
|
|
|
|
grantedPermissions: arr |
|
|
|
|
grantedPermissions: instance.validateForm.value.power || [] |
|
|
|
|
} |
|
|
|
|
let body2=instance.validateForm.value.menus |
|
|
|
|
this.http.put('/api/services/app/Role/Update', body).subscribe((data:any) => { |
|
|
|
|
let body2 = instance.validateForm.value.menus || [] |
|
|
|
|
this.http.put('/api/services/app/Role/Update', body).subscribe((data: any) => { |
|
|
|
|
resolve(data) |
|
|
|
|
this.http.post('/api/services/app/Role/SetRoleMenus', body2, { |
|
|
|
|
params: { |
|
|
|
|
roleId: data.result.id |
|
|
|
|
} |
|
|
|
|
}).subscribe(data => { |
|
|
|
|
resolve(data) |
|
|
|
|
|
|
|
|
|
// this.message.create('success', '分配成功!');
|
|
|
|
|
|
|
|
|
|
this.message.create('success', '修改成功!'); |
|
|
|
|
this.getAllRoles() |
|
|
|
|
return true |
|
|
|
|
resolve(data) |
|
|
|
|
}, err => { |
|
|
|
|
this.message.create('warning', '分配菜单错误!'); |
|
|
|
|
}) |
|
|
|
|
this.message.create('success', '修改成功!'); |
|
|
|
|
this.getAllRoles() |
|
|
|
|
return true |
|
|
|
|
|
|
|
|
|
}, err => { |
|
|
|
|
this.message.create('warning', '修改角色错误!'); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|