feat: 添加用户明细详情

develop
zhangyousheng 2023-08-28 22:24:51 +08:00
parent 20158c37d6
commit 4d3b25c5e4
2 changed files with 46 additions and 7 deletions

View File

@ -41,10 +41,31 @@
Loading="_loading"
PageIndex="@_pageIndex"
PageSize="@_pageSize"
OnExpand="OnRowExpand"
OnPageIndexChange="OnPageIndexChanged"
OnPageSizeChange="OnPageSizeChange">
<PropertyColumn Property="c => c.Name" title="用户姓名"/>
<PropertyColumn Property="c => c.TotalPoint" title="总积分"/>
<ChildContent Context="data">
<PropertyColumn Property="c => c.Name" title="用户姓名"/>
<PropertyColumn Property="c => c.TotalPoint" title="总积分"/>
<ActionColumn Title="操作" Width="220">
<Button Type="Primary" OnClick="() => Add(data.UserId)">新增积分</Button>
</ActionColumn>
</ChildContent>
<ExpandTemplate Context="rowData">
<Table DataSource="rowData.Data.Items" Loading="rowData.Data.Items == null" HidePagination>
<ChildContent Context="data">
<PropertyColumn Property="c => c.Point" title="积分"/>
<PropertyColumn Property="c => c.CreateTime" title="新增时间" Format="yyyy-MM-dd HH:mm"/>
<ActionColumn Title="Action">
<Space Size="@("middle")">
<SpaceItem>
<Button Danger OnClick="() => Delete(data.UserPointId)">删除积分</Button>
</SpaceItem>
</Space>
</ActionColumn>
</ChildContent>
</Table>
</ExpandTemplate>
</Table>
</PageContainer>
@ -60,7 +81,7 @@
@ref="@_form">
<FormItem Label="姓名">
<Select TItem="UserDto"
TItemValue="int"
TItemValue="int?"
Mode="default"
DataSource="@_users"
@bind-Value="@context.UserId"
@ -85,10 +106,10 @@
public class Model
{
[Required]
public int UserId { get; set; }
public int? UserId { get; set; }
[Required]
public int Point { get; set; }
public int? Point { get; set; }
}
private Model model = new Model();
@ -115,6 +136,8 @@
private void HandleCancel(MouseEventArgs e)
{
model.UserId = null;
model.Point = null;
_visible = false;
}
@ -147,10 +170,16 @@
_form.Submit();
await UserPointService.CreateUserPoint(new CreateUserPointDto()
{
UserId = model.UserId,
Point = model.Point
UserId = model.UserId.Value,
Point = model.Point.Value
}).ConfigureAwait(false);
await RefreshTable().ConfigureAwait(false);
}
private async Task Add(int userId)
{
model.UserId = userId;
_visible = true;
}
}

View File

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AntDesign;
using AntDesign.TableModels;
using Microsoft.AspNetCore.Components;
using UserPointManagement.Application.Services;
using UserPointManagement.Model.Dtos.User;
@ -72,4 +74,12 @@ public class UserPointDetailBase : ComponentBase
await MessageService.Success("删除成功!");
await RefreshTable();
}
protected async Task OnRowExpand(RowData<UserPointInfoDto> rowData)
{
if (rowData.Data.Items != null)
{
return;
}
}
}