+
\ No newline at end of file
diff --git a/src/app/home/system-management/role/editrole/editrole.component.ts b/src/app/home/system-management/role/editrole/editrole.component.ts
index e2a7144..fd63e39 100644
--- a/src/app/home/system-management/role/editrole/editrole.component.ts
+++ b/src/app/home/system-management/role/editrole/editrole.component.ts
@@ -12,22 +12,14 @@ import { TreeService } from 'src/app/service/tree.service';
export class EditroleComponent implements OnInit {
@Input() data?: any;
- @Input() optionList?: any;
- @Input() nodes?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
multipleValue: any
ngOnInit(): void {
- this.multipleValue = this.data.grantedPermissions
this.validateForm = this.fb.group({
- name: [null, [Validators.required]],
- power: [null],
- menus: [null]
+ name: [null, [Validators.required]]
});
- if (this.optionList.length == 0) {
- this.loadMore()
- }
}
totalCount
@@ -36,14 +28,4 @@ export class EditroleComponent implements OnInit {
this.modal.destroy({ data: 'this the result data' });
}
- // optionList = [];
- //获取权限列表
- loadMore() {
- this.http.get('/api/services/app/Role/GetAllPermissions').subscribe((data: any) => {
- this.optionList = data.result.items
- this.modal.containerInstance.config.nzOkLoading = false
- // console.log('所有权限',data)
- })
- }
-
}
diff --git a/src/app/home/system-management/role/role.component.html b/src/app/home/system-management/role/role.component.html
index 30fd9ee..41655c1 100644
--- a/src/app/home/system-management/role/role.component.html
+++ b/src/app/home/system-management/role/role.component.html
@@ -6,21 +6,39 @@
-
+
角色名称 |
创建/修改时间 |
+ 状态 |
操作 |
- 访客 |
- 2021-11-19 |
+ {{item.name}} |
+ {{item.creationTime | date:"yyyy-MM-dd"}} |
+
+
+ 已启用
+
+
+ 已禁用
+
+ |
编辑
- 禁用
+
+
+ 禁用
+
+
+
+
+ 启用
+
+
删除
|
diff --git a/src/app/home/system-management/role/role.component.ts b/src/app/home/system-management/role/role.component.ts
index 1736cc0..020feb1 100644
--- a/src/app/home/system-management/role/role.component.ts
+++ b/src/app/home/system-management/role/role.component.ts
@@ -14,47 +14,61 @@ import { EditroleComponent } from './editrole/editrole.component';
export class RoleComponent implements OnInit {
constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient, private toTree: TreeService) { }
- listOfData = [11
- ];
+ listOfData = [];
ngOnInit(): void {
+ this.getAllRoles()
}
- getAllRoles() {
+
+
+ //获取角色列表
+ isLoading = false
+ async getAllRoles() {
+ this.isLoading = true
+ let params = {
+ PageNumber: 1,
+ PageSize: 100
+ }
+ await new Promise((resolve, reject) => {
+ this.http.get('/api/Roles', {
+ params: params
+ }).subscribe((data: any) => {
+ this.isLoading = false
+ this.listOfData = data.items
+ resolve(data)
+ })
+ })
}
+
+
addRole() {
const modal = this.modal.create({
nzTitle: '新增角色',
nzContent: AddroleComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 400,
- nzComponentParams: {
- nodes: null
- },
nzMaskClosable: false,
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
- console.log('表单信息', instance.validateForm)
let body = {
- name: instance.validateForm.value.name,
- DisplayName: instance.validateForm.value.name,
- grantedPermissions: instance.validateForm.value.power || []
+ name: instance.validateForm.value.name
}
- let body2 = instance.validateForm.value.menus || []
- this.http.post('/api/services/app/Role/Create', body).subscribe({
- next: (data) => {
+ this.http.post('/api/Roles', body).subscribe({
+ next: async (data) => {
+ await this.getAllRoles()
+ this.message.create('success', '创建成功');
resolve(data)
- this.message.create('success', '创建成功!');
- this.getAllRoles()
return true
},
error: (err) => {
- this.message.create('warning', '分配菜单错误!');
+ this.isLoading = false
+ this.message.create('warning', '创建失败');
}
})
})
} else {
- this.message.create('warning', '请填写完整!');
+ this.message.create('warning', '请填写完整');
return false
}
}
@@ -76,28 +90,24 @@ export class RoleComponent implements OnInit {
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
- console.log('表单信息', instance.validateForm)
let body = {
- id: item.id,
name: instance.validateForm.value.name,
- DisplayName: instance.validateForm.value.name,
- grantedPermissions: instance.validateForm.value.power || []
}
- let body2 = instance.validateForm.value.menus || []
- this.http.put('/api/services/app/Role/Update', body).subscribe({
- next: (data) => {
+ this.http.patch(`/api/Roles/${item.id}`, body).subscribe({
+ next: async (data) => {
+ await this.getAllRoles()
resolve(data)
- this.message.create('success', '修改成功!');
- this.getAllRoles()
+ this.message.create('success', '修改成功');
return true
},
error: (err) => {
- this.message.create('warning', '分配菜单错误!');
+ this.message.create('warning', '修改失败');
+ return false
}
})
})
} else {
- this.message.create('warning', '请填写完整!');
+ this.message.create('warning', '请填写完整');
return false
}
}
@@ -107,18 +117,37 @@ export class RoleComponent implements OnInit {
// Return a result when closed
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
}
- forbidRole(item) {
-
+ forbidRole(item, type) {
+ this.isLoading = true
+ let body = {
+ enabled: type,
+ }
+ this.http.patch(`/api/Roles/${item.id}`, body).subscribe({
+ next: async (data) => {
+ await this.getAllRoles()
+ this.message.create('success', '修改成功');
+ },
+ error: (err) => {
+ this.isLoading = false
+ this.message.create('warning', '修改失败');
+ }
+ })
}
deleteRole(item) {
this.modal.confirm({
- nzTitle: `确定要删除${item.title}这个机构吗?`,
+ nzTitle: `确定要删除${item.name}这个机构吗?`,
nzOkText: '确定',
nzOkType: 'primary',
nzOnOk: () => {
- this.http.delete(`/api/Organizations/${item.origin.id}`).subscribe(data => {
-
- this.message.create('success', '删除成功!');
+ this.http.delete(`/api/Roles/${item.id}`).subscribe({
+ next: async (data) => {
+ await this.getAllRoles()
+ this.message.create('success', '删除成功');
+ },
+ error: (err) => {
+ this.isLoading = false
+ this.message.create('warning', '删除失败');
+ }
})
},
nzCancelText: '取消',
diff --git a/src/app/pages/login/login.component.ts b/src/app/pages/login/login.component.ts
index 11b2507..51cd0a8 100644
--- a/src/app/pages/login/login.component.ts
+++ b/src/app/pages/login/login.component.ts
@@ -97,20 +97,28 @@ export class LoginComponent implements OnInit {
password: this.validateForm.value.password
}).subscribe({
next: (data: any) => {
- this.isLoading = false;
- this.rememberInfo()
- this.autoLogin()
sessionStorage.setItem("token", data.token);
sessionStorage.setItem("refreshToken", data.refreshToken);
- this.router.navigate(['/system'])
- this.message.create('success', `登录成功`);
+ this.http.get('/api/Accounts/Profile').subscribe({
+ next: (data: any) => {
+ console.log('登录用户信息', data)
+ this.isLoading = false;
+ this.rememberInfo()
+ this.autoLogin()
+ this.router.navigate(['/system'])
+ this.message.create('success', `登录成功`);
+ sessionStorage.setItem("userData", JSON.stringify(data));
+ },
+ error: (err) => {
+ this.isLoading = false;
+ }
+ })
+
},
error: (err) => {
this.isLoading = false;
}
- }
-
- )
+ })
}
forget() {