feat: 更新依赖包支持多列排序
This commit is contained in:
parent
09de55a641
commit
ecff092ea4
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor" Version="6.1.2-beta10" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="6.1.2-beta12" />
|
||||
<PackageReference Include="Longbow.Security.Cryptography" Version="5.2.0" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.1" />
|
||||
<PackageReference Include="PetaPoco.Extensions" Version="5.2.0" />
|
||||
|
|
|
@ -44,6 +44,10 @@ public static class DatabaseExtensions
|
|||
{
|
||||
sql.OrderBy(sortOrder == SortOrder.Asc ? sortName : $"{sortName} desc");
|
||||
}
|
||||
else if (options.SortList != null && options.SortList.Any())
|
||||
{
|
||||
sql.OrderBy(string.Join(",", options.SortList));
|
||||
}
|
||||
return db.FetchAsync<TModel>(sql);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
IsTree="IsTree" OnTreeExpand="OnTreeExpand!" TreeIcon="fa-chevron-circle-right"
|
||||
ShowDefaultButtons="ShowDefaultButtons" ShowAdvancedSearch="ShowAdvancedSearch"
|
||||
ShowEmpty="true" EmptyText="暂无数据" EmptyImage="images/empty.svg"
|
||||
UseInjectDataService="true" DataService="DataService" OnQueryAsync="OnQueryAsync!"
|
||||
UseInjectDataService="true" DataService="DataService" OnQueryAsync="OnQueryAsync!" SortList="SortList"
|
||||
ShowSkeleton="true" ShowToolbar="true" ShowExtendButtons="ShowExtendButtons" ShowSearch="true"
|
||||
ShowCardView="true" ShowColumnList="true" ExtendButtonColumnWidth="@ExtendButtonColumnWidth"
|
||||
CustomerSearchModel="@TableSearchModel">
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
[Parameter]
|
||||
public int ExtendButtonColumnWidth { get; set; } = 130;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public List<string>? SortList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@page "/Admin/Dicts"
|
||||
|
||||
<AdminTable TItem="DataAccess.Models.Dict" TableSearchModel="DictsSearchModel" OnQueryAsync="OnQueryAsync">
|
||||
<AdminTable TItem="DataAccess.Models.Dict" TableSearchModel="DictsSearchModel" SortList="SortList">
|
||||
<ColumnsTemplete>
|
||||
<TableColumn @bind-Field="context.Category" Filterable="true" Searchable="true" Sortable="true"></TableColumn>
|
||||
<TableColumn @bind-Field="context.Name" Filterable="true" Searchable="true" Sortable="true"></TableColumn>
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using BootstrapAdmin.DataAccess.Models;
|
||||
using BootstrapAdmin.Web.Core;
|
||||
using BootstrapAdmin.Web.Models;
|
||||
using BootstrapAdmin.Web.Models;
|
||||
|
||||
namespace BootstrapAdmin.Web.Pages.Admin
|
||||
{
|
||||
|
@ -11,52 +9,6 @@ namespace BootstrapAdmin.Web.Pages.Admin
|
|||
{
|
||||
private ITableSearchModel DictsSearchModel { get; set; } = new DictsSearchModel();
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IDict? DictService { get; set; }
|
||||
|
||||
private Task<QueryData<Dict>> OnQueryAsync(QueryPageOptions options)
|
||||
{
|
||||
var ret = new QueryData<Dict>()
|
||||
{
|
||||
IsSorted = true,
|
||||
IsFiltered = true,
|
||||
IsSearch = true
|
||||
};
|
||||
|
||||
var items = DictService.GetAll();
|
||||
|
||||
// 处理模糊查询
|
||||
if (!string.IsNullOrEmpty(options.SearchText))
|
||||
{
|
||||
items = items.Where(i => i.Category.Contains(options.SearchText) || i.Name.Contains(options.SearchText)).ToList();
|
||||
}
|
||||
|
||||
// 处理高级查询
|
||||
if (options.CustomerSearchs.Any())
|
||||
{
|
||||
items = items.Where(options.CustomerSearchs.GetFilterFunc<Dict>()).ToList();
|
||||
}
|
||||
|
||||
// 处理过滤
|
||||
if (options.Filters.Any())
|
||||
{
|
||||
items = items.Where(options.Filters.GetFilterFunc<Dict>()).ToList();
|
||||
}
|
||||
|
||||
// 处理排序
|
||||
if (!string.IsNullOrEmpty(options.SortName))
|
||||
{
|
||||
items = items.Sort<Dict>(options.SortName, options.SortOrder).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = items.OrderBy(i => i.Define).ThenBy(i => i.Category).ThenBy(i => i.Name).ToList();
|
||||
}
|
||||
|
||||
ret.TotalCount = items.Count;
|
||||
ret.Items = items;
|
||||
return Task.FromResult(ret);
|
||||
}
|
||||
private List<string> SortList { get; } = new List<string> { "Define", "Category", "Name" };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<AdminAlert Text="演示系统禁止修改内置后台任务" IsShow="IsDemo" />
|
||||
|
||||
<Table TItem="TasksModel" ExtendButtonColumnWidth="270" IsBordered="true" IsStriped="true"
|
||||
IsMultipleSelect="true" IsFixedHeader="false"
|
||||
IsMultipleSelect="true" IsFixedHeader="false" SortList="SortList"
|
||||
ShowToolbar="true" ShowExtendButtons="true" SelectedRows="SelectedRows"
|
||||
ShowEditButtonCallback="OnShowButtonCallback" ShowDeleteButtonCallback="OnShowButtonCallback"
|
||||
OnQueryAsync="OnQueryAsync" OnDeleteAsync="OnDeleteAsync" OnSaveAsync="OnSaveAsync">
|
||||
|
|
|
@ -27,6 +27,8 @@ public partial class Tasks
|
|||
|
||||
private bool IsDemo { get; set; }
|
||||
|
||||
private List<string> SortList { get; } = new List<string>() { "Name", "LastRuntime desc" };
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
@ -36,7 +38,7 @@ public partial class Tasks
|
|||
|
||||
private Task<QueryData<TasksModel>> OnQueryAsync(QueryPageOptions options)
|
||||
{
|
||||
var tasks = TaskServicesManager.ToList().OrderBy(i => i.Name).ToTasksModelList();
|
||||
var tasks = TaskServicesManager.ToList().ToTasksModelList();
|
||||
var model = tasks.FirstOrDefault(i => i.Name == SelectedRows.FirstOrDefault()?.Name);
|
||||
SelectedRows.Clear();
|
||||
if (model != null)
|
||||
|
|
Loading…
Reference in New Issue