Browse Source

新增角色级别

beijing
jingbowen 2 years ago
parent
commit
e4f66c82d6
  1. 11
      src/app/system-management/role/addrole/addrole.component.html
  2. 10
      src/app/system-management/role/addrole/addrole.component.ts
  3. 8
      src/app/system-management/role/editrole/editrole.component.html
  4. 13
      src/app/system-management/role/editrole/editrole.component.ts
  5. 5
      src/app/system-management/role/role.component.html
  6. 20
      src/app/system-management/role/role.component.ts

11
src/app/system-management/role/addrole/addrole.component.html

@ -19,6 +19,17 @@
</ng-template>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="组织等级">组织等级</nz-form-label>
<nz-form-control>
<nz-select formControlName="organizationsLevel" nzPlaceHolder="请选择组织等级">
<nz-option *ngFor="let o of levelList" [nzValue]="o.id" [nzLabel]="o.name"></nz-option>
</nz-select>
<ng-template #renderTemplate>
<nz-spin *ngIf="isLoading"></nz-spin>
</ng-template>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="菜单">菜单</nz-form-label>
<nz-form-control>

10
src/app/system-management/role/addrole/addrole.component.ts

@ -26,7 +26,8 @@ export class AddroleComponent implements OnInit {
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
power: [null],
menus: [null]
menus: [null],
organizationsLevel:[null]
});
}
@ -53,6 +54,13 @@ export class AddroleComponent implements OnInit {
this.modal.destroy({ data: 'this the result data' });
}
optionList = [];
levelList=[
{id:0,name:'无'},
{id:1,name:'销售公司'},
{id:2,name:'省公司'},
{id:3,name:'区域'},
{id:4,name:'油站'},
]
isLoading = false;
//获取权限列表
loadMore() {

8
src/app/system-management/role/editrole/editrole.component.html

@ -16,6 +16,14 @@
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="组织等级">组织等级</nz-form-label>
<nz-form-control>
<nz-select [(ngModel)]="levelValue" formControlName="organizationsLevel" nzPlaceHolder="请选择组织等级">
<nz-option *ngFor="let o of levelList" [nzValue]="o.id" [nzLabel]="o.name"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="菜单">菜单</nz-form-label>
<nz-form-control>

13
src/app/system-management/role/editrole/editrole.component.ts

@ -15,18 +15,27 @@ export class EditroleComponent implements OnInit {
@Input() nodes?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
levelList=[
{id:0,name:'无'},
{id:1,name:'销售公司'},
{id:2,name:'省公司'},
{id:3,name:'区域'},
{id:4,name:'油站'},
]
multipleValue: any
levelValue
ngOnInit(): void {
console.log(this.data)
console.log(6666,this.optionList)
this.nodes.length != 0 ? null : this.getAllMenus()
this.multipleValue = this.data.grantedPermissions
this.levelValue=this.data.organizationsLevel
this.getMenus()
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
power: [null],
menus: [null]
menus: [null],
organizationsLevel:[null]
});
if (this.optionList.length == 0) {
this.loadMore()

5
src/app/system-management/role/role.component.html

@ -14,6 +14,7 @@
<tr>
<th style="padding-left: 40px;">角色</th>
<th [nzWidth]="'60%'">权限</th>
<th>等级</th>
<th>创建/修改时间</th>
<th>操作</th>
</tr>
@ -24,9 +25,13 @@
<td>
<span *ngFor="let item of data.grantedFlatPermissions">{{item.displayName}}</span>
</td>
<td>
{{data.organizationsLevel}}
</td>
<td>
{{(data.lastModificationTime ? data.lastModificationTime : data.creationTime) | date:"yyyy-MM-dd HH:mm:ss"}}
</td>
<td class="operation">
<a (click)="edit(data)">编辑</a>
<!-- <a (click)="allotMenus(data)">分配菜单</a> -->

20
src/app/system-management/role/role.component.ts

@ -38,7 +38,19 @@ export class RoleComponent implements OnInit {
params: params
}).subscribe((data: any) => {
console.log('角色列表', data.result.items)
this.listOfData = data.result.items
console.log(JSON.parse(sessionStorage.getItem('userdata')));
let level=JSON.parse(sessionStorage.getItem('userdata')).organization.level
data.result.items.forEach(ele=>{
console.log(ele);
if(ele.organizationsLevel>=level||ele.organizationsLevel==0){
this.listOfData.push(ele)
}
})
this.listOfData=[...this.listOfData]
})
}
@ -80,7 +92,8 @@ export class RoleComponent implements OnInit {
let body = {
name: instance.validateForm.value.name,
DisplayName: instance.validateForm.value.name,
grantedPermissions: instance.validateForm.value.power || []
grantedPermissions: instance.validateForm.value.power || [],
organizationsLevel: instance.validateForm.value.organizationsLevel
}
let body2 = instance.validateForm.value.menus || []
this.http.post('/api/services/app/Role/Create', body).subscribe((data: any) => {
@ -132,7 +145,8 @@ export class RoleComponent implements OnInit {
id: item.id,
name: instance.validateForm.value.name,
DisplayName: instance.validateForm.value.name,
grantedPermissions: instance.validateForm.value.power || []
grantedPermissions: instance.validateForm.value.power || [],
organizationsLevel: instance.validateForm.value.organizationsLevel
}
let body2 = instance.validateForm.value.menus || []
this.http.put('/api/services/app/Role/Update', body).subscribe((data: any) => {

Loading…
Cancel
Save