fix: 修复新增积分逻辑
							parent
							
								
									1c4cbc6d45
								
							
						
					
					
						commit
						3b890baa6c
					
				|  | @ -14,6 +14,6 @@ public class UserPoint | ||||||
|     { |     { | ||||||
|         UserId = userId; |         UserId = userId; | ||||||
|         Point = point; |         Point = point; | ||||||
|         CreateTime = DateTime.Now; |         CreateTime = DateTime.UtcNow; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -4,6 +4,9 @@ | ||||||
| @using System.Text.Json | @using System.Text.Json | ||||||
| @using global::UserPointManagement.Model.Dtos.User | @using global::UserPointManagement.Model.Dtos.User | ||||||
| @using global::UserPointManagement.Model.Dtos.UserPoint | @using global::UserPointManagement.Model.Dtos.UserPoint | ||||||
|  | @using UserPointManagement.Application.Services | ||||||
|  | @inject IUserPointService UserPointService; | ||||||
|  | 
 | ||||||
| <PageContainer Title="用户积分管理"> | <PageContainer Title="用户积分管理"> | ||||||
|     <GridRow Style="margin: 10px 0"> |     <GridRow Style="margin: 10px 0"> | ||||||
|         <GridCol Span="12"> |         <GridCol Span="12"> | ||||||
|  | @ -45,6 +48,36 @@ | ||||||
|     </Table> |     </Table> | ||||||
| </PageContainer> | </PageContainer> | ||||||
| 
 | 
 | ||||||
|  | <Modal Title="@("新增积分")" | ||||||
|  |        Visible="@_visible" | ||||||
|  |        OnOk="@HandleOk" | ||||||
|  |        OnCancel="@HandleCancel"> | ||||||
|  |     <Form Loading="loading" Model="@model" | ||||||
|  |           LabelColSpan="8" | ||||||
|  |           WrapperColSpan="16" | ||||||
|  |           OnFinish="OnFinish" | ||||||
|  |           OnFinishFailed="OnFinishFailed" | ||||||
|  |           @ref="@_form"> | ||||||
|  |         <FormItem Label="姓名"> | ||||||
|  |             <Select TItem="UserDto" | ||||||
|  |                     TItemValue="int" | ||||||
|  |                     Mode="default" | ||||||
|  |                     DataSource="@_users" | ||||||
|  |                     @bind-Value="@context.UserId" | ||||||
|  |                     LabelName="@nameof(UserDto.Name)" | ||||||
|  |                     ValueName="@nameof(UserDto.Id)" | ||||||
|  |                     Placeholder="请选择用户" | ||||||
|  |                     DefaultActiveFirstOption="false" | ||||||
|  |                     EnableSearch | ||||||
|  |                     AllowClear> | ||||||
|  |             </Select> | ||||||
|  |         </FormItem> | ||||||
|  |         <FormItem Label="积分"> | ||||||
|  |             <AntDesign.InputNumber @bind-Value="@context.Point"/> | ||||||
|  |         </FormItem> | ||||||
|  |     </Form> | ||||||
|  | </Modal> | ||||||
|  | 
 | ||||||
| @code { | @code { | ||||||
| 
 | 
 | ||||||
|     #region original form coding |     #region original form coding | ||||||
|  | @ -52,9 +85,10 @@ | ||||||
|     public class Model |     public class Model | ||||||
|     { |     { | ||||||
|         [Required] |         [Required] | ||||||
|         public string Name { get; set; } |         public int UserId { get; set; } | ||||||
| 
 | 
 | ||||||
|         public string Mobile { get; set; } |         [Required] | ||||||
|  |         public int Point { get; set; } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private Model model = new Model(); |     private Model model = new Model(); | ||||||
|  | @ -111,7 +145,11 @@ | ||||||
|     private async Task HandleOk(MouseEventArgs e) |     private async Task HandleOk(MouseEventArgs e) | ||||||
|     { |     { | ||||||
|         _form.Submit(); |         _form.Submit(); | ||||||
|     // TODO: 添加积分 |         await UserPointService.CreateUserPoint(new CreateUserPointDto() | ||||||
|  |         { | ||||||
|  |             UserId = model.UserId, | ||||||
|  |             Point = model.Point | ||||||
|  |         }).ConfigureAwait(false); | ||||||
|         await RefreshTable().ConfigureAwait(false); |         await RefreshTable().ConfigureAwait(false); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue