feat: 权限维护页面增加表头排序功能

This commit is contained in:
Argo Zhang 2020-01-27 15:15:22 +08:00
parent c620323461
commit 91b174f296
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
6 changed files with 43 additions and 11 deletions

View File

@ -10,9 +10,9 @@
<TableToolbarButton class="btn btn-warning" Icon="fa fa-sitemap" Title="分配角色" OnClick="AssignRoles" />
</TableToolbarTemplate>
<TableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.GroupCode"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.GroupName"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Description"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.GroupCode" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.GroupName" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Description" Sort="true"></LgbTableHeader>
</TableHeader>
<RowTemplate>
<td>@context.GroupCode</td>

View File

@ -17,8 +17,8 @@
</div>
</TableInfoTemplate>
<TableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.RoleName"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Description"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.RoleName" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Description" Sort="true"></LgbTableHeader>
</TableHeader>
<RowTemplate>
<td>@context.RoleName</td>

View File

@ -10,12 +10,12 @@
<TableToolbarButton class="btn btn-warning" Icon="fa fa-sitemap" Title="分配角色" OnClick="AssignRoles" />
</TableToolbarTemplate>
<TableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.UserName"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.DisplayName"></LgbTableHeader>
<LgbTableHeader TItem="DateTime" @bind-Value="@context.RegisterTime"></LgbTableHeader>
<LgbTableHeader TItem="DateTime?" @bind-Value="@context.ApprovedTime"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.ApprovedBy"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Description"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.UserName" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.DisplayName" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="DateTime" @bind-Value="@context.RegisterTime" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="DateTime?" @bind-Value="@context.ApprovedTime" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.ApprovedBy" Sort="true"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Description" Sort="true"></LgbTableHeader>
</TableHeader>
<RowTemplate>
<td>@context.UserName</td>

View File

@ -21,6 +21,16 @@ namespace Bootstrap.Pages.Admin.Components
if (!string.IsNullOrEmpty(QueryModel.GroupName)) data = data.Where(d => d.GroupName.Contains(QueryModel.GroupName, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(QueryModel.Description)) data = data.Where(d => d.Description != null && d.Description.Contains(QueryModel.Description, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(options.SearchText)) data = data.Where(d => d.GroupName.Contains(options.SearchText, StringComparison.OrdinalIgnoreCase) || (d.Description ?? "").Contains(options.SearchText, StringComparison.OrdinalIgnoreCase));
// sort
data = options.SortName switch
{
nameof(Group.GroupName) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.GroupName) : data.OrderByDescending(d => d.GroupName),
nameof(Group.GroupCode) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.GroupCode) : data.OrderByDescending(d => d.GroupCode),
nameof(Group.Description) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.Description) : data.OrderByDescending(d => d.Description),
_ => data
};
var totalCount = data.Count();
var items = data.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems);
return new QueryData<Group>() { Items = items, TotalCount = totalCount, PageIndex = options.PageIndex, PageItems = options.PageItems };

View File

@ -21,6 +21,15 @@ namespace Bootstrap.Pages.Admin.Components
if (!string.IsNullOrEmpty(QueryModel.RoleName)) data = data.Where(d => d.RoleName.Contains(QueryModel.RoleName, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(QueryModel.Description)) data = data.Where(d => d.Description != null && d.Description.Contains(QueryModel.Description, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(options.SearchText)) data = data.Where(d => d.RoleName.Contains(options.SearchText, StringComparison.OrdinalIgnoreCase) || d.Description.Contains(options.SearchText, StringComparison.OrdinalIgnoreCase));
// sort
data = options.SortName switch
{
nameof(Role.RoleName) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.RoleName) : data.OrderByDescending(d => d.RoleName),
nameof(Role.Description) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.Description) : data.OrderByDescending(d => d.Description),
_ => data
};
var totalCount = data.Count();
var items = data.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems);
return new QueryData<Role>() { Items = items, TotalCount = totalCount, PageIndex = options.PageIndex, PageItems = options.PageItems };

View File

@ -21,6 +21,19 @@ namespace Bootstrap.Pages.Admin.Components
if (!string.IsNullOrEmpty(QueryModel.UserName)) data = data.Where(d => d.UserName.Contains(QueryModel.UserName, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(QueryModel.DisplayName)) data = data.Where(d => d.DisplayName.Contains(QueryModel.DisplayName, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(options.SearchText)) data = data.Where(d => d.UserName.Contains(options.SearchText, StringComparison.OrdinalIgnoreCase) || d.DisplayName.Contains(options.SearchText, StringComparison.OrdinalIgnoreCase));
// sort
data = options.SortName switch
{
nameof(User.UserName) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.UserName) : data.OrderByDescending(d => d.UserName),
nameof(User.DisplayName) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.DisplayName) : data.OrderByDescending(d => d.DisplayName),
nameof(User.Description) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.Description) : data.OrderByDescending(d => d.Description),
nameof(User.ApprovedBy) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.ApprovedBy) : data.OrderByDescending(d => d.ApprovedBy),
nameof(User.ApprovedTime) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.ApprovedTime) : data.OrderByDescending(d => d.ApprovedTime),
nameof(User.RegisterTime) => options.SortOrder == SortOrder.Asc ? data.OrderBy(d => d.RegisterTime) : data.OrderByDescending(d => d.RegisterTime),
_ => data
};
var totalCount = data.Count();
var items = data.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems);
return new QueryData<User>() { Items = items, TotalCount = totalCount, PageIndex = options.PageIndex, PageItems = options.PageItems };