This commit is contained in:
2025-12-25 12:41:37 +08:00
parent 7b6ec9c1d8
commit f7bb6bb2dc
10 changed files with 363 additions and 109 deletions

View File

@@ -17,29 +17,43 @@
<ChildContent>
<Spin Spinning="pageLoading">
<Card Title="货币信息">
<Card Title="国家信息">
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync">
@if (Id > 0 && languageList.Any())
{
<Tabs ActiveKey="@context.LanguageId" OnTabClick="OnLanguageTabChange">
<TabPane Key="0">
<TabTemplate>
<span>标准</span>
</TabTemplate>
</TabPane>
@foreach (var item in languageList)
{
<TabPane Key="@item.Key.ToString()">
<TabTemplate>
<span>@item.Value</span>
</TabTemplate>
</TabPane>
}
</Tabs>
}
<FormItem Label="名称" Required>
<Input @bind-Value="@context.Name" Placeholder="货币名称" />
<Input @bind-Value="@context.Name" Placeholder="国家" />
</FormItem>
<FormItem Label="货币代码">
<Input @bind-Value="@context.CurrencyCode" Placeholder="货币代码" />
<FormItem Label="首字母">
<Input @bind-Value="@context.Initial" Placeholder="首字母" />
</FormItem>
<FormItem Label="汇率">
<Input @bind-Value="@context.Rate" Placeholder="汇率" />
<FormItem Label="两个字母ISO代码">
<Input @bind-Value="@context.TwoLetterISOCode" Placeholder="两个字母ISO代码" />
</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 Label="三字母ISO代码">
<Input @bind-Value="@context.ThreeLetterISOCode" Placeholder="三字母ISO代码" />
</FormItem>
<FormItem Label="自定义格式">
<Input @bind-Value="@context.CustomFormatting" Placeholder="自定义格式" />
<FormItem Label="数字ISO代码">
<Input @bind-Value="@context.NumericISOCode" Placeholder="数字ISO代码" />
</FormItem>
<FormItem Label="允许发货">
<Checkbox Checked="@context.AllowShipping">允许发货</Checkbox>
</FormItem>
<FormItem Label="显示排序">
<Input @bind-Value="@context.DisplayOrder" Placeholder="显示排序" />
@@ -65,9 +79,13 @@
public long Id { get; set; }
[SupplyParameterFromForm]
CurrencyModel model { get; set; } = new();
Form<CurrencyModel> editform = null!;
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary();
CountryModel model { get; set; } = new();
Form<CountryModel> editform = null!;
Country Country = new();
List<KeyValue> languageList = new();
bool pageLoading = false;
bool saving = false;
@@ -85,6 +103,16 @@
base.OnParametersSet();
}
async Task LoadLanguage()
{
var url = $"/api/language/enabled";
var apiResult = await HttpService.Get<ApiResult<List<KeyValue>>>(url);
if (apiResult.Success)
{
languageList = apiResult.Data ?? new List<KeyValue>();
}
}
async void LoadData()
{
pageLoading = true;
@@ -98,7 +126,7 @@
}
else
{
model = apiResult.Data.Adapt<CurrencyModel>();
model = apiResult.Data.Adapt<CountryModel>();
}
}
else
@@ -134,4 +162,30 @@
}
}
void OnLanguageTabChange(string key)
{
if (key != "0")
{
model.LanguageId = key;
var data = model.Localized.Where(p => p.LanguageId == key.ToInt()).ToList();
if (data.Any())
{
var name = nameof(model.Name);
model.Name = data.SingleOrDefault(p => p.Key == name)?.Value ?? "";
}
else
{
model.Name = string.Empty;
}
}
else
{
// model = Mapper.Map<CountryModel>(model);
// model.LanguageId = key;
// model.IsEdit = true;
}
}
}