Skip to content

Commit ec00e69

Browse files
committed
新增底部工具栏标签<util-footer-toolbar>, 封装 Ng-Alain 底部工具栏 <footer-toolbar> 组件.
新增查询表单标签 <util-search-form>,自动设置内部栅格列 span. <util-table> 标签新增 enable-custom-column 属性,开启自定义列设置. <util-a> 标签新增 show-table-settings 属性,点击弹出表格自定义列设置界面. <util-a> 标签新增 is-search 属性, 创建具有展开和收起效果的查询按钮. 修复 Util.Data.EntityFrameworkCore.StoreBase 更新实体验证并发导致的 bug
1 parent 87b5e6b commit ec00e69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2159
-860
lines changed

build/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<VersionMinor>0</VersionMinor>
55
<VersionPatch>1</VersionPatch>
66
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
7-
<VersionSuffix>pre-6</VersionSuffix>
7+
<VersionSuffix></VersionSuffix>
88
</PropertyGroup>
99
</Project>

src/Util.Data.EntityFrameworkCore/StoreBase.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Util.Exceptions;
44
using Util.Validation;
55

6-
namespace Util.Data.EntityFrameworkCore;
6+
namespace Util.Data.EntityFrameworkCore;
77

88
/// <summary>
99
/// 存储器
@@ -133,7 +133,7 @@ public TEntity FindById( object id ) {
133133
if ( id.SafeString().IsEmpty() )
134134
return null;
135135
var key = GetKey( id );
136-
if( IsTracking )
136+
if ( IsTracking )
137137
return Set.Find( key );
138138
return Single( t => t.Id.Equals( key ) );
139139
}
@@ -142,7 +142,7 @@ public TEntity FindById( object id ) {
142142
/// 获取标识
143143
/// </summary>
144144
protected object GetKey( object id ) {
145-
if( id is TKey )
145+
if ( id is TKey )
146146
return id;
147147
return Util.Helpers.Convert.To<TKey>( id );
148148
}
@@ -158,7 +158,7 @@ protected object GetKey( object id ) {
158158
if ( id.SafeString().IsEmpty() )
159159
return null;
160160
var key = GetKey( id );
161-
if( IsTracking )
161+
if ( IsTracking )
162162
return await Set.FindAsync( new[] { key }, cancellationToken );
163163
return await SingleAsync( t => t.Id.Equals( key ), cancellationToken );
164164
}
@@ -212,7 +212,7 @@ public virtual TEntity Single( Expression<Func<TEntity, bool>> condition ) {
212212
}
213213

214214
/// <inheritdoc />
215-
public virtual TEntity Single( Expression<Func<TEntity, bool>> condition,Func<IQueryable<TEntity>, IQueryable<TEntity>> action ) {
215+
public virtual TEntity Single( Expression<Func<TEntity, bool>> condition, Func<IQueryable<TEntity>, IQueryable<TEntity>> action ) {
216216
if ( action == null )
217217
return Single( condition );
218218
return action( Find() ).FirstOrDefault( condition );
@@ -328,7 +328,7 @@ public virtual int Count( Expression<Func<TEntity, bool>> condition = null ) {
328328
/// </summary>
329329
protected virtual void Validate( IEnumerable<TEntity> entities ) {
330330
entities.CheckNull( nameof( entities ) );
331-
foreach ( var entity in entities )
331+
foreach ( var entity in entities )
332332
Validate( entity );
333333
}
334334

@@ -337,7 +337,7 @@ protected virtual void Validate( IEnumerable<TEntity> entities ) {
337337
/// </summary>
338338
protected virtual void Validate( TEntity entity ) {
339339
entity.CheckNull( nameof( entity ) );
340-
if ( entity is IValidation validation )
340+
if ( entity is IValidation validation )
341341
validation.Validate();
342342
}
343343

@@ -382,6 +382,8 @@ protected void Update( TEntity entity ) {
382382
protected virtual void ValidateVersion( EntityEntry<TEntity> entry, TEntity entity ) {
383383
if ( entity is not IVersion current )
384384
return;
385+
if ( entry.State == EntityState.Added )
386+
return;
385387
if ( current.Version == null || current.Version.Length == 0 ) {
386388
ThrowConcurrencyException( entity );
387389
return;

src/Util.Ui.Angular/Configs/AngularConst.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,4 +1700,8 @@ public static class AngularConst {
17001700
/// 自动换行
17011701
/// </summary>
17021702
public const string BindWrap = "bind-wrap";
1703+
/// <summary>
1704+
/// 单元格控件
1705+
/// </summary>
1706+
public const string BindCellControl = "bind-cell-control";
17031707
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Util.Ui.Angular.Builders;
2+
using Util.Ui.Angular.Configs;
3+
using Util.Ui.Configs;
4+
5+
namespace Util.Ui.NgAlain.Components.FooterToolbars.Builders;
6+
7+
/// <summary>
8+
/// 底部工具栏生成器
9+
/// </summary>
10+
public class FooterToolbarBuilder : AngularTagBuilder {
11+
/// <summary>
12+
/// 配置
13+
/// </summary>
14+
private readonly Config _config;
15+
/// <summary>
16+
/// 初始化底部工具栏生成器
17+
/// </summary>
18+
/// <param name="config">配置</param>
19+
public FooterToolbarBuilder( Config config ) : base( config, "footer-toolbar" ) {
20+
_config = config;
21+
}
22+
23+
/// <summary>
24+
/// 配置错误收集
25+
/// </summary>
26+
public FooterToolbarBuilder ErrorCollect() {
27+
AttributeIfNotEmpty( "[errorCollect]", _config.GetValue( UiConst.ErrorCollect ) );
28+
return this;
29+
}
30+
31+
/// <summary>
32+
/// 配置额外信息
33+
/// </summary>
34+
public FooterToolbarBuilder Extra() {
35+
AttributeIfNotEmpty( "extra", _config.GetValue( UiConst.Extra ) );
36+
AttributeIfNotEmpty( "[extra]", _config.GetValue( AngularConst.BindExtra ) );
37+
return this;
38+
}
39+
40+
/// <summary>
41+
/// 配置
42+
/// </summary>
43+
public override void Config() {
44+
base.Config();
45+
ErrorCollect().Extra();
46+
}
47+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Razor.TagHelpers;
2+
using Util.Ui.Angular.TagHelpers;
3+
using Util.Ui.Configs;
4+
using Util.Ui.NgAlain.Components.FooterToolbars.Renders;
5+
using Util.Ui.Renders;
6+
7+
namespace Util.Ui.NgAlain.Components.FooterToolbars;
8+
9+
/// <summary>
10+
/// ng-alain 底部工具栏,生成的标签为&lt;footer-toolbar&gt;&lt;/footer-toolbar&gt;
11+
/// </summary>
12+
[HtmlTargetElement( "util-footer-toolbar" )]
13+
public class FooterToolbarTagHelper : AngularTagHelperBase {
14+
/// <summary>
15+
/// [errorCollect],是否收集表单错误,需要放入 form 标签内, 默认值: false
16+
/// </summary>
17+
public string ErrorCollect { get; set; }
18+
/// <summary>
19+
/// extra,额外信息,显示在左边
20+
/// </summary>
21+
public string Extra { get; set; }
22+
/// <summary>
23+
/// [extra],额外信息,显示在左边
24+
/// </summary>
25+
public string BindExtra { get; set; }
26+
27+
/// <inheritdoc />
28+
protected override IRender GetRender( TagHelperContext context, TagHelperOutput output, TagHelperContent content ) {
29+
var config = new Config( context, output, content );
30+
return new FooterToolbarRender( config );
31+
}
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Util.Ui.Angular.Extensions;
2+
using Util.Ui.Builders;
3+
using Util.Ui.Configs;
4+
using Util.Ui.NgAlain.Components.FooterToolbars.Builders;
5+
using Util.Ui.Renders;
6+
7+
namespace Util.Ui.NgAlain.Components.FooterToolbars.Renders;
8+
9+
/// <summary>
10+
/// 底部工具栏渲染器
11+
/// </summary>
12+
public class FooterToolbarRender : RenderBase {
13+
/// <summary>
14+
/// 配置
15+
/// </summary>
16+
private readonly Config _config;
17+
18+
/// <summary>
19+
/// 初始化底部工具栏渲染器
20+
/// </summary>
21+
/// <param name="config">配置</param>
22+
public FooterToolbarRender( Config config ) {
23+
_config = config;
24+
}
25+
26+
/// <summary>
27+
/// 获取标签生成器
28+
/// </summary>
29+
protected override TagBuilder GetTagBuilder() {
30+
var builder = new FooterToolbarBuilder( _config );
31+
builder.Config();
32+
return builder;
33+
}
34+
35+
/// <inheritdoc />
36+
public override IHtmlContent Clone() {
37+
return new FooterToolbarRender( _config.CopyRemoveAttributes() );
38+
}
39+
}

src/Util.Ui.NgZorro/Components/Links/ATagHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public class ATagHelper : ButtonTagHelperBase {
4343
/// 扩展属性,是否查询表单链接,折叠时显示展开文本,展开时显示收起文本
4444
/// </summary>
4545
public bool IsSearch { get; set; }
46+
/// <summary>
47+
/// 扩展属性,显示表格设置,参数值为表格标识
48+
/// </summary>
49+
public string ShowTableSettings { get; set; }
4650

4751
/// <inheritdoc />
4852
protected override IRender GetRender( TagHelperContext context, TagHelperOutput output, TagHelperContent content ) {

src/Util.Ui.NgZorro/Components/Links/Builders/ABuilder.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Util.Ui.NgZorro.Components.Base;
55
using Util.Ui.NgZorro.Components.Icons.Builders;
66
using Util.Ui.NgZorro.Configs;
7+
using Util.Ui.NgZorro.Directives.Tooltips;
8+
using Util.Ui.NgZorro.Enums;
79

810
namespace Util.Ui.NgZorro.Components.Links.Builders;
911

@@ -70,8 +72,8 @@ public ABuilder IsSearch() {
7072
return this;
7173
this.OnClick( "expand=!expand" );
7274
var options = NgZorroOptionsService.GetOptions();
73-
if (options.EnableI18n)
74-
AppendContent("{{" + $"expand?('{I18nKeys.Collapse}'|i18n):('{I18nKeys.Expand}'|i18n)" + "}}");
75+
if ( options.EnableI18n )
76+
AppendContent( "{{" + $"expand?('{I18nKeys.Collapse}'|i18n):('{I18nKeys.Expand}'|i18n)" + "}}" );
7577
else
7678
AppendContent( "{{expand?'收起':'展开'}}" );
7779
var icon = new IconBuilder( _config );
@@ -80,11 +82,29 @@ public ABuilder IsSearch() {
8082
return this;
8183
}
8284

85+
/// <summary>
86+
/// 配置显示表格设置
87+
/// </summary>
88+
public ABuilder ShowTableSettings() {
89+
var tableId = _config.GetValue( UiConst.ShowTableSettings );
90+
if ( tableId.IsEmpty() )
91+
return this;
92+
this.OnClick( $"ts_{tableId}.show()" );
93+
Class( "btn-table-settings" );
94+
var options = NgZorroOptionsService.GetOptions();
95+
this.TooltipTitle( options.EnableI18n ? "util.tableSettings" : "表格设置" );
96+
var icon = new IconBuilder( _config );
97+
icon.Type( AntDesignIcon.Setting );
98+
AppendContent( icon );
99+
return this;
100+
}
101+
83102
/// <summary>
84103
/// 配置
85104
/// </summary>
86105
public override void Config() {
87106
base.Config();
88-
ConfigButton().Href().Target().Rel().RouterLink().DropdownMenu().DropdownMenuPlacement().IsSearch();
107+
ConfigButton().Href().Target().Rel().RouterLink().DropdownMenu()
108+
.DropdownMenuPlacement().IsSearch().ShowTableSettings();
89109
}
90110
}

src/Util.Ui.NgZorro/Components/Tables/Builders/TableBuilder.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Util.Ui.Angular.Builders;
22
using Util.Ui.Angular.Configs;
33
using Util.Ui.Angular.Extensions;
4-
using Util.Ui.Configs;
54
using Util.Ui.Extensions;
65
using Util.Ui.NgZorro.Components.Tables.Configs;
76
using Util.Ui.NgZorro.Components.Tables.Helpers;
@@ -499,6 +498,32 @@ public TableBuilder ConfigKeys() {
499498
return this;
500499
}
501500

501+
/// <summary>
502+
/// 配置自定义列
503+
/// </summary>
504+
public TableBuilder CustomColumn() {
505+
CustomColumn( _config.GetValue( UiConst.CustomColumn ) );
506+
return this;
507+
}
508+
509+
/// <summary>
510+
/// 配置自定义列
511+
/// </summary>
512+
public TableBuilder CustomColumn( string value ) {
513+
AttributeIfNotEmpty( "[nzCustomColumn]", value );
514+
return this;
515+
}
516+
517+
/// <summary>
518+
/// 配置启用自定义列
519+
/// </summary>
520+
public TableBuilder EnableCustomColumn() {
521+
if (_shareConfig.IsEnableCustomColumn == false)
522+
return this;
523+
CustomColumn( $"{_shareConfig.TableSettingsId}.columns" );
524+
return this;
525+
}
526+
502527
/// <summary>
503528
/// 配置事件
504529
/// </summary>
@@ -566,6 +591,7 @@ public override void Config() {
566591
.Layout()
567592
.QueryParam().Url().DeleteUrl()
568593
.Sort().AutoLoad().ConfigKeys()
594+
.CustomColumn().EnableCustomColumn()
569595
.Events();
570596
ConfigAutoCreate();
571597
if ( _shareConfig.IsEnableExtend )

src/Util.Ui.NgZorro/Components/Tables/Builders/TableColumnBuilder.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Util.Ui.Angular.Builders;
22
using Util.Ui.Angular.Configs;
33
using Util.Ui.Builders;
4-
using Util.Ui.Configs;
54
using Util.Ui.NgZorro.Components.Tables.Builders.Contents;
65
using Util.Ui.NgZorro.Components.Tables.Configs;
76
using Util.Ui.NgZorro.Enums;
@@ -160,6 +159,34 @@ public TableColumnBuilder IndentSize() {
160159
return this;
161160
}
162161

162+
/// <summary>
163+
/// 配置单元格控件
164+
/// </summary>
165+
public virtual TableColumnBuilder CellControl() {
166+
CellControl( _config.GetValue( UiConst.CellControl ) );
167+
AttributeIfNotEmpty( "[nzCellControl]", _config.GetValue( AngularConst.BindCellControl ) );
168+
return this;
169+
}
170+
171+
/// <summary>
172+
/// 配置单元格控件
173+
/// </summary>
174+
/// <param name="value">值</param>
175+
public virtual TableColumnBuilder CellControl( string value ) {
176+
AttributeIfNotEmpty( "nzCellControl", value );
177+
return this;
178+
}
179+
180+
/// <summary>
181+
/// 配置启用自定义列
182+
/// </summary>
183+
public TableColumnBuilder EnableCustomColumn() {
184+
if ( _shareConfig.IsEnableCustomColumn == false )
185+
return this;
186+
CellControl( _shareConfig.CellControl );
187+
return this;
188+
}
189+
163190
/// <summary>
164191
/// 配置事件
165192
/// </summary>
@@ -177,7 +204,7 @@ public override void Config() {
177204
ShowCheckbox().Disabled().Indeterminate().Checked()
178205
.ShowExpand().Expand()
179206
.Left().Right().Align().BreakWord().Ellipsis()
180-
.IndentSize()
207+
.IndentSize().CellControl().EnableCustomColumn()
181208
.Events();
182209
ConfigContent();
183210
}

0 commit comments

Comments
 (0)