diff --git a/ruoyi-egg/app/controller/system/sysMenu.js b/ruoyi-egg/app/controller/system/sysMenu.js index 54b83628ac1613268c3f659ccd448ad738a08692..ac24b688261a00ce377233ed0d0f8c14f0cf3789 100644 --- a/ruoyi-egg/app/controller/system/sysMenu.js +++ b/ruoyi-egg/app/controller/system/sysMenu.js @@ -52,10 +52,14 @@ class SysMenuController extends Controller { * @param {*} ctx */ async detail(ctx) { - ctx.body = await ctx.service.system.sysMenu.detail(ctx.params.menuId); + if (ctx.params.menuId == "treeselect") { + ctx.body = await ctx.service.system.sysMenu.tree({}); + } else { + ctx.body = await ctx.service.system.sysMenu.detail(ctx.params.menuId); + } ctx.status = 200; } - + /** * 创建 * @param {*} ctx diff --git a/ruoyi-egg/app/service/system/sysMenu.js b/ruoyi-egg/app/service/system/sysMenu.js index 6911118f7d0c445ec71a79d2d00030c0b9e13c72..fec34550d54b557ec0372ac083ac9434183229e8 100644 --- a/ruoyi-egg/app/service/system/sysMenu.js +++ b/ruoyi-egg/app/service/system/sysMenu.js @@ -59,7 +59,16 @@ class SysMenuService extends Service { }); return this.ServerResponse.createBySuccessData(rows); } - + async tree(params) { + let res = await this.allList(params); + res.data = res.data.map((item) => { + item.label = item.menuName; + item.id = item.menuId; + return item; + }); + res = this.ctx.changeToTree(res.data, "parentId", "menuId"); + return this.ServerResponse.createBySuccessData(res); + } /** * 新增 * @returns