优化菜单设置权限功能,懒人版一件选中权限

master
lemon橪 2021-08-06 11:58:53 +08:00
parent 1fe7c050a4
commit 4c217b85e9
1 changed files with 39 additions and 32 deletions

View File

@ -76,22 +76,22 @@
<!-- 保存权限弹出选择权限 --> <!-- 保存权限弹出选择权限 -->
<Modal width="800" v-model="selectIsSuperModel" title="选择菜单权限" :loading="superModelLoading" @on-ok="saveRole"> <Modal width="800" v-model="selectIsSuperModel" title="选择菜单权限" :loading="superModelLoading" @on-ok="saveRole">
<!-- <div class="btns"> <div class="btns">
<Button type="primary" class="btn-item">一键选中·数据权限</Button> <Button type="primary" @click="setRole()" class="btn-item">一键选中·数据权限</Button>
<Button class="btn-item">一键选中·查看权</Button> <Button class="btn-item" @click="setRole('onlyView')">·</Button>
</div> --> </div>
<div class="role-list"> <div class="role-list">
<div class="role-item" v-for="(item, index) in saveRoleWay" :key="index"> <div class="role-item" v-for="(item, index) in saveRoleWay" :key="index">
<div class="title">{{ item.title }}</div> <div class="title">{{ item.title }}</div>
<div class="content"> <div class="content">
<RadioGroup type="button" button-style="solid" v-model="item.isSuper"> <RadioGroup type="button" button-style="solid" v-model="item.isSuper">
<Radio :label="true"> <Radio :label="true">
<span>操作数据权限</span> <span>操作数据权限</span>
</Radio> </Radio>
<Radio :label="false"> <Radio :label="false">
<span>查看权限</span> <span>查看权限</span>
</Radio> </Radio>
</RadioGroup> </RadioGroup>
</div> </div>
</div> </div>
</div> </div>
@ -337,6 +337,17 @@ export default {
this.getRoleList(); this.getRoleList();
}, },
/**
* 设置权限
*/
setRole(val) {
let enable;
val == "onlyView" ? (enable = false) : (enable = true);
this.saveRoleWay.map((item) => {
item.isSuper = enable;
});
},
/** /**
* 查询所有角色 * 查询所有角色
*/ */
@ -515,7 +526,7 @@ export default {
} }
// //
this.checkPermTree(this.permData, rolePerms); this.checkPermTree(this.permData, rolePerms);
console.warn(this.permData);
this.permModalVisible = true; this.permModalVisible = true;
}, },
// //
@ -535,7 +546,6 @@ export default {
}, },
// //
hasPerm(p, rolePerms) { hasPerm(p, rolePerms) {
console.log(p, rolePerms);
if (!rolePerms) return false; if (!rolePerms) return false;
let flag = false; let flag = false;
for (let i = 0; i < rolePerms.length; i++) { for (let i = 0; i < rolePerms.length; i++) {
@ -568,7 +578,6 @@ export default {
let way = []; let way = [];
selectedNodes.forEach((e) => { selectedNodes.forEach((e) => {
console.log(e);
let perm = { let perm = {
title: e.title, title: e.title,
isSuper: e.isSuper, isSuper: e.isSuper,
@ -707,44 +716,42 @@ export default {
display: flex; display: flex;
padding: 20px 0; padding: 20px 0;
align-items: center; align-items: center;
>.title{ > .title {
flex: 2; flex: 2;
text-align: right; text-align: right;
} }
>.content{ > .content {
flex: 10; flex: 10;
} }
} }
.btns{ .btns {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: center;
} }
.btn-item{ .btn-item {
margin-right: 20px; margin-right: 20px;
} }
.permModal { .permModal {
.ivu-modal-body { .ivu-modal-body {
max-height: 560px; max-height: 560px;
overflow: auto; overflow: auto;
} }
} }
.depModal { .depModal {
.ivu-modal-body { .ivu-modal-body {
max-height: 500px; max-height: 500px;
overflow: auto; overflow: auto;
} }
} }
.tips{ .tips {
font-size: 12px; font-size: 12px;
color: #999; color: #999;
margin-left: 8px; margin-left: 8px;
} }
.title{ .title {
font-weight: bold; font-weight: bold;
margin-right: 20px; margin-right: 20px;
} }
</style> </style>