调整地区实体
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,266 @@
|
||||
<h3>CountryList</h3>
|
||||
@page "/country/list"
|
||||
@page "/{locale}/country/list"
|
||||
@inject ILogger<CountryList> Logger
|
||||
@attribute [Authorize]
|
||||
|
||||
|
||||
|
||||
<PageContainer Title="国家地区">
|
||||
<Breadcrumb>
|
||||
<Breadcrumb>
|
||||
<BreadcrumbItem>Home</BreadcrumbItem>
|
||||
<BreadcrumbItem>系统配置</BreadcrumbItem>
|
||||
<BreadcrumbItem>货币管理</BreadcrumbItem>
|
||||
</Breadcrumb>
|
||||
</Breadcrumb>
|
||||
<ChildContent>
|
||||
<Spin Spinning="pageLoading">
|
||||
<Card>
|
||||
<Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish">
|
||||
<Row Justify="RowJustify.Start" Gutter="16">
|
||||
<Col>
|
||||
<FormItem Label="名称">
|
||||
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
|
||||
</FormItem>
|
||||
</Col>
|
||||
@if (searchExpand)
|
||||
{
|
||||
<AntDesign.Col>
|
||||
<FormItem Label="发布时间">
|
||||
<RangePicker @bind-Value="search.RangeTime"></RangePicker>
|
||||
</FormItem>
|
||||
</AntDesign.Col>
|
||||
<AntDesign.Col>
|
||||
<FormItem Label="状态">
|
||||
<SimpleSelect DefaultValue="" Style="width:120px;" @bind-Value="@search.Status">
|
||||
<SelectOptions>
|
||||
<SimpleSelectOption Value="" Label="全部"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="1" Label="草稿"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="2" Label="已发布"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="3" Label="已删除"></SimpleSelectOption>
|
||||
</SelectOptions>
|
||||
</SimpleSelect>
|
||||
</FormItem>
|
||||
</AntDesign.Col>
|
||||
}
|
||||
<Col>
|
||||
<div class="ant-form-item">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
|
||||
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
|
||||
<a style="font-size:12px; display:flex; align-items:center;text-align:center;" @onclick="()=>{searchExpand=!searchExpand;}">
|
||||
<Icon Type="@(searchExpand?"up":"down")"></Icon> @if (searchExpand)
|
||||
{
|
||||
<span>收起</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>展开</span>
|
||||
}
|
||||
</a>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</Card>
|
||||
<Card Title="" Class="hideborder">
|
||||
<Extra>
|
||||
<div class="extraContent">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增货币</Button>
|
||||
</div>
|
||||
</Extra>
|
||||
<ChildContent>
|
||||
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true">
|
||||
<Selection CheckStrictly />
|
||||
<PropertyColumn Property="c => c.Name" Title="名称" />
|
||||
<PropertyColumn Property="c => c.CurrencyCode" Title="货币代码" />
|
||||
<PropertyColumn Property="c => c.Rate" Title="汇率" />
|
||||
<PropertyColumn Property="c => c.PrimaryCurrency" Title="默认货币">
|
||||
@if (context.PrimaryCurrency)
|
||||
{
|
||||
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme="IconThemeType.Outline" /></AntDesign.Text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Type="minus" Theme="IconThemeType.Outline" />
|
||||
}
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.Enabled" Title="状态">
|
||||
@if (context.Enabled)
|
||||
{
|
||||
<Text>已激活</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Text>未激活</text>
|
||||
}
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.DisplayOrder" Title="排序" />
|
||||
<ActionColumn Title="操作" Align="ColumnAlign.Right">
|
||||
<Space>
|
||||
<SpaceItem>
|
||||
<a @onclick="(e)=>HandleEdit(context)">编辑</a>
|
||||
</SpaceItem>
|
||||
@*<SpaceItem>
|
||||
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
|
||||
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
|
||||
OkText="确定"
|
||||
CancelText="取消">
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</SpaceItem>*@
|
||||
</Space>
|
||||
</ActionColumn>
|
||||
</Table>
|
||||
<br />
|
||||
<Row Justify="RowJustify.End">
|
||||
@if (PagingList.Count > 0)
|
||||
{
|
||||
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||
}
|
||||
</Row>
|
||||
</ChildContent>
|
||||
</Card>
|
||||
</Spin>
|
||||
</ChildContent>
|
||||
</PageContainer>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string Locale { get; set; } = string.Empty;
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
int? Page { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "size")]
|
||||
int? PageSize { get; set; }
|
||||
|
||||
bool pageLoading = false;
|
||||
bool searchExpand = false;
|
||||
|
||||
Form<CurrencySearchModel> searchForm = new();
|
||||
CurrencySearchModel search = new();
|
||||
|
||||
PagingList<CurrencyModel> PagingList = new() { Size = 20 };
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
loadQueryString();
|
||||
await LoadListAsync();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
void loadQueryString()
|
||||
{
|
||||
var uri = new Uri(Navigation.Uri);
|
||||
var query = uri.Query;
|
||||
search.Name = query.GetQueryString("Name");
|
||||
search.Status = query.GetQueryString("Status");
|
||||
|
||||
var data = query.GetQueryString("RangeTime");
|
||||
if (!string.IsNullOrEmpty(data))
|
||||
{
|
||||
var rangetime = data.Split("-");
|
||||
if (rangetime != null && rangetime.Length > 0)
|
||||
{
|
||||
searchExpand = true;
|
||||
search.RangeTime[0] = rangetime[0].NumberToDateTime();
|
||||
search.RangeTime[1] = rangetime[1].NumberToDateTime();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async Task LoadListAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = "/api/currency/search";
|
||||
var apiResult = await HttpService.GetPagingList<CurrencyModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
PagingList = apiResult.Data;
|
||||
}
|
||||
}
|
||||
else if (apiResult.Code == 403)
|
||||
{
|
||||
ModalService.Error(new ConfirmOptions() { Title = "权限不足", Content = apiResult.Message });
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
finally
|
||||
{
|
||||
pageLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchReset()
|
||||
{
|
||||
search = new CurrencySearchModel();
|
||||
searchForm?.Reset();
|
||||
}
|
||||
|
||||
private void OnSearch(int page)
|
||||
{
|
||||
var queryString = search.BuildQueryString();
|
||||
if (string.IsNullOrEmpty(queryString))
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?page={page}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?page={page}&{queryString}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?{queryString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchFinish()
|
||||
{
|
||||
Page = Page.GetValueOrDefault(1) - 1;
|
||||
|
||||
OnSearch(Page.Value);
|
||||
}
|
||||
|
||||
private void OnPageChanged(PaginationEventArgs args)
|
||||
{
|
||||
OnSearch(args.Page);
|
||||
}
|
||||
|
||||
void HandleAddNew()
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/create");
|
||||
}
|
||||
|
||||
|
||||
void HandleEdit(CurrencyModel model)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/edit/{model.Id}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
@page "/stateprovince/create"
|
||||
@page "/stateprovince/edit/{id:long}"
|
||||
@page "/{locale}/stateprovince/create"
|
||||
@page "/{locale}/stateprovince/edit/{id:long}"
|
||||
|
||||
@inject ILogger<StateProvinceEdit> 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
@page "/stateprovince/list"
|
||||
@page "/{locale}/stateprovince/list"
|
||||
@inject ILogger<StateProvinceList> Logger
|
||||
@attribute [Authorize]
|
||||
|
||||
|
||||
|
||||
<PageContainer Title="州省管理">
|
||||
<Breadcrumb>
|
||||
<Breadcrumb>
|
||||
<BreadcrumbItem>Home</BreadcrumbItem>
|
||||
<BreadcrumbItem>系统配置</BreadcrumbItem>
|
||||
<BreadcrumbItem>州省管理</BreadcrumbItem>
|
||||
</Breadcrumb>
|
||||
</Breadcrumb>
|
||||
<ChildContent>
|
||||
<Spin Spinning="pageLoading">
|
||||
<Card>
|
||||
<Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish">
|
||||
<Row Justify="RowJustify.Start" Gutter="16">
|
||||
<Col>
|
||||
<FormItem Label="名称">
|
||||
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
|
||||
</FormItem>
|
||||
</Col>
|
||||
@if (searchExpand)
|
||||
{
|
||||
<AntDesign.Col>
|
||||
<FormItem Label="发布时间">
|
||||
<RangePicker @bind-Value="search.RangeTime"></RangePicker>
|
||||
</FormItem>
|
||||
</AntDesign.Col>
|
||||
<AntDesign.Col>
|
||||
<FormItem Label="状态">
|
||||
<SimpleSelect DefaultValue="" Style="width:120px;" @bind-Value="@search.Status">
|
||||
<SelectOptions>
|
||||
<SimpleSelectOption Value="" Label="全部"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="1" Label="草稿"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="2" Label="已发布"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="3" Label="已删除"></SimpleSelectOption>
|
||||
</SelectOptions>
|
||||
</SimpleSelect>
|
||||
</FormItem>
|
||||
</AntDesign.Col>
|
||||
}
|
||||
<Col>
|
||||
<div class="ant-form-item">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
|
||||
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
|
||||
<a style="font-size:12px; display:flex; align-items:center;text-align:center;" @onclick="()=>{searchExpand=!searchExpand;}">
|
||||
<Icon Type="@(searchExpand?"up":"down")"></Icon> @if (searchExpand)
|
||||
{
|
||||
<span>收起</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>展开</span>
|
||||
}
|
||||
</a>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</Card>
|
||||
<Card Title="" Class="hideborder">
|
||||
<Extra>
|
||||
<div class="extraContent">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增货币</Button>
|
||||
</div>
|
||||
</Extra>
|
||||
<ChildContent>
|
||||
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true">
|
||||
<Selection CheckStrictly />
|
||||
<PropertyColumn Property="c => c.Name" Title="名称" />
|
||||
<PropertyColumn Property="c => c.CurrencyCode" Title="货币代码" />
|
||||
<PropertyColumn Property="c => c.Rate" Title="汇率" />
|
||||
<PropertyColumn Property="c => c.PrimaryCurrency" Title="默认货币">
|
||||
@if (context.PrimaryCurrency)
|
||||
{
|
||||
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme="IconThemeType.Outline" /></AntDesign.Text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Type="minus" Theme="IconThemeType.Outline" />
|
||||
}
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.Enabled" Title="状态">
|
||||
@if (context.Enabled)
|
||||
{
|
||||
<Text>已激活</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Text>未激活</text>
|
||||
}
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.DisplayOrder" Title="排序" />
|
||||
<ActionColumn Title="操作" Align="ColumnAlign.Right">
|
||||
<Space>
|
||||
<SpaceItem>
|
||||
<a @onclick="(e)=>HandleEdit(context)">编辑</a>
|
||||
</SpaceItem>
|
||||
@*<SpaceItem>
|
||||
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
|
||||
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
|
||||
OkText="确定"
|
||||
CancelText="取消">
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</SpaceItem>*@
|
||||
</Space>
|
||||
</ActionColumn>
|
||||
</Table>
|
||||
<br />
|
||||
<Row Justify="RowJustify.End">
|
||||
@if (PagingList.Count > 0)
|
||||
{
|
||||
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||
}
|
||||
</Row>
|
||||
</ChildContent>
|
||||
</Card>
|
||||
</Spin>
|
||||
</ChildContent>
|
||||
</PageContainer>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string Locale { get; set; } = string.Empty;
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
int? Page { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "size")]
|
||||
int? PageSize { get; set; }
|
||||
|
||||
bool pageLoading = false;
|
||||
bool searchExpand = false;
|
||||
|
||||
Form<CurrencySearchModel> searchForm = new();
|
||||
CurrencySearchModel search = new();
|
||||
|
||||
PagingList<CurrencyModel> PagingList = new() { Size = 20 };
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
loadQueryString();
|
||||
await LoadListAsync();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
void loadQueryString()
|
||||
{
|
||||
var uri = new Uri(Navigation.Uri);
|
||||
var query = uri.Query;
|
||||
search.Name = query.GetQueryString("Name");
|
||||
search.Status = query.GetQueryString("Status");
|
||||
|
||||
var data = query.GetQueryString("RangeTime");
|
||||
if (!string.IsNullOrEmpty(data))
|
||||
{
|
||||
var rangetime = data.Split("-");
|
||||
if (rangetime != null && rangetime.Length > 0)
|
||||
{
|
||||
searchExpand = true;
|
||||
search.RangeTime[0] = rangetime[0].NumberToDateTime();
|
||||
search.RangeTime[1] = rangetime[1].NumberToDateTime();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async Task LoadListAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = "/api/currency/search";
|
||||
var apiResult = await HttpService.GetPagingList<CurrencyModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
PagingList = apiResult.Data;
|
||||
}
|
||||
}
|
||||
else if (apiResult.Code == 403)
|
||||
{
|
||||
ModalService.Error(new ConfirmOptions() { Title = "权限不足", Content = apiResult.Message });
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
finally
|
||||
{
|
||||
pageLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchReset()
|
||||
{
|
||||
search = new CurrencySearchModel();
|
||||
searchForm?.Reset();
|
||||
}
|
||||
|
||||
private void OnSearch(int page)
|
||||
{
|
||||
var queryString = search.BuildQueryString();
|
||||
if (string.IsNullOrEmpty(queryString))
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?page={page}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?page={page}&{queryString}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?{queryString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchFinish()
|
||||
{
|
||||
Page = Page.GetValueOrDefault(1) - 1;
|
||||
|
||||
OnSearch(Page.Value);
|
||||
}
|
||||
|
||||
private void OnPageChanged(PaginationEventArgs args)
|
||||
{
|
||||
OnSearch(args.Page);
|
||||
}
|
||||
|
||||
void HandleAddNew()
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/create");
|
||||
}
|
||||
|
||||
|
||||
void HandleEdit(CurrencyModel model)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/edit/{model.Id}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -56,15 +56,174 @@ namespace Atomx.Admin.Extensions
|
||||
|
||||
if (!db.Languages.Any())
|
||||
{
|
||||
Language language = new Language();
|
||||
language.Culture = "zh-cn";
|
||||
language.CreateTime = DateTime.UtcNow;
|
||||
language.UpdateTime = DateTime.UtcNow;
|
||||
language.Name = "中文";
|
||||
language.DisplayOrder = 0;
|
||||
language.Enabled = true;
|
||||
language.Title = "中文";
|
||||
db.Languages.Add(language);
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "en-US",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "English",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "英语"
|
||||
});
|
||||
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "zh-CN",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "简体中文",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "简体中文"
|
||||
});
|
||||
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "zh-TW",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "繁体中文",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "繁体中文"
|
||||
});
|
||||
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "ja-JP",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "日本語",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "日语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "ko-KR",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "한국어",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "朝鲜语/韩语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "ms-MY",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Bahasa Melayu",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "马来语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "es-ES",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Español",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "西班牙语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "pt-PT",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Português",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "葡萄牙语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "fr-FR",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Français",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "法语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "ar-SA",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "العربية",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "阿拉伯语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "hi-IN",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "हिन्दी",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "印度语 (印地语)"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "id-ID",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Bahasa Indonesia",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "印尼语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "vi-VN",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Tiếng Việt",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "越南语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "ru-RU",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Русский",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "俄语"
|
||||
});
|
||||
db.Languages.Add(new()
|
||||
{
|
||||
Culture = "de-DE",
|
||||
CreateTime = DateTime.UtcNow,
|
||||
UpdateTime = DateTime.UtcNow,
|
||||
Name = "Deutsch",
|
||||
DisplayOrder = 0,
|
||||
Enabled = true,
|
||||
Title = "德语"
|
||||
});
|
||||
}
|
||||
if (!db.Currencies.Any())
|
||||
{
|
||||
db.Currencies.Add(new Currency() { Name = "美元", CreateTime = DateTime.UtcNow, CurrencyCode = "USD", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 0, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 1, SiteId = 0, Symbolic = "$", Title = "美元" });
|
||||
db.Currencies.Add(new Currency() { Name = "人民币", CreateTime = DateTime.UtcNow, CurrencyCode = "CNY", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 1, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 6.43M, SiteId = 0, Symbolic = "¥", Title = "人民币" });
|
||||
db.Currencies.Add(new Currency() { Name = "欧元", CreateTime = DateTime.UtcNow, CurrencyCode = "EUR", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 2, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 0.86M, SiteId = 0, Symbolic = "€", Title = "欧元" });
|
||||
db.Currencies.Add(new Currency() { Name = "英镑", CreateTime = DateTime.UtcNow, CurrencyCode = "GBP", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 3, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 0.75M, SiteId = 0, Symbolic = "£", Title = "英镑" });
|
||||
db.Currencies.Add(new Currency() { Name = "澳元", CreateTime = DateTime.UtcNow, CurrencyCode = "AUD", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 4, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 1.34M, SiteId = 0, Symbolic = "A$", Title = "澳元" });
|
||||
db.Currencies.Add(new Currency() { Name = "加拿大元", CreateTime = DateTime.UtcNow, CurrencyCode = "CAD", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 5, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 1.32M, SiteId = 0, Symbolic = "C$", Title = "加拿大元" });
|
||||
db.Currencies.Add(new Currency() { Name = "港币", CreateTime = DateTime.UtcNow, CurrencyCode = "HKD", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 6, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 7.84M, SiteId = 0, Symbolic = "HK$", Title = "港币" });
|
||||
db.Currencies.Add(new Currency() { Name = "日元", CreateTime = DateTime.UtcNow, CurrencyCode = "JPY", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 7, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 110.45M, SiteId = 0, Symbolic = "¥", Title = "日元" });
|
||||
db.Currencies.Add(new Currency() { Name = "俄罗斯卢布", CreateTime = DateTime.UtcNow, CurrencyCode = "RUB", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 8, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 63.25M, SiteId = 0, Symbolic = "₽", Title = "俄罗斯卢布" });
|
||||
db.Currencies.Add(new Currency() { Name = "瑞典克朗", CreateTime = DateTime.UtcNow, CurrencyCode = "SEK", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 9, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 8.8M, SiteId = 0, Symbolic = "kr", Title = "瑞典克朗" });
|
||||
db.Currencies.Add(new Currency() { Name = "印度卢比", CreateTime = DateTime.UtcNow, CurrencyCode = "INR", CustomFormatting = string.Empty, DisplayLocale = string.Empty, DisplayOrder = 10, Enabled = true, EnableDisplay = false, EnablePay = false, Rate = 68.03M, SiteId = 0, Symbolic = "₹", Title = "印度卢比" });
|
||||
|
||||
}
|
||||
|
||||
if (!db.Permissions.Any())
|
||||
|
||||
Reference in New Issue
Block a user