Known是基于Blazor的企业级快速开发框架,低代码,跨平台,开箱即用,一处代码,多处运行。本次版本主要是修复一些BUG和表格页面功能增强。
C#
和Blazor
的快速开发框架,开箱即用,跨平台。UI
默认支持AntDesign
,可扩展其他UI组件库。Blazor
,在线表单设计,自动生成代码UI
:抽象UI层,易扩展,支持Ant Design
等C#
语言:全量使用C#
进行全栈开发如果对您有帮助,点击⭐Star⭐关注 ,感谢支持开源!
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));
}
//前端,在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项目
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>()
}];
});