@page "/currency/create" @page "/currency/edit/{id:long}" @page "/{locale}/currency/create" @page "/{locale}/currency/edit/{id:long}" @inject ILogger Logger @attribute [Authorize] 管理后台 系统配置 货币管理
@foreach (var item in LanguageCultures) { } 启用
@code { [Parameter] public string Locale { get; set; } = string.Empty; [Parameter] public long Id { get; set; } [SupplyParameterFromForm] CurrencyModel model { get; set; } = new(); Form editform = null!; Dictionary 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>(url); if (apiResult.Success) { if (apiResult.Data == null) { Navigation.NavigateTo($"/currency/create"); } else { model = apiResult.Data.Adapt(); } } 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(); result = await HttpService.Post>(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 }); } } } }