mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 05:29:47 +08:00
!3602 feat(#I65HOU): add QueryPageOptions on OnExportAsync callback on Table component
* chore: bump version 7.1.5-beta01 * test: 更新单元测试 * doc: 更新 OnExportAsync 回调接口 * chore: 更新打包脚本 * feat: OnExportAsync 增加 参数接口更新
This commit is contained in:
parent
bc5d65a2c3
commit
ae1762b305
@ -54,7 +54,7 @@
|
||||
IsPagination="true" PageItemsSource="@PageItemsSource"
|
||||
IsStriped="true" IsBordered="true" IsMultipleSelect="true"
|
||||
ShowToolbar="true" ShowDefaultButtons="false" ShowExportButton="true"
|
||||
OnExportAsync="ExportAsync" OnQueryAsync="@OnQueryAsync">
|
||||
OnExportAsync="OnExportAsync" OnQueryAsync="@OnQueryAsync">
|
||||
<TableColumns>
|
||||
<TableColumn @bind-Field="@context.DateTime" Width="180" />
|
||||
<TableColumn @bind-Field="@context.Name" Width="100" />
|
||||
|
@ -64,7 +64,7 @@ public partial class TablesExport
|
||||
});
|
||||
}
|
||||
|
||||
private static Task<bool> ExportAsync(IEnumerable<Foo> Items) => Task.FromResult(true);
|
||||
private static Task<bool> OnExportAsync(IEnumerable<Foo> Items, QueryPageOptions options) => Task.FromResult(true);
|
||||
|
||||
private async Task ExcelExportAsync()
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.1.4</Version>
|
||||
<Version>7.1.5-beta01</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
|
@ -421,32 +421,7 @@ public partial class Table<TItem>
|
||||
async Task OnQuery()
|
||||
{
|
||||
QueryData<TItem>? queryData = null;
|
||||
var queryOption = new QueryPageOptions()
|
||||
{
|
||||
IsPage = IsPagination,
|
||||
PageIndex = PageIndex,
|
||||
PageItems = PageItems,
|
||||
SearchText = SearchText,
|
||||
SortOrder = SortOrder,
|
||||
SortName = SortName,
|
||||
SearchModel = SearchModel,
|
||||
StartIndex = StartIndex
|
||||
};
|
||||
|
||||
queryOption.Filters.AddRange(Filters.Values);
|
||||
queryOption.Searchs.AddRange(GetSearchs());
|
||||
queryOption.AdvanceSearchs.AddRange(GetAdvanceSearchs());
|
||||
queryOption.CustomerSearchs.AddRange(GetCustomerSearchs());
|
||||
|
||||
if (!string.IsNullOrEmpty(SortString))
|
||||
{
|
||||
queryOption.SortList.AddRange(SortString.Split(",", StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
|
||||
if (CustomerSearchModel != null)
|
||||
{
|
||||
queryOption.SearchModel = CustomerSearchModel;
|
||||
}
|
||||
var queryOption = BuildQueryPageOptions();
|
||||
|
||||
queryData = await InternalOnQueryAsync(queryOption);
|
||||
TotalCount = queryData.TotalCount;
|
||||
@ -546,6 +521,37 @@ public partial class Table<TItem>
|
||||
}
|
||||
}
|
||||
|
||||
private QueryPageOptions BuildQueryPageOptions()
|
||||
{
|
||||
var queryOption = new QueryPageOptions()
|
||||
{
|
||||
IsPage = IsPagination,
|
||||
PageIndex = PageIndex,
|
||||
PageItems = PageItems,
|
||||
SearchText = SearchText,
|
||||
SortOrder = SortOrder,
|
||||
SortName = SortName,
|
||||
SearchModel = SearchModel,
|
||||
StartIndex = StartIndex
|
||||
};
|
||||
|
||||
queryOption.Filters.AddRange(Filters.Values);
|
||||
queryOption.Searchs.AddRange(GetSearchs());
|
||||
queryOption.AdvanceSearchs.AddRange(GetAdvanceSearchs());
|
||||
queryOption.CustomerSearchs.AddRange(GetCustomerSearchs());
|
||||
|
||||
if (!string.IsNullOrEmpty(SortString))
|
||||
{
|
||||
queryOption.SortList.AddRange(SortString.Split(",", StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
|
||||
if (CustomerSearchModel != null)
|
||||
{
|
||||
queryOption.SearchModel = CustomerSearchModel;
|
||||
}
|
||||
return queryOption;
|
||||
}
|
||||
|
||||
private void ResetSelectedRows(IEnumerable<TItem> items) => SelectedRows = items.Where(i => SelectedRows.Any(row => ComparerItem(i, row))).ToList();
|
||||
|
||||
/// <summary>
|
||||
|
@ -199,7 +199,7 @@ public partial class Table<TItem>
|
||||
/// 获得/设置 导出按钮异步回调方法
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Func<IEnumerable<TItem>, Task<bool>>? OnExportAsync { get; set; }
|
||||
public Func<IEnumerable<TItem>, QueryPageOptions, Task<bool>>? OnExportAsync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 保存弹窗中的保存按钮显示文本 默认为资源文件中的 保存
|
||||
@ -809,12 +809,10 @@ public partial class Table<TItem>
|
||||
var ret = false;
|
||||
if (OnExportAsync != null)
|
||||
{
|
||||
ret = await OnExportAsync(Rows);
|
||||
ret = await OnExportAsync(Rows, BuildQueryPageOptions());
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果未提供 OnExportAsync 回调委托使用注入服务来尝试解析
|
||||
// TODO: 这里将本页数据作为参数传递给导出服务,服务本身可以利用自身优势获取全部所需数据,如果获取全部数据呢?
|
||||
ret = await ExcelExport.ExportAsync(Rows, Columns);
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -4603,7 +4603,7 @@ public class TableTest : TableTestBase
|
||||
var table = cut.FindComponent<Table<Foo>>();
|
||||
table.SetParametersAndRender(pb =>
|
||||
{
|
||||
pb.Add(a => a.OnExportAsync, foos => Task.FromResult(true));
|
||||
pb.Add(a => a.OnExportAsync, (foos, options) => Task.FromResult(true));
|
||||
});
|
||||
await cut.InvokeAsync(() => button.Click());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user