角色管理,修改
This commit is contained in:
+4
-4
@@ -78,7 +78,7 @@
|
||||
</nz-form-item>
|
||||
</div>
|
||||
<div class="user-table">
|
||||
<nz-table [nzShowPagination]='false' #dataSet [nzData]="userList">
|
||||
<nz-table [nzShowPagination]='false' #dataSetShow [nzData]="userList">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>姓名</th>
|
||||
@@ -88,7 +88,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let item of dataSet.data">
|
||||
<tr *ngFor="let item of dataSetShow.data">
|
||||
<td>{{item.real_name}}</td>
|
||||
<td>{{item.login_name}}</td>
|
||||
<td>{{item.mobile}}</td>
|
||||
@@ -170,7 +170,7 @@
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<div class="user-table table-box">
|
||||
<nz-table [nzShowPagination]='false' #dataSet [nzData]="userSelecteds">
|
||||
<nz-table [nzShowPagination]='false' #dataSetSelect [nzData]="userSelecteds">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>姓名</th>
|
||||
@@ -180,7 +180,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let item of dataSet.data;let i=index">
|
||||
<tr *ngFor="let item of dataSetSelect.data;let i=index">
|
||||
<td>{{item.real_name}}</td>
|
||||
<td>{{item.login_name}}</td>
|
||||
<td>{{item.mobile}}</td>
|
||||
|
||||
+4
-4
@@ -14,8 +14,8 @@
|
||||
<nz-form-label [nzSm]="4" [nzXs]="24" nzRequired>角色类型</nz-form-label>
|
||||
<nz-form-control [nzSm]="14" [nzXs]="24">
|
||||
<nz-radio-group formControlName="role_type">
|
||||
<label nz-radio [nzValue]=0>系统内置</label>
|
||||
<label nz-radio [nzValue]=1>用户定义</label>
|
||||
<label nz-radio nzValue='0'>系统内置</label>
|
||||
<label nz-radio nzValue='1'>用户定义</label>
|
||||
</nz-radio-group>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
@@ -26,7 +26,7 @@
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<div class="user-table table-box">
|
||||
<nz-table [nzShowPagination]='false' #dataSet [nzData]="userSelecteds">
|
||||
<nz-table [nzShowPagination]='false' #userDataSet [nzData]="userSelecteds">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>姓名</th>
|
||||
@@ -36,7 +36,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let item of dataSet.data;let i=index">
|
||||
<tr *ngFor="let item of userDataSet.data;let i=index">
|
||||
<td>{{item.real_name}}</td>
|
||||
<td>{{item.login_name}}</td>
|
||||
<td>{{item.mobile}}</td>
|
||||
|
||||
+89
-23
@@ -38,8 +38,9 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
real_name:'',
|
||||
}
|
||||
collectionSize:any ;
|
||||
|
||||
|
||||
public permissionChecked:any=[]; //角色详情的权限列表
|
||||
isLoadingSave:any=false;
|
||||
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
private http:HttpClientService,
|
||||
@@ -51,13 +52,14 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.validateForm = this.fb.group({
|
||||
role_name:[ '', [ Validators.required ] ],
|
||||
role_type:[ 1, [ Validators.required ] ], //0=系统内置(不可删除) ,1=用户定义
|
||||
role_type:[ '1', [ Validators.required ] ], //0=系统内置(不可删除) ,1=用户定义
|
||||
description:[ ''],
|
||||
role_code:[ ''],
|
||||
status:[''],
|
||||
user:[],
|
||||
permission:[],
|
||||
});
|
||||
this.queryTable();
|
||||
//取路由参数
|
||||
this.route.queryParams.subscribe(routeParams=>{
|
||||
this.modifyType=routeParams.operateType;
|
||||
@@ -102,25 +104,42 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
user:users,
|
||||
})
|
||||
console.log(this.validateForm.value)
|
||||
this.http.post('/sysapi/setting/role/add/',this.validateForm.value).subscribe((json)=>{
|
||||
if(json.is_success){
|
||||
this.message.success(`新增成功!`);
|
||||
this.router.navigate(['app/system/roles'])
|
||||
}else{
|
||||
this.message.error(`新增失败!`);
|
||||
}
|
||||
})
|
||||
this.isLoadingSave=true;
|
||||
if(this.modifyType==1){
|
||||
this.http.post('/sysapi/setting/role/add/',this.validateForm.value).subscribe((json)=>{
|
||||
this.isLoadingSave=true;
|
||||
if(json.is_success){
|
||||
this.message.success(`新增成功!`);
|
||||
this.router.navigate(['app/system/roles'])
|
||||
}else{
|
||||
this.message.error(`新增失败!`);
|
||||
}
|
||||
})
|
||||
}else if(this.modifyType==2){
|
||||
this.isLoadingSave=true;
|
||||
this.http.put('/sysapi/setting/role/update/'+this.roleId,this.validateForm.value).subscribe((json)=>{
|
||||
if(json.is_success){
|
||||
this.message.success(`修改成功!`);
|
||||
this.router.navigate(['app/system/roles'])
|
||||
}else{
|
||||
this.message.error(`修改失败!`);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
//修改时查询该角色下的所有用户
|
||||
queryUserById():void{
|
||||
this.http.get('/sysapi/setting/role/users/'+this.roleId).subscribe((json)=>{
|
||||
if(json.is_success){
|
||||
if(json.body&&json.body.length>0){
|
||||
json.body.forEach(item=>{
|
||||
console.log()
|
||||
this.userSelecteds = [ ...this.userSelecteds, item];
|
||||
})
|
||||
}
|
||||
console.log(12121212)
|
||||
console.log(json.body)
|
||||
json.body.forEach(item=>{
|
||||
item.checked=true;
|
||||
item.disabled=false;
|
||||
this.userSelecteds = [ ...this.userSelecteds, item];
|
||||
})
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
@@ -141,7 +160,10 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
role_code:item.role_code,
|
||||
status:item.status,
|
||||
})
|
||||
|
||||
this.permissionChecked=item.permission;
|
||||
console.log(22211111)
|
||||
console.log(this.permissionChecked)
|
||||
this.initTree();
|
||||
}else{
|
||||
this.statusParamsDetail=4;
|
||||
}
|
||||
@@ -164,6 +186,19 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
this.visibleUsers = false;
|
||||
console.log(this.userSelecteds)
|
||||
}
|
||||
//处理机构负责人选择和数据回填
|
||||
userSelect(){
|
||||
if(this.userData){
|
||||
this.userData.forEach(item=>{
|
||||
this.userSelecteds.forEach(option=>{
|
||||
if(item.uid==option.uid){
|
||||
item.checked=true;
|
||||
item.disabled=true;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
//删除机构负责人
|
||||
delectConfirm(item){
|
||||
this.userSelecteds=this.userSelecteds.filter(function(option){
|
||||
@@ -176,7 +211,7 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
this.queryTable();
|
||||
}
|
||||
//关闭机构选择页面
|
||||
close(): void {
|
||||
closeUser(): void {
|
||||
this.visibleUsers = false;
|
||||
}
|
||||
//翻页
|
||||
@@ -189,11 +224,11 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
this.statusParamsUsers.status=1;
|
||||
this.http.get('/sysapi/setting/user/list',this.search).subscribe((json)=>{
|
||||
if(json.is_success){
|
||||
this.userData=json.body.list;
|
||||
let data=json.body.list;
|
||||
this.collectionSize=json.body.total;
|
||||
if(json.body.list&&json.body.list.length>0){
|
||||
this.statusParamsUsers.status=3;
|
||||
this.userData.forEach(item=>{
|
||||
data.forEach(item=>{
|
||||
if(this.userSelecteds.length>0){
|
||||
this.userSelecteds.forEach(option=>{
|
||||
if(item.uid==option.uid){
|
||||
@@ -209,9 +244,14 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
}else{
|
||||
this.statusParamsUsers.status=4;
|
||||
}
|
||||
this.userData=data;
|
||||
console.log(5555)
|
||||
console.log(data)
|
||||
}else{
|
||||
this.statusParamsUsers.status=0;
|
||||
}
|
||||
console.log(66666)
|
||||
console.log(this.userSelecteds)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -256,7 +296,15 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
//新树模型
|
||||
initTree(){
|
||||
this.http.get('/sysapi/setting/permission/menu/list').subscribe(json=>{
|
||||
|
||||
if(json.is_success){
|
||||
if(json.body&&json.body.length>0){
|
||||
if(this.modifyType==2&&this.permissionChecked.length>0){
|
||||
json.body.forEach(item=>{
|
||||
this.foreachNode(item);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
let treeList=[];
|
||||
treeList.push({ //一层目录
|
||||
name:"全部权限",
|
||||
@@ -271,5 +319,23 @@ export class RoleManagementModifyComponent implements OnInit {
|
||||
let node = zTree.getNodes();
|
||||
})
|
||||
}
|
||||
|
||||
//递归方法处理权限树回填
|
||||
foreachNode(node){
|
||||
this.setNode(node);
|
||||
if(node.children&&node.children.length>0){
|
||||
node.children.forEach(item=>{
|
||||
this.foreachNode(item)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
//递归方法,处理单个节点
|
||||
setNode(node){
|
||||
this.permissionChecked.forEach(item=>{
|
||||
if(item.pid==node.id){
|
||||
console.log(node.name)
|
||||
node.checked=true;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user