完善角色菜单分配管理
This commit is contained in:
@@ -26,12 +26,5 @@ export default {
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
},
|
||||
|
||||
GetTopMenusByHttpUser() {
|
||||
return myaxios({
|
||||
url: '/Menu/GetTopMenusByHttpUser',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,36 @@
|
||||
import myaxios from '@/util/myaxios'
|
||||
export default {
|
||||
getRole() {
|
||||
getList() {
|
||||
return myaxios({
|
||||
url: '/Role/getRole',
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
setMenuByRole(roleList, menuList) {
|
||||
return myaxios({
|
||||
url: '/Role/setMenuByRole',
|
||||
url: '/Role/GetList',
|
||||
method: 'post',
|
||||
data: { ids1: roleList, ids2: menuList }
|
||||
data: {
|
||||
parameters: [
|
||||
{
|
||||
key: "isDeleted",
|
||||
value: "0",
|
||||
type: 0
|
||||
|
||||
}
|
||||
],
|
||||
orderBys: [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
})
|
||||
},
|
||||
GetTopMenusByRoleId(roleId) {
|
||||
giveRoleSetMenu(roleList, menuList) {
|
||||
return myaxios({
|
||||
url: `/Role/GetTopMenusByRoleId?roleId=${roleId}`,
|
||||
method: 'get'
|
||||
url: '/Role/GiveRoleSetMenu',
|
||||
method: 'put',
|
||||
data: { RoleIds: roleList, menuIds: menuList }
|
||||
})
|
||||
},
|
||||
|
||||
getInMenuByRoleId(roleId) {
|
||||
return myaxios({
|
||||
url: `/Role/GetInMenuByRoleId?roleId=${roleId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -6,30 +6,28 @@
|
||||
角色菜单分配管理 —
|
||||
<small class="text-body-1"
|
||||
>你可以在这里多角色分配多菜单/选中一个可查看</small
|
||||
> </template
|
||||
>
|
||||
<v-divider></v-divider>
|
||||
<app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn>
|
||||
<app-btn class="my-4 mr-4" @click="setMenu">确定分配</app-btn
|
||||
>
|
||||
|
||||
<app-btn class="my-4" color="secondary" @click="clear">清空选择</app-btn></material-card
|
||||
>
|
||||
</template>
|
||||
<v-divider></v-divider>
|
||||
<app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn>
|
||||
<app-btn class="my-4 mr-4" @click="setMenu">确定分配</app-btn>
|
||||
|
||||
<app-btn class="my-4" color="secondary" @click="clear"
|
||||
>清空选择</app-btn
|
||||
></material-card
|
||||
>
|
||||
|
||||
</v-col>
|
||||
|
||||
|
||||
<v-col cols="12" md="4" lg="4">
|
||||
<v-card class="mx-auto" width="100%">
|
||||
<v-treeview
|
||||
|
||||
|
||||
selectable
|
||||
:items="RoleItems"
|
||||
v-model="selectionRole"
|
||||
return-object
|
||||
open-all
|
||||
hoverable
|
||||
item-text="role_name"
|
||||
item-text="roleName"
|
||||
>
|
||||
</v-treeview>
|
||||
</v-card>
|
||||
@@ -38,7 +36,7 @@
|
||||
<v-col cols="12" md="8" lg="8">
|
||||
<v-card class="mx-auto" width="100%">
|
||||
<v-treeview
|
||||
ref="tree"
|
||||
ref="tree"
|
||||
open-on-click
|
||||
selectable
|
||||
:items="Menuitems"
|
||||
@@ -47,7 +45,7 @@
|
||||
return-object
|
||||
open-all
|
||||
hoverable
|
||||
item-text="menu_name"
|
||||
item-text="menuName"
|
||||
>
|
||||
<template v-slot:append="{ item }">
|
||||
<v-btn>id:{{ item.id }}</v-btn>
|
||||
@@ -68,8 +66,12 @@ export default {
|
||||
selectionRole: {
|
||||
handler(val, oldVal) {
|
||||
if (val.length == 1) {
|
||||
roleApi.GetTopMenusByRoleId(val[0].id).then((resp) => {
|
||||
this.selectionMenu = resp.data;
|
||||
roleApi.getInMenuByRoleId(val[0].id).then((resp) => {
|
||||
if (resp.data.menus == null) {
|
||||
this.selectionMenu = [];
|
||||
} else {
|
||||
this.selectionMenu = resp.data.menus;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -77,9 +79,9 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
showAll(){
|
||||
this.$refs.tree.updateAll(true);
|
||||
},
|
||||
showAll() {
|
||||
this.$refs.tree.updateAll(true);
|
||||
},
|
||||
clear() {
|
||||
this.selectionMenu = [];
|
||||
this.selectionRole = [];
|
||||
@@ -93,20 +95,20 @@ export default {
|
||||
this.selectionMenu.forEach((ele) => {
|
||||
menuIds.push(ele.id);
|
||||
});
|
||||
roleApi.setMenuByRole(roleIds, menuIds).then((resp) => {
|
||||
this.$dialog.notify.info(resp.msg, {
|
||||
roleApi.giveRoleSetMenu(roleIds, menuIds).then((resp) => {
|
||||
this.$dialog.notify.info(resp.message, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
});
|
||||
},
|
||||
init() {
|
||||
roleApi.getRole().then((resp) => {
|
||||
roleApi.getList().then((resp) => {
|
||||
this.RoleItems = resp.data;
|
||||
});
|
||||
|
||||
menuApi.GetMenuInMould().then((resp) => {
|
||||
this.Menuitems = [resp.data];
|
||||
menuApi.getMenuTree().then((resp) => {
|
||||
this.Menuitems = resp.data;
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user