!2286 feat(#I4PBOF): add AdvanceSearchs on QueryOptions for Table component

* test: 移除不需要的单元测试
* feat: bump version to beta13
* feat: Table 组件增加 AdvanceSearchs 条件集合
This commit is contained in:
Argo 2022-01-04 09:04:02 +00:00
parent df09bf8389
commit e59096592a
5 changed files with 32 additions and 26 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>6.1.2-beta12</Version>
<Version>6.1.2-beta13</Version>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

View File

@ -333,6 +333,7 @@ public partial class Table<TItem>
SortList = SortList,
Filters = Filters.Values,
Searchs = GetSearchs(),
AdvanceSearchs = GetAdvanceSearchs(),
CustomerSearchs = GetCustomerSearchs(),
SearchModel = SearchModel,
StartIndex = StartIndex

View File

@ -219,6 +219,30 @@ public partial class Table<TItem>
return searchs;
}
/// <summary>
/// 获得 <see cref="SearchModel"/> 中过滤条件
/// </summary>
/// <returns></returns>
protected IEnumerable<IFilterAction> GetAdvanceSearchs()
{
var searchs = new List<IFilterAction>();
// 处理 SearchModel 条件
if (SearchModel != null)
{
// 处理 SearchModel
var searchColumns = Columns.Where(i => i.Searchable);
foreach (var property in SearchModel.GetType().GetProperties().Where(i => searchColumns.Any(col => col.GetFieldName() == i.Name)))
{
var v = property.GetValue(SearchModel);
if (v != null)
{
searchs.Add(new SearchFilterAction(property.Name, v, FilterAction.Equal));
}
}
}
return searchs;
}
/// <summary>
/// 通过列集合中的 <see cref="ITableColumn.Searchable"/> 列与 <see cref="SearchText"/> 拼装 IFilterAction 集合
/// </summary>

View File

@ -28,10 +28,15 @@ public class QueryPageOptions
public IEnumerable<IFilterAction> Searchs { get; set; } = Enumerable.Empty<IFilterAction>();
/// <summary>
/// 获得/设置 获得 <see cref="Table{TItem}.CustomerSearchModel"/> 中过滤条件 <see cref="Table{TItem}.SearchTemplate"/> 模板中的条件无法获得
/// 获得/设置 获得 <see cref="Table{TItem}.CustomerSearchModel"/> 中过滤条件 <see cref="Table{TItem}.SearchTemplate"/> 模板中的条件请使用 <see cref="AdvanceSearchs" />获得
/// </summary>
public IEnumerable<IFilterAction> CustomerSearchs { get; set; } = Enumerable.Empty<IFilterAction>();
/// <summary>
/// 获得/设置 获得 <see cref="Table{TItem}.SearchModel"/> 中过滤条件
/// </summary>
public IEnumerable<IFilterAction> AdvanceSearchs { get; set; } = Enumerable.Empty<IFilterAction>();
/// <summary>
/// 获得/设置 排序字段名称
/// </summary>

View File

@ -35,30 +35,6 @@ public class EmptyTest : BootstrapBlazorTestBase
Assert.Contains(text, cut.Markup);
}
[Fact]
public void Width_Ok()
{
var cut = Context.RenderComponent<Empty>(builder =>
{
builder.Add(p => p.Width, "200");
builder.Add(i => i.Image, "/src/image/argo.png");
});
Assert.Contains("width=\"200\"", cut.Markup);
}
[Fact]
public void Height_Ok()
{
var cut = Context.RenderComponent<Empty>(builder =>
{
builder.Add(p => p.Height, "200");
builder.Add(i => i.Image, "/src/image/argo.png");
});
Assert.Contains("height=\"200\"", cut.Markup);
}
[Fact]
public void ChildContent_Ok()
{