前端对接接口

This commit is contained in:
橙子
2021-10-19 19:07:42 +08:00
parent ad9d1d9452
commit 99b64f48b0
5 changed files with 50 additions and 31 deletions

View File

@@ -75,7 +75,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
return Result.Success(); return Result.Success();
} }
[HttpGet] [HttpGet]
public async Task<Result> GetMenuByRloeIds(int roleId) public async Task<Result> GetMenuByRloe(int roleId)
{ {
var menuList =await _roleService.GetMenusByRoleId(roleId); var menuList =await _roleService.GetMenusByRoleId(roleId);
return Result.Success().SetData(menuList); return Result.Success().SetData(menuList);

View File

@@ -12,5 +12,12 @@ export default {
method: 'post', method: 'post',
data: { ids1: roleList, ids2: menuList } data: { ids1: roleList, ids2: menuList }
}) })
},
getMenuByRloe(roleId) {
return myaxios({
url: `/Role/getMenuByRloe?roleId=${roleId}`,
method: 'get'
})
} }
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<app-btn dark class="ma-4" @click="dialog = true"> 添加新项 </app-btn> <app-btn dark class="ma-4" @click="dialog = true"> 添加新项 </app-btn>
<app-btn dark class="ma-4" color="secondary" @click="deleteItem(null)"> <app-btn dark class="my-4" color="secondary" @click="deleteItem(null)">
删除所选 删除所选
</app-btn> </app-btn>
@@ -39,6 +39,7 @@
</v-dialog> </v-dialog>
<v-treeview <v-treeview
open-on-click
selectable selectable
:items="desserts" :items="desserts"
:selection-type="selectionType" :selection-type="selectionType"
@@ -52,6 +53,8 @@
<v-btn class="mr-2">编号:{{ item.id }}</v-btn> <v-btn class="mr-2">编号:{{ item.id }}</v-btn>
<v-btn class="mr-2">图标:{{ item.icon }}</v-btn> <v-btn class="mr-2">图标:{{ item.icon }}</v-btn>
<v-btn class="mr-2">路由:{{ item.router }}</v-btn> <v-btn class="mr-2">路由:{{ item.router }}</v-btn>
<v-btn v-if="item.mould" class="mr-2">接口名:{{ item.mould.mould_name }}</v-btn>
<v-btn v-if="item.mould" class="mr-2">接口地址:{{ item.mould.url }}</v-btn>
<ccCombobox <ccCombobox
headers="设置接口权限" headers="设置接口权限"
itemText="mould_name" itemText="mould_name"

View File

@@ -1,14 +1,18 @@
<template> <template>
<v-row> <v-row>
<v-col cols="12"> <v-col cols="12">
<material-card color="primary" icon="mdi-account-outline"> <material-card color="primary" icon="mdi-account-outline">
<template #title> <template #title>
角色菜单分配管理 <small class="text-body-1">你可以在这里多角色分配多菜单</small> 角色菜单分配管理
</template><app-btn class="ma-4" @click="setMenu">确定分配</app-btn></material-card> <small class="text-body-1"
>你可以在这里多角色分配多菜单/选中一个可查看</small
> </template
><app-btn class="ma-4" @click="setMenu">确定分配</app-btn
><app-btn class="my-4" color="secondary" @click="clear">清空选择</app-btn></material-card
>
</v-col> </v-col>
<v-col cols="12" md="4" lg="4"> <v-col cols="12" md="4" lg="4">
<v-card class="mx-auto" width="100%"> <v-card class="mx-auto" width="100%">
<v-treeview <v-treeview
selectable selectable
:items="RoleItems" :items="RoleItems"
@@ -25,6 +29,7 @@
<v-col cols="12" md="8" lg="8"> <v-col cols="12" md="8" lg="8">
<v-card class="mx-auto" width="100%"> <v-card class="mx-auto" width="100%">
<v-treeview <v-treeview
open-on-click
selectable selectable
:items="Menuitems" :items="Menuitems"
selection-type="leaf" selection-type="leaf"
@@ -47,36 +52,40 @@ import roleApi from "../api/roleApi";
import menuApi from "../api/menuApi"; import menuApi from "../api/menuApi";
export default { export default {
created() { created() {
this.init(); this.init();
}, },
watch: { watch: {
selectionRole:{ selectionRole: {
handler(val, oldVal){ handler(val, oldVal) {
if(val.length==1) if (val.length == 1) {
{ roleApi.getMenuByRloe(val[0].id).then((resp) => {
//// this.selectionMenu = resp.data;
this.selectionMenu=[{id:38},{id:39}] });
} }
}, },
deep:true deep: true,
}, },
}, },
methods: { methods: {
setMenu(){ clear() {
var roleIds=[]; this.selectionMenu = [];
var menuIds=[]; this.selectionRole = [];
this.selectionRole.forEach((ele)=>{ },
roleIds.push(ele.id) setMenu() {
}) var roleIds = [];
this.selectionMenu.forEach((ele)=>{ var menuIds = [];
menuIds.push(ele.id) this.selectionRole.forEach((ele) => {
}) roleIds.push(ele.id);
roleApi.setMenuByRole(roleIds,menuIds).then(resp=>{ });
this.$dialog.notify.info(resp.msg, { this.selectionMenu.forEach((ele) => {
menuIds.push(ele.id);
});
roleApi.setMenuByRole(roleIds, menuIds).then((resp) => {
this.$dialog.notify.info(resp.msg, {
position: "top-right", position: "top-right",
timeout: 5000, timeout: 5000,
}); });
}) });
}, },
init() { init() {
roleApi.getRole().then((resp) => { roleApi.getRole().then((resp) => {