优化 表格查询功能
This commit is contained in:
parent
d8224e68d2
commit
6d67743869
|
|
@ -23,9 +23,9 @@ namespace VideoAnalysisRazor.Layouts
|
|||
new MenuDataItem
|
||||
{
|
||||
Path = "/",
|
||||
Name = "首页",
|
||||
Key = "hone",
|
||||
Icon = "home",
|
||||
Name = "课堂指标",
|
||||
Key = "EvaluationProject",
|
||||
Icon = "EvaluationProject",
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ namespace Learn.VideoAnalysis.Components.Pages
|
|||
async void OnChange(QueryModel<CourseGradingCriteria> query)
|
||||
{
|
||||
tableLoading = true;
|
||||
Expression<Func<CourseGradingCriteria, bool>> where = null;
|
||||
List<IConditionalModel> where = default!;
|
||||
if (query.FilterModel != null && ((query.FilterModel?.Count() ?? 0) > 0))
|
||||
{
|
||||
where = query.GetFilterExpression();
|
||||
where = query.ToSqlSugerWhere();
|
||||
}
|
||||
_dataSource = await criteria.AsQueryable()
|
||||
.WhereIF(where != null, where)
|
||||
.Where(where)
|
||||
.ToPageListAsync(query.PageIndex - 1, query.PageSize, _total);
|
||||
tableLoading = false;
|
||||
StateHasChanged();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
<PackageReference Include="AntDesign.Charts" Version="0.4.0" />
|
||||
<PackageReference Include="AntDesign.Extensions.Localization" Version="0.20.2.1" />
|
||||
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
||||
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using FreeRedis;
|
||||
using AntDesign;
|
||||
using AntDesign.TableModels;
|
||||
using FreeRedis;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using SqlSugar;
|
||||
using SqlSugar.IOC;
|
||||
|
|
@ -71,7 +73,43 @@ namespace VideoAnalysisCore.Common
|
|||
/// </summary>
|
||||
public static class ExpandFunction
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 转换 ant 查询枚举 到 sqlsuger枚举
|
||||
/// </summary>
|
||||
/// <param name="filterOperator">ant 查询枚举</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public static ConditionalType ConvertToConditionalType(TableFilterCompareOperator filterOperator)
|
||||
{
|
||||
return filterOperator switch
|
||||
{
|
||||
TableFilterCompareOperator.Equals => ConditionalType.Equal,
|
||||
TableFilterCompareOperator.Contains => ConditionalType.Like,
|
||||
TableFilterCompareOperator.StartsWith => ConditionalType.LikeLeft,
|
||||
TableFilterCompareOperator.EndsWith => ConditionalType.LikeRight,
|
||||
TableFilterCompareOperator.GreaterThan => ConditionalType.GreaterThan,
|
||||
TableFilterCompareOperator.LessThan => ConditionalType.LessThan,
|
||||
TableFilterCompareOperator.GreaterThanOrEquals => ConditionalType.GreaterThanOrEqual,
|
||||
TableFilterCompareOperator.LessThanOrEquals => ConditionalType.LessThanOrEqual,
|
||||
TableFilterCompareOperator.Condition => ConditionalType.In,
|
||||
TableFilterCompareOperator.NotEquals => ConditionalType.NoEqual,
|
||||
TableFilterCompareOperator.IsNull => ConditionalType.IsNullOrEmpty,
|
||||
TableFilterCompareOperator.IsNotNull => ConditionalType.IsNot,
|
||||
TableFilterCompareOperator.NotContains => ConditionalType.NoLike,
|
||||
TableFilterCompareOperator.TheSameDateWith => ConditionalType.EqualNull,
|
||||
TableFilterCompareOperator.Between => ConditionalType.Range,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(filterOperator), filterOperator, "未知的枚举类型!")
|
||||
};
|
||||
}
|
||||
public static List<IConditionalModel> ToSqlSugerWhere(this QueryModel qm )
|
||||
{
|
||||
return qm.FilterModel.SelectMany(s => s.Filters.Select(x => new ConditionalModel()
|
||||
{
|
||||
FieldName = s.FieldName,
|
||||
ConditionalType = ConvertToConditionalType( x.FilterCompareOperator),
|
||||
FieldValue = x.Value.ToString(),
|
||||
} as IConditionalModel)).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取应用有效程序集
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -55,5 +55,6 @@
|
|||
<PackageReference Include="Whisper.net" Version="1.5.0" />
|
||||
<PackageReference Include="Whisper.net.Runtime" Version="1.5.0" />
|
||||
<PackageReference Include="xFFmpeg.NET" Version="6.0.0" />
|
||||
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in New Issue