调整地区实体
This commit is contained in:
@@ -1,5 +1,137 @@
|
||||
<h3>CountryEdit</h3>
|
||||
@page "/country/create"
|
||||
@page "/country/edit/{id:long}"
|
||||
@page "/{locale}/country/create"
|
||||
@page "/{locale}/country/edit/{id:long}"
|
||||
|
||||
@inject ILogger<CountryEdit> Logger
|
||||
@attribute [Authorize]
|
||||
|
||||
<PageContainer Title="@(Id > 0 ? "编辑国家信息" : "新增国家信息")">
|
||||
<Breadcrumb>
|
||||
<Breadcrumb>
|
||||
<BreadcrumbItem Href="/">管理后台</BreadcrumbItem>
|
||||
<BreadcrumbItem Href="/admin/list">系统配置</BreadcrumbItem>
|
||||
<BreadcrumbItem Href="/country/list">国家管理</BreadcrumbItem>
|
||||
</Breadcrumb>
|
||||
</Breadcrumb>
|
||||
<ChildContent>
|
||||
|
||||
<Spin Spinning="pageLoading">
|
||||
<Card Title="货币信息">
|
||||
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync">
|
||||
<FormItem Label="名称" Required>
|
||||
<Input @bind-Value="@context.Name" Placeholder="货币名称" />
|
||||
</FormItem>
|
||||
<FormItem Label="货币代码">
|
||||
<Input @bind-Value="@context.CurrencyCode" Placeholder="货币代码" />
|
||||
</FormItem>
|
||||
<FormItem Label="汇率">
|
||||
<Input @bind-Value="@context.Rate" Placeholder="汇率" />
|
||||
</FormItem>
|
||||
<FormItem Label="展示本地">
|
||||
<SimpleSelect @bind-Value="@context.DisplayLocale" Placeholder="语言文化">
|
||||
<SelectOptions>
|
||||
@foreach (var item in LanguageCultures)
|
||||
{
|
||||
<SimpleSelectOption Value="@item.Key" Label="@($"{item.Value} - {item.Key}")"></SimpleSelectOption>
|
||||
}
|
||||
</SelectOptions>
|
||||
</SimpleSelect>
|
||||
</FormItem>
|
||||
<FormItem Label="自定义格式">
|
||||
<Input @bind-Value="@context.CustomFormatting" Placeholder="自定义格式" />
|
||||
</FormItem>
|
||||
<FormItem Label="显示排序">
|
||||
<Input @bind-Value="@context.DisplayOrder" Placeholder="显示排序" />
|
||||
</FormItem>
|
||||
<FormItem Label="状态">
|
||||
<Checkbox Checked="@context.Enabled">启用</Checkbox>
|
||||
</FormItem>
|
||||
<FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }">
|
||||
<Button Type="@ButtonType.Primary" HtmlType="submit" Loading="saving">
|
||||
提交保存
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Card>
|
||||
</Spin>
|
||||
</ChildContent>
|
||||
</PageContainer>
|
||||
@code {
|
||||
[Parameter]
|
||||
public string Locale { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public long Id { get; set; }
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
CurrencyModel model { get; set; } = new();
|
||||
Form<CurrencyModel> editform = null!;
|
||||
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary();
|
||||
bool pageLoading = false;
|
||||
bool saving = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (Id > 0)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
async void LoadData()
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = $"/api/currency/{Id}";
|
||||
var apiResult = await HttpService.Get<ApiResult<Currency>>(url);
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data == null)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/create");
|
||||
}
|
||||
else
|
||||
{
|
||||
model = apiResult.Data.Adapt<CurrencyModel>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/create");
|
||||
}
|
||||
|
||||
pageLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
async void OnFormFinishAsync()
|
||||
{
|
||||
if (editform.Validate())
|
||||
{
|
||||
saving = true;
|
||||
var url = $"api/currency/save";
|
||||
var result = new ApiResult<string>();
|
||||
result = await HttpService.Post<ApiResult<string>>(url, model);
|
||||
|
||||
|
||||
if (result.Code == (int)ResultCode.Success)
|
||||
{
|
||||
saving = false;
|
||||
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
|
||||
Navigation.NavigateTo($"/currency/list");
|
||||
}
|
||||
else
|
||||
{
|
||||
saving = false;
|
||||
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user