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