From eaf36fec5e4b178f9ee2532689949cd88cd8c761 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Wed, 15 Dec 2021 14:59:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E9=85=8D=E6=8E=88=E6=9D=83=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapAdmin.DataAccess.Models/User.cs | 15 +++-- .../Components/BlazorTable.razor | 9 ++- .../Components/BlazorTable.razor.cs | 19 ++----- .../Components/UserGroup.razor | 5 ++ .../Components/UserGroup.razor.cs | 16 ++++++ .../Components/UserRole.razor | 5 ++ .../Components/UserRole.razor.cs | 16 ++++++ .../Pages/Admin/Users.razor | 22 ++++--- .../Pages/Admin/Users.razor.cs | 57 +++++++------------ 9 files changed, 95 insertions(+), 69 deletions(-) create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor.cs create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor.cs diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.Models/User.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/User.cs index 102c94f1..8f44b001 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.Models/User.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/User.cs @@ -1,4 +1,6 @@ using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Xml.Linq; namespace BootstrapAdmin.DataAccess.Models { @@ -10,6 +12,7 @@ namespace BootstrapAdmin.DataAccess.Models /// /// 获得/设置 系统登录用户名 /// + [Display(Name = "登录名称")] public string UserName { get; set; } = ""; /// @@ -40,7 +43,7 @@ namespace BootstrapAdmin.DataAccess.Models /// /// 获取/设置 密码 /// - [DisplayName("登录密码")] + [Display(Name = "登录密码")] public string Password { get; set; } = ""; /// @@ -56,25 +59,25 @@ namespace BootstrapAdmin.DataAccess.Models /// /// 获得/设置 用户注册时间 /// - [DisplayName("注册时间")] + [Display(Name = "注册时间")] public DateTime RegisterTime { get; set; } = DateTime.Now; /// /// 获得/设置 用户被批复时间 /// - [DisplayName("授权时间")] + [Display(Name = "授权时间")] public DateTime? ApprovedTime { get; set; } /// /// 获得/设置 用户批复人 /// - [DisplayName("授权人")] + [Display(Name = "授权人")] public string? ApprovedBy { get; set; } /// /// 获得/设置 用户的申请理由 /// - [DisplayName("说明")] + [Display(Name = "说明")] public string Description { get; set; } = ""; /// @@ -90,7 +93,7 @@ namespace BootstrapAdmin.DataAccess.Models /// /// 获得/设置 新密码 /// - [DisplayName("确认密码")] + [Display(Name = "确认密码")] public string NewPassword { get; set; } = ""; /// diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor b/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor index 344efa84..8b887e43 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor @@ -4,15 +4,18 @@ IsPagination="IsPagination" PageItemsSource="PageItemsSource" UseInjectDataService="true" DataService="DataService" OnQueryAsync="OnQueryAsync!" ShowToolbar="true" ShowExtendButtons="true" ShowSearch="true" - ShowCardView="true" ShowColumnList="true" @bind-SelectedRows="SelectedRows" + ShowCardView="true" ShowColumnList="true" CustomerSearchModel="@TableSearchModel"> @TableToolbarTemplate - @ColumnsTemplete(context) + @ColumnsTemplete?.Invoke(context) - @CustomerSearchTemplate(context) + @CustomerSearchTemplate?.Invoke(context) + + @RowButtonTemplate?.Invoke(context) + diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor.cs index fd711a5c..531eb41c 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/BlazorTable.razor.cs @@ -22,7 +22,12 @@ /// /// /// - [NotNull] + [Parameter] + public RenderFragment? RowButtonTemplate { get; set; } + + /// + /// + /// [Parameter] public RenderFragment? CustomerSearchTemplate { get; set; } @@ -56,17 +61,5 @@ /// [Parameter] public Func>>? OnQueryAsync { get; set; } - - /// - /// - /// - [Parameter] - public List SelectedRows { get; set; } = new List(); - - /// - /// - /// - [Parameter] - public EventCallback> SelectedRowsChanged { get; set; } } } diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor b/src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor new file mode 100644 index 00000000..a421f10d --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor @@ -0,0 +1,5 @@ +

UserGroup

+ +@code { + +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor.cs new file mode 100644 index 00000000..8d45f8fc --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/UserGroup.razor.cs @@ -0,0 +1,16 @@ +namespace BootstrapAdmin.Web.Components +{ + /// + /// + /// + public partial class UserGroup + { + /// + /// + /// + [Parameter] + [NotNull] + [EditorRequired] + public string? UserName { get; set; } + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor b/src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor new file mode 100644 index 00000000..d758a089 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor @@ -0,0 +1,5 @@ +

UserRole

+ +@code { + +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor.cs new file mode 100644 index 00000000..bc162953 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/UserRole.razor.cs @@ -0,0 +1,16 @@ +namespace BootstrapAdmin.Web.Components +{ + /// + /// + /// + public partial class UserRole + { + /// + /// + /// + [Parameter] + [NotNull] + [EditorRequired] + public string? UserName { get; set; } + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor index d315631d..c9bfbb27 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor @@ -1,16 +1,20 @@ @page "/Admin/Users" - + - - + + - - - - - - + + + + + + + + + + diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor.cs index e8210100..00b8fdad 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Users.razor.cs @@ -1,4 +1,5 @@ using BootstrapAdmin.DataAccess.Models; +using BootstrapAdmin.Web.Components; namespace BootstrapAdmin.Web.Pages.Admin { @@ -11,52 +12,32 @@ namespace BootstrapAdmin.Web.Pages.Admin [NotNull] private DialogService? DialogService { get; set; } - [Inject] - [NotNull] - private ToastService? ToastService { get; set; } - - private List SelectedRows { get; set; } = new List(); - - private async Task OnAssignmentDept(IEnumerable users) + private async Task OnAssignmentDept(User user) { - if (users.Count() == 1) + var option = new DialogOption() { - //var option = new DialogOption() - //{ - // Title = "部门授权", - // BodyTemplate = BootstrapDynamicComponent.CreateComponent>(new Dictionary - // { - // [nameof(CheckboxList.Items)] = GroupHelper.Retrieves().Select(s => new SelectedItem(s.GroupCode, s.GroupName)) - // }).Render() - //}; + Title = $"分配部门 - {user.ToString()}", + Component = BootstrapDynamicComponent.CreateComponent(new Dictionary + { + [nameof(UserGroup.UserName)] = user.UserName + }) + }; - //await DialogService.Show(option); - } - else - { - await ToastService.Warning("部门授权", "请选择一个用户"); - } + await DialogService.Show(option); } - private async Task OnAssignmentRoles(IEnumerable users) + private async Task OnAssignmentRoles(User user) { - if (users.Count() != 0) + var option = new DialogOption() { - //var option = new DialogOption() - //{ - // Title = "分配角色", - // BodyTemplate = BootstrapDynamicComponent.CreateComponent>(new Dictionary - // { - // [nameof(CheckboxList.Items)] = RoleHelper.Retrieves().Select(s => new SelectedItem(s.Id!, s.RoleName) { Active = s.Checked == "" ? false : true }) - // }).Render() - //}; + Title = $"分配角色 - {user.ToString()}", + Component = BootstrapDynamicComponent.CreateComponent(new Dictionary + { + [nameof(UserGroup.UserName)] = user.UserName + }) + }; - //await DialogService.Show(option); - } - else - { - await ToastService.Warning("分配角色", "请选择一个用户"); - } + await DialogService.Show(option); } } }