76

V2.0.9

本次版本主要是修复一些BUG和表格页面功能增强。

更新日期

  • 2024-08-22

更新内容

  • 🐛修复DataReader转字典报错问题
  • 😄AntBlazor升级至V0.20.2
  • 🐛修复实体类表单确定继续主键重复问题
  • 🐛修复打开新增表单克隆默认实体只读属性报错问题
  • 🔨优化无代码表单界面无法验证和输入字符减少问题
  • 😄添加支持WebApi项目
  • 😄表格排序和默认排序方式设置
  • 😄表格页面添加默认分页大小设置
  • 😄表格查询条件支持默认值
  • 😄分页查询支持数据统计
  • 😄数据字典类别支持修改和删除
  • 🐛修复SqlSugar日期查询条件问题
  • 🔨优化多语言设置

详细内容

1. 内置功能增强

  • 数据字典类别支持修改和删除

输入图片说明

2. 表格功能增强

  • 表格排序和默认排序方式设置
  • 表格页面添加默认分页大小设置

输入图片说明

  • 表格查询条件支持默认值
//在OnPageInitAsync方法中设置DefaultQuery对象,对象属性为实体类属性
//注意:一定要在await base.OnPageInitAsync();之前设置
protected override async Task OnPageInitAsync()
{
    var date = DateTime.Now.ToString("yyyy-MM-dd");
    DefaultQuery = new { CreateTime = $"{date}~{date}" };
    
    await base.OnPageInitAsync();
    Service = await CreateServiceAsync<ISystemService>();

    Table.OnQuery = Service.QueryLogsAsync;
    Table.Column(c => c.Type).Template((b, r) => b.Tag(r.Type));
}

输入图片说明

  • 分页查询支持数据统计,统计支持SQL函数和SQL表达式
//前端,在OnPageInitAsync中设置TopStatis模板,查询数据时根据后端返回结果自动刷新
protected override async Task OnPageInitAsync()
{
    await base.OnPageInitAsync();
    Service = await CreateServiceAsync<IApplyService>();

    Table.FormType = typeof(ApplyForm);
    Table.OnQuery = Service.QueryApplysAsync;
    Table.TopStatis = this.BuildTree<PagingResult<TbApply>>((b, r) =>
    {
        var sb = new System.Text.StringBuilder();
        sb.Append("<div style=\"padding-left:10px;color:#108ee9;\">");
        sb.Append($"总数:<span style=\"font-weight:bold\">{r?.TotalCount}</span>,");
        sb.Append($"撤回:<span style=\"font-weight:bold\">{r?.Statis?.GetValue<int>("RevokeCount")}</span>,");
        sb.Append($"待审核:<span style=\"font-weight:bold\">{r?.Statis?.GetValue<int>("VerifingCount")}</span>,");
        sb.Append($"审核通过:<span style=\"font-weight:bold\">{r?.Statis?.GetValue<int>("PassCount")}</span>,");
        sb.Append($"审核退回:<span style=\"font-weight:bold\">{r?.Statis?.GetValue<int>("FailCount")}</span>");
        sb.Append("</div>");
        b.Markup(sb.ToString());
    });
    Table.Column(c => c.BizStatus).Template((b, r) => b.Tag(r.BizStatus));
}

//后端,设置查询条件StatisColumns统计栏位属性,支持Function和Expression
internal static Task<PagingResult<TbApply>> QueryApplysAsync(Database db, PagingCriteria criteria)
{
    var sql = @"select a.*,b.BizStatus,b.CurrStep,b.CurrBy,b.ApplyBy,b.ApplyTime,b.VerifyBy,b.VerifyTime,b.VerifyNote 
from TbApply a,SysFlow b 
where a.Id=b.BizId and a.CompNo=@CompNo";
    criteria.StatisColumns = [
        new StatisColumnInfo { Id = nameof(TbApply.Id), Function = "count" },
        new StatisColumnInfo { Id = "RevokeCount", Expression = $"sum(case when BizStatus='{FlowStatus.Revoked}' then 1 else 0 end)" },
        new StatisColumnInfo { Id = "VerifingCount", Expression = $"sum(case when BizStatus='{FlowStatus.Verifing}' then 1 else 0 end)" },
        new StatisColumnInfo { Id = "PassCount", Expression = $"sum(case when BizStatus='{FlowStatus.VerifyPass}' then 1 else 0 end)" },
        new StatisColumnInfo { Id = "FailCount", Expression = $"sum(case when BizStatus='{FlowStatus.VerifyFail}' then 1 else 0 end)" }
    ];
    return db.QueryPageAsync<TbApply>(sql, criteria);
}

输入图片说明

3. WebApi项目

  • 添加支持WebApi项目,在项目Program中AddKnown和AddKnownCore
builder.Services.AddKnown(info =>
{
    info.Id = "API";
    info.Type = AppType.WebApi;//App类型设为WebApi
});
builder.Services.AddKnownCore(info =>
{
    //数据库连接
    info.Connections = [new Known.ConnectionInfo
    {
        Name = "Default",
        DatabaseType = DatabaseType.SQLite,
        ProviderType = typeof(Microsoft.Data.Sqlite.SqliteFactory),
        ConnectionString = builder.Configuration.GetSection("ConnString").Get<string>()
    }];
});