71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
using AntDesign.TableModels;
|
|
using Microsoft.AspNetCore.Components;
|
|
using SqlSugar;
|
|
using System.Linq.Expressions;
|
|
using VideoAnalysisCore.Common;
|
|
using VideoAnalysisCore.Model;
|
|
|
|
namespace Learn.VideoAnalysis.Components.Pages
|
|
{
|
|
public partial class EvaluationProject : ComponentBase
|
|
{
|
|
|
|
[Inject] private ConfirmService ComfirmService { get; set; } = default!;
|
|
[Inject] private Repository<CourseGradingCriteria> criteria { get; set; } = default!;
|
|
|
|
|
|
IEnumerable<CourseGradingCriteria> _selectedRows = [];
|
|
ITable _table;
|
|
|
|
List<CourseGradingCriteria> _dataSource = null;
|
|
RefAsync<int> _total = 0;
|
|
|
|
bool tableLoading = false;
|
|
|
|
/// <summary>
|
|
/// 分页 查询 筛选 时
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
async void OnChange(QueryModel<CourseGradingCriteria> query)
|
|
{
|
|
tableLoading = true;
|
|
List<IConditionalModel> where = default!;
|
|
if (query.FilterModel != null && ((query.FilterModel?.Count() ?? 0) > 0))
|
|
{
|
|
where = query.ToSqlSugerWhere();
|
|
}
|
|
_dataSource = await criteria.AsQueryable()
|
|
.Where(where)
|
|
.ToPageListAsync(query.PageIndex - 1, query.PageSize, _total);
|
|
tableLoading = false;
|
|
StateHasChanged();
|
|
|
|
}
|
|
/// <summary>
|
|
/// 删除行
|
|
/// </summary>
|
|
/// <param name="row"></param>
|
|
/// <returns></returns>
|
|
async Task Delete(CourseGradingCriteria row)
|
|
{
|
|
if (!await Comfirm($"确定要删除这条数据吗? [{row.NamePrompt}]?"))
|
|
return;
|
|
await criteria.DeleteByIdAsync(row.Id);
|
|
_table.ReloadData();
|
|
}
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
protected override void OnInitialized()
|
|
{
|
|
}
|
|
|
|
private async Task<bool> Comfirm(string message)
|
|
{
|
|
return await ComfirmService.Show(message, "提示", ConfirmButtons.YesNo, ConfirmIcon.Warning) == ConfirmResult.Yes;
|
|
}
|
|
|
|
}
|
|
|
|
}
|