feat: 菜单默认全部展开

This commit is contained in:
Argo-Lenovo 2022-07-06 15:06:21 +08:00
parent 35cc0f5174
commit e3b67c9427
2 changed files with 6 additions and 6 deletions

View File

@ -1,8 +1,8 @@
@page "/Admin/Menus" @page "/Admin/Menus"
<AdminTable TItem="DataAccess.Models.Navigation" <AdminTable TItem="DataAccess.Models.Navigation"
IsTree="true" OnTreeExpand="OnTreeExpand" TreeNodeConverter="TreeNodeConverter" ExtendButtonColumnWidth="200" IsTree="true" OnTreeExpand="OnTreeExpand" TreeNodeConverter="TreeNodeConverter" ModelEqualityComparer="ModelEqualityComparer"
CustomerSearchModel="SearchModel" OnQueryAsync="OnQueryAsync"> ExtendButtonColumnWidth="200" CustomerSearchModel="SearchModel" OnQueryAsync="OnQueryAsync">
<TableToolbarTemplate> <TableToolbarTemplate>
<TableToolbarButton TItem="DataAccess.Models.Navigation" Color="Color.Info" Icon="fa fa-sitemap" Text="分配角色" <TableToolbarButton TItem="DataAccess.Models.Navigation" Color="Color.Info" Icon="fa fa-sitemap" Text="分配角色"
IsEnableWhenSelectedOneRow="true" IsShow="@AuthorizeButton("assignRole")" IsEnableWhenSelectedOneRow="true" IsShow="@AuthorizeButton("assignRole")"

View File

@ -141,12 +141,12 @@ public partial class Menus
ret.AddRange(items.Where(i => i.ParentId == parentId).Select((nav, index) => new TableTreeNode<Navigation>(nav) ret.AddRange(items.Where(i => i.ParentId == parentId).Select((nav, index) => new TableTreeNode<Navigation>(nav)
{ {
HasChildren = navs.Any(i => i.ParentId == nav.Id), HasChildren = navs.Any(i => i.ParentId == nav.Id),
IsExpand = false, IsExpand = navs.Any(i => i.ParentId == nav.Id),
// 获得子项集合 Items = BuildTreeNodes(navs.Where(i => i.ParentId == nav.Id), nav.Id)
// IsExpand = navs.Any(i => i.ParentId == nav.Id)
// Items = BuildTreeNodes(navs.Where(i => i.ParentId == nav.Id), nav.Id)
})); }));
return ret; return ret;
} }
} }
private bool ModelEqualityComparer(Navigation x, Navigation y) => x.Id == y.Id;
} }