155 lines
4.8 KiB
C#
155 lines
4.8 KiB
C#
using AntDesign;
|
|
using AntDesign.TableModels;
|
|
using FreeRedis;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using SqlSugar;
|
|
using System.Drawing;
|
|
using System.Linq.Expressions;
|
|
using System.Reflection;
|
|
using UserCenter.Model;
|
|
using UserCenter.Model.Enum;
|
|
using VideoAnalysisCore.Common;
|
|
using VideoAnalysisCore.Model.Enum;
|
|
using VideoAnalysisCore.Model;
|
|
using Learn.VideoAnalysis.API.Expand;
|
|
|
|
|
|
namespace Learn.VideoAnalysis.Components.Pages
|
|
{
|
|
public partial class EvaluationProject : ComponentBase
|
|
{
|
|
|
|
[Inject] private ConfirmService ComfirmService { get; set; } = default!;
|
|
[Inject] private ModalService ModalService { get; set; } = default!;
|
|
[Inject] private Repository<CourseGradingCriteria> criteria { get; set; } = default!;
|
|
[Inject] private INotificationService _notice { get; set; } = default!;
|
|
|
|
|
|
IEnumerable<CourseGradingCriteria> _selectedRows = [];
|
|
ITable _table;
|
|
IForm? form;
|
|
|
|
List<CourseGradingCriteria> _dataSource = null;
|
|
RefAsync<int> _total = 0;
|
|
|
|
bool tableLoading = false;
|
|
Table<CourseGradingCriteria> tableRef;
|
|
List<CourseGradingCriteria> _editSource = null;
|
|
|
|
|
|
bool modalShow =false;
|
|
bool modalBtnLoading = false;
|
|
CourseGradingCriteria rowData;
|
|
SubjectEnum editSubject;
|
|
|
|
async void SubjectEnumSelect()
|
|
{
|
|
_editSource = await criteria.GetListAsync(x => x.Subject.Value == editSubject);
|
|
await this.InvokeAsync(StateHasChanged);
|
|
}
|
|
void EditAddRow()
|
|
{
|
|
if (form is not null && form.Validate())
|
|
{
|
|
var data = rowData;
|
|
data.Subject = editSubject;
|
|
if (_editSource is null)
|
|
_editSource = new() { data };
|
|
else
|
|
_editSource.Add(data);
|
|
rowData = new();
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 新增或者修改
|
|
/// </summary>
|
|
void StartEdit()
|
|
{
|
|
rowData = new();
|
|
modalShow = true;
|
|
}
|
|
|
|
async Task EditOnOkAsync()
|
|
{
|
|
var data = rowData;
|
|
modalBtnLoading = true;
|
|
if (_editSource is null || _editSource.Count == 0)
|
|
{
|
|
await _notice.Open(new NotificationConfig()
|
|
{
|
|
Message = "提示",
|
|
Description = "无效的学科课堂指标数据",
|
|
NotificationType = NotificationType.Warning
|
|
});
|
|
modalBtnLoading = false;
|
|
return;
|
|
}
|
|
if (_editSource.Sum(x => x.TotalScore) != 100)
|
|
{
|
|
await _notice.Open(new NotificationConfig()
|
|
{
|
|
Message = "提示",
|
|
Description = "课堂指标 总分不满100!请完善",
|
|
NotificationType = NotificationType.Warning
|
|
});
|
|
modalBtnLoading = false;
|
|
return;
|
|
}
|
|
await criteria.DeleteAsync(s => s.Subject == editSubject);
|
|
await criteria.InsertRangeAsync(_editSource);
|
|
|
|
_table.ReloadData();
|
|
modalShow = false;
|
|
modalBtnLoading = false;
|
|
StateHasChanged();
|
|
|
|
}
|
|
/// <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, 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;
|
|
}
|
|
|
|
}
|
|
|
|
}
|