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