From e59096592aceddd3913cea7049654a4acefa7565 Mon Sep 17 00:00:00 2001 From: Argo Date: Tue, 4 Jan 2022 09:04:02 +0000 Subject: [PATCH] =?UTF-8?q?!2286=20feat(#I4PBOF):=20add=20AdvanceSearchs?= =?UTF-8?q?=20on=20QueryOptions=20for=20Table=20component=20*=20test:=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=8D=E9=9C=80=E8=A6=81=E7=9A=84=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=20*=20feat:=20bump=20version=20to?= =?UTF-8?q?=20beta13=20*=20feat:=20Table=20=E7=BB=84=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20AdvanceSearchs=20=E6=9D=A1=E4=BB=B6=E9=9B=86?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- .../Components/Table/Table.razor.Edit.cs | 1 + .../Components/Table/Table.razor.Search.cs | 24 +++++++++++++++++++ src/BootstrapBlazor/Misc/QueryPageOptions.cs | 7 +++++- test/UnitTest/Components/EmptyTest.cs | 24 ------------------- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 60721e6c0..267b4a36f 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 6.1.2-beta12 + 6.1.2-beta13 diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs index 3446512a8..0f3fb6379 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs @@ -333,6 +333,7 @@ public partial class Table SortList = SortList, Filters = Filters.Values, Searchs = GetSearchs(), + AdvanceSearchs = GetAdvanceSearchs(), CustomerSearchs = GetCustomerSearchs(), SearchModel = SearchModel, StartIndex = StartIndex diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Search.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Search.cs index 47ac4ba51..89c40bc95 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Search.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Search.cs @@ -219,6 +219,30 @@ public partial class Table return searchs; } + /// + /// 获得 中过滤条件 + /// + /// + protected IEnumerable GetAdvanceSearchs() + { + var searchs = new List(); + // 处理 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; + } + /// /// 通过列集合中的 列与 拼装 IFilterAction 集合 /// diff --git a/src/BootstrapBlazor/Misc/QueryPageOptions.cs b/src/BootstrapBlazor/Misc/QueryPageOptions.cs index 6f4a8137d..40e5e32ab 100644 --- a/src/BootstrapBlazor/Misc/QueryPageOptions.cs +++ b/src/BootstrapBlazor/Misc/QueryPageOptions.cs @@ -28,10 +28,15 @@ public class QueryPageOptions public IEnumerable Searchs { get; set; } = Enumerable.Empty(); /// - /// 获得/设置 获得 中过滤条件 模板中的条件无法获得 + /// 获得/设置 获得 中过滤条件 模板中的条件请使用 获得 /// public IEnumerable CustomerSearchs { get; set; } = Enumerable.Empty(); + /// + /// 获得/设置 获得 中过滤条件 + /// + public IEnumerable AdvanceSearchs { get; set; } = Enumerable.Empty(); + /// /// 获得/设置 排序字段名称 /// diff --git a/test/UnitTest/Components/EmptyTest.cs b/test/UnitTest/Components/EmptyTest.cs index 8322db8c8..6417b1c74 100644 --- a/test/UnitTest/Components/EmptyTest.cs +++ b/test/UnitTest/Components/EmptyTest.cs @@ -35,30 +35,6 @@ public class EmptyTest : BootstrapBlazorTestBase Assert.Contains(text, cut.Markup); } - [Fact] - public void Width_Ok() - { - var cut = Context.RenderComponent(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(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() {