添加菜单查询

This commit is contained in:
橙子
2022-04-26 19:21:37 +08:00
parent 7e427605ab
commit 90b39d075d
6 changed files with 41 additions and 51 deletions

View File

@@ -34,9 +34,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
//暂未制作逻辑删除与多租户的过滤 //暂未制作逻辑删除与多租户的过滤
public async Task<List<MenuEntity>> GetMenuTree() public async Task<Result> GetMenuTree()
{ {
return await _iMenuService.GetMenuTreeAsync(); return Result.Success().SetData(await _iMenuService.GetMenuTreeAsync());
} }
} }
} }

View File

@@ -32,7 +32,7 @@ namespace Yi.Framework.Model.Models
/// <summary> /// <summary>
/// ///
///</summary> ///</summary>
[SugarColumn(ColumnName="MenuCode" )] [SugarColumn(ColumnName= "PermissionCode")]
public string PermissionCode { get; set; } public string PermissionCode { get; set; }
/// <summary> /// <summary>
/// ///

View File

@@ -13,7 +13,7 @@ namespace Yi.Framework.Service
{ {
//ParentId 0,代表为根目录,只能存在一个 //ParentId 0,代表为根目录,只能存在一个
//复杂查询直接使用db代理 //复杂查询直接使用db代理
return await _repository._Db.Queryable<MenuEntity>().ToTreeAsync(it=>it.Children,it=>it.ParentId,0); return await _repository._Db.Queryable<MenuEntity>().Where(u=>u.IsDeleted==false).ToTreeAsync(it=>it.Children,it=>it.ParentId,0);
} }
} }
} }

View File

@@ -1,8 +1,8 @@
import myaxios from '@/util/myaxios' import myaxios from '@/util/myaxios'
export default { export default {
GetMenuInMould() { getMenuTree() {
return myaxios({ return myaxios({
url: '/Menu/GetMenuInMould', url: '/Menu/getMenuTree',
method: 'get' method: 'get'
}) })
}, },
@@ -34,13 +34,7 @@ export default {
data: data data: data
}) })
}, },
SetMouldByMenu(menuId, mouldId) {
return myaxios({
url: '/Menu/SetMouldByMenu',
method: 'post',
data: { id1: menuId, id2: mouldId }
})
},
GetTopMenusByHttpUser() { GetTopMenusByHttpUser() {
return myaxios({ return myaxios({
url: '/Menu/GetTopMenusByHttpUser', url: '/Menu/GetTopMenusByHttpUser',

View File

@@ -1,15 +1,12 @@
<template> <template>
<div> <div>
<v-divider></v-divider> <v-divider></v-divider>
<app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn> <app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn>
<app-btn dark class="my-4 mr-4" @click="dialog = true"> 添加新项 </app-btn> <app-btn dark class="my-4 mr-4" @click="dialog = true"> 添加新项 </app-btn>
<app-btn dark class="my-4" color="secondary" @click="deleteItem(null)"> <app-btn dark class="my-4" color="secondary" @click="deleteItem(null)">
删除所选 删除所选
</app-btn> </app-btn>
<v-dialog v-model="dialog" max-width="500px"> <v-dialog v-model="dialog" max-width="500px">
<v-card> <v-card>
<v-card-title> <v-card-title>
@@ -53,15 +50,16 @@
return-object return-object
open-all open-all
hoverable hoverable
item-text="menu_name" item-text="menuName"
> >
<template v-slot:append="{ item }"> <template v-slot:append="{ item }">
<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.permissionCode }}</v-btn>
<v-btn class="mr-2">路由:{{ item.router }}</v-btn> <!-- <v-btn class="mr-2">图标:{{ item.icon }}</v-btn> -->
<v-btn v-if="item.mould" class="mr-2">接口名:{{ item.mould.mould_name }}</v-btn> <!-- <v-btn class="mr-2">路由:{{ item.router }}</v-btn> -->
<v-btn v-if="item.mould" class="mr-2" color="secondary">接口地址:{{ item.mould.url }}</v-btn> <!-- <v-btn v-if="item.mould" class="mr-2">接口:{{ item.mould.mould_name }}</v-btn>
<ccCombobox <v-btn v-if="item.mould" class="mr-2" color="secondary">接口地址:{{ item.mould.url }}</v-btn> -->
<!-- <ccCombobox
headers="设置接口权限" headers="设置接口权限"
itemText="url" itemText="url"
:items="mouldList" :items="mouldList"
@@ -72,8 +70,8 @@
保存</v-btn 保存</v-btn
> >
</template> </template>
</ccCombobox> </ccCombobox> -->
<app-btn <app-btn
@click=" @click="
parentId = item.id; parentId = item.id;
dialog = true; dialog = true;
@@ -82,8 +80,9 @@
> >
<app-btn class="mx-2" @click="editItem(item)">编辑</app-btn> <app-btn class="mx-2" @click="editItem(item)">编辑</app-btn>
<app-btn color="secondary" class="mr-2" @click="deleteItem(item)">删除</app-btn> <app-btn color="secondary" class="mr-2" @click="deleteItem(item)"
>删除</app-btn
>
</template> </template>
</v-treeview> </v-treeview>
</div> </div>
@@ -108,7 +107,7 @@ export default {
icon: "mdi-start", icon: "mdi-start",
router: "test", router: "test",
menu_name: "测试", menu_name: "测试",
is_show:1 is_show: 1,
}, },
}), }),
computed: { computed: {
@@ -120,20 +119,20 @@ export default {
this.init(); this.init();
}, },
methods: { methods: {
showAll(){ showAll() {
this.$refs.tree.updateAll(true); this.$refs.tree.updateAll(true);
},
setMould(item) {
menuApi.SetMouldByMenu(item.id, this.mouldSelect[0].id).then((resp) => {
this.$dialog.notify.info(resp.msg, {
position: "top-right",
timeout: 5000,
});
this.init();
});
}, },
// setMould(item) {
// menuApi.SetMouldByMenu(item.id, this.mouldSelect[0].id).then((resp) => {
// this.$dialog.notify.info(resp.msg, {
// position: "top-right",
// timeout: 5000,
// });
// this.init();
// });
// },
getSelect(data) { getSelect(data) {
this.mouldSelect = data; this.mouldSelect = data;
}, },
@@ -173,20 +172,17 @@ showAll(){
}, },
init() { init() {
this.parentId = 0; this.parentId = 0;
mouldApi.getMould().then((resp) => { // mouldApi.getMould().then((resp) => {
this.mouldList = resp.data; // this.mouldList = resp.data;
}); // });
menuApi.GetMenuInMould().then((resp) => { menuApi.getMenuTree().then((resp) => {
this.desserts =[ resp.data]; this.desserts = resp.data;
}); });
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem); this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1; this.editedIndex = -1;
}); });
}, },
editItem(item) { editItem(item) {
this.editedIndex = item.id; this.editedIndex = item.id;