chore
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据ID
|
/// 数据ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 语言
|
/// 语言
|
||||||
|
|||||||
137
Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyEdit.razor
Normal file
137
Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyEdit.razor
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
@page "/currency/create"
|
||||||
|
@page "/currency/edit/{id:long}"
|
||||||
|
@page "/{locale}/currency/create"
|
||||||
|
@page "/{locale}/currency/edit/{id:long}"
|
||||||
|
|
||||||
|
@inject ILogger<CurrencyEdit> Logger
|
||||||
|
@attribute [Authorize]
|
||||||
|
|
||||||
|
<PageContainer Title="@(Id > 0 ? "编辑货币信息" : "新增货币信息")">
|
||||||
|
<Breadcrumb>
|
||||||
|
<Breadcrumb>
|
||||||
|
<BreadcrumbItem Href="/">管理后台</BreadcrumbItem>
|
||||||
|
<BreadcrumbItem Href="/admin/list">系统功能</BreadcrumbItem>
|
||||||
|
<BreadcrumbItem>货币管理</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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
@inject ILogger<CurrencyList> Logger
|
@inject ILogger<CurrencyList> Logger
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
|
|
||||||
<PageTitle>货币管理</PageTitle>
|
|
||||||
<PageContainer Title="语言管理">
|
<PageContainer Title="货币管理">
|
||||||
<Breadcrumb>
|
<Breadcrumb>
|
||||||
<Breadcrumb>
|
<Breadcrumb>
|
||||||
<BreadcrumbItem>Home</BreadcrumbItem>
|
<BreadcrumbItem>Home</BreadcrumbItem>
|
||||||
@@ -112,7 +112,10 @@
|
|||||||
</Table>
|
</Table>
|
||||||
<br />
|
<br />
|
||||||
<Row Justify="RowJustify.End">
|
<Row Justify="RowJustify.End">
|
||||||
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
@if (PagingList.Count > 0)
|
||||||
|
{
|
||||||
|
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||||
|
}
|
||||||
</Row>
|
</Row>
|
||||||
</ChildContent>
|
</ChildContent>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -247,7 +250,7 @@
|
|||||||
|
|
||||||
void HandleAddNew()
|
void HandleAddNew()
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo($"/currency/edit");
|
Navigation.NavigateTo($"/currency/create");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,10 @@
|
|||||||
</Table>
|
</Table>
|
||||||
<br />
|
<br />
|
||||||
<Row Justify="RowJustify.End">
|
<Row Justify="RowJustify.End">
|
||||||
<Pagination PageIndex="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
@if (PagingList.Count > 0)
|
||||||
|
{
|
||||||
|
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||||
|
}
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,10 @@
|
|||||||
</Table>
|
</Table>
|
||||||
<br />
|
<br />
|
||||||
<Row Justify="RowJustify.End">
|
<Row Justify="RowJustify.End">
|
||||||
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
@if (PagingList.Count > 0)
|
||||||
|
{
|
||||||
|
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||||
|
}
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
</ChildContent>
|
</ChildContent>
|
||||||
|
|||||||
@@ -92,6 +92,13 @@
|
|||||||
</ActionColumn>
|
</ActionColumn>
|
||||||
</ColumnDefinitions>
|
</ColumnDefinitions>
|
||||||
</Table>
|
</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>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增帐号" : "编辑帐号")' OnClose="_ => CloseDrawer()">
|
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增帐号" : "编辑帐号")' OnClose="_ => CloseDrawer()">
|
||||||
@@ -290,9 +297,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPageChanged(int args)
|
private void OnPageChanged(PaginationEventArgs args)
|
||||||
{
|
{
|
||||||
OnSearch(args);
|
OnSearch(args.Page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseDrawer()
|
void CloseDrawer()
|
||||||
|
|||||||
@@ -98,7 +98,10 @@
|
|||||||
</Table>
|
</Table>
|
||||||
<br />
|
<br />
|
||||||
<Row Justify="RowJustify.End">
|
<Row Justify="RowJustify.End">
|
||||||
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
@if (PagingList.Count > 0)
|
||||||
|
{
|
||||||
|
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||||
|
}
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,13 @@
|
|||||||
</ActionColumn>
|
</ActionColumn>
|
||||||
</ColumnDefinitions>
|
</ColumnDefinitions>
|
||||||
</Table>
|
</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>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增语言" : "编辑语言")' OnClose="_ => CloseDrawer()">
|
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增语言" : "编辑语言")' OnClose="_ => CloseDrawer()">
|
||||||
@@ -252,9 +259,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPageChanged(int args)
|
private void OnPageChanged(PaginationEventArgs args)
|
||||||
{
|
{
|
||||||
OnSearch(args);
|
OnSearch(args.Page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseDrawer()
|
void CloseDrawer()
|
||||||
|
|||||||
@@ -90,7 +90,10 @@
|
|||||||
</Table>
|
</Table>
|
||||||
<br />
|
<br />
|
||||||
<Row Justify="RowJustify.End">
|
<Row Justify="RowJustify.End">
|
||||||
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
@if (PagingList.Count > 0)
|
||||||
|
{
|
||||||
|
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||||
|
}
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
</Spin>
|
</Spin>
|
||||||
|
|||||||
@@ -90,7 +90,10 @@
|
|||||||
</Table>
|
</Table>
|
||||||
<br />
|
<br />
|
||||||
<Row Justify="RowJustify.End">
|
<Row Justify="RowJustify.End">
|
||||||
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
@if (PagingList.Count > 0)
|
||||||
|
{
|
||||||
|
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||||
|
}
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
11
Atomx.Admin/Atomx.Admin.Client/Services/NavigationService.cs
Normal file
11
Atomx.Admin/Atomx.Admin.Client/Services/NavigationService.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Atomx.Admin.Client.Services
|
||||||
|
{
|
||||||
|
public interface INavigationService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NavigationService
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using AntDesign;
|
using Atomx.Admin.Client.Models;
|
||||||
using Atomx.Admin.Client.Models;
|
|
||||||
using Atomx.Admin.Services;
|
using Atomx.Admin.Services;
|
||||||
using Atomx.Common.Entities;
|
using Atomx.Common.Entities;
|
||||||
using Atomx.Common.Models;
|
using Atomx.Common.Models;
|
||||||
@@ -8,8 +7,8 @@ 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.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
||||||
@@ -197,7 +196,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
result.Success = false;
|
result.Success = false;
|
||||||
return new JsonResult(result);
|
return new JsonResult(result);
|
||||||
}
|
}
|
||||||
if (model.IsEdit && model.Id > 0)
|
if (model.Id.HasValue && model.Id > 0)
|
||||||
{
|
{
|
||||||
var data = _dbContext.Currencies.SingleOrDefault(p => p.Id == model.Id);
|
var data = _dbContext.Currencies.SingleOrDefault(p => p.Id == model.Id);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
@@ -211,20 +210,33 @@ namespace Atomx.Admin.Controllers
|
|||||||
data = _mapper.Map(model, data);
|
data = _mapper.Map(model, data);
|
||||||
data.UpdateTime = DateTime.UtcNow;
|
data.UpdateTime = DateTime.UtcNow;
|
||||||
_dbContext.SaveChanges();
|
_dbContext.SaveChanges();
|
||||||
await _cacheService.GetCurrenciesById(model.Id, data);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var data = _mapper.Map<Currency>(model);
|
var data = new Currency()
|
||||||
data.CreateTime = DateTime.UtcNow;
|
{
|
||||||
|
Name = model.Name,
|
||||||
|
CurrencyCode = model.CurrencyCode,
|
||||||
|
DisplayLocale = model.DisplayLocale,
|
||||||
|
CustomFormatting = model.CustomFormatting,
|
||||||
|
Rate = (decimal)model.Rate,
|
||||||
|
DisplayOrder = model.DisplayOrder,
|
||||||
|
EnableDisplay = model.Enabled,
|
||||||
|
Symbolic = "",
|
||||||
|
Enabled = model.Enabled,
|
||||||
|
Title = model.Name,
|
||||||
|
EnablePay = true,
|
||||||
|
CreateTime = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
_dbContext.Currencies.Add(data);
|
_dbContext.Currencies.Add(data);
|
||||||
_dbContext.SaveChanges();
|
_dbContext.SaveChanges();
|
||||||
await _cacheService.GetCurrenciesById(model.Id, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Data = true;
|
result.Data = true;
|
||||||
|
|
||||||
|
//todo 更新缓存
|
||||||
|
|
||||||
return new JsonResult(result);
|
return new JsonResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ namespace Atomx.Common.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据ID
|
/// 数据ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
[Key]
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ namespace Atomx.Data
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
base.OnModelCreating(builder);
|
||||||
|
builder.Entity<Currency>(entity =>
|
||||||
|
{
|
||||||
|
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user