修改权限问题,去掉不要的代码
This commit is contained in:
+10
-8
@@ -79,12 +79,13 @@
|
||||
this.menuData = this.addLevel(treeData, 1);
|
||||
},
|
||||
getSysMenu() {
|
||||
this.$api.role.sysRoleGetRoleHome({roleId: this.$store.state.userInfo.roleIdList[0]}).then(({data}) => {
|
||||
this.$api.menu.getSysMenu({roleId: this.$store.state.userInfo.roleIdList[0]}).then(({data}) => {
|
||||
debugger
|
||||
if (data === null) {
|
||||
data = []
|
||||
}
|
||||
data = data.sort((a, b) => a.sort - b.sort);
|
||||
let menu = data;//.filter(item => item.belong);
|
||||
let menu = data.filter(item => item.belong);
|
||||
let menuData = [];
|
||||
let menuFun = (menu) => {
|
||||
menuData = [...menuData, ...menu]
|
||||
@@ -110,7 +111,7 @@
|
||||
treeData.forEach(item => {
|
||||
obj[item.id] = item;
|
||||
})
|
||||
|
||||
debugger
|
||||
this.$store.commit('saveMenuData', Object.values(obj));
|
||||
|
||||
this.getMenu();
|
||||
@@ -119,12 +120,13 @@
|
||||
},
|
||||
created() {
|
||||
// 判定菜单是否存在,存在则不加载
|
||||
let menuData = this.$store.state.menuData;
|
||||
if (menuData.length == 0) {
|
||||
// let menuData = this.$store.state.menuData;
|
||||
// debugger
|
||||
// if (menuData.length == 0) {
|
||||
this.getSysMenu();
|
||||
} else {
|
||||
this.getMenu();
|
||||
}
|
||||
// } else {
|
||||
// this.getMenu();
|
||||
// }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
+54
-45
@@ -21,8 +21,8 @@
|
||||
<vxe-column show-overflow show-header-overflow title="操作" width="250" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="modifyRow(row)">编辑</el-button>
|
||||
<el-button type="text" @click="openPermission(row, 2)">角色权限</el-button>
|
||||
<el-button type="text" @click="openPermission(row, 1)">首页权限</el-button>
|
||||
<el-button type="text" @click="openPermission(row)">角色权限</el-button>
|
||||
<!-- <el-button type="text" @click="openPermission(row, 1)">首页权限</el-button>-->
|
||||
<el-button type="text" class="del-btn" @click="delSysRole(row)">删除</el-button>
|
||||
</template>
|
||||
</vxe-column>
|
||||
@@ -46,7 +46,7 @@
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 角色权限 -->
|
||||
<el-dialog :title="isHomePage === 2 ? '角色权限' : '首页权限'" :visible.sync="dialogPermission" width="750px" :close-on-click-modal="false"
|
||||
<el-dialog title="角色权限" :visible.sync="dialogPermission" width="750px" :close-on-click-modal="false"
|
||||
:close-on-press-escape="false" modal-append-to-body append-to-body>
|
||||
<div class="permission-form">
|
||||
<vxe-table ref="rolePermission" :data="treeData" :empty-render="{name: 'NotData'}" align="left" border height="300px" row-id="id"
|
||||
@@ -64,11 +64,12 @@
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
<div class="done">
|
||||
<template v-if="isHomePage === 1">
|
||||
<el-button type="primary" @click="sysRoleSaveRoleHome">确定</el-button>
|
||||
<el-button @click="getSysHome(roleId)">重置</el-button>
|
||||
</template>
|
||||
<template v-if="isHomePage === 2">
|
||||
<!-- <template v-if="isHomePage === 1">-->
|
||||
<!-- <el-button type="primary" @click="sysRoleSaveRoleHome">确定</el-button>-->
|
||||
<!-- <el-button @click="getSysHome(roleId)">重置</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- <template v-if="isHomePage === 2">-->
|
||||
<template>
|
||||
<el-button type="primary" @click="sysRoleSaveRoleMenu">确定</el-button>
|
||||
<el-button @click="getSysMenu(roleId)">重置</el-button>
|
||||
</template>
|
||||
@@ -95,11 +96,12 @@ export default {
|
||||
dialogPermission: false,
|
||||
treeData: [],
|
||||
checkboxConfig: {
|
||||
checkRowKeys: []
|
||||
checkRowKeys: [],
|
||||
checkStrictly: true
|
||||
},
|
||||
roleId: '',
|
||||
tableKey: uuidv4(),
|
||||
isHomePage: null, // 配置首页 1首页 2权限
|
||||
// isHomePage: null, // 配置首页 1首页 2权限
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -170,25 +172,25 @@ export default {
|
||||
},
|
||||
/* =============================================== 角色权限 =============================================== */
|
||||
// 获取菜单
|
||||
openPermission(row, type) {
|
||||
openPermission(row) {
|
||||
this.roleId = row.rid;
|
||||
this.isHomePage = type;
|
||||
if(type === 2){
|
||||
// this.isHomePage = type;
|
||||
// if(type === 2){
|
||||
this.$api.menu.getSysMenu({roleId: row.rid}).then(({data}) => {
|
||||
this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
|
||||
this.tableKey = uuidv4();
|
||||
this.dialogPermission = true;
|
||||
})
|
||||
}else if(type === 1) {
|
||||
this.$api.role.sysRoleGetRoleHome({roleId: row.rid}).then(({data}) => {
|
||||
if(data === null){
|
||||
data = []
|
||||
}
|
||||
this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
|
||||
this.tableKey = uuidv4();
|
||||
this.dialogPermission = true;
|
||||
})
|
||||
}
|
||||
// }else if(type === 1) {
|
||||
// this.$api.role.sysRoleGetRoleHome({roleId: row.rid}).then(({data}) => {
|
||||
// if(data === null){
|
||||
// data = []
|
||||
// }
|
||||
// this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
|
||||
// this.tableKey = uuidv4();
|
||||
// this.dialogPermission = true;
|
||||
// })
|
||||
// }
|
||||
},
|
||||
// 获取权限
|
||||
getSysMenu(roleId){
|
||||
@@ -198,18 +200,25 @@ export default {
|
||||
})
|
||||
},
|
||||
// 获取首页
|
||||
getSysHome(roleId){
|
||||
this.$api.role.sysRoleGetRoleHome({roleId}).then(({data}) => {
|
||||
if(data === null){
|
||||
data = []
|
||||
}
|
||||
this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
|
||||
this.tableKey = uuidv4();
|
||||
})
|
||||
},
|
||||
// getSysHome(roleId){
|
||||
// this.$api.role.sysRoleGetRoleHome({roleId}).then(({data}) => {
|
||||
// if(data === null){
|
||||
// data = []
|
||||
// }
|
||||
// this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
|
||||
// this.tableKey = uuidv4();
|
||||
// })
|
||||
// },
|
||||
// 添加权限
|
||||
sysRoleSaveRoleMenu() {
|
||||
let ids = this.$refs.rolePermission.getCheckboxRecords().map(item => item.id);
|
||||
// 获取全部选中和半选中的数据
|
||||
let checkedData = this.$refs.rolePermission.getCheckboxRecords();
|
||||
let indeterminateData = this.$refs.rolePermission.getCheckboxIndeterminateRecords();
|
||||
|
||||
let allCheckData = [];
|
||||
allCheckData = checkedData.concat(indeterminateData);
|
||||
|
||||
let ids = allCheckData.map(item => item.id);
|
||||
let params = {
|
||||
rid: this.roleId,
|
||||
menusstr: ids
|
||||
@@ -219,18 +228,18 @@ export default {
|
||||
this.dialogPermission = false;
|
||||
})
|
||||
},
|
||||
// 首页配置
|
||||
sysRoleSaveRoleHome(){
|
||||
let ids = this.$refs.rolePermission.getCheckboxRecords().map(item => item.id);
|
||||
let params = {
|
||||
rid: this.roleId,
|
||||
menusstr: ids
|
||||
}
|
||||
this.$api.role.sysRoleSaveRoleHome(params).then(_ => {
|
||||
this.$message.success('操作成功');
|
||||
this.dialogPermission = false;
|
||||
})
|
||||
},
|
||||
// // 首页配置
|
||||
// sysRoleSaveRoleHome(){
|
||||
// let ids = this.$refs.rolePermission.getCheckboxRecords().map(item => item.id);
|
||||
// let params = {
|
||||
// rid: this.roleId,
|
||||
// menusstr: ids
|
||||
// }
|
||||
// this.$api.role.sysRoleSaveRoleHome(params).then(_ => {
|
||||
// this.$message.success('操作成功');
|
||||
// this.dialogPermission = false;
|
||||
// })
|
||||
// },
|
||||
|
||||
// 菜单
|
||||
sysMenuFindAllMenus() {
|
||||
|
||||
Reference in New Issue
Block a user