iotgateway/WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/GeneratorFiles/Spa/Blazor/Edit.txt
2021-12-14 14:10:44 +08:00

42 lines
1.2 KiB
Plaintext

@page "$pagepath$"
@using $vmnamespace$;
@inherits BasePage
<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
<Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
$formfields$
</Row>
<div class="modal-footer table-modal-footer">
<Button Color="Color.Primary" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose" />
<Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Edit"]" IsAsync="true" />
</div>
</ValidateForm>
@code {
private $modelname$VM Model = null;
private ValidateForm vform { get; set; }
[Parameter]
public string id { get; set; }
$fieldinit$
protected override async Task OnInitializedAsync()
{
$init$
var rv = await WtmBlazor.Api.CallAPI<$modelname$VM>($"/api/$modelname$/{id}");
Model = rv.Data;
await base.OnInitializedAsync();
}
private async Task Submit(EditContext context)
{
await PostsForm(vform, $"/api/$modelname$/edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
}
public void OnClose()
{
CloseDialog();
}
}