Merge branch 'master' into net6.0
This commit is contained in:
commit
e527e2fa59
@ -54,18 +54,30 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
return SUCCESS(sysMenuService.GetMenuByMenuId(menuId), "yyyy-MM-dd HH:mm:ss");
|
return SUCCESS(sysMenuService.GetMenuByMenuId(menuId), "yyyy-MM-dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 获取菜单下拉树列表(分配角色所需菜单)
|
///// 获取菜单下拉树列表(分配角色所需菜单)
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
[HttpGet("treeSelect")]
|
//[HttpGet("treeSelect")]
|
||||||
public IActionResult TreeSelect()
|
//public IActionResult TreeSelect()
|
||||||
{
|
//{
|
||||||
long userId = HttpContext.GetUId();
|
// long userId = HttpContext.GetUId();
|
||||||
var list = sysMenuService.SelectMenuList(new MenuQueryDto(), userId).FindAll(f => f.visible == "0");
|
// var list = sysMenuService.SelectMenuList(new MenuQueryDto(), userId).FindAll(f => f.visible == "0");
|
||||||
var treeMenus = sysMenuService.BuildMenuTreeSelect(list);
|
// var treeMenus = sysMenuService.BuildMenuTreeSelect(list);
|
||||||
|
|
||||||
return SUCCESS(treeMenus);
|
// return SUCCESS(treeMenus);
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据菜单编号获取菜单列表,菜单管理首次进入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="menuId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("list/{menuId}")]
|
||||||
|
[ActionPermissionFilter(Permission = "system:menu:query")]
|
||||||
|
public IActionResult GetMenuList(int menuId = 0)
|
||||||
|
{
|
||||||
|
return SUCCESS(sysMenuService.GetMenusByMenuId(menuId), "yyyy-MM-dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -18,7 +18,7 @@ namespace ZR.Admin.WebApi.Hubs
|
|||||||
public DateTime LoginTime { get; set; }
|
public DateTime LoginTime { get; set; }
|
||||||
public string UserIP { get; set; }
|
public string UserIP { get; set; }
|
||||||
|
|
||||||
public OnlineUsers(string clientid, string name, long? userid, string? userip)
|
public OnlineUsers(string clientid, string name, long? userid, string userip)
|
||||||
{
|
{
|
||||||
ConnnectionId = clientid;
|
ConnnectionId = clientid;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|||||||
@ -80,6 +80,7 @@ namespace ZR.Model.System.Dto
|
|||||||
public string Visible { get; set; }
|
public string Visible { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
public string MenuTypeIds { get; set; } = string.Empty;
|
public string MenuTypeIds { get; set; } = string.Empty;
|
||||||
|
public int? ParentId { get; set; }
|
||||||
public string[] MenuTypeIdArr
|
public string[] MenuTypeIdArr
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@ -21,12 +21,6 @@ namespace ZR.Model.System
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string MenuName { get; set; }
|
public string MenuName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 父菜单名称
|
|
||||||
/// </summary>
|
|
||||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
|
||||||
public string parentName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 父菜单ID
|
/// 父菜单ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -90,5 +84,21 @@ namespace ZR.Model.System
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public List<SysMenu> children { get; set; } = new List<SysMenu>();
|
public List<SysMenu> children { get; set; } = new List<SysMenu>();
|
||||||
|
/// <summary>
|
||||||
|
/// 子菜单个数
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public int SubNum { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否包含子节点,前端用
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public bool HasChildren
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SubNum > 0 || children.Count > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ namespace ZR.Repository.System
|
|||||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.visible == menu.Visible)
|
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.visible == menu.Visible)
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.status == menu.Status)
|
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.status == menu.Status)
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), it => menu.MenuTypeIdArr.Contains(it.menuType))
|
||||||
.OrderBy(it => new { it.parentId, it.orderNum })
|
.OrderBy(it => new { it.parentId, it.orderNum })
|
||||||
.ToTree(it => it.children, it => it.parentId, 0);
|
.ToTree(it => it.children, it => it.parentId, 0);
|
||||||
}
|
}
|
||||||
@ -32,19 +32,20 @@ namespace ZR.Repository.System
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据用户查询系统菜单列表(菜单管理)
|
/// 根据用户查询系统菜单列表(菜单管理)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sysMenu"></param>
|
/// <param name="menu"></param>
|
||||||
/// <param name="roles">用户角色集合</param>
|
/// <param name="roles">用户角色集合</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<SysMenu> SelectTreeMenuListByUserId(MenuQueryDto sysMenu, List<long> roles)
|
public List<SysMenu> SelectTreeMenuListByRoles(MenuQueryDto menu, List<long> roles)
|
||||||
{
|
{
|
||||||
var roleMenus = Context.Queryable<SysRoleMenu>()
|
var roleMenus = Context.Queryable<SysRoleMenu>()
|
||||||
.Where(r => roles.Contains(r.Role_id));
|
.Where(r => roles.Contains(r.Role_id));
|
||||||
|
|
||||||
return Context.Queryable<SysMenu>()
|
return Context.Queryable<SysMenu>()
|
||||||
.InnerJoin(roleMenus, (c, j) => c.MenuId == j.Menu_id)
|
.InnerJoin(roleMenus, (c, j) => c.MenuId == j.Menu_id)
|
||||||
.WhereIF(!string.IsNullOrEmpty(sysMenu.MenuName), (c, j) => c.MenuName.Contains(sysMenu.MenuName))
|
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), (c, j) => c.MenuName.Contains(menu.MenuName))
|
||||||
.WhereIF(!string.IsNullOrEmpty(sysMenu.Visible), (c, j) => c.visible == sysMenu.Visible)
|
.WhereIF(!string.IsNullOrEmpty(menu.Visible), (c, j) => c.visible == menu.Visible)
|
||||||
.WhereIF(!string.IsNullOrEmpty(sysMenu.Status), (c, j) => c.status == sysMenu.Status)
|
.WhereIF(!string.IsNullOrEmpty(menu.Status), (c, j) => c.status == menu.Status)
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), c => menu.MenuTypeIdArr.Contains(c.menuType))
|
||||||
.OrderBy((c, j) => new { c.parentId, c.orderNum })
|
.OrderBy((c, j) => new { c.parentId, c.orderNum })
|
||||||
.Select(c => c)
|
.Select(c => c)
|
||||||
.ToTree(it => it.children, it => it.parentId, 0);
|
.ToTree(it => it.children, it => it.parentId, 0);
|
||||||
@ -60,6 +61,7 @@ namespace ZR.Repository.System
|
|||||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.visible == menu.Visible)
|
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.visible == menu.Visible)
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.status == menu.Status)
|
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.status == menu.Status)
|
||||||
|
.WhereIF(menu.ParentId != null, it => it.parentId == menu.ParentId)
|
||||||
.OrderBy(it => new { it.parentId, it.orderNum })
|
.OrderBy(it => new { it.parentId, it.orderNum })
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -87,35 +89,22 @@ namespace ZR.Repository.System
|
|||||||
|
|
||||||
#region 左侧菜单树
|
#region 左侧菜单树
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 管理员获取左侧菜单树
|
///// 根据用户角色获取左侧菜单树
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <returns></returns>
|
///// <param name="roleIds"></param>
|
||||||
public List<SysMenu> SelectMenuTreeAll()
|
///// <returns></returns>
|
||||||
{
|
//public List<SysMenu> SelectMenuTreeByRoleIds(List<long> roleIds)
|
||||||
var menuTypes = new string[] { "M", "C" };
|
//{
|
||||||
|
// var menuTypes = new string[] { "M", "C" };
|
||||||
return Context.Queryable<SysMenu>()
|
// return Context.Queryable<SysMenu>()
|
||||||
.Where(f => f.status == "0" && menuTypes.Contains(f.menuType))
|
// .Where((menu) =>
|
||||||
.OrderBy(it => new { it.parentId, it.orderNum }).ToList();
|
// menuTypes.Contains(menu.menuType)
|
||||||
}
|
// && menu.status == "0"
|
||||||
|
// && SqlFunc.Subqueryable<SysRoleMenu>().Where(s => roleIds.Contains(s.Role_id) && s.Menu_id == menu.MenuId).Any())
|
||||||
/// <summary>
|
// .OrderBy((menu) => new { menu.parentId, menu.orderNum })
|
||||||
/// 根据用户角色获取左侧菜单树
|
// .Select((menu) => menu).ToList();
|
||||||
/// </summary>
|
//}
|
||||||
/// <param name="roleIds"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<SysMenu> SelectMenuTreeByRoleIds(List<long> roleIds)
|
|
||||||
{
|
|
||||||
var menuTypes = new string[] { "M", "C" };
|
|
||||||
return Context.Queryable<SysMenu>()
|
|
||||||
.Where((menu) =>
|
|
||||||
menuTypes.Contains(menu.menuType)
|
|
||||||
&& menu.status == "0"
|
|
||||||
&& SqlFunc.Subqueryable<SysRoleMenu>().Where(s => roleIds.Contains(s.Role_id) && s.Menu_id == menu.MenuId).Any())
|
|
||||||
.OrderBy((menu) => new { menu.parentId, menu.orderNum })
|
|
||||||
.Select((menu) => menu).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ namespace ZR.Service.System.IService
|
|||||||
List<SysMenu> SelectTreeMenuList(MenuQueryDto menu, long userId);
|
List<SysMenu> SelectTreeMenuList(MenuQueryDto menu, long userId);
|
||||||
|
|
||||||
SysMenu GetMenuByMenuId(int menuId);
|
SysMenu GetMenuByMenuId(int menuId);
|
||||||
|
List<SysMenu> GetMenusByMenuId(int menuId);
|
||||||
int AddMenu(SysMenu menu);
|
int AddMenu(SysMenu menu);
|
||||||
|
|
||||||
int EditMenu(SysMenu menu);
|
int EditMenu(SysMenu menu);
|
||||||
|
|||||||
@ -41,7 +41,7 @@ namespace ZR.Service
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var userRoles = SysRoleService.SelectUserRoles(userId);
|
var userRoles = SysRoleService.SelectUserRoles(userId);
|
||||||
menuList = MenuRepository.SelectTreeMenuListByUserId(menu, userRoles);
|
menuList = MenuRepository.SelectTreeMenuListByRoles(menu, userRoles);
|
||||||
}
|
}
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
@ -75,6 +75,21 @@ namespace ZR.Service
|
|||||||
return MenuRepository.SelectMenuById(menuId);
|
return MenuRepository.SelectMenuById(menuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据菜单id获取菜单列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="menuId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysMenu> GetMenusByMenuId(int menuId)
|
||||||
|
{
|
||||||
|
var list = MenuRepository.GetList(f => f.parentId == menuId).OrderBy(f => f.orderNum).ToList();
|
||||||
|
Context.ThenMapper(list, item =>
|
||||||
|
{
|
||||||
|
item.SubNum = Context.Queryable<SysMenu>().SetContext(x => x.parentId, () => item.MenuId, item).Count();
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加菜单
|
/// 添加菜单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -154,17 +169,19 @@ namespace ZR.Service
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<SysMenu> SelectMenuTreeByUserId(long userId)
|
public List<SysMenu> SelectMenuTreeByUserId(long userId)
|
||||||
{
|
{
|
||||||
List<SysMenu> menus;
|
MenuQueryDto dto = new() { Status = "0", MenuTypeIds = "M,C" };
|
||||||
|
//List<SysMenu> menus;
|
||||||
if (SysRoleService.IsAdmin(userId))
|
if (SysRoleService.IsAdmin(userId))
|
||||||
{
|
{
|
||||||
menus = MenuRepository.SelectMenuTreeAll();
|
return MenuRepository.SelectTreeMenuList(dto);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<long> roleIds = SysRoleService.SelectUserRoles(userId);
|
List<long> roleIds = SysRoleService.SelectUserRoles(userId);
|
||||||
menus = MenuRepository.SelectMenuTreeByRoleIds(roleIds);
|
//menus = MenuRepository.SelectMenuTreeByRoleIds(roleIds);
|
||||||
|
return MenuRepository.SelectTreeMenuListByRoles(dto, roleIds);
|
||||||
}
|
}
|
||||||
return GetChildPerms(menus, 0);
|
//return GetChildPerms(menus, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -205,25 +222,25 @@ namespace ZR.Service
|
|||||||
|
|
||||||
#region 方法
|
#region 方法
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据父节点的ID获取所有子节点
|
///// 根据父节点的ID获取所有子节点
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="list">分类表</param>
|
///// <param name="list">分类表</param>
|
||||||
/// <param name="parentId">传入的父节点ID</param>
|
///// <param name="parentId">传入的父节点ID</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
public List<SysMenu> GetChildPerms(List<SysMenu> list, int parentId)
|
//public List<SysMenu> GetChildPerms(List<SysMenu> list, int parentId)
|
||||||
{
|
//{
|
||||||
List<SysMenu> returnList = new List<SysMenu>();
|
// List<SysMenu> returnList = new List<SysMenu>();
|
||||||
var data = list.FindAll(f => f.parentId == parentId);
|
// var data = list.FindAll(f => f.parentId == parentId);
|
||||||
|
|
||||||
foreach (var item in data)
|
// foreach (var item in data)
|
||||||
{
|
// {
|
||||||
RecursionFn(list, item);
|
// RecursionFn(list, item);
|
||||||
|
|
||||||
returnList.Add(item);
|
// returnList.Add(item);
|
||||||
}
|
// }
|
||||||
return returnList;
|
// return returnList;
|
||||||
}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 递归列表
|
/// 递归列表
|
||||||
|
|||||||
@ -8,7 +8,13 @@ export function listMenu(query) {
|
|||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 查询菜单列表
|
||||||
|
export function listMenuById(menuId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/menu/list/' + menuId,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
// 查询菜单详细
|
// 查询菜单详细
|
||||||
export function getMenu(menuId) {
|
export function getMenu(menuId) {
|
||||||
return request({
|
return request({
|
||||||
@ -75,4 +81,4 @@ export const getRouters = (query) => {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,11 @@
|
|||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-if="refreshTable" v-loading="loading" :data="menuList" :default-expand-all="isExpandAll" row-key="menuId" border
|
<el-table v-if="refreshTable" v-loading="loading" :data="menuList" :default-expand-all="isExpandAll"
|
||||||
|
row-key="menuId"
|
||||||
|
border
|
||||||
|
lazy
|
||||||
|
:load="loadMenu"
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||||
<el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column>
|
<el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column>
|
||||||
<el-table-column prop="icon" label="图标" align="center" width="80">
|
<el-table-column prop="icon" label="图标" align="center" width="80">
|
||||||
@ -217,6 +221,7 @@ import {
|
|||||||
addMenu,
|
addMenu,
|
||||||
changeMenuSort,
|
changeMenuSort,
|
||||||
updateMenu,
|
updateMenu,
|
||||||
|
listMenuById
|
||||||
} from "@/api/system/menu";
|
} from "@/api/system/menu";
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
@ -228,7 +233,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: false,
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 菜单表格树数据
|
// 菜单表格树数据
|
||||||
@ -274,13 +279,16 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
// this.getList();
|
||||||
this.getDicts("sys_show_hide").then((response) => {
|
this.getDicts("sys_show_hide").then((response) => {
|
||||||
this.visibleOptions = response.data;
|
this.visibleOptions = response.data;
|
||||||
});
|
});
|
||||||
this.getDicts("sys_normal_disable").then((response) => {
|
this.getDicts("sys_normal_disable").then((response) => {
|
||||||
this.statusOptions = response.data;
|
this.statusOptions = response.data;
|
||||||
});
|
});
|
||||||
|
listMenuById(0).then((response) => {
|
||||||
|
this.menuList = response.data
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 选择图标
|
// 选择图标
|
||||||
@ -309,7 +317,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 查询菜单下拉树结构 */
|
/** 查询菜单下拉树结构 */
|
||||||
getTreeselect() {
|
getTreeselect() {
|
||||||
listMenu().then((response) => {
|
listMenu({ menuTypeIds: 'M,C,F' }).then((response) => {
|
||||||
this.menuOptions = [];
|
this.menuOptions = [];
|
||||||
const menu = { menuId: 0, menuName: "根菜单", children: [] };
|
const menu = { menuId: 0, menuName: "根菜单", children: [] };
|
||||||
menu.children = response.data;
|
menu.children = response.data;
|
||||||
@ -453,6 +461,11 @@ export default {
|
|||||||
this.refreshTable = true;
|
this.refreshTable = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
loadMenu (row, treeNode, resolve) {
|
||||||
|
listMenuById(row.menuId).then((res) => {
|
||||||
|
resolve(res.data)
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user