|
|
@ -142,6 +142,7 @@ export default { |
|
|
|
this.pageNo = val; |
|
|
|
this.pageNo = val; |
|
|
|
this.getData(); |
|
|
|
this.getData(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取权限树 |
|
|
|
getPer(){ |
|
|
|
getPer(){ |
|
|
|
if(!this.permissions.length){ |
|
|
|
if(!this.permissions.length){ |
|
|
|
this.$get(this.api.queryPermissionMenu).then(res => { |
|
|
|
this.$get(this.api.queryPermissionMenu).then(res => { |
|
|
@ -156,11 +157,13 @@ export default { |
|
|
|
this.permissions.length && this.$refs.per.setCheckedNodes([]) |
|
|
|
this.permissions.length && this.$refs.per.setCheckedNodes([]) |
|
|
|
this.roleVisible = true |
|
|
|
this.roleVisible = true |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 递归处理勾选的权限 |
|
|
|
handleRolePer(data,permissions){ |
|
|
|
handleRolePer(data,permissions){ |
|
|
|
let result = data |
|
|
|
let result = data |
|
|
|
if(permissions.length){ |
|
|
|
if(permissions.length){ |
|
|
|
permissions.map(e => { |
|
|
|
permissions.map(e => { |
|
|
|
if(result.includes(e.id) && e.children.length){ |
|
|
|
if(result.includes(e.id) && e.children.length){ |
|
|
|
|
|
|
|
// 如果该权限下的子权限不是每个都勾选了,就把该权限的id从已勾选的id集合里去除,因为如果不去除的话,这个权限就会勾选,同时会把该权限下的所有子权限都一起勾选 |
|
|
|
e.children.every(n => result.includes(n)) || result.splice(result.indexOf(e.id),1) |
|
|
|
e.children.every(n => result.includes(n)) || result.splice(result.indexOf(e.id),1) |
|
|
|
} |
|
|
|
} |
|
|
|
e.children.length && this.handleRolePer(data,e.children) |
|
|
|
e.children.length && this.handleRolePer(data,e.children) |
|
|
@ -204,6 +207,7 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
let roleRes = await this.$post(this.api.saveOrUpdate,roleData) |
|
|
|
let roleRes = await this.$post(this.api.saveOrUpdate,roleData) |
|
|
|
if(roleRes.success){ |
|
|
|
if(roleRes.success){ |
|
|
|
|
|
|
|
// 获取已勾选的,和半勾选的(即子级没有全部勾选的节点),半勾选的一样要传给后端 |
|
|
|
let permissionId = [...this.$refs.per.getHalfCheckedKeys(),...this.$refs.per.getCheckedKeys()] |
|
|
|
let permissionId = [...this.$refs.per.getHalfCheckedKeys(),...this.$refs.per.getCheckedKeys()] |
|
|
|
let perData = { |
|
|
|
let perData = { |
|
|
|
clientId: this.clientId, |
|
|
|
clientId: this.clientId, |
|
|
|