完善国家管理和数据多语言

This commit is contained in:
2025-12-26 00:21:11 +08:00
parent 46794708ff
commit 030299fa53
10 changed files with 182 additions and 150 deletions

View File

@@ -1,8 +1,11 @@
namespace Atomx.Admin.Client.Models using System.Runtime.Serialization;
namespace Atomx.Admin.Client.Models
{ {
public class StateProvinceSearch public class StateProvinceSearch
{ {
public long CountryId { get; set; } [IgnoreDataMember]
public long? CountryId { get; set; }
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
} }
} }

View File

@@ -21,12 +21,12 @@
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync"> <Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync">
@if (Id > 0 && languageList.Count() > 0) @if (Id > 0 && languageList.Count() > 0)
{ {
<Tabs ActiveKey="@context.LanguageId" OnTabClick="OnLanguageTabChange"> <Tabs ActiveKey="@model.LanguageId" OnTabClick="OnLanguageTabChange">
<TabPane Key="0"> @* <TabPane Key="0">
<TabTemplate> <TabTemplate>
<span>标准</span> <span>标准</span>
</TabTemplate> </TabTemplate>
</TabPane> </TabPane> *@
@foreach (var item in languageList) @foreach (var item in languageList)
{ {
<TabPane Key="@item.Key.ToString()"> <TabPane Key="@item.Key.ToString()">
@@ -38,28 +38,28 @@
</Tabs> </Tabs>
} }
<FormItem Label="名称" Required> <FormItem Label="名称" Required>
<Input @bind-Value="@context.Name" Placeholder="国家" /> <Input @bind-Value="@model.Name" Placeholder="国家" />
</FormItem> </FormItem>
<FormItem Label="首字母"> <FormItem Label="首字母">
<Input @bind-Value="@context.Initial" Placeholder="首字母" /> <Input @bind-Value="@model.Initial" Placeholder="首字母" />
</FormItem> </FormItem>
<FormItem Label="两个字母ISO代码"> <FormItem Label="两个字母ISO代码">
<Input @bind-Value="@context.TwoLetterISOCode" Placeholder="两个字母ISO代码" /> <Input @bind-Value="@model.TwoLetterISOCode" Placeholder="两个字母ISO代码" />
</FormItem> </FormItem>
<FormItem Label="三字母ISO代码"> <FormItem Label="三字母ISO代码">
<Input @bind-Value="@context.ThreeLetterISOCode" Placeholder="三字母ISO代码" /> <Input @bind-Value="@model.ThreeLetterISOCode" Placeholder="三字母ISO代码" />
</FormItem> </FormItem>
<FormItem Label="数字ISO代码"> <FormItem Label="数字ISO代码">
<Input @bind-Value="@context.NumericISOCode" Placeholder="数字ISO代码" /> <Input @bind-Value="@model.NumericISOCode" Placeholder="数字ISO代码" />
</FormItem> </FormItem>
<FormItem Label="允许发货"> <FormItem Label="允许发货">
<Checkbox Checked="@context.AllowShipping">允许发货</Checkbox> <Checkbox Checked="@model.AllowShipping">允许发货</Checkbox>
</FormItem> </FormItem>
<FormItem Label="显示排序"> <FormItem Label="显示排序">
<Input @bind-Value="@context.DisplayOrder" Placeholder="显示排序" /> <Input @bind-Value="@model.DisplayOrder" Placeholder="显示排序" />
</FormItem> </FormItem>
<FormItem Label="状态"> <FormItem Label="状态">
<Checkbox Checked="@context.Enabled">启用</Checkbox> <Checkbox T="bool" Label="启用" @bind-value="model.Enabled" Size="InputSize.Small" Class="ps-0" />
</FormItem> </FormItem>
<FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }"> <FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }">
<Button Type="@ButtonType.Primary" HtmlType="submit" Loading="saving"> <Button Type="@ButtonType.Primary" HtmlType="submit" Loading="saving">
@@ -71,6 +71,7 @@
</Spin> </Spin>
</ChildContent> </ChildContent>
</PageContainer> </PageContainer>
@code { @code {
[Parameter] [Parameter]
public string Locale { get; set; } = string.Empty; public string Locale { get; set; } = string.Empty;
@@ -110,7 +111,17 @@
var apiResult = await HttpService.Get<ApiResult<List<KeyValue>>>(url); var apiResult = await HttpService.Get<ApiResult<List<KeyValue>>>(url);
if (apiResult.Success) if (apiResult.Success)
{ {
languageList = apiResult.Data ?? new List<KeyValue>(); if(apiResult.Data == null)
{
languageList = new List<KeyValue>();
}
else
{
languageList = apiResult.Data;
languageList.Insert(0, new KeyValue() { Key = "0", Value = "标准" });
}
StateHasChanged(); StateHasChanged();
} }
} }
@@ -145,6 +156,7 @@
{ {
if (editform.Validate()) if (editform.Validate())
{ {
Console.WriteLine(model.ToJson());
saving = true; saving = true;
var url = $"api/country/save"; var url = $"api/country/save";
var result = new ApiResult<string>(); var result = new ApiResult<string>();

View File

@@ -48,16 +48,23 @@
<PropertyColumn Property="c => c.Enabled" Title="状态"> <PropertyColumn Property="c => c.Enabled" Title="状态">
@if (context.Enabled) @if (context.Enabled)
{ {
<Text>已激活</text> <AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
} }
else else
{ {
<Text>未激活</text> <Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
} }
</PropertyColumn> </PropertyColumn>
<PropertyColumn Property="c => c.DisplayOrder" Title="排序" /> <PropertyColumn Property="c => c.DisplayOrder" Title="排序" />
<ActionColumn Title="操作" Align="ColumnAlign.Right"> <ActionColumn Title="操作" Align="ColumnAlign.Right">
<Space> <Space>
<SpaceItem>
<a @onclick="(e) => GotoStateProvince(context)">州省管理</a>
</SpaceItem>
<SpaceItem>
<a @onclick="(e) => GotoArea(context)">城市管理</a>
</SpaceItem>
<SpaceItem> <SpaceItem>
<a @onclick="(e)=>HandleEdit(context)">编辑</a> <a @onclick="(e)=>HandleEdit(context)">编辑</a>
</SpaceItem> </SpaceItem>
@@ -127,7 +134,7 @@
pageLoading = true; pageLoading = true;
try try
{ {
var url = "/api/country/searh"; var url = "/api/country/search";
var apiResult = await HttpService.GetPagingList<Country>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20)); var apiResult = await HttpService.GetPagingList<Country>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success) if (apiResult.Success)
{ {
@@ -205,4 +212,13 @@
Navigation.NavigateTo($"/country/edit/{model.Id}"); Navigation.NavigateTo($"/country/edit/{model.Id}");
} }
void GotoStateProvince(Country model)
{
Navigation.NavigateTo($"/stateprovince/list/{model.Id}");
}
void GotoArea(Country model)
{
Navigation.NavigateTo($"/area/list/{model.Id}");
}
} }

View File

@@ -16,7 +16,7 @@
<Spin Spinning="pageLoading"> <Spin Spinning="pageLoading">
<Card> <Card>
<Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish"> <Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish">
<Row Justify="RowJustify.Start" Gutter="16"> <Row Justify="RowJustify.Start" Gutter="(16, 16)">
<Col> <Col>
<FormItem Label="名称"> <FormItem Label="名称">
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear /> <Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
@@ -43,7 +43,7 @@
</AntDesign.Col> </AntDesign.Col>
} }
<Col> <Col>
<div class="ant-form-item"> <div class="ant-form-item" style="display:flex">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button> <Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</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;}"> <a style="font-size:12px; display:flex; align-items:center;text-align:center;" @onclick="()=>{searchExpand=!searchExpand;}">
@@ -61,6 +61,7 @@
</Row> </Row>
</Form> </Form>
</Card> </Card>
<br />
<Card Title="" Class="hideborder"> <Card Title="" Class="hideborder">
<Extra> <Extra>
<div class="extraContent"> <div class="extraContent">
@@ -86,11 +87,11 @@
<PropertyColumn Property="c => c.Enabled" Title="状态"> <PropertyColumn Property="c => c.Enabled" Title="状态">
@if (context.Enabled) @if (context.Enabled)
{ {
<Text>已激活</text> <AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
} }
else else
{ {
<Text>未激活</text> <Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
} }
</PropertyColumn> </PropertyColumn>
<PropertyColumn Property="c => c.DisplayOrder" Title="排序" /> <PropertyColumn Property="c => c.DisplayOrder" Title="排序" />

View File

@@ -1,51 +1,41 @@
@page "/stateprovince/create" @page "/stateprovince/{countryId:long}/create"
@page "/stateprovince/edit/{id:long}" @page "/stateprovince/{countryId:long}/edit/{id:long}"
@page "/{locale}/stateprovince/create" @page "/{locale}/stateprovince/{countryId:long}/create"
@page "/{locale}/stateprovince/edit/{id:long}" @page "/{locale}/stateprovince/{countryId:long}/edit/{id:long}"
@inject ILogger<StateProvinceEdit> Logger @inject ILogger<StateProvinceEdit> Logger
@attribute [Authorize] @attribute [Authorize]
<PageContainer Title="@(Id > 0 ? "编辑国家信息" : "新增国家信息")"> <PageContainer Title="@(Id > 0 ? "编辑州省信息" : "新增州省信息")">
<Breadcrumb> <Breadcrumb>
<Breadcrumb> <Breadcrumb>
<BreadcrumbItem Href="/">管理后台</BreadcrumbItem> <BreadcrumbItem Href="/">管理后台</BreadcrumbItem>
<BreadcrumbItem Href="/admin/list">系统配置</BreadcrumbItem> <BreadcrumbItem Href="/settings">系统配置</BreadcrumbItem>
<BreadcrumbItem Href="/country/list">国家管理</BreadcrumbItem> <BreadcrumbItem Href="/country/list">国家管理</BreadcrumbItem>
</Breadcrumb> </Breadcrumb>
</Breadcrumb> </Breadcrumb>
<ChildContent> <ChildContent>
<Spin Spinning="pageLoading"> <Spin Spinning="pageLoading">
<Card Title="货币信息"> <Card Title="州省信息">
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync"> <Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync">
<FormItem Label="国家">
<Input @bind-Value="@country.Name" Placeholder="国家名称" Disabled />
</FormItem>
<FormItem Label="名称" Required> <FormItem Label="名称" Required>
<Input @bind-Value="@context.Name" Placeholder="货币名称" /> <Input @bind-Value="@context.Name" Placeholder="名称" />
</FormItem> </FormItem>
<FormItem Label="货币代码"> <FormItem Label="首字母">
<Input @bind-Value="@context.CurrencyCode" Placeholder="货币代码" /> <Input @bind-Value="@context.Initial" Placeholder="首字母" />
</FormItem> </FormItem>
<FormItem Label="汇率"> <FormItem Label="缩写">
<Input @bind-Value="@context.Rate" Placeholder="汇率" /> <Input @bind-Value="@context.Abbreviation" 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>
<FormItem Label="显示排序"> <FormItem Label="显示排序">
<Input @bind-Value="@context.DisplayOrder" Placeholder="显示排序" /> <Input @bind-Value="@context.DisplayOrder" Placeholder="显示排序" />
</FormItem> </FormItem>
<FormItem Label="状态"> <FormItem Label="状态">
<Checkbox Checked="@context.Enabled">启用</Checkbox> <Checkbox T="bool" Label="启用" @bind-value="model.Enabled" Size="InputSize.Small" Class="ps-0" />
</FormItem> </FormItem>
<FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }"> <FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }">
<Button Type="@ButtonType.Primary" HtmlType="submit" Loading="saving"> <Button Type="@ButtonType.Primary" HtmlType="submit" Loading="saving">
@@ -60,14 +50,17 @@
@code { @code {
[Parameter] [Parameter]
public string Locale { get; set; } = string.Empty; public string Locale { get; set; } = string.Empty;
[Parameter]
public long CountryId { get; set; }
[Parameter] [Parameter]
public long Id { get; set; } public long Id { get; set; }
[SupplyParameterFromForm] [SupplyParameterFromForm]
CurrencyModel model { get; set; } = new(); StateProvinceModel model { get; set; } = new();
Form<CurrencyModel> editform = null!; Form<StateProvinceModel> editform = null!;
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary(); List<KeyValue> languageList = new();
Country country = new();
StateProvinceLocalizedModel stateProvince = new();
bool pageLoading = false; bool pageLoading = false;
bool saving = false; bool saving = false;
@@ -78,6 +71,8 @@
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
_ = LoadLanguage();
_ = LoadCountry();
if (Id > 0) if (Id > 0)
{ {
LoadData(); LoadData();
@@ -85,25 +80,65 @@
base.OnParametersSet(); base.OnParametersSet();
} }
async void LoadData() async Task LoadCountry()
{ {
pageLoading = true; var url = $"/api/country?id={CountryId}";
var url = $"/api/currency/{Id}"; var apiResult = await HttpService.Get<ApiResult<Country>>(url);
var apiResult = await HttpService.Get<ApiResult<Currency>>(url); if (apiResult.Success)
{
if (apiResult.Data != null)
{
country = apiResult.Data;
StateHasChanged();
}
else
{
Navigation.NavigateTo($"/country/list");
}
}
}
async Task LoadLanguage()
{
var url = $"/api/language/enabled";
var apiResult = await HttpService.Get<ApiResult<List<KeyValue>>>(url);
if (apiResult.Success) if (apiResult.Success)
{ {
if (apiResult.Data == null) if (apiResult.Data == null)
{ {
Navigation.NavigateTo($"/currency/create"); languageList = new List<KeyValue>();
} }
else else
{ {
model = apiResult.Data.Adapt<CurrencyModel>(); languageList = apiResult.Data;
languageList.Insert(0, new KeyValue() { Key = "0", Value = "标准" });
}
StateHasChanged();
}
}
async void LoadData()
{
pageLoading = true;
var url = $"/api/stateprovince/detail/{Id}";
var apiResult = await HttpService.Get<ApiResult<StateProvinceLocalizedModel>>(url);
if (apiResult.Success)
{
if (apiResult.Data == null)
{
Navigation.NavigateTo($"/country/list");
}
else
{
stateProvince = apiResult.Data;
model = apiResult.Data.Adapt<StateProvinceModel>();
} }
} }
else else
{ {
Navigation.NavigateTo($"/currency/create"); Navigation.NavigateTo($"/country/list");
} }
pageLoading = false; pageLoading = false;
@@ -115,7 +150,7 @@
if (editform.Validate()) if (editform.Validate())
{ {
saving = true; saving = true;
var url = $"api/currency/save"; var url = $"api/stateprovince/save";
var result = new ApiResult<string>(); var result = new ApiResult<string>();
result = await HttpService.Post<ApiResult<string>>(url, model); result = await HttpService.Post<ApiResult<string>>(url, model);
@@ -124,7 +159,7 @@
{ {
saving = false; saving = false;
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" }); await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
Navigation.NavigateTo($"/currency/list"); Navigation.NavigateTo($"/stateprovince/list");
} }
else else
{ {

View File

@@ -1,5 +1,5 @@
@page "/stateprovince/list" @page "/stateprovince/list/{countryId:long}"
@page "/{locale}/stateprovince/list" @page "/{locale}/stateprovince/list/{countryId:long}"
@inject ILogger<StateProvinceList> Logger @inject ILogger<StateProvinceList> Logger
@attribute [Authorize] @attribute [Authorize]
@@ -17,88 +17,50 @@
<Spin Spinning="pageLoading"> <Spin Spinning="pageLoading">
<Card> <Card>
<Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish"> <Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish">
<Row Justify="RowJustify.Start" Gutter="16"> <Row Justify="RowJustify.Start" Gutter="(16, 16)">
<Col> <Col>
<FormItem Label="名称"> <FormItem Label="名称">
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear /> <Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
</FormItem> </FormItem>
</Col> </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> <Col>
<div class="ant-form-item"> <div class="ant-form-item" style="display:flex">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button> <Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</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> </div>
</Col> </Col>
</Row> </Row>
</Form> </Form>
</Card> </Card>
<Card Title="" Class="hideborder"> <br />
<Card Title="州、省列表" Class="hideborder">
<Extra> <Extra>
<div class="extraContent"> <div class="extraContent">
<Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增货币</Button> <Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增州省</Button>
</div> </div>
</Extra> </Extra>
<ChildContent> <ChildContent>
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true"> <Table DataSource="PagingList.Items" PageSize="100" HidePagination="true">
<Selection CheckStrictly /> <Selection CheckStrictly />
<PropertyColumn Property="c => c.Name" Title="名称" /> <PropertyColumn Property="c => c.Name" Title="名称" />
<PropertyColumn Property="c => c.CurrencyCode" Title="货币代码" /> <PropertyColumn Property="c => c.Initial" Title="首字母" />
<PropertyColumn Property="c => c.Rate" Title="汇率" /> <PropertyColumn Property="c => c.Abbreviation" 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="状态"> <PropertyColumn Property="c => c.Enabled" Title="状态">
@if (context.Enabled) @if (context.Enabled)
{ {
<Text>已激活</text> <AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
} }
else else
{ {
<Text>未激活</text> <Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
} }
</PropertyColumn> </PropertyColumn>
<PropertyColumn Property="c => c.DisplayOrder" Title="排序" /> <PropertyColumn Property="c => c.DisplayOrder" Title="排序" />
<ActionColumn Title="操作" Align="ColumnAlign.Right"> <ActionColumn Title="操作" Align="ColumnAlign.Right">
<Space> <Space>
<SpaceItem> <SpaceItem>
<a @onclick="(e)=>HandleEdit(context)">编辑</a> <a @onclick="(e) => HandleEdit(context)">编辑</a>
</SpaceItem> </SpaceItem>
@*<SpaceItem> @*<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")" <Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
@@ -127,6 +89,8 @@
@code { @code {
[Parameter] [Parameter]
public string Locale { get; set; } = string.Empty; public string Locale { get; set; } = string.Empty;
[Parameter]
public long CountryId { get; set; }
[SupplyParameterFromQuery] [SupplyParameterFromQuery]
int? Page { get; set; } int? Page { get; set; }
@@ -137,10 +101,10 @@
bool pageLoading = false; bool pageLoading = false;
bool searchExpand = false; bool searchExpand = false;
Form<CurrencySearchModel> searchForm = new(); Form<StateProvinceSearch> searchForm = new();
CurrencySearchModel search = new(); StateProvinceSearch search = new();
PagingList<CurrencyModel> PagingList = new() { Size = 20 }; PagingList<StateProvince> PagingList = new() { Size = 20 };
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@@ -160,21 +124,7 @@
var uri = new Uri(Navigation.Uri); var uri = new Uri(Navigation.Uri);
var query = uri.Query; var query = uri.Query;
search.Name = query.GetQueryString("Name"); search.Name = query.GetQueryString("Name");
search.Status = query.GetQueryString("Status"); search.CountryId = CountryId;
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() async Task LoadListAsync()
@@ -182,8 +132,8 @@
try try
{ {
pageLoading = true; pageLoading = true;
var url = "/api/currency/search"; var url = "/api/stateprovince/search";
var apiResult = await HttpService.GetPagingList<CurrencyModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20)); var apiResult = await HttpService.GetPagingList<StateProvince>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success) if (apiResult.Success)
{ {
if (apiResult.Data != null) if (apiResult.Data != null)
@@ -206,7 +156,7 @@
void OnSearchReset() void OnSearchReset()
{ {
search = new CurrencySearchModel(); search = new();
searchForm?.Reset(); searchForm?.Reset();
} }
@@ -217,22 +167,22 @@
{ {
if (page > 1) if (page > 1)
{ {
Navigation.NavigateTo($"/currency/list?page={page}"); Navigation.NavigateTo($"/stateprovince/list/{CountryId}?page={page}");
} }
else else
{ {
Navigation.NavigateTo($"/currency/list"); Navigation.NavigateTo($"/stateprovince/list/{CountryId}");
} }
} }
else else
{ {
if (page > 1) if (page > 1)
{ {
Navigation.NavigateTo($"/currency/list?page={page}&{queryString}"); Navigation.NavigateTo($"/stateprovince/list/{CountryId}?page={page}&{queryString}");
} }
else else
{ {
Navigation.NavigateTo($"/currency/list?{queryString}"); Navigation.NavigateTo($"/stateprovince/list/{CountryId}?{queryString}");
} }
} }
} }
@@ -251,17 +201,13 @@
void HandleAddNew() void HandleAddNew()
{ {
Navigation.NavigateTo($"/currency/create"); Navigation.NavigateTo($"/stateprovince/{CountryId}/create");
} }
void HandleEdit(CurrencyModel model) void HandleEdit(StateProvince model)
{ {
Navigation.NavigateTo($"/currency/edit/{model.Id}"); Navigation.NavigateTo($"/stateprovince/{CountryId}/edit/{model.Id}");
} }
} }
@code {
}

View File

@@ -61,7 +61,7 @@ namespace Atomx.Admin.Controllers
/// <param name="page"></param> /// <param name="page"></param>
/// <param name="size"></param> /// <param name="size"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("searh")] [HttpPost("search")]
[Authorize(Policy = Permissions.User.View)] [Authorize(Policy = Permissions.User.View)]
public IActionResult AddressList(AreaSearch search, int page, int size = 20) public IActionResult AddressList(AreaSearch search, int page, int size = 20)
{ {

View File

@@ -9,6 +9,7 @@ using Atomx.Data.CacheServices;
using Atomx.Data.Services; using Atomx.Data.Services;
using Atomx.Utils.Extension; using Atomx.Utils.Extension;
using FluentValidation; using FluentValidation;
using Mapster;
using MapsterMapper; using MapsterMapper;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -61,7 +62,7 @@ namespace Atomx.Admin.Controllers
/// <param name="page"></param> /// <param name="page"></param>
/// <param name="size"></param> /// <param name="size"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("searh")] [HttpPost("search")]
public IActionResult Search(CountrySearch search, int page, int size = 20) public IActionResult Search(CountrySearch search, int page, int size = 20)
{ {
if (page < 1) if (page < 1)
@@ -214,8 +215,19 @@ namespace Atomx.Admin.Controllers
_dbContext.LocalizedProperties.AddRange(addLocalizedList); _dbContext.LocalizedProperties.AddRange(addLocalizedList);
} }
data.Enabled = model.Enabled; var config = new TypeAdapterConfig();
data.DisplayOrder = model.DisplayOrder; config.NewConfig<CountryModel, Country>()
.Ignore(dest => dest.Name).Ignore(dest => dest.Id);
data = model.Adapt<CountryModel, Country>(data, config);
//data = _mapper.Map(model, data);
//data.TwoLetterISOCode = model.TwoLetterISOCode;
//data.Initial = model.Initial;
//data.AllowShipping = model.AllowShipping;
//data.NumericISOCode = model.NumericISOCode;
//data.ThreeLetterISOCode = model.ThreeLetterISOCode;
//data.Enabled = model.Enabled;
//data.DisplayOrder = model.DisplayOrder;
try try

View File

@@ -57,7 +57,7 @@ namespace Atomx.Admin.Controllers
/// <param name="page"></param> /// <param name="page"></param>
/// <param name="size"></param> /// <param name="size"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("searh")] [HttpPost("search")]
[Authorize(Policy = Permissions.User.View)] [Authorize(Policy = Permissions.User.View)]
public IActionResult AddressList(StateProvinceSearch search, int page, int size = 20) public IActionResult AddressList(StateProvinceSearch search, int page, int size = 20)
{ {

View File

@@ -1,6 +1,7 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Web; using System.Web;
using System.Runtime.Serialization;
namespace Atomx.Utils.Extension namespace Atomx.Utils.Extension
{ {
@@ -96,6 +97,12 @@ namespace Atomx.Utils.Extension
var modelDict = source.GetType().GetProperties().ToDictionary(a => a.Name.ToLower()); var modelDict = source.GetType().GetProperties().ToDictionary(a => a.Name.ToLower());
foreach (var item in modelDict) foreach (var item in modelDict)
{ {
// Skip properties marked with IgnoreDataMember
if (item.Value.IsDefined(typeof(IgnoreDataMemberAttribute), false))
{
continue;
}
if (item.Value.PropertyType != typeof(DateTime?[])) if (item.Value.PropertyType != typeof(DateTime?[]))
{ {
System.Reflection.PropertyInfo? pi = null; System.Reflection.PropertyInfo? pi = null;