|
@ -45,16 +45,9 @@ |
|
|
prop="name" |
|
|
prop="name" |
|
|
label="角色名" |
|
|
label="角色名" |
|
|
sortable="custom" |
|
|
sortable="custom" |
|
|
width="180" |
|
|
:align="'left'" |
|
|
align="left" |
|
|
|
|
|
/> |
|
|
/> |
|
|
<el-table-column |
|
|
<el-table-column label="操作" :align="'center'" width="150"> |
|
|
prop="extraProperties.Description" |
|
|
|
|
|
label="角色描述" |
|
|
|
|
|
align="left" |
|
|
|
|
|
:show-overflow-tooltip="true" |
|
|
|
|
|
/> |
|
|
|
|
|
<el-table-column label="操作" align="center" width="150"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
<template slot-scope="scope"> |
|
|
<el-button |
|
|
<el-button |
|
|
type="text" |
|
|
type="text" |
|
@ -73,8 +66,6 @@ |
|
|
> |
|
|
> |
|
|
</template> |
|
|
</template> |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
|
<!-- <el-table-column prop="address" label="创建时间" /> |
|
|
|
|
|
<el-table-column prop="address" label="编辑" /> --> |
|
|
|
|
|
</el-table> |
|
|
</el-table> |
|
|
</div> |
|
|
</div> |
|
|
<div class="Footer"> |
|
|
<div class="Footer"> |
|
@ -97,7 +88,11 @@ |
|
|
> |
|
|
> |
|
|
</div> |
|
|
</div> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col :md="8" v-permission="['AbpIdentity.Roles.Update']"> |
|
|
<el-col |
|
|
|
|
|
v-loading="treeLoading" |
|
|
|
|
|
:md="8" |
|
|
|
|
|
v-permission="['AbpIdentity.Roles.Update']" |
|
|
|
|
|
> |
|
|
<el-card class="box-card" shadow="never"> |
|
|
<el-card class="box-card" shadow="never"> |
|
|
<div slot="header" class="clearfix" style="height: 20px"> |
|
|
<div slot="header" class="clearfix" style="height: 20px"> |
|
|
<el-tooltip |
|
|
<el-tooltip |
|
@ -109,24 +104,24 @@ |
|
|
<span class="role-span">【{{name}}角色】模块权限</span> |
|
|
<span class="role-span">【{{name}}角色】模块权限</span> |
|
|
</el-tooltip> |
|
|
</el-tooltip> |
|
|
<el-button |
|
|
<el-button |
|
|
:loading="savePerLoading" |
|
|
:loading="treeLoading" |
|
|
:disabled="multipleSelection.length != 1" |
|
|
:disabled="multipleSelection.length != 1" |
|
|
icon="el-icon-check" |
|
|
icon="el-icon-check" |
|
|
size="mini" |
|
|
size="mini" |
|
|
style="float: right; padding: 6px 9px" |
|
|
style="float: right; padding: 6px 9px" |
|
|
type="primary" |
|
|
type="primary" |
|
|
@click="savePer" |
|
|
@click="savePer" |
|
|
>保存 |
|
|
v-permission="['AbpIdentity.Roles.ManagePermissions']" |
|
|
</el-button> |
|
|
v-if="name != 'admin'" |
|
|
|
|
|
>保存</el-button> |
|
|
</div> |
|
|
</div> |
|
|
<el-tree |
|
|
<el-tree |
|
|
ref="tree" |
|
|
ref="tree" |
|
|
v-loading="treeLoading" |
|
|
|
|
|
:check-strictly="false" |
|
|
:check-strictly="false" |
|
|
:data="permissionsData" |
|
|
:data="permissionsData" |
|
|
:props="defaultProps" |
|
|
:props="defaultProps" |
|
|
show-checkbox |
|
|
show-checkbox |
|
|
node-key="id" |
|
|
node-key="name" |
|
|
class="permission-tree" |
|
|
class="permission-tree" |
|
|
/> |
|
|
/> |
|
|
</el-card> |
|
|
</el-card> |
|
@ -149,16 +144,6 @@ |
|
|
<el-form-item label="名称" prop="name"> |
|
|
<el-form-item label="名称" prop="name"> |
|
|
<el-input v-model="form.name" style="width: 380px" maxlength="23" /> |
|
|
<el-input v-model="form.name" style="width: 380px" maxlength="23" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item label="描述"> |
|
|
|
|
|
<el-input |
|
|
|
|
|
type="textarea" |
|
|
|
|
|
:rows="2" |
|
|
|
|
|
placeholder="请输入描述信息" |
|
|
|
|
|
style="width: 380px" |
|
|
|
|
|
v-model="form.extraProperties.Description" |
|
|
|
|
|
> |
|
|
|
|
|
</el-input> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-form> |
|
|
</el-form> |
|
|
<div slot="footer" class="dialog-footer"> |
|
|
<div slot="footer" class="dialog-footer"> |
|
|
<el-button @click="resetform">取 消</el-button> |
|
|
<el-button @click="resetform">取 消</el-button> |
|
@ -170,13 +155,12 @@ |
|
|
<script> |
|
|
<script> |
|
|
import { |
|
|
import { |
|
|
getPageListRoles, |
|
|
getPageListRoles, |
|
|
getpermissionsRoles, |
|
|
getPermissionsRoles, |
|
|
menuPermissions, |
|
|
savePermissionsRoles, |
|
|
|
|
|
updatePermissionsGranted, |
|
|
postCreateRoles, |
|
|
postCreateRoles, |
|
|
postUpdateRoles, |
|
|
postUpdateRoles, |
|
|
postDeleteRoles, |
|
|
postDeleteRoles, |
|
|
putpermissionsRoles, |
|
|
|
|
|
saveOrUpdateDescribe |
|
|
|
|
|
} from "@/api/wms-auth"; |
|
|
} from "@/api/wms-auth"; |
|
|
import permission from "@/utils/permission/index"; |
|
|
import permission from "@/utils/permission/index"; |
|
|
import searchNormal from "@/components/searchNormal/index.vue" |
|
|
import searchNormal from "@/components/searchNormal/index.vue" |
|
@ -192,8 +176,6 @@ export default { |
|
|
URL: 'identity/roles', |
|
|
URL: 'identity/roles', |
|
|
// 角色名称 |
|
|
// 角色名称 |
|
|
name: '', |
|
|
name: '', |
|
|
//所有权限 |
|
|
|
|
|
rolesAll: [], |
|
|
|
|
|
//编辑弹出 |
|
|
//编辑弹出 |
|
|
dialogVisible: false, |
|
|
dialogVisible: false, |
|
|
//创建与编辑判断 |
|
|
//创建与编辑判断 |
|
@ -210,12 +192,6 @@ export default { |
|
|
pagesize: 20, |
|
|
pagesize: 20, |
|
|
Sorting: "", |
|
|
Sorting: "", |
|
|
}, |
|
|
}, |
|
|
// Thecurrent: '', |
|
|
|
|
|
//选择添加分组 |
|
|
|
|
|
//筛选栏分组 |
|
|
|
|
|
// value1: '', |
|
|
|
|
|
//报表组 |
|
|
|
|
|
// roleList: [], |
|
|
|
|
|
//当前用户ID |
|
|
//当前用户ID |
|
|
usersId: "", |
|
|
usersId: "", |
|
|
//编辑参数 |
|
|
//编辑参数 |
|
@ -225,14 +201,9 @@ export default { |
|
|
name: "", |
|
|
name: "", |
|
|
isDefault: true, |
|
|
isDefault: true, |
|
|
isPublic: true, |
|
|
isPublic: true, |
|
|
extraProperties: { |
|
|
|
|
|
Description: "", |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
// 左侧table加载 |
|
|
// 左侧table加载 |
|
|
tableLoading:false, |
|
|
tableLoading:false, |
|
|
//权限模板保存按钮加载 |
|
|
|
|
|
savePerLoading: false, |
|
|
|
|
|
//权限模板树形控件加载 |
|
|
//权限模板树形控件加载 |
|
|
treeLoading: false, |
|
|
treeLoading: false, |
|
|
//权限模板树形控件默认勾选的数组 |
|
|
//权限模板树形控件默认勾选的数组 |
|
@ -241,7 +212,7 @@ export default { |
|
|
permissionsData: [], |
|
|
permissionsData: [], |
|
|
defaultProps: { |
|
|
defaultProps: { |
|
|
children: "children", |
|
|
children: "children", |
|
|
label: "name", |
|
|
label: "displayName", |
|
|
}, |
|
|
}, |
|
|
//渲染权限模板参数 |
|
|
//渲染权限模板参数 |
|
|
params: { |
|
|
params: { |
|
@ -269,45 +240,6 @@ export default { |
|
|
this.pageList(); |
|
|
this.pageList(); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
//sort 按照排序字段(现在为数字) 默认sort |
|
|
|
|
|
sortData(sort){ |
|
|
|
|
|
return function(a,b){ |
|
|
|
|
|
const val1 = a[sort]; |
|
|
|
|
|
const val2 = b[sort]; |
|
|
|
|
|
return val1 - val2; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 树状图格式化数据 |
|
|
|
|
|
initTreeData(list,code = ""){ |
|
|
|
|
|
const children = [] |
|
|
|
|
|
// 对于list,每个元素.如果他的parentCode==code,他就是当前的children |
|
|
|
|
|
list.forEach(item => { |
|
|
|
|
|
if (item['parentCode'] == code) { |
|
|
|
|
|
// children.push(item) |
|
|
|
|
|
children.push( |
|
|
|
|
|
{ |
|
|
|
|
|
id: item.id, |
|
|
|
|
|
displayName: item.permission, |
|
|
|
|
|
name: item.name, |
|
|
|
|
|
parentCode: item.parentCode, |
|
|
|
|
|
code: item.code, |
|
|
|
|
|
sort: item.sort, |
|
|
|
|
|
children: [] |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
//排序 |
|
|
|
|
|
children.find(findItem => findItem.id == item.id).children=this.initTreeData(list,item['code']).sort(this.sortData('sort')) |
|
|
|
|
|
this.rolesAll.forEach(itemRes => { |
|
|
|
|
|
if (item.permission == itemRes.name) { |
|
|
|
|
|
if (itemRes.isGranted) { |
|
|
|
|
|
this.checkedPermission.push(item.id); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
return children |
|
|
|
|
|
}, |
|
|
|
|
|
//请求数据渲染table |
|
|
//请求数据渲染table |
|
|
pageList(val) { |
|
|
pageList(val) { |
|
|
const data = { |
|
|
const data = { |
|
@ -335,7 +267,6 @@ export default { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
this.queryInfo.Sorting = prop + " " + order; |
|
|
this.queryInfo.Sorting = prop + " " + order; |
|
|
// alert(this.listQuery.Sorting) |
|
|
|
|
|
this.handleFilter(); |
|
|
this.handleFilter(); |
|
|
}, |
|
|
}, |
|
|
//排序触发页面更新 |
|
|
//排序触发页面更新 |
|
@ -363,7 +294,6 @@ export default { |
|
|
this.$refs.form.resetFields(); |
|
|
this.$refs.form.resetFields(); |
|
|
this.dialogVisible = false; |
|
|
this.dialogVisible = false; |
|
|
this.form.name = ""; |
|
|
this.form.name = ""; |
|
|
this.form.extraProperties.Description = ""; |
|
|
|
|
|
this.$refs.multipleTable.clearSelection(); |
|
|
this.$refs.multipleTable.clearSelection(); |
|
|
}, |
|
|
}, |
|
|
//创建角色 |
|
|
//创建角色 |
|
@ -388,7 +318,6 @@ export default { |
|
|
this.usersId = row.id; |
|
|
this.usersId = row.id; |
|
|
this.form.name = row.name; |
|
|
this.form.name = row.name; |
|
|
this.concurrencyStamp = row.concurrencyStamp; |
|
|
this.concurrencyStamp = row.concurrencyStamp; |
|
|
this.form.extraProperties.Description = row.extraProperties.Description; |
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
//删除 |
|
|
//删除 |
|
@ -405,6 +334,7 @@ export default { |
|
|
postDeleteRoles(row.id).then((res) => { |
|
|
postDeleteRoles(row.id).then((res) => { |
|
|
this.$successMsg("删除成功!"); |
|
|
this.$successMsg("删除成功!"); |
|
|
this.pageList(); |
|
|
this.pageList(); |
|
|
|
|
|
this.permissionsData = [] |
|
|
}); |
|
|
}); |
|
|
}) |
|
|
}) |
|
|
.catch(() => {}); |
|
|
.catch(() => {}); |
|
@ -416,7 +346,6 @@ export default { |
|
|
if (valid && !this.isEdit) { |
|
|
if (valid && !this.isEdit) { |
|
|
postCreateRoles(this.form) |
|
|
postCreateRoles(this.form) |
|
|
.then((res) => { |
|
|
.then((res) => { |
|
|
this.saveOrUpdateDescribe(res.id) |
|
|
|
|
|
this.resetform(); |
|
|
this.resetform(); |
|
|
this.$successMsg("创建成功!"); |
|
|
this.$successMsg("创建成功!"); |
|
|
this.queryInfo.currentPage = 1; |
|
|
this.queryInfo.currentPage = 1; |
|
@ -432,7 +361,6 @@ export default { |
|
|
postUpdateRoles(data, this.usersId) |
|
|
postUpdateRoles(data, this.usersId) |
|
|
.then((res) => { |
|
|
.then((res) => { |
|
|
this.$successMsg("编辑成功!"); |
|
|
this.$successMsg("编辑成功!"); |
|
|
this.saveOrUpdateDescribe(this.usersId) |
|
|
|
|
|
this.pageList(); |
|
|
this.pageList(); |
|
|
this.resetform(); |
|
|
this.resetform(); |
|
|
}) |
|
|
}) |
|
@ -445,149 +373,60 @@ export default { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
// 描述特殊储存处理 |
|
|
|
|
|
saveOrUpdateDescribe (id) { |
|
|
|
|
|
saveOrUpdateDescribe({description:this.form.extraProperties.Description}, id).then(res => { |
|
|
|
|
|
// console.log(res) |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
console.log(err) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
handleSelectionChange(val) { |
|
|
handleSelectionChange(val) { |
|
|
this.multipleSelection = val; |
|
|
this.multipleSelection = val; |
|
|
}, |
|
|
}, |
|
|
//模板权限保存 |
|
|
//模板权限保存 |
|
|
savePer() { |
|
|
savePer(){ |
|
|
this.savePerLoading = true; |
|
|
let _allList = [] |
|
|
let params = {}; |
|
|
|
|
|
let checkedKeys = this.$refs.tree.getCheckedKeys(); |
|
|
let checkedKeys = this.$refs.tree.getCheckedKeys(); |
|
|
params.permissions = []; |
|
|
this.permissionsData.forEach(item=>{ |
|
|
this.permissionsData.forEach((element) => { |
|
|
// 菜单层级 |
|
|
element.children.forEach((item) => { |
|
|
item.children.forEach(item_menu=>{ |
|
|
let perm = {}; |
|
|
let _Granted1 = checkedKeys.indexOf(item_menu.name) >= 0 ? true : false |
|
|
perm.name = item.displayName; |
|
|
_allList.push({isGranted:_Granted1,name:item_menu.name}) |
|
|
perm.isGranted = false; |
|
|
// 增删改层级 |
|
|
if (checkedKeys.indexOf(item.id) > -1) { |
|
|
if(item_menu.children){ |
|
|
perm.isGranted = true; |
|
|
item_menu.children.forEach(item_handle=>{ |
|
|
} |
|
|
let _Granted2 = checkedKeys.indexOf(item_handle.name) >= 0 ? true : false |
|
|
// 赋值节点下的增删改权限 |
|
|
_allList.push({isGranted:_Granted2,name:item_handle.name}) |
|
|
this.getZSG(item.displayName, params, perm.isGranted) |
|
|
// 如果增删改有已选,更改父级为true |
|
|
params.permissions.push(perm); |
|
|
if(_Granted2){ |
|
|
item.children.forEach((i) => { |
|
|
_allList.forEach((allItem)=>{ |
|
|
let perm = {}; |
|
|
if(allItem.name == item_handle.parentName){ |
|
|
perm.name = i.displayName; |
|
|
allItem.isGranted = true |
|
|
perm.isGranted = false; |
|
|
} |
|
|
if (checkedKeys.indexOf(i.id) > -1) { |
|
|
}) |
|
|
perm.isGranted = true; |
|
|
} |
|
|
} |
|
|
|
|
|
// 赋值节点下的增删改权限 |
|
|
|
|
|
this.getZSG(i.displayName, params, perm.isGranted) |
|
|
|
|
|
params.permissions.push(perm); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
params.permissions.forEach((item,index) => { |
|
|
|
|
|
// 排除二级菜单 |
|
|
|
|
|
if (item.name == 'skip') { |
|
|
|
|
|
params.permissions.splice(index, 1) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用户权限 | 角色权限 包含其子节点 创建,编辑,删除,更改 |
|
|
|
|
|
if (item.name == 'AbpIdentity.Users' ) { |
|
|
|
|
|
if (item.isGranted) { |
|
|
|
|
|
params.permissions.push({ |
|
|
|
|
|
isGranted: true, |
|
|
|
|
|
name: 'AbpIdentity.Users.Create' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: true, |
|
|
|
|
|
name: 'AbpIdentity.Users.Update' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: true, |
|
|
|
|
|
name: 'AbpIdentity.Users.Delete' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: true, |
|
|
|
|
|
name: 'AbpIdentity.Users.ManagePermissions' |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
params.permissions.push({ |
|
|
|
|
|
isGranted: false, |
|
|
|
|
|
name: 'AbpIdentity.Users.Create' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: false, |
|
|
|
|
|
name: 'AbpIdentity.Users.Update' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: false, |
|
|
|
|
|
name: 'AbpIdentity.Users.Delete' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: false, |
|
|
|
|
|
name: 'AbpIdentity.Users.ManagePermissions' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (item.name == 'AbpIdentity.Roles' ) { |
|
|
|
|
|
if (item.isGranted) { |
|
|
|
|
|
params.permissions.push({ |
|
|
|
|
|
isGranted: true, |
|
|
|
|
|
name: 'AbpIdentity.Roles.Create' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: true, |
|
|
|
|
|
name: 'AbpIdentity.Roles.Update' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: true, |
|
|
|
|
|
name: 'AbpIdentity.Roles.Delete' |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
params.permissions.push({ |
|
|
|
|
|
isGranted: false, |
|
|
|
|
|
name: 'AbpIdentity.Roles.Create' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: false, |
|
|
|
|
|
name: 'AbpIdentity.Roles.Update' |
|
|
|
|
|
},{ |
|
|
|
|
|
isGranted: false, |
|
|
|
|
|
name: 'AbpIdentity.Roles.Delete' |
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 修改必备权限,否则菜单无法正常显示 ************************* |
|
|
|
|
|
params.permissions.filter((item) => { |
|
|
|
|
|
if (item.name == 'AbpIdentity.Roles.ManagePermissions' || item.name == 'Auth.UserMenu') { |
|
|
|
|
|
item.isGranted = true |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
this.treeLoading = true; |
|
|
putpermissionsRoles( |
|
|
savePermissionsRoles( |
|
|
"/permission-management/permissions?providerName=R&providerKey=" + |
|
|
`/permission-management/permissions?providerName=${this.params.providerName}&providerKey=${this.multipleSelection[0].name}`, |
|
|
this.multipleSelection[0].name, |
|
|
{permissions:_allList} |
|
|
params |
|
|
|
|
|
).then((response) => { |
|
|
).then((response) => { |
|
|
this.$notify({ |
|
|
updatePermissionsGranted(this.params.providerName,this.multipleSelection[0].name).then(()=>{ |
|
|
title: "成功", |
|
|
this.$notify({ |
|
|
message: "更新成功", |
|
|
title: "成功", |
|
|
type: "success", |
|
|
message: "更新成功", |
|
|
duration: 2000, |
|
|
type: "success", |
|
|
}); |
|
|
duration: 2000, |
|
|
this.savePerLoading = false; |
|
|
}); |
|
|
}).catch(err=>{ |
|
|
this.treeLoading = false; |
|
|
this.savePerLoading = false; |
|
|
// 如果更改的是当前用户,则页面刷新 |
|
|
}); |
|
|
if(this.multipleSelection[0].name == this.$store.getters.currentUserInfo.name){ |
|
|
}, |
|
|
location.reload() |
|
|
// 节点下的增删改权限 |
|
|
|
|
|
getZSG(name,params,isGranted) { |
|
|
|
|
|
if (name !== 'skip') { |
|
|
|
|
|
this.rolesAll.forEach(item => { |
|
|
|
|
|
if (item.parentName == name ) { |
|
|
|
|
|
let perm = {} |
|
|
|
|
|
perm.name = item.name |
|
|
|
|
|
perm.isGranted = isGranted |
|
|
|
|
|
params.permissions.push(perm) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
}).catch(()=>{ |
|
|
|
|
|
this.treeLoading = false; |
|
|
}) |
|
|
}) |
|
|
} |
|
|
}).catch(err=>{ |
|
|
|
|
|
this.treeLoading = false; |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
//点击table行渲染权限模板 |
|
|
//点击table行渲染权限模板 |
|
|
handleRowClick(row, column, event) { |
|
|
handleRowClick(row, column, event) { |
|
|
let that = this |
|
|
let that = this |
|
@ -609,50 +448,48 @@ export default { |
|
|
// } |
|
|
// } |
|
|
|
|
|
|
|
|
this.params.providerKey = row.name; |
|
|
this.params.providerKey = row.name; |
|
|
getpermissionsRoles(this.params).then((res) => { |
|
|
getPermissionsRoles(this.params).then((res) => { |
|
|
this.rolesAll = [] |
|
|
|
|
|
this.permissionsData = []; |
|
|
this.permissionsData = []; |
|
|
this.checkedPermission = []; |
|
|
this.checkedPermission = []; |
|
|
// 根据前端菜单,进行重置分组 |
|
|
// 根据前端菜单,进行重置分组 |
|
|
res.groups.forEach(itemRes => { |
|
|
res.groups.forEach((itemRes,indexRes) => { |
|
|
|
|
|
itemRes.children = [] |
|
|
|
|
|
this.permissionsData.push(itemRes) |
|
|
|
|
|
// todo:使用递归优化 |
|
|
itemRes.permissions.forEach(item => { |
|
|
itemRes.permissions.forEach(item => { |
|
|
// if (item.displayName !== '创建' && item.displayName !== '编辑' && item.displayName !== '删除' && item.displayName !== '修改') { |
|
|
if(!item.parentName){ |
|
|
this.rolesAll.push(item) |
|
|
// 当前权限 |
|
|
// } |
|
|
if(item.isGranted)this.checkedPermission.push(item.name) |
|
|
|
|
|
this.permissionsData[indexRes].children.push(item) |
|
|
|
|
|
}else{ |
|
|
|
|
|
// 当前权限 |
|
|
|
|
|
if(item.isGranted)this.checkedPermission.push(item.name) |
|
|
|
|
|
this.permissionsData[indexRes].children.forEach((pItem,pindex)=>{ |
|
|
|
|
|
if(pItem.name == item.parentName){ |
|
|
|
|
|
if(!this.permissionsData[indexRes].children[pindex].children)this.permissionsData[indexRes].children[pindex].children = [] |
|
|
|
|
|
this.permissionsData[indexRes].children[pindex].children.push(item) |
|
|
|
|
|
// 如果children中有一个为flase,当前权限,则删除父级,用于回显 |
|
|
|
|
|
if(item.isGranted == false){ |
|
|
|
|
|
if(this.checkedPermission.indexOf(item.parentName) >= 0){ |
|
|
|
|
|
this.checkedPermission.splice(this.checkedPermission.indexOf(item.parentName),1) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
let filters = [] |
|
|
that.$nextTick(() => { |
|
|
filters.push({ |
|
|
that.$refs.tree.setCheckedKeys(this.checkedPermission) |
|
|
logic: "And", |
|
|
|
|
|
column: "portal", |
|
|
|
|
|
action: "==", |
|
|
|
|
|
value: "0" |
|
|
|
|
|
}) |
|
|
}) |
|
|
const data = { |
|
|
console.log('拥有权限',this.checkedPermission) |
|
|
condition: { |
|
|
console.log('菜单树',this.permissionsData) |
|
|
filters: filters |
|
|
that.treeLoading = false; |
|
|
}, |
|
|
}) |
|
|
Sorting: "", |
|
|
.catch((err)=>{ |
|
|
SkipCount: 0, |
|
|
this.$errorMsg('暂无更改权限') |
|
|
MaxResultCount: 1000, |
|
|
that.treeLoading = false; |
|
|
}; |
|
|
}) |
|
|
menuPermissions(data).then((res) => { |
|
|
|
|
|
let rs = that.initTreeData(res.items,'').sort(that.sortData('sort')) |
|
|
|
|
|
rs.forEach(item => { |
|
|
|
|
|
that.permissionsData.push(item); |
|
|
|
|
|
}) |
|
|
|
|
|
that.$nextTick(() => { |
|
|
|
|
|
that.$refs.tree.setCheckedKeys(that.checkedPermission) |
|
|
|
|
|
}) |
|
|
|
|
|
// console.log('菜单树',that.permissionsData) |
|
|
|
|
|
// console.log('拥有权限',that.checkedPermission) |
|
|
|
|
|
// console.log('所有权限',that.rolesAll) |
|
|
|
|
|
that.treeLoading = false; |
|
|
|
|
|
}).catch((err)=>{ |
|
|
|
|
|
that.treeLoading = false; |
|
|
|
|
|
console.log(err) |
|
|
|
|
|
}) |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|