Newer
Older
import {Component, OnInit, ViewChild} from '@angular/core';
import {SystemService} from '../system.service';
import {RoleComponent} from '../modal/role/role.component';
import {SelectPersonComponent} from '../../modal/select-person/select-person.component';
import {SeparationComponent} from '../modal/separation/separation.component';
selector: 'jhi-power',
templateUrl: './power.component.html',
styles: []
@ViewChild('smartSelectPerson') smartSelectPerson:SelectPersonComponent;
constructor(private systemSer: SystemService,private message:NzMessageService,
getRole() {
this.systemSer.role().subscribe(
(res) => {
this.dataSet = res.data;
}
);
this.smartRole.showAddModal();
}
//编辑角色
showEditModal(id){
this.smartRole.showEditModal(id);
}
//授予用户
//但一角色批量添加用户
batchAdduserToRole(e){
let str ="";
e.forEach(res=>{
str += res.id +",";
});
str = str.substring(0,str.length-1);
let formData = new FormData();
formData.append("roleId",this.roleId);
formData.append("users",str);
this.systemSer.batchGrantUserToRole(formData).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("授予成功")
}else{
this.message.error(res.errMsg);
}
}
)
}
//删除角色
deleteRole(data) {
this.modalSer.confirm({
nzTitle:'删除',
nzContent:'<b style="color: red">确定删除该角色</b>',
nzOkText:'确定',
nzOkType:'danger',
nzOnOk:()=>{
this.systemSer.deleteRole(data.id).subscribe(
(res) => {
if(res.errCode == 10000){
this.message.success("删除成功");
this.getRole();
}else{
this.message.error(res.errMsg);
}
//三员分立
showSeparationModal(){
this.smartSeparation.showModal("三员分立");
}