You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.8 KiB
100 lines
2.8 KiB
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
import { Component, OnInit, Input } from '@angular/core'; |
|
import { NzModalRef } from 'ng-zorro-antd/modal'; |
|
import { HttpClient } from '@angular/common/http'; |
|
import { TreeService } from 'src/app/service/tree.service'; |
|
@Component({ |
|
selector: 'app-editrole', |
|
templateUrl: './editrole.component.html', |
|
styleUrls: ['./editrole.component.scss'] |
|
}) |
|
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) { } |
|
levelList=[] |
|
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 |
|
let level=JSON.parse(sessionStorage.getItem('userdata')).organization.level |
|
let levelList=[ |
|
{level:0,name:'无'}, |
|
{level:1,name:'销售公司'}, |
|
{level:2,name:'省公司'}, |
|
{level:3,name:'区域'}, |
|
{level:4,name:'油站'}, |
|
] |
|
levelList.forEach(e=>{ |
|
if(e.level>=level||e.level==0){ |
|
this.levelList.push(e) |
|
} |
|
}) |
|
this.getMenus() |
|
this.validateForm = this.fb.group({ |
|
name: [null, [Validators.required]], |
|
power: [null], |
|
menus: [null], |
|
organizationsLevel:[null] |
|
}); |
|
if (this.optionList.length == 0) { |
|
this.loadMore() |
|
} |
|
} |
|
getMenus() { |
|
let params = { |
|
Id: this.data.id, |
|
} |
|
this.http.get('/api/services/app/Role/Get', { |
|
params: params |
|
}).subscribe((data: any) => { |
|
let arr = [] |
|
data.result.menus.forEach(element => { |
|
arr.push(element.id) |
|
}); |
|
this.validateForm.patchValue({ |
|
menus: arr |
|
}); |
|
}) |
|
} |
|
totalCount |
|
getAllMenus() { |
|
let params = { |
|
SkipCount: '0', |
|
MaxResultCount: '999' |
|
} |
|
this.http.get('/api/services/app/Menu/GetAll', { |
|
params: params |
|
}).subscribe((data: any) => { |
|
console.log(666, data) |
|
this.totalCount = data.result.totalCount |
|
data.result.items.forEach(element => { |
|
element.key = element.id |
|
element.title = element.name |
|
element.selectable = false |
|
}); |
|
this.nodes = [...this.toTree.toTree(data.result.items)] |
|
}) |
|
} |
|
destroyModal(): void { |
|
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) |
|
}) |
|
} |
|
|
|
}
|
|
|