77 lines
2.8 KiB
Plaintext
77 lines
2.8 KiB
Plaintext
@page "/Project"
|
|
@using AntDesign
|
|
@using AntDesign.TableModels
|
|
@using System.ComponentModel.DataAnnotations
|
|
@using SqlSugar
|
|
@using VideoAnalysisCore.Model
|
|
|
|
<Table @ref="_table" Loading="tableLoading" TItem="CourseGradingCriteria" ScrollY="600px" PageSize="15" Total="_total" DataSource="_dataSource" @bind-SelectedRows="_selectedRows" OnChange="OnChange">
|
|
<TitleTemplate>
|
|
<Flex Justify="end" Gap="10">
|
|
<Button Type="primary" @onclick="()=> StartEdit(default)">新增</Button>
|
|
@* <Button Disabled="!_selectedRows.Any()" Danger @onclick="DeleteAll">Delete</Button> *@
|
|
</Flex>
|
|
</TitleTemplate>
|
|
<ColumnDefinitions Context="row">
|
|
<ActionColumn Title="操作列" Width ="230px">
|
|
<a @onclick="() => StartEdit(row)">修改</a>
|
|
<Button Type="@ButtonType.Link" Danger @onclick="() => Delete(row)">
|
|
删除</Button>
|
|
</ActionColumn>
|
|
<PropertyColumn Property="c=>c.Id" Width="130px" Filterable="true" Sortable="true" />
|
|
<PropertyColumn Property="c=>c.NamePrompt" />
|
|
</ColumnDefinitions>
|
|
</Table>
|
|
|
|
@inject ModalService ModalService
|
|
@code
|
|
{
|
|
/// <summary>
|
|
/// 新增或者修改
|
|
/// </summary>
|
|
/// <param name="row"></param>
|
|
void StartEdit(CourseGradingCriteria row)
|
|
{
|
|
var data = row == null ? new() : row;
|
|
IForm? form = default;
|
|
ModalRef<bool> modalRef = default;
|
|
modalRef = ModalService.CreateModal<bool>(new()
|
|
{
|
|
Title = data.Id > 0 ? "修改" : "新增",
|
|
Content =
|
|
@<Form @ref="form" Model="data" OnFinish="()=> modalRef.OkAsync(true)"
|
|
LabelColSpan="6" WrapperColSpan="18">
|
|
<FormItem Label="标准提问词" >
|
|
<TextArea Rows="4" @bind-Value="@context.NamePrompt" />
|
|
</FormItem>
|
|
</Form>
|
|
,
|
|
OkText = "确定",
|
|
CancelText = "取消",
|
|
OnOk = async (e) =>
|
|
{
|
|
if (!form.Validate())
|
|
return;
|
|
// save db and refresh
|
|
modalRef.SetConfirmLoading(true);
|
|
|
|
if (data.Id > 0)
|
|
await criteria.UpdateAsync(data);
|
|
else
|
|
data.Id = await criteria.InsertReturnBigIdentityAsync(data);
|
|
//弹窗按钮 show
|
|
modalRef.SetConfirmLoading(false);
|
|
|
|
await modalRef.CloseAsync();
|
|
_table.ReloadData();
|
|
StateHasChanged();
|
|
},
|
|
OnCancel = async (e) =>
|
|
{
|
|
if (form.IsModified && (!await Comfirm("表格已经更新,您确定要退出吗?")))
|
|
return;
|
|
await modalRef.CloseAsync();
|
|
}
|
|
});
|
|
}
|
|
} |