chore
This commit is contained in:
207
Atomx.Admin/Atomx.Admin.Client/Pages/Settings/AreaList.razor
Normal file
207
Atomx.Admin/Atomx.Admin.Client/Pages/Settings/AreaList.razor
Normal file
@@ -0,0 +1,207 @@
|
||||
@page "/area/list/{countryId:long}"
|
||||
@page "/{locale}/area/list/{countryId:long}"
|
||||
@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>
|
||||
<div class="ant-form-item">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
|
||||
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
|
||||
</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.Initial" Title="首字母" />
|
||||
<PropertyColumn Property="c => c.NumericISOCode" Title="ISO代码" />
|
||||
<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;
|
||||
[Parameter]
|
||||
public long CountryId { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
int? Page { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "size")]
|
||||
int? PageSize { get; set; }
|
||||
|
||||
bool pageLoading = false;
|
||||
|
||||
Form<CountrySearch> searchForm = new();
|
||||
CountrySearch search = new();
|
||||
|
||||
PagingList<Country> 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");
|
||||
}
|
||||
|
||||
async Task LoadListAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = "/api/country/search";
|
||||
var apiResult = await HttpService.GetPagingList<Country>(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 CountrySearch();
|
||||
searchForm?.Reset();
|
||||
}
|
||||
|
||||
private void OnSearch(int page)
|
||||
{
|
||||
var queryString = search.BuildQueryString();
|
||||
if (string.IsNullOrEmpty(queryString))
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list?page={page}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list?page={page}&{queryString}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list?{queryString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchFinish()
|
||||
{
|
||||
Page = Page.GetValueOrDefault(1) - 1;
|
||||
|
||||
OnSearch(Page.Value);
|
||||
}
|
||||
|
||||
private void OnPageChanged(PaginationEventArgs args)
|
||||
{
|
||||
OnSearch(args.Page);
|
||||
}
|
||||
|
||||
void HandleAddNew()
|
||||
{
|
||||
Navigation.NavigateTo($"/country/create");
|
||||
}
|
||||
|
||||
|
||||
void HandleEdit(Country model)
|
||||
{
|
||||
Navigation.NavigateTo($"/country/edit/{model.Id}");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user