Skip to content

Commit 92bf36b

Browse files
committed
refactor: 移除 FieldKey 接口参数
1 parent 44dfaba commit 92bf36b

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

src/BootstrapBlazor/Components/Filters/IFilterAction.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ namespace BootstrapBlazor.Components;
1313
[JsonDerivedType(typeof(SearchFilterAction))]
1414
public interface IFilterAction
1515
{
16-
/// <summary>
17-
/// 获得/设置 过滤器 Key 值
18-
/// </summary>
19-
public string? FieldKey { get; set; }
20-
2116
/// <summary>
2217
/// 获得 IFilter 实例中的过滤条件集合
2318
/// </summary>

src/BootstrapBlazor/Components/Filters/SearchFilterAction.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ namespace BootstrapBlazor.Components;
1313
/// <param name="action"></param>
1414
public class SearchFilterAction(string name, object? value, FilterAction action = FilterAction.Contains) : IFilterAction
1515
{
16-
/// <summary>
17-
/// <inheritdoc/>
18-
/// </summary>
19-
public string? FieldKey { get; set; } = name;
20-
2116
/// <summary>
2217
/// 获得/设置 过滤条件名称
2318
/// </summary>

src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public partial class TableColumnFilter : IFilter
7474
[NotNull]
7575
public IFilterAction? FilterAction { get; set; }
7676

77+
private string _fieldKey = "";
78+
7779
/// <summary>
7880
/// <inheritdoc/>
7981
/// </summary>
@@ -82,6 +84,7 @@ protected override void OnInitialized()
8284
base.OnInitialized();
8385

8486
Column.Filter = this;
87+
_fieldKey = Column.GetFieldName();
8588
}
8689

8790
/// <summary>
@@ -126,20 +129,14 @@ public async Task OnFilterAsync()
126129
return;
127130
}
128131

129-
var fieldKey = FilterAction.FieldKey;
130-
if (string.IsNullOrEmpty(fieldKey))
131-
{
132-
return;
133-
}
134-
135132
var action = FilterAction.GetFilterConditions();
136133
if (action.Filters != null && action.Filters.Count > 0)
137134
{
138-
Table.Filters[fieldKey] = FilterAction;
135+
Table.Filters[_fieldKey] = FilterAction;
139136
}
140137
else
141138
{
142-
Table.Filters.Remove(fieldKey);
139+
Table.Filters.Remove(_fieldKey);
143140
}
144141

145142
await Table.OnFilterAsync();

0 commit comments

Comments
 (0)