添加项目文件。

This commit is contained in:
2025-12-02 13:10:10 +08:00
parent 93a2382a16
commit 289aa4cbe7
400 changed files with 91177 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
<h3>ContentEdit</h3>
@code {
}

View File

@@ -0,0 +1,7 @@
@page "/content/list"
<h3>ContentList</h3>
@code {
}

View File

@@ -0,0 +1,5 @@
<h3>PageEdit</h3>
@code {
}

View File

@@ -0,0 +1,8 @@
@page "/content/page/list"
<h3>PageList</h3>
@code {
}

View File

@@ -0,0 +1,18 @@
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}

View File

@@ -0,0 +1,24 @@
@page "/"
@attribute [Authorize]
<PageTitle>Home</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.
<li>
<a href="/category/list">产品分类</a>
</li>
<li>
<a href="/product/category/edit">产品分类编辑</a>
</li>
<li>
<a href="/system/language/list">多语言设置</a>
</li>
<li>
<a href="/system/locale/resource/list">多语言资源设置</a>
</li>
<li>
<a href="/system/role/list">角色管理</a>
</li>

View File

@@ -0,0 +1,140 @@
@page "/account/login"
@layout EmptyLayout
@inject ILogger<Login> Logger
<PageTitle>登录</PageTitle>
@if (!dataLoaded)
{
<Spin Spinning="_isLoading" />
}
else
{
<Flex Style="height:100vh" Justify="FlexJustify.Center" Align="FlexAlign.Center" Direction="FlexDirection.Vertical">
<GridRow Justify="RowJustify.Center" Class="">
<GridCol>
<Card>
<Form @ref="form" Model="@login" OnFinish="LoginAsync">
<FluentValidationValidator />
<FormItem>
<AntDesign.Input Placeholder="登录账号" Size="InputSize.Large" @bind-Value="@login.Account">
<Prefix><Icon Type="user" /></Prefix>
</AntDesign.Input>
</FormItem>
<FormItem>
<AntDesign.Input Placeholder="登录密码" Size="InputSize.Large" @bind-Value="@login.Password" Type="InputType.Password">
<Prefix><Icon Type="lock" /></Prefix>
</AntDesign.Input>
</FormItem>
<FormItem>
<a style="float: left;">
忘记密码
</a>
<a style="float: right;">
<NavLink href="/register">马上注册</NavLink>
</a>
</FormItem>
<FormItem>
<Button Type="ButtonType.Primary" HtmlType="submit" Class="submit" Size="ButtonSize.Large" Block>登录</Button>
</FormItem>
</Form>
</Card>
</GridCol>
</GridRow>
<GridRow Style="padding-top:40px">
<span style="font-size:12px;padding-right:3px;">Copyright © 2025-@DateTime.Now.Year Atomx.cn All rights reserved.</span>
<span style="font-size:12px">runing as @handler</span>
</GridRow>
</Flex>
}
@code {
string handler = "Server";
[Parameter]
[SupplyParameterFromQuery(Name = "ReturnUrl")]
public string? ReturnUrl { get; set; }
[SupplyParameterFromForm]
public LoginModel login { get; set; } = new();
private Form<LoginModel> form = null!;
bool dataLoaded = false;
string message { get; set; } = string.Empty;
private bool _isLoading = false;
protected override void OnInitialized()
{
if (OperatingSystem.IsBrowser())
{
handler = "Wasm";
}
else
{
handler = "Server";
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
if (authState.User.Identity != null)
{
if (authState.User.Identity.IsAuthenticated)
{
Navigation.NavigateTo(ReturnUrl ?? "/");
}
}
}
if (!dataLoaded)
{
dataLoaded = true;
StateHasChanged();
}
}
private async Task LoginAsync()
{
if (form.Validate())
{
var api = "/api/sign/in";
var result = await HttpService.Post<ApiResult<string>>(api, login);
if (result.Success)
{
Console.WriteLine("请求api成功");
if (!string.IsNullOrEmpty(result.Data))
{
await localStorage.SetItemAsStringAsync(StorageKeys.JWTTokenKeyName, result.Data);
await localStorage.SetItemAsStringAsync("refreshToken", result.Data);
var authState = (AuthStateProvider as PersistentAuthenticationStateProvider);
if (authState != null)
{
authState.UpdateAuthenticationState(result.Data);
}
Logger.LogInformation($"登录成功跳转目标,{ReturnUrl}");
Navigation.NavigateTo(ReturnUrl ?? "/");
}
}
else
{
ModalService.Error(new ConfirmOptions() { Title = "提示", Content = result.Message });
}
}
}
private async Task OnPasswordKeyDown(KeyboardEventArgs value)
{
if (value.Key == "Enter")
{
await LoginAsync();
}
}
}

View File

@@ -0,0 +1,11 @@
@page "/logout"
@layout EmptyLayout
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await ((PersistentAuthenticationStateProvider)AuthStateProvider).MarkUserAsLoggedOut();
Navigation.NavigateTo("/account/login");
await base.OnAfterRenderAsync(firstRender);
}
}

View File

@@ -0,0 +1,5 @@
<h3>OrderList</h3>
@code {
}

View File

@@ -0,0 +1,7 @@
@page "/orders/view/{OrderId:long}"
<h3>OrderView</h3>
@code {
}

View File

@@ -0,0 +1,137 @@
@page "/product/category/edit"
@page "/product/category/edit/{Id:long?}"
@inject ILogger<CategoryEdit> Logger
@* @attribute [Authorize] *@
<PageTitle>分类编辑</PageTitle>
<Title Level="4">分类信息</Title>
<Spin Spinning="pageLoading">
<Card Title="" Class="hideborder"
Style="margin-top: 24px;"
BodyStyle="padding: 0 32px 40px 32px">
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="19" OnFinish="OnFormFinishAsync">
@* @if (languages.Count > 1 && Id > 0)
{
<Tabs ActiveKey="@context.Language" OnTabClick="OnLanguageTabChange">
<TabPane Key="0">
<TabTemplate>
<span>标准</span>
</TabTemplate>
</TabPane>
@foreach (var item in languages)
{
<TabPane Key="@item.Id.ToString()">
<TabTemplate>
<span>@item.Name @item.Id.ToString()</span>
</TabTemplate>
</TabPane>
}
</Tabs>
}
<FormItem Label="上级菜单">
<SimpleSelect DefaultValue="" Style="width:300px;" @bind-Value="@context.ParentId">
<SelectOptions>
<SimpleSelectOption Value="0" Label="无上级"></SimpleSelectOption>
@foreach (var item in categories)
{
<SimpleSelectOption Value="@item.Id.ToString()" Label="@item.Name"></SimpleSelectOption>
}
</SelectOptions>
</SimpleSelect>
</FormItem>
<FormItem Label="分类名称" Required>
<Input @bind-Value="@context.Name" Placeholder="分类名称" />
</FormItem>
<FormItem Label="URL缩略名" Required>
<Input @bind-Value="@context.Slug" Placeholder="URL缩略名" />
</FormItem>
<FormItem Label="图标">
<Button OnClick="HandleSetIcon">
@if (string.IsNullOrEmpty(formModel.Image))
{
<span>选择图标</span>
}
else
{
<span>已选图标:</span>
}
</Button> <Button Size="@ButtonSize.Large" Type="@ButtonType.Text" Icon="@formModel.Image"></Button>
</FormItem> *@
<FormItem Label="Meta描述">
<Input @bind-Value="@context.MetaDescription" Placeholder="Meta描述" />
</FormItem>
<FormItem Label="Meta关键词">
<Input @bind-Value="@context.MetaKeywords" Placeholder="Meta关键词" />
</FormItem>
<FormItem Label="显示排序">
<Input @bind-Value="@context.DisplayOrder" Placeholder="显示排序" />
</FormItem>
<FormItem Label="状态">
<Checkbox @bind-Checked="@context.Enabled">启用</Checkbox>
</FormItem>
<FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }">
<Button Type="@ButtonType.Primary" HtmlType="submit">
提交保存
</Button>
</FormItem>
</Form>
</Card>
</Spin>
@code {
[SupplyParameterFromQuery]
int? Lang { get; set; }
[Parameter]
public long? Id { get; set; }
[SupplyParameterFromForm]
CategoryModel model { get; set; } = new();
Form<CategoryModel> editform = null!;
bool pageLoading = true;
List<CategoryItem> Categories = new();
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override async Task OnParametersSetAsync()
{
pageLoading = true;
// await LoadCategories();
// if (Id > 0)
// {
// await LoadData();
// await SearchAttribute(string.Empty);
// }
// else
// {
// editCategory = true;
// CategoryPath = string.Empty;
// }
// if (Categories.Any())
// {
// BindCategory();
// }
pageLoading = false;
base.OnParametersSet();
}
async Task LoadCategories()
{
var url = $"/api/category/items";
var apiResult = await HttpService.Get<ApiResult<List<CategoryItem>>>(url);
if (apiResult.Success)
{
Categories = apiResult.Data ?? new();
}
}
async void OnFormFinishAsync()
{
}
}

View File

@@ -0,0 +1,336 @@
@page "/category/list"
@inject ILogger<CategoryList> Logger
@attribute [Authorize]
<PageTitle>分类管理</PageTitle>
<Title Level="4">菜单管理</Title>
<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>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="categories" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
菜单列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Name" Title="名称">
<AntDesign.Text>@GetName(context)</AntDesign.Text>
</PropertyColumn>
<PropertyColumn Property="c=>c.Slug" Title="缩略名" Width="80px" Align="ColumnAlign.Center">
</PropertyColumn>
<PropertyColumn Property="c=>c.DisplayOrder" Title="排序" Width="100px" />
<PropertyColumn Property="c=>c.Enabled" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Enabled)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CreateTime" Title="时间" Width="190px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
@if (context.IsLast)
{
<SpaceItem>
<a Href="@($"/attribute/list?categoryid={context.Id}")">属性</a>
</SpaceItem>
<SpaceItem>
<a Href="@($"/specification/list?categoryid={context.Id}")">规格</a>
</SpaceItem>
}
<SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
<Overlay>
<Menu>
<MenuItem>
<a @onclick="(e)=>OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
</MenuItem>
<MenuDivider />
<MenuItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a> <Icon Type="@IconType.Outline.Delete" /> 删除</a>
</Popconfirm>
</MenuItem>
</Menu>
</Overlay>
<ChildContent>
<a class="ant-dropdown-link" @onclick:preventDefault>
<Icon Type="@IconType.Outline.Menu" />
</a>
</ChildContent>
</Dropdown>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='("设置菜单")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="5" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="名称">
<Input @bind-Value="model.Name" For="(()=>model.Name)" />
</FormItem>
<FormItem Label="缩略名">
<Input @bind-Value="model.Slug" For="(()=>model.Slug)" />
</FormItem>
<FormItem Label="上级分类">
<Select @bind-Value="@model.ParentId" TItemValue="long" TItem="string" Placeholder="请选择上级分类">
<SelectOptions>
<SelectOption Value="0L" Label="无" />
@foreach (var item in categories)
{
<SelectOption Value="@item.Id" Label="@GetName(item)" />
}
</SelectOptions>
</Select>
</FormItem>
<FormItem Label="排序">
<Input @bind-Value="model.DisplayOrder" For="(()=>model.DisplayOrder)" />
</FormItem>
<FormItem Label="状态">
<Checkbox @bind-Value="model.Enabled" For="(()=>model.Enabled)">启用</Checkbox>
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromForm]
CategorySearch search { get; set; } = new();
Form<CategorySearch> searchForm = null!;
[SupplyParameterFromForm]
CategoryModel model { get; set; } = new();
Form<CategoryModel> editform = null!;
List<CategoryItem> categories = new();
bool drawerVisible;
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Name = query.GetQueryString("Name");
}
private async void LoadList()
{
var url = "/api/category/list";
var apiResult = await HttpService.Get<ApiResult<List<CategoryItem>>>(url);
if (apiResult.Success)
{
if (apiResult.Data != null)
{
categories = apiResult.Data;
StateHasChanged();
}
}
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
void OnSearchReset()
{
search = new();
searchForm?.Reset();
OnSearchFinish();
}
private void OnReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/category/list?page={page}");
}
else
{
Navigation.NavigateTo($"/category/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/category/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/category/list?{queryString}");
}
}
LoadList();
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/category/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
void OnEditClick(CategoryItem item)
{
this.model = item.Adapt<CategoryModel>();
drawerVisible = true;
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
var data = model.Adapt<CategoryModel>();
if (model.Id > 0)
{
var url = $"api/category/edit";
result = await HttpService.Post<ApiResult<string>>(url, data);
}
else
{
var url = $"api/category/add";
result = await HttpService.Post<ApiResult<string>>(url, data);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private string GetPath(string path)
{
var array = path.Split(",").ToList();
var pathText = string.Empty;
foreach (var item in array)
{
var name = categories.Where(p => p.Id == item.ToLong()).Select(p => p.Name).SingleOrDefault();
if (string.IsNullOrEmpty(pathText))
{
pathText = name;
}
else
{
pathText = $"{pathText}>{name}";
}
}
return pathText;
}
private string GetName(CategoryItem menu)
{
string name = string.Empty;
if (menu.Depth > 0)
{
var symbol = " ";
for (var i = 0; i < menu.Depth; i++)
{
symbol = $"{symbol}{symbol}";
}
name = $"{symbol}├ {menu.Name}";
}
else
{
name = menu.Name;
}
return name;
}
void OnCreateClick()
{
model = new CategoryModel();
drawerVisible = true;
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
}

View File

@@ -0,0 +1,5 @@
<h3>GoodsList</h3>
@code {
}

View File

@@ -0,0 +1,290 @@
@page "/attribute/predefined/list/{AttributeId:long}"
@inject ILogger<PredefinedAttributeList> Logger
@attribute [Authorize]
<PageTitle>产品属性管理</PageTitle>
<Title Level="4">属性列表</Title>
<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.Value" Placeholder="名称" AllowClear />
</FormItem>
</Col>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
@productAttribute.Name 属性预设值列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Value" Title="名称"></PropertyColumn>
<PropertyColumn Property="c=>c.DisplayOrder" Title="排序" Width="150px" Align="ColumnAlign.Center" />
<PropertyColumn Property="c=>c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CreateTime" Title="时间" Width="200px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="180px">
<Space>
<SpaceItem>
<a @onclick="(e)=>OnEditClick(context)">编辑</a>
</SpaceItem>
<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a>删除</a>
</Popconfirm>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='($"设置{productAttribute.Name}属性预设值")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="4" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="名称">
<Input @bind-Value="model.Value" For="(()=>model.Value)" />
</FormItem>
<FormItem Label="排序">
<Input @bind-Value="model.DisplayOrder" For="(()=>model.DisplayOrder)" />
</FormItem>
<FormItem Label="状态">
<RadioGroup @bind-Value="@model.Status" ButtonStyle="RadioButtonStyle.Solid">
<Radio RadioButton Value="1">启用</Radio>
<Radio RadioButton Value="2">禁用</Radio>
</RadioGroup>
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[Parameter]
public long AttributeId { get; set; }
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
ProductAttributeOptionSearch search { get; set; } = new();
Form<ProductAttributeOptionSearch> searchForm = null!;
[SupplyParameterFromForm]
ProductAttributeOptionModel model { get; set; } = new();
Form<ProductAttributeOptionModel> editform = null!;
ProductAttribute productAttribute = new();
PagingList<ProductAttributeOption> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
LoadAttribute();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Value = query.GetQueryString("Value");
}
private async void LoadAttribute()
{
var url = $"/api/productattribute/{AttributeId}";
var apiResult = await HttpService.Get<ApiResult<ProductAttribute>>(url);
if (apiResult.Success)
{
if (apiResult.Data != null)
{
productAttribute = apiResult.Data;
}
}
}
private async void LoadList()
{
loading = true;
var url = "/api/productattributeoption/search";
var apiResult = await HttpService.GetPagingList<ProductAttributeOption>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnSearchReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/attribute/predefined/list/{AttributeId}?page={page}");
}
else
{
Navigation.NavigateTo($"/attribute/predefined/list/{AttributeId}");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/attribute/predefined/list/{AttributeId}?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/attribute/predefined/list/{AttributeId}?{queryString}");
}
}
}
void OnPageChanged(PaginationEventArgs args)
{
OnSearch(args.Page);
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/productattributeoption/delete/{model.Id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/productattributeoption/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/productattributeoption/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
void OnEditClick(ProductAttributeOption option)
{
this.model = option.Adapt<ProductAttributeOptionModel>();
drawerVisible = true;
}
void OnCreateClick()
{
model = new();
drawerVisible = true;
}
private void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
}

View File

@@ -0,0 +1,325 @@
@page "/specification/predefined/list/{SpecificationId:long}"
@inject ILogger<PredefinedSpecificationList> Logger
@attribute [Authorize]
<PageTitle>产品规格管理</PageTitle>
<Title Level="4">属性列表</Title>
<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.Value" Placeholder="名称" AllowClear />
</FormItem>
</Col>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
@specificationAttribute.Name 属性列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Value" Title="名称"></PropertyColumn>
<PropertyColumn Property="c=>c.DisplayOrder" Title="排序" Width="150px" Align="ColumnAlign.Center" />
<PropertyColumn Property="c=>c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CreateTime" Title="时间" Width="200px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="180px">
<Space>
<SpaceItem>
<a @onclick="(e)=>OnEditClick(context)">编辑</a>
</SpaceItem>
<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a>删除</a>
</Popconfirm>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='($"设置{specificationAttribute.Name}规格预设值")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="4" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="名称">
<Input @bind-Value="model.Value" For="(()=>model.Value)" />
</FormItem>
<FormItem Label="排序">
<Input @bind-Value="model.DisplayOrder" For="(()=>model.DisplayOrder)" />
</FormItem>
<FormItem Label="状态">
<RadioGroup @bind-Value="@model.Status" ButtonStyle="RadioButtonStyle.Solid">
<Radio RadioButton Value="1">启用</Radio>
<Radio RadioButton Value="2">禁用</Radio>
</RadioGroup>
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[Parameter]
public long SpecificationId { get; set; }
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
SpecificationAttributeOptionSearch search { get; set; } = new();
Form<SpecificationAttributeOptionSearch> searchForm = null!;
[SupplyParameterFromForm]
SpecificationAttributeOptionModel model { get; set; } = new();
Form<SpecificationAttributeOptionModel> editform = null!;
SpecificationAttribute specificationAttribute = new();
PagingList<SpecificationAttributeOption> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
private bool drawerVisible;
SpecificationAttributeOptionModelValidator validator = new();
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
LoadSpecification();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Value = query.GetQueryString("Value");
}
private async void LoadList()
{
loading = true;
var url = "/api/specificationattributeoption/search";
var apiResult = await HttpService.GetPagingList<SpecificationAttributeOption>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
private async void LoadSpecification()
{
var url = $"/api/specificationattribute/{SpecificationId}";
var apiResult = await HttpService.Get<ApiResult<SpecificationAttribute>>(url);
if (apiResult.Success)
{
if (apiResult.Data != null)
{
specificationAttribute = apiResult.Data;
}
}
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnSearchReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/specification/predefined/list/{SpecificationId}?page={page}");
}
else
{
Navigation.NavigateTo($"/specification/predefined/list/{SpecificationId}");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/specification/predefined/list/{SpecificationId}?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/specification/predefined/list/{SpecificationId}?{queryString}");
}
}
// LoadList();
}
void OnPageChanged(PaginationEventArgs args)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
Navigation.NavigateTo($"/attribute/list?page={args.Page}");
}
else
{
Navigation.NavigateTo($"/attribute/list?page={Page}&{queryString}");
}
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/specificationattributeoption/delete/{model.Id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
model.SpecificationId = SpecificationId;
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/specificationattributeoption/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/specificationattributeoption/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private void OnPageChanged(int args)
{
OnSearch(args);
}
private bool _editDrawerOpen;
private void OpenDrawer()
{
model = new();
_editDrawerOpen = true;
}
void OnEditClick(SpecificationAttributeOption item)
{
this.model = item.Adapt<SpecificationAttributeOptionModel>();
drawerVisible = true;
}
void OnDrawerOverlayClick(bool state)
{
if (!state)
{
model = new();
_editDrawerOpen = state;
}
}
void OnCreateClick()
{
drawerVisible = true;
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
}

View File

@@ -0,0 +1,339 @@
@page "/attribute/list"
@rendermode InteractiveAuto
@inject ILogger<ProductAttributeList> Logger
@inject HttpService HttpService
@attribute [Authorize]
<PageTitle>产品属性管理</PageTitle>
<Title Level="4">属性列表</Title>
<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>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
属性列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Name" Title="名称"></PropertyColumn>
<PropertyColumn Property="c=>c.ControlType" Title="控件">
@if (context.ControlType == 1)
{
<Tag Color="TagColor.Green">选项</Tag>
}
else
{
<Tag>文本框</Tag>
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CategoryName" Title="分类"></PropertyColumn>
<PropertyColumn Property="c=>c.WeightIsRequired" Title="重量" Width="100px">
@if (context.WeightIsRequired)
{
<Tag>必填</Tag>
}
</PropertyColumn>
<PropertyColumn Property="c=>c.IsRequired" Title="默认" Width="100px">
@if (context.IsRequired)
{
<Tag>必选</Tag>
}
</PropertyColumn>
<PropertyColumn Property="c=>c.DisplayOrder" Title="排序" Width="150px" Align="ColumnAlign.Center" />
<PropertyColumn Property="c=>c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CreateTime" Title="时间" Width="200px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="180px">
<Space>
<SpaceItem>
<a @onclick="(e)=>OnViewPredefinedListClick(context.Id)">预设值</a>
</SpaceItem>
<SpaceItem>
<a @onclick="(e)=>OnEditClick(context)">编辑</a>
</SpaceItem>
<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a>删除</a>
</Popconfirm>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='("设置菜单")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="4" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="名称">
<Input @bind-Value="model.Name" For="(()=>model.Name)" />
</FormItem>
<FormItem Label="控件">
<RadioGroup @bind-Value="@model.ControlType" ButtonStyle="RadioButtonStyle.Solid">
<Radio RadioButton Value="0">默认(文本)</Radio>
<Radio RadioButton Value="1">选项</Radio>
</RadioGroup>
</FormItem>
<FormItem Label="重量">
<Checkbox @bind-Value="model.WeightIsRequired">必填</Checkbox>
</FormItem>
<FormItem Label="默认">
<Checkbox @bind-Value="model.IsRequired">默认属性</Checkbox>
</FormItem>
<FormItem Label="状态">
<RadioGroup @bind-Value="@model.Status" ButtonStyle="RadioButtonStyle.Solid">
<Radio RadioButton Value="1">启用</Radio>
<Radio RadioButton Value="2">禁用</Radio>
</RadioGroup>
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery]
long CategoryId { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
ProductAttributeSearch search { get; set; } = new();
Form<ProductAttributeSearch> searchForm = null!;
[SupplyParameterFromForm]
ProductAttributeModel model { get; set; } = new();
Form<ProductAttributeModel> editform = null!;
PagingList<ProductAttributeItemModel> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
private bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
model.CategoryId = CategoryId;
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Name = query.GetQueryString("Name");
search.CategoryId = CategoryId;
}
private async void LoadList()
{
loading = true;
var url = "/api/productattribute/search";
var apiResult = await HttpService.GetPagingList<ProductAttributeItemModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnSearchReset()
{
search = new();
LoadList();
}
private void OnReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/attribute/list?page={page}");
}
else
{
Navigation.NavigateTo($"/attribute/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/attribute/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/attribute/list?{queryString}");
}
}
}
void OnPageChanged(PaginationEventArgs args)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
Navigation.NavigateTo($"/attribute/list?page={args.Page}");
}
else
{
Navigation.NavigateTo($"/attribute/list?page={Page}&{queryString}");
}
}
void OnEditClick(ProductAttribute productAttribute)
{
this.model = productAttribute.Adapt<ProductAttributeModel>();
drawerVisible = true;
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/productattribute/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
Console.WriteLine("run on from finish ");
if (CategoryId > 0)
{
model.CategoryId = CategoryId;
}
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/productattribute/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/productattribute/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private void OnPageChanged(int args)
{
OnSearch(args);
}
void OnCreateClick()
{
drawerVisible = true;
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
void OnViewPredefinedListClick(long id)
{
Navigation.NavigateTo($"/attribute/Predefined/list/{id}");
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,425 @@
@page "/product/list"
@inject ILogger<ProductList> Logger
@attribute [Authorize]
<PageTitle>产品管理</PageTitle>
<Title Level="4">产品列表</Title>
<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.Title" Placeholder="名称" AllowClear />
</FormItem>
</Col>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
产品列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Title" Title="名称">
<div>@context.Title</div>
<Text Copyable Type="TextElementType.Secondary" CopyConfig="CopyHint">@context.Id</Text>
</PropertyColumn>
<PropertyColumn Property="c=>c.StockQuantity" Title="库存" Width="150px" Align="ColumnAlign.Center" />
<PropertyColumn Property="c=>c.DisplayOrder" Title="排序" Width="150px" Align="ColumnAlign.Center" />
<PropertyColumn Property="c=>c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CreateTime" Title="时间" Width="200px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="180px">
<Space>
<SpaceItem>
<a @onclick="(e)=>OnClickAddStock(context)">入库</a>
</SpaceItem>
<SpaceItem>
<a @onclick="(e)=>OnEditClick(context.Id)">编辑</a>
</SpaceItem>
<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a>删除</a>
</Popconfirm>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='("设置库存")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="5" @ref="@stockForm" Model="@stockModel" OnFinish="OnStockFormFinish">
<FluentValidationValidator />
<FormItem Label="产品名称">
@stockModel.Title
</FormItem>
@if (!stockModel.AddAttribute)
{
@foreach (var item in stockModel.ProductStockAttributes)
{
<FormItem Label="@item.Name">
<Select @bind-Value="@item.AttributeValue.OptionId" TItemValue="long" TItem="long">
<SelectOptions>
@foreach (var value in item.ProductAttributeValues)
{
<SelectOption Value="@value.Id" Label="@GetAttributeValue(value)" />
}
</SelectOptions>
</Select>
</FormItem>
}
}
<FormItem Label="规格">
<Checkbox @bind-Value="@stockModel.AddAttribute" Disabled=false>
设置新规格
</Checkbox>
</FormItem>
@if (stockModel.AddAttribute)
{
@foreach (var item in stockModel.ProductStockAttributes)
{
<FormItem Label="@item.Name">
<Input @bind-Value="@item.AttributeValue.Name" Placeholder="请输入规格" Style="width:160px;"></Input>
@if (item.WeightIsRequired)
{
<AntDesign.Input Type="InputType.Text" @bind-Value="@item.AttributeValue.Weight" Placeholder="重量" WrapperStyle="width:80px">
<Suffix>@GetWeightUnit(item.WeightUnit)</Suffix>
</AntDesign.Input>
}
</FormItem>
}
}
<FormItem Label="SKU编码">
<Input @bind-Value="stockModel.ProductAttributeCombination.SkuNumber" For="(()=>stockModel.ProductAttributeCombination.SkuNumber)" />
</FormItem>
<FormItem Label="存放仓库">
<AutoComplete TOption="SelectItem" Placeholder="输入或选择仓储" @bind-Value="@stockModel.WarehouseId"
OnInput="(e) => OnWarehouseInput(e)"
Options="warehouseSelectItems">
<OptionTemplate Context="option">
<AutoCompleteOption Value="@option.Value.Id" Label="@option.Value.Name">
</AutoCompleteOption>
</OptionTemplate>
</AutoComplete>
</FormItem>
<FormItem Label="新增库存">
<Input Type="InputType.Number" @bind-Value="stockModel.AddStockQuantity" For="(()=>stockModel.AddStockQuantity)" />
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
ProductSearch search { get; set; } = new();
Form<ProductSearch> searchForm = null!;
PagingList<Product> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
[SupplyParameterFromForm]
ProductAddStockModel stockModel { get; set; } = new();
Form<ProductAddStockModel> stockForm = null!;
bool drawerVisible;
string WarehouseName = string.Empty;
List<SelectItem> warehouseSelectItems = new();
public TypographyCopyableConfig CopyHint { get; set; } = null!;
protected override void OnInitialized()
{
CopyHint = new() { OnCopy = () => MessageService.Success("复制成功") };
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Title = query.GetQueryString("Title");
search.CategoryId = query.GetQueryString("CategoryId");
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();
}
}
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
MessageService.Info("正在查询数据...");
OnSearch(Page.Value);
}
private void OnSearchReset()
{
search = new();
LoadList();
}
private async void LoadList()
{
loading = true;
var url = "/api/product/search";
var apiResult = await HttpService.GetPagingList<Product>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
private void OnReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/product/list?page={page}");
}
else
{
Navigation.NavigateTo($"/product/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/product/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/product/list?{queryString}");
}
}
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/product/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
void OnPageChanged(PaginationEventArgs args)
{
OnSearch(args.Page);
}
void OnCreateClick()
{
Navigation.NavigateTo($"/product/create");
}
void OnEditClick(long id)
{
Navigation.NavigateTo($"/product/edit/{id}");
}
async Task OnClickAddStock(Product product)
{
drawerVisible = true;
stockModel = product.Adapt<ProductAddStockModel>();
stockModel.ProductId = product.Id;
var url = $"/api/product/attributes/{product.Id}";
var apiResult = await HttpService.Post<ApiResult<List<ProductStockAttributeModel>>>(url, new());
if (apiResult.Success)
{
stockModel.ProductStockAttributes = apiResult.Data ?? new();
}
WarehouseSearch warehouseSearch = new()
{
CorporationId = product.CorporationId
};
url = $"/api/warehouse/select";
var selectResult = await HttpService.Post<ApiResult<List<SelectItem>>>(url, warehouseSearch);
if (selectResult.Success)
{
warehouseSelectItems = selectResult.Data ?? new();
}
}
async void OnWarehouseInput(ChangeEventArgs e)
{
WarehouseSearch warehouseSearch = new()
{
CorporationId = stockModel.CorporationId,
Name = e.Value?.ToString()
};
var url = $"/api/warehouse/select";
var selectResult = await HttpService.Post<ApiResult<List<SelectItem>>>(url, warehouseSearch);
if (selectResult.Success)
{
warehouseSelectItems = selectResult.Data ?? new();
}
}
Func<object, object, bool> CompareWith = (a, b) =>
{
if (a is SelectItem o1 && b is SelectItem o2)
{
return o1.Name == o2.Name;
}
else
{
return false;
}
};
void CloseDrawer()
{
drawerVisible = false;
stockForm.Reset();
}
async Task OnStockFormFinish()
{
if (stockForm.Validate())
{
var result = new ApiResult<string>();
Console.WriteLine(stockModel.ToJson());
var url = $"api/product/stock/add";
result = await HttpService.Post<ApiResult<string>>(url, stockModel);
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
string GetAttributeValue(ProductAttributeValueModel value)
{
if (value.Weight > 0)
{
return $"{value.Name}{value.Weight.RemoveTrailingZeros()}{GetWeightUnit(value.WeightUnit)}";
}
else
{
return value.Name;
}
}
string GetWeightUnit(int weightUnit)
{
switch (weightUnit)
{
case 1:
return $"mg";
case 3:
return $"kg";
case 4:
return $"t";
case 5:
return $"lb";
case 6:
return $"oz";
default:
return $"g";
}
}
}

View File

@@ -0,0 +1,258 @@
@page "/product/stock/list"
@inject ILogger<ProductStockList> Logger
@attribute [Authorize]
<PageTitle>产品库存列表</PageTitle>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
产品库存列表
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Title" Title="名称"></PropertyColumn>
<ActionColumn Title="规格">
@foreach (var item in context.Sku)
{
<AntDesign.Text>
@item.ValueName
@if (item.Weight > 0)
{
<AntDesign.Text>@($"{item.Weight}{@GetWeightUnit(item.WeightUnit)}")</AntDesign.Text>
}
</AntDesign.Text>
}
</ActionColumn>
<PropertyColumn Property="c=>c.Weight" Title="重量" Width="150px" Align="ColumnAlign.Center">
@context.Weight.RemoveTrailingZeros()
</PropertyColumn>
<PropertyColumn Property="c=>c.StockQuantity" Title="库存" Width="80px" Align="ColumnAlign.Center">
</PropertyColumn>
<PropertyColumn Property="c=>c.UpdateTime" Title="更新时间" Width="200px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="180px">
<Space>
<SpaceItem>
<a @onclick="(e)=>OnClickAddStock(context)">入库</a>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='("规格库存入库")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="4" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="产品标题">
@model.Title
</FormItem>
<FormItem Label="规格">
@if (model.Sku != null)
{
@foreach (var item in model.Sku)
{
<GridRow>
<GridCol>@item.AttributeName</GridCol>
<GridCol>
@item.ValueName
@if (item.Weight > 0)
{
<AntDesign.Text>@($"{item.Weight}{@GetWeightUnit(item.WeightUnit)}")</AntDesign.Text>
}
</GridCol>
</GridRow>
}
}
</FormItem>
<FormItem Label="新增库存">
<Input @bind-Value="@model.AddStockQuantity"></Input>
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
ProductStockUnitSearch search { get; set; } = new();
Form<ProductStockUnitSearch> searchForm = null!;
PagingList<ProductStockUnitModel> PagingList = new();
[SupplyParameterFromForm]
ProductStockModel model { get; set; } = new();
Form<ProductStockModel> editform = null!;
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
private bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Key = query.GetQueryString("Key");
search.Type = query.GetQueryString("Type").ToInt();
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnSearchReset()
{
search = new();
LoadList();
}
private async void LoadList()
{
loading = true;
var url = "/api/product/stock/search";
var apiResult = await HttpService.GetPagingList<ProductStockUnitModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
private void OnReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/product/stock/list?page={page}");
}
else
{
Navigation.NavigateTo($"/product/stock/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/product/stock/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/product/stock/list?{queryString}");
}
}
}
void OnPageChanged(PaginationEventArgs args)
{
OnSearch(args.Page);
}
string PriceFormat(decimal value)
{
return value.ToString("G");
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
void OnClickAddStock(ProductStockUnitModel item)
{
model = item.Adapt<ProductStockModel>();
drawerVisible = true;
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
var url = $"api/product/skustock/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
string GetWeightUnit(int weightUnit)
{
switch (weightUnit)
{
case 1:
return $"mg";
case 3:
return $"kg";
case 4:
return $"t";
case 5:
return $"lb";
case 6:
return $"oz";
default:
return $"g";
}
}
}

View File

@@ -0,0 +1,319 @@
@page "/specification/list"
@inject ILogger<SpecificationList> Logger
@attribute [Authorize]
<PageTitle>产品规格管理</PageTitle>
<Title Level="4">属性列表</Title>
<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>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
属性列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Name" Title="名称"></PropertyColumn>
<PropertyColumn Property="c=>c.ControlType" Title="控件">
@if (context.ControlType == 1)
{
<Tag Color="TagColor.Green">选项</Tag>
}
else
{
<Tag>文本框</Tag>
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CategoryName" Title="分类"></PropertyColumn>
<PropertyColumn Property="c=>c.DisplayOrder" Title="排序" Width="150px" Align="ColumnAlign.Center" />
<PropertyColumn Property="c=>c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CreateTime" Title="时间" Width="200px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="180px">
<Space>
<SpaceItem>
<a @onclick="(e)=>OnViewPredefinedListClick(context.Id)">预设值</a>
</SpaceItem>
<SpaceItem>
<a @onclick="(e)=>OnEditClick(context)">编辑</a>
</SpaceItem>
<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a>删除</a>
</Popconfirm>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='("设置规格属性")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="4" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="名称">
<Input @bind-Value="model.Name" For="(()=>model.Name)" />
</FormItem>
<FormItem Label="控件">
<RadioGroup @bind-Value="@model.ControlType" ButtonStyle="RadioButtonStyle.Solid">
<Radio RadioButton Value="0">默认(文本)</Radio>
<Radio RadioButton Value="1">选项</Radio>
</RadioGroup>
</FormItem>
<FormItem Label="状态">
<RadioGroup @bind-Value="@model.Status" ButtonStyle="RadioButtonStyle.Solid">
<Radio RadioButton Value="1">启用</Radio>
<Radio RadioButton Value="2">禁用</Radio>
</RadioGroup>
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery]
long CategoryId { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
SpecificationAttributeSearch search { get; set; } = new();
Form<SpecificationAttributeSearch> searchForm = null!;
[SupplyParameterFromForm]
SpecificationAttributeModel model { get; set; } = new();
Form<SpecificationAttributeModel> editform = null!;
PagingList<SpecificationAttributeItemModel> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
private bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Name = query.GetQueryString("Name");
search.CategoryId = CategoryId;
}
private async void LoadList()
{
loading = true;
var url = "/api/specificationattribute/search";
var apiResult = await HttpService.GetPagingList<SpecificationAttributeItemModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnSearchReset()
{
search = new();
LoadList();
}
private void OnReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/specification/list?page={page}");
}
else
{
Navigation.NavigateTo($"/specification/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/specification/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/specification/list?{queryString}");
}
}
}
void OnEditClick(SpecificationAttribute attribute)
{
this.model = attribute.Adapt<SpecificationAttributeModel>();
drawerVisible = true;
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/specificationattribute/delete/{model.Id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
if (CategoryId > 0)
{
model.CategoryId = CategoryId;
}
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/specificationattribute/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/specificationattribute/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
void OnPageChanged(PaginationEventArgs args)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
Navigation.NavigateTo($"/specification/list?page={args.Page}");
}
else
{
Navigation.NavigateTo($"/specification/list?page={Page}&{queryString}");
}
}
void OnCreateClick()
{
drawerVisible = true;
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
void OnViewPredefinedListClick(long id)
{
Navigation.NavigateTo($"/specification/Predefined/list/{id}");
}
}

View File

@@ -0,0 +1,10 @@
@page "/account/register"
@inject ILogger<Register> Logger
<PageTitle>注册账号</PageTitle>
<h3>Register</h3>
@code {
}

View File

@@ -0,0 +1,317 @@
@page "/setting/messagetemplate/list"
@inject ILogger<MessageTemplateList> Logger
@* @attribute [Authorize] *@
<PageTitle>消息模板</PageTitle>
<Title Level="4">消息模版管理</Title>
<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.Key" Placeholder="名称" AllowClear />
</FormItem>
</Col>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
菜单列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c => c.Type" Title="模版类型" Width="150px">
@if (context.Type == (int)MessageTemplateType.Message)
{
<AntDesign.Text>站内信</AntDesign.Text>
}
else if (context.Type == (int)MessageTemplateType.Email)
{
<AntDesign.Text>邮件</AntDesign.Text>
}
else if (context.Type == (int)MessageTemplateType.Sms)
{
<AntDesign.Text>短信</AntDesign.Text>
}
</PropertyColumn>
<PropertyColumn Property="c => c.Name" Title="模版名称" />
<PropertyColumn Property="c => c.Key" Title="模版Code" Width="100px" />
<PropertyColumn Property="c => c.Title" Title="模版标题" />
<PropertyColumn Property="c => c.Enabled" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Enabled)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.CreateTime" Title="时间" Width="190px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
<SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
<Overlay>
<Menu>
<MenuItem>
<a @onclick="(e) => HandleEdit(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
</MenuItem>
<MenuDivider />
<MenuItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a> <Icon Type="@IconType.Outline.Delete" /> 删除</a>
</Popconfirm>
</MenuItem>
</Menu>
</Overlay>
<ChildContent>
<a class="ant-dropdown-link" @onclick:preventDefault>
<Icon Type="@IconType.Outline.Menu" />
</a>
</ChildContent>
</Dropdown>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<Row Justify="RowJustify.End">
<Pagination PageIndex="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Modal Title="@("消息模版设置")" Visible="@modalVisible" Width="700" MaskClosable="true" OkText="@("保存")" CancelText="@("取消")" OnOk="@HandleModalOk" OnCancel="@HandleCancel">
<Form Model="@template" @ref="@editForm" LabelCol="new ColLayoutParam { Span = 5 }" WrapperCol="new ColLayoutParam { Span = 15 }" Name="modalForm" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="消息模版类型">
<SimpleSelect DefaultValue="" Style="width:120px;" @bind-Value="@context.Type">
<SelectOptions>
<SimpleSelectOption Value="" Label="请选择消息模版类型"></SimpleSelectOption>
<SimpleSelectOption Value="@(((int)MessageTemplateType.Message).ToString())" Label="站内信"></SimpleSelectOption>
<SimpleSelectOption Value="@(((int)MessageTemplateType.Email).ToString())" Label="邮件模版"></SimpleSelectOption>
<SimpleSelectOption Value="@(((int)MessageTemplateType.Sms).ToString())" Label="短信模版"></SimpleSelectOption>
</SelectOptions>
</SimpleSelect>
</FormItem>
<FormItem Label="消息模版名称">
<Input Placeholder="消息模版名称" @bind-Value="@context.Name" />
</FormItem>
<FormItem Label="模版Code">
<Input Placeholder="模版Code" @bind-Value="@context.Key" Disabled="@(context.Id > 0)" />
</FormItem>
<FormItem Label="消息标题">
<Input Placeholder="消息标题" @bind-Value="@context.Title" />
</FormItem>
<FormItem Label="消息内容">
<TextArea Placeholder="消息内容" @bind-Value="@context.Body" />
</FormItem>
<FormItem Label="状态">
<Checkbox @bind-Value="@context.Enabled" Disabled=false>
启用
</Checkbox>
</FormItem>
</Form>
</Modal>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromForm]
MessageTemplateSearch search { get; set; } = new();
Form<MessageTemplateSearch> searchForm = null!;
[SupplyParameterFromForm]
MessageTemplateModel template { get; set; } = new();
Form<MessageTemplateModel> editForm = null!;
PagingList<MessageTemplate> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
bool modalVisible { get; set; } = false;
bool modalLoading { get; set; } = false;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Key = query.GetQueryString("Key");
}
private async void LoadList()
{
loading = true;
var url = "/api/messagetemplate/search";
var apiResult = await HttpService.GetPagingList<MessageTemplate>(url, search, Page.GetValueOrDefault(1) - 1);
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
void OnSearchReset()
{
search = new();
searchForm?.Reset();
OnSearchFinish();
}
void OnPageChanged(PaginationEventArgs args)
{
OnSearch(args.Page);
}
private void OnReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/setting/messagetemplate/list?page={page}");
}
else
{
Navigation.NavigateTo($"/setting/messagetemplate/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/setting/messagetemplate/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/setting/messagetemplate/list?{queryString}");
}
}
LoadList();
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"api/messagetemplate/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
void OnCreateClick()
{
template = new();
modalVisible = true;
}
void HandleEdit(MessageTemplate model)
{
template = model.Adapt<MessageTemplateModel>();
modalVisible = true;
}
void HandleModalOk()
{
editForm.Submit();
}
async Task OnFormFinish()
{
if (editForm.Validate())
{
var result = new ApiResult<string>();
var data = template.Adapt<MessageTemplate>();
if (template.Id > 0)
{
var url = $"api/messagetemplate/edit";
result = await HttpService.Post<ApiResult<string>>(url, data);
}
else
{
var url = $"api/messagetemplate/add";
result = await HttpService.Post<ApiResult<string>>(url, data);
}
if (result.Code == (int)ResultCode.Success)
{
modalVisible = false;
LoadList();
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
void HandleCancel()
{
modalVisible = false;
}
}

View File

@@ -0,0 +1,7 @@
@page "/settings"
@* @attribute [Authorize] *@
@inject ILogger<Settings> Logger
@code {
}

View File

@@ -0,0 +1,10 @@
@page "/system/app/version/list"
@inject ILogger<AppVersionList> Logger
@inject HttpService HttpService
@* @attribute [Authorize] *@
@code {
}

View File

@@ -0,0 +1,7 @@
@page "/system/app/list"
@inject ILogger<SiteAppList> Logger
@* @attribute [Authorize] *@
@code {
}

View File

@@ -0,0 +1,291 @@
@page "/system/file/list"
<PageTitle>上传文件</PageTitle>
<Title Level="4">上传文件</Title>
<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>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
文件列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">上传新文件</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c => c.Name" Title="文件">
</PropertyColumn>
<PropertyColumn Property="c => c.ContentType" Title="类型" Width="80px" Align="ColumnAlign.Center">
</PropertyColumn>
<PropertyColumn Property="c => c.Size" Title="文件大小" Width="100px" />
<PropertyColumn Property="c => c.Type" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Type == 1)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.CreateTime" Title="最后登录" Width="190px" />
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="190px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
<SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
<Overlay>
<Menu>
<MenuItem>
<a @onclick="(e) => OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
</MenuItem>
<MenuDivider />
<MenuItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a> <Icon Type="@IconType.Outline.Delete" /> 删除</a>
</Popconfirm>
</MenuItem>
</Menu>
</Overlay>
<ChildContent>
<a class="ant-dropdown-link" @onclick:preventDefault>
<Icon Type="@IconType.Outline.Menu" />
</a>
</ChildContent>
</Dropdown>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增帐号" : "编辑帐号")' OnClose="_ => CloseDrawer()">
<Form LabelColSpan="5" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="帐号名称">
<Input @bind-Value="model.Name" For="(()=>model.Name)" Placeholder="帐号名称" />
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
UploadFileSearch search { get; set; } = new();
Form<UploadFileSearch> searchForm = null!;
[SupplyParameterFromForm]
UploadFileModel model { get; set; } = new();
Form<UploadFileModel> editform = null!;
PagingList<UploadFile> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Name = query.GetQueryString("Name");
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();
}
}
}
private async void LoadList()
{
loading = true;
var url = "/api/uploadfile/search";
var apiResult = await HttpService.GetPagingList<UploadFile>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
private void OnReset()
{
search = new();
LoadList();
}
void OnSearchReset()
{
search = new();
searchForm?.Reset();
OnSearchFinish();
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/system/upload/list?page={page}");
}
else
{
Navigation.NavigateTo($"/system/upload/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/system/upload/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/system/upload/list?{queryString}");
}
}
}
void OnCreateClick()
{
model = new();
drawerVisible = true;
}
void OnEditClick(UploadFile file)
{
this.model = file.Adapt<UploadFileModel>();
drawerVisible = true;
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/uploadfile/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/uploadfile/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/uploadfile/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private void OnPageChanged(int args)
{
OnSearch(args);
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
}

View File

@@ -0,0 +1,347 @@
@page "/admin/list"
@inject ILogger<AdminList> Logger
@* @attribute [Authorize] *@
<PageTitle>管理员账号管理</PageTitle>
<Title Level="4">管理员帐号</Title>
<Card Class="">
<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.Username" Placeholder="帐号" AllowClear />
</FormItem>
</Col>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<br />
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
帐号列表
<div>
<AuthorizeView Policy="@Permissions.Admin.Edit">
<Authorized>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</Authorized>
<NotAuthorized>
没有权限
</NotAuthorized>
</AuthorizeView>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c => c.Username" Title="帐号">
</PropertyColumn>
<PropertyColumn Property="c => c.Email" Title="邮件" Width="80px" Align="ColumnAlign.Center">
</PropertyColumn>
<PropertyColumn Property="c => c.Mobile" Title="手机号" Width="100px" />
<PropertyColumn Property="c => c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.LastLogin" Title="最后登录" Width="190px" />
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="190px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
<SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
<Overlay>
<Menu>
<MenuItem>
<a @onclick="(e) => OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
</MenuItem>
<MenuDivider />
<MenuItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a> <Icon Type="@IconType.Outline.Delete" /> 删除</a>
</Popconfirm>
</MenuItem>
</Menu>
</Overlay>
<ChildContent>
<a class="ant-dropdown-link" @onclick:preventDefault>
<Icon Type="@IconType.Outline.Menu" />
</a>
</ChildContent>
</Dropdown>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增帐号" : "编辑帐号")' OnClose="_ => CloseDrawer()">
<Form LabelColSpan="5" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="帐号名称">
<Input @bind-Value="model.Username" For="(()=>model.Username)" Placeholder="帐号名称" />
</FormItem>
<FormItem Label="电子邮件">
<Input @bind-Value="model.Email" For="(()=>model.Email)" Placeholder="电子邮件" />
</FormItem>
<FormItem Label="手机号码">
<Input @bind-Value="model.Mobile" For="(()=>model.Mobile)" Placeholder="手机号码" />
</FormItem>
@if (context.Id > 0)
{
<FormItem Label="密码设置">
<Checkbox @bind-Value="@context.SetPassword" Disabled=false>
重置密码
</Checkbox>
</FormItem>
}
@if (context.Id == 0)
{
<FormItem Label="登录密码">
<Input @bind-Value="@context.Password" Placeholder="登录密码" />
</FormItem>
}
@if ((context.Id > 0 && context.SetPassword) || context.Id == 0)
{
<FormItem Label="新密码">
<Input @bind-Value="@context.NewPassword" Placeholder="新登录密码" />
</FormItem>
}
@if ((context.Id > 0 && context.SetPassword) || context.Id == 0)
{
<FormItem Label="确认密码">
<Input @bind-Value="@context.RePassword" Placeholder="确认密码" />
</FormItem>
}
<FormItem Label="可用状态">
<RadioGroup @bind-Value="@context.Status">
<Radio RadioButton Value=0>禁用</Radio>
<Radio RadioButton Value=1>启用</Radio>
</RadioGroup>
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
AdminSearch search { get; set; } = new();
Form<AdminSearch> searchForm = null!;
[SupplyParameterFromForm]
AdminModel model { get; set; } = new();
Form<AdminModel> editform = null!;
PagingList<Admin> PagingList = new();
bool loading { get; set; } = true;
bool searchExpand { get; set; } = false;
bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Username = query.GetQueryString("Username");
search.Mobile = query.GetQueryString("Mobile");
search.Email = query.GetQueryString("Email");
search.RealName = query.GetQueryString("RealName");
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();
}
}
}
private async void LoadList()
{
loading = true;
var url = "/api/admin/search";
var apiResult = await HttpService.GetPagingList<Admin>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
private void OnReset()
{
search = new();
LoadList();
}
void OnSearchReset()
{
search = new();
searchForm?.Reset();
OnSearchFinish();
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/admin/list?page={page}");
}
else
{
Navigation.NavigateTo($"/admin/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/admin/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/admin/list?{queryString}");
}
}
}
void OnCreateClick()
{
model = new();
drawerVisible = true;
}
void OnEditClick(Admin admin)
{
this.model = admin.Adapt<AdminModel>();
this.model.Password = string.Empty;
drawerVisible = true;
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/admin/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/admin/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/admin/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private void OnPageChanged(int args)
{
OnSearch(args);
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
}

View File

@@ -0,0 +1,7 @@
@page "/system/currency/list"
<h3>CurrencyList</h3>
@code {
}

View File

@@ -0,0 +1,238 @@
@page "/system/language/list"
@inject ILogger<LanguageList> Logger
<PageTitle>语言管理</PageTitle>
<Title Level="4">多语言</Title>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
多语言列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c => c.Name" Title="帐号">
</PropertyColumn>
<PropertyColumn Property="c => c.Title" Title="邮件" Width="80px" Align="ColumnAlign.Center">
</PropertyColumn>
<PropertyColumn Property="c => c.Culture" Title="手机号" Width="100px" />
<PropertyColumn Property="c => c.Enabled" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Enabled)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.ResourceVersion" Title="最后登录" Width="190px" />
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="190px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
<SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
<Overlay>
<Menu>
<MenuItem>
<a @onclick="(e) => OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
</MenuItem>
<MenuDivider />
<MenuItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a> <Icon Type="@IconType.Outline.Delete" /> 删除</a>
</Popconfirm>
</MenuItem>
</Menu>
</Overlay>
<ChildContent>
<a class="ant-dropdown-link" @onclick:preventDefault>
<Icon Type="@IconType.Outline.Menu" />
</a>
</ChildContent>
</Dropdown>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增帐号" : "编辑帐号")' OnClose="_ => CloseDrawer()">
<Form LabelColSpan="5" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="语言名称">
<Input @bind-Value="model.Name" For="(()=>model.Name)" Placeholder="语言名称" />
</FormItem>
<FormItem Label="语言标题">
<Input @bind-Value="model.Culture" For="(()=>model.Culture)" Placeholder="语言标题" />
</FormItem>
<FormItem Label="手机号码">
<Input @bind-Value="model.FlagImage" For="(()=>model.FlagImage)" Placeholder="手机号码" />
</FormItem>
@* <FormItem Label="可用状态">
<Checkbox T="bool" Label="启用" @bind-value="model.Enabled" Size="InputSize.Small" Class="ps-0" />
</FormItem> *@
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
LanguageSearch search { get; set; } = new();
[SupplyParameterFromForm]
LanguageModel model { get; set; } = new();
Form<LanguageModel> editform = null!;
PagingList<Language> PagingList = new();
bool loading { get; set; } = true;
bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
LoadList();
base.OnParametersSet();
}
private async void LoadList()
{
loading = true;
var url = "/api/language/search";
var apiResult = await HttpService.GetPagingList<Language>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/system/language/list?page={page}");
}
else
{
Navigation.NavigateTo($"/system/language/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/system/language/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/system/language/list?{queryString}");
}
}
}
void OnCreateClick()
{
model = new();
drawerVisible = true;
}
void OnEditClick(Language admin)
{
this.model = admin.Adapt<LanguageModel>();
drawerVisible = true;
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/language/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/language/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/language/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private void OnPageChanged(int args)
{
OnSearch(args);
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
}

View File

@@ -0,0 +1,6 @@
@page "/system/locale/resource/list/{culture}"
@inject ILogger<LocaleResourceList> Logger
@code {
}

View File

@@ -0,0 +1,350 @@
@page "/system/menu/list"
@inject ILogger<MenuList> Logger
@using MenuItem = Atomx.Admin.Client.Models.MenuItem
@using Menu = Atomx.Common.Entities.Menu
@* @attribute [Authorize] *@
<PageTitle>菜单管理</PageTitle>
<Title Level="4">菜单管理</Title>
<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>
<Col>
<div class="ant-form-item" style="width:200px;display:flex;">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Class="mt-3">
<Table DataSource="Menus" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
菜单列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c=>c.Name" Title="名称">
<AntDesign.Text>@GetName(context)</AntDesign.Text>
</PropertyColumn>
<PropertyColumn Property="c=>c.Icon" Title="图标" Width="60px" Align="ColumnAlign.Center">
@if (!string.IsNullOrEmpty(context.Icon)) {
<Icon Type="@context.Icon" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.Key" Title="分组标识" Ellipsis/>
<PropertyColumn Property="c=>c.Url" Title="链接" />
<PropertyColumn Property="c=>c.DisplayOrder" Title="排序" Width="80px" Align="ColumnAlign.Center" />
<PropertyColumn Property="c=>c.Enabled" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Enabled)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c=>c.CreateTime" Title="时间" Width="150px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="120px">
<Space>
<SpaceItem>
<a @onclick="(e)=>OnEditClick(context)">编辑</a>
</SpaceItem>
<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a>删除</a>
</Popconfirm>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='("设置菜单")' OnClose="_=>CloseDrawer()">
<Form LabelColSpan="4" @ref="@editform" Model="@menu" Class="px-5" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="名称">
<Input @bind-Value="menu.Name" For="(()=>menu.Name)" />
</FormItem>
<FormItem Label="分组标识">
<Input @bind-Value="menu.Key" For="(()=>menu.Key)" />
</FormItem>
<FormItem Label="链接">
<Input @bind-Value="menu.Url" For="(()=>menu.Url)" />
</FormItem>
<FormItem Label="上级分类">
<Select @bind-Value="@menu.ParentId" TItemValue="long" TItem="string" Placeholder="请选择上级分类">
<SelectOptions>
<SelectOption Value="0L" Label="无" />
@foreach(var item in Menus)
{
<SelectOption Value="@item.Id" Label="@GetName(item)" />
}
</SelectOptions>
</Select>
</FormItem>
@if (menu.ParentId == 0)
{
<FormItem Label="图标">
<Select ItemValue="c=>c"
ItemLabel="c=>c"
DataSource="IconsExtension.IconList()"
@bind-Value="@menu.Icon">
<ItemTemplate Context="Icon">
<p class="mt-2"><Icon Type="@Icon" /> @Icon</p>
</ItemTemplate>
<LabelTemplate Context="Icon">
<p class="mt-1"><Icon Type="@Icon" /> @Icon</p>
</LabelTemplate>
</Select>
</FormItem>
}
<FormItem Label="显示排序">
<Input @bind-Value="menu.DisplayOrder" For="(()=>menu.DisplayOrder)" />
</FormItem>
<FormItem Label="状态">
<Checkbox T="bool" Label="启用" @bind-value="menu.Enabled" Size="InputSize.Small" Class="ps-0" />
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Class="mt-5" Style="width: 100%;">保存</Button>
</FormItem>
</Form >
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromForm]
MenuSearch search { get; set; } = new();
Form<MenuSearch> searchForm = null!;
[SupplyParameterFromForm]
MenuModel menu { get; set; } = new();
Form<MenuModel> editform = null!;
List<MenuItem> Menus = new();
private bool drawerVisible;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
loadQueryString();
LoadList();
base.OnParametersSet();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Name = query.GetQueryString("Name");
}
private async void LoadList()
{
var url = "/api/menu/list";
var apiResult = await HttpService.Get<ApiResult<List<MenuItem>>>(url);
if (apiResult.Success)
{
if (apiResult.Data != null)
{
Menus = apiResult.Data;
StateHasChanged();
}
}
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
void OnSearchReset()
{
search = new();
searchForm?.Reset();
OnSearchFinish();
}
private void OnReset()
{
search = new();
LoadList();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/system/menu/list?page={page}");
}
else
{
Navigation.NavigateTo($"/system/menu/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/system/menu/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/system/menu/list?{queryString}");
}
}
LoadList();
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/menu/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
ModalService.Info(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
ModalService.Error(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
void OnCreateClick()
{
menu = new();
drawerVisible = true;
}
void OnEditClick(Common.Entities.Menu model)
{
menu = model.Adapt<MenuModel>();
drawerVisible = true;
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
var data = menu.Adapt<Menu>();
if (menu.Id > 0)
{
var url = $"api/menu/edit";
result = await HttpService.Post<ApiResult<string>>(url, data);
}
else
{
var url = $"api/menu/add";
result = await HttpService.Post<ApiResult<string>>(url, data);
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title="提示", Content="数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private string GetPath(string path)
{
var array = path.Split(",").ToList();
var pathText = string.Empty;
foreach (var item in array)
{
var name = Menus.Where(p => p.Id == item.ToLong()).Select(p => p.Name).SingleOrDefault();
if (string.IsNullOrEmpty(pathText))
{
pathText = name;
}
else
{
pathText = $"{pathText}>{name}";
}
}
return pathText ?? string.Empty;
}
private string GetName(MenuItem menu)
{
string name = string.Empty;
if (menu.Depth > 0)
{
var symbol = " ";
for (var i = 0; i < menu.Depth; i++)
{
symbol = $"{symbol}├ ";
}
name = $"{symbol}{menu.Name}";
}
else
{
name = menu.Name;
}
return name;
}
private void OpenDrawer()
{
drawerVisible = true;
}
private void CloseDrawer()
{
menu = new();
drawerVisible = false;
}
}

View File

@@ -0,0 +1,186 @@
@page "/system/role/permission/{RoleId:long}"
@inject ILogger<RoleList> Logger
<PageTitle>权限设置</PageTitle>
<Spin Spinning="loading">
<Title Level="4">编辑角色权限</Title>
<Card>
<Form @ref="editForm" Model="model" LabelColSpan="2" WrapperColSpan="22" Class="search-form" OnFinish="OnFormFinishAsync">
<FormItem Label="角色">
为角色 <Text>@role?.Name</Text> 设置权限
</FormItem>
<FormItem Label="权限">
<div class="ant-form-item-control-input-content">
@if (!PermissionGroups.Any())
{
<div>
<p>暂无权限可设置</p>
</div>
}
else
{
@foreach (var group in PermissionGroups)
{
<GridRow Style="padding-top:10px;">
<GridCol Span="24">
<label class="ant-checkbox-wrapper">
<span class="ant-checkbox @((@group.PermissionItems.Count(p => p.IsSelected) > 0 && @group.PermissionItems.Count(p => p.IsSelected) < @group.PermissionItems.Count) ? "ant-checkbox-indeterminate" : "")">
<input class="ant-checkbox-input" type="checkbox"
@onchange="(e) => ToggleAllPermissions(group, (bool)e.Value!)"
checked="@group.PermissionItems.All(p => p.IsSelected)" />
<span class="ant-checkbox-inner"></span>
</span>
<span>
<span class="form-check-label fw-bold">
@group.CategoryName
</span>
<small class="text-muted ms-2">
(@group.PermissionItems.Count(p => p.IsSelected)/@group.PermissionItems.Count)
</small>
</span>
</label>
</GridCol>
</GridRow>
<GridRow Style="margin-left:20px;margin-right:20px;">
@foreach (var permission in group.PermissionItems)
{
<GridCol Span="6">
<label class="ant-checkbox-wrapper">
<span class="ant-checkbox">
<input class="ant-checkbox-input" type="checkbox"
@bind="permission.IsSelected"
id="perm_@permission.Name" />
<span class="ant-checkbox-inner"></span>
</span>
<span class="form-check-label" for="perm_@permission.Name">
@permission.Description
<small class="text-muted d-block">@permission.Name</small>
</span>
</label>
</GridCol>
}
</GridRow>
}
}
</div>
</FormItem>
<FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 2 }">
<Button Type="@ButtonType.Primary" HtmlType="submit" Loading="@isSaving">
@if (isSaving)
{
<span>保存中...</span>
}
else
{
<span>保存权限设置</span>
}
</Button>
</FormItem>
</Form>
</Card>
</Spin>
@code {
[Parameter]
public long RoleId { get; set; }
bool loading = false;
bool isSaving = false;
Role role;
List<RolePermissionGroup> PermissionGroups = new List<RolePermissionGroup>();
[SupplyParameterFromForm]
RoleModel model { get; set; } = new();
Form<RoleModel> editForm = null!;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override async Task OnParametersSetAsync()
{
loading = true;
await LoadRoleAndPermission();
loading = false;
base.OnParametersSet();
}
async Task LoadRoleAndPermission()
{
var roleResult = await HttpService.Get<ApiResult<Role>>($"/api/role/{RoleId}");
if (roleResult.Success)
{
if (roleResult.Data != null)
{
role = roleResult.Data;
StateHasChanged();
}
}
var apiResult = await HttpService.Get<ApiResult<List<RolePermissionGroup>>>($"/api/role/permission/{RoleId}");
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PermissionGroups = apiResult.Data;
StateHasChanged();
}
}
}
private void ToggleAllPermissions(RolePermissionGroup group, bool isSelected)
{
foreach (var permission in group.PermissionItems)
{
permission.IsSelected = isSelected;
}
StateHasChanged();
}
async void OnFormFinishAsync()
{
isSaving = true;
StateHasChanged();
try
{
var selectedPermissions = PermissionGroups!
.SelectMany(g => g.PermissionItems)
.Where(p => p.IsSelected)
.Select(p => p.Name)
.ToList();
model = role.Adapt<RoleModel>();
model.Permission = string.Join(",", selectedPermissions);
var url = $"api/role/edit";
var result = await HttpService.Post<ApiResult<string>>(url, model);
if (result.Success)
{
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "权限设置保存成功!" });
}
else
{
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "服务异常!" });
}
Navigation.NavigateTo("/system/role/list");
}
catch (Exception ex)
{
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "保存权限设置失败!" });
}
finally
{
isSaving = false;
StateHasChanged();
}
}
}

View File

@@ -0,0 +1,259 @@
@page "/system/role/list"
@inject ILogger<RoleList> Logger
<PageTitle>角色管理</PageTitle>
<Title Level="4">角色管理</Title>
<Card Class="mt-3">
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
角色列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c => c.Name" Title="角色">
</PropertyColumn>
<PropertyColumn Property="c => c.Description" Title="说明" />
<PropertyColumn Property="c => c.IsSystemRole" Title="系统" Width="80px" Align="ColumnAlign.Center">
@if (context.IsSystemRole)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<AntDesign.Text Type="TextElementType.Secondary"><Icon Type="minus" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
</PropertyColumn>
<PropertyColumn Property="c => c.Count" Title="用户数" Width="100px" />
<PropertyColumn Property="c => c.Enabled" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Enabled)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme=" IconThemeType.Outline" Width="1.3em" Height="1.3em" /></AntDesign.Text>
}
else
{
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="190px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
<SpaceItem>
<Button Type="ButtonType.Link" OnClick="() => OnEditPermissionClick(context)">权限管理</Button>
</SpaceItem>
<SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
<Overlay>
<Menu>
<MenuItem>
<a @onclick="(e) => OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
</MenuItem>
@if (!context.IsSystemRole)
{
<MenuDivider />
<MenuItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a> <Icon Type="@IconType.Outline.Delete" /> 删除</a>
</Popconfirm>
</MenuItem>
}
</Menu>
</Overlay>
<ChildContent>
<a class="ant-dropdown-link" @onclick:preventDefault>
<Icon Type="@IconType.Outline.Menu" />
</a>
</ChildContent>
</Dropdown>
</SpaceItem>
</Space>
</ActionColumn>
</ColumnDefinitions>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增角色" : "编辑角色")' OnClose="_ => CloseDrawer()">
<Form LabelColSpan="5" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="角色名称">
<Input @bind-Value="model.Name" For="(()=>model.Name)" Placeholder="角色名称" />
</FormItem>
<FormItem Label="角色说明">
<Input @bind-Value="model.Description" For="(()=>model.Culture)" Placeholder="角色说明" />
</FormItem>
<FormItem Label="可用状态">
<Checkbox T="bool" Label="启用" @bind-value="model.Enabled" Size="InputSize.Small" Class="ps-0" />
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
</Form>
</Drawer>
@code {
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
[SupplyParameterFromForm]
RoleSearch search { get; set; } = default!;
[SupplyParameterFromForm]
RoleModel model { get; set; } = default!;
Form<RoleModel> editform = null!;
PagingList<Role> PagingList = new();
bool loading { get; set; } = true;
bool drawerVisible;
bool isSave = false;
protected override void OnInitialized()
{
search ??= new RoleSearch();
model ??= new RoleModel();
base.OnInitialized();
}
protected override async Task OnParametersSetAsync()
{
await LoadList();
}
private async Task LoadList()
{
loading = true;
var url = "/api/role/search";
var apiResult = await HttpService.GetPagingList<Role>(url, search ?? new RoleSearch(), Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
loading = false;
StateHasChanged();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/system/role/list?page={page}");
}
else
{
Navigation.NavigateTo($"/system/role/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/system/role/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/system/role/list?{queryString}");
}
}
}
void OnCreateClick()
{
model = new();
drawerVisible = true;
}
void OnEditPermissionClick(Role role)
{
Navigation.NavigateTo($"/system/role/permission/{role.Id}");
}
void OnEditClick(Role role)
{
model = role.Adapt<RoleModel>();
drawerVisible = true;
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/role/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
await LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
}
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var apiResult = new ApiResult<string>();
if (model != null)
{
if (model.Id > 0)
{
var url = $"api/role/edit";
apiResult = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/role/add";
apiResult = await HttpService.Post<ApiResult<string>>(url, model);
}
if (apiResult.Success)
{
ModalService.Success(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
CloseDrawer();
await LoadList();
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = apiResult.Message });
}
}
}
StateHasChanged();
}
private void OnPageChanged(PaginationEventArgs args)
{
OnSearch(args.Page);
}
void CloseDrawer()
{
drawerVisible = false;
editform.Reset();
}
}

View File

@@ -0,0 +1,5 @@
<h3>UserList</h3>
@code {
}

View File

@@ -0,0 +1,63 @@
@page "/weather"
<PageTitle>Weather</PageTitle>
<h1>Weather</h1>
<p>This component demonstrates showing data.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th aria-label="Temperature in Celsius">Temp. (C)</th>
<th aria-label="Temperature in Farenheit">Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
// Simulate asynchronous loading to demonstrate a loading indicator
await Task.Delay(500);
var startDate = DateOnly.FromDateTime(DateTime.Now);
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = summaries[Random.Shared.Next(summaries.Length)]
}).ToArray();
}
private class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}