feat: 完善部门维护界面

This commit is contained in:
Argo-Lenovo 2021-12-20 00:12:45 +08:00
parent accc58a6b0
commit fcee12335e
5 changed files with 121 additions and 1 deletions

View File

@ -0,0 +1,37 @@
using System.ComponentModel.DataAnnotations;
namespace BootstrapAdmin.DataAccess.Models
{
/// <summary>
/// Group 实体类
/// </summary>
public class Group
{
/// <summary>
/// 获得/设置 主键 ID
/// </summary>
public string? Id { get; set; }
/// <summary>
/// 获得/设置 群组名称
/// </summary>
[Display(Name = "群组名称")]
[NotNull]
public string? GroupName { get; set; }
/// <summary>
/// 获得/设置 群组编码
/// </summary>
[Display(Name = "群组编码")]
[NotNull]
public string? GroupCode { get; set; }
/// <summary>
/// 获得/设置 群组描述
/// </summary>
[Display(Name = "群组描述")]
public string? Description { get; set; }
public override string ToString() => $"{GroupName}({GroupCode})";
}
}

View File

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

View File

@ -0,0 +1,13 @@
namespace BootstrapAdmin.Web.Components
{
public partial class GroupUser
{
/// <summary>
///
/// </summary>
[Parameter]
[NotNull]
[EditorRequired]
public string? GroupId { get; set; }
}
}

View File

@ -1 +1,17 @@
@page "/Admin/Groups"
<BlazorTable TItem="DataAccess.Models.Group" ExtendButtonColumnWidth="260">
<TableToolbarTemplate>
<TableToolbarButton TItem="DataAccess.Models.Group" IsEnableWhenSelectedOneRow="true" Color="Color.Warning" Icon="fa fa-user" Text="分配用户" OnClickCallback="groups => OnAssignmentUsers(groups.First())" />
<TableToolbarButton TItem="DataAccess.Models.Group" IsEnableWhenSelectedOneRow="true" Color="Color.Info" Icon="fa fa-sitemap" Text="分配角色" OnClickCallback="groups => OnAssignmentRoles(groups.First())" />
</TableToolbarTemplate>
<ColumnsTemplete>
<TableColumn @bind-Field="@context.GroupName" Sortable="true" Filterable="true" Searchable="true" Width="180"></TableColumn>
<TableColumn @bind-Field="@context.GroupCode" Sortable="true" Filterable="true" Searchable="true" Width="180"></TableColumn>
<TableColumn @bind-Field="@context.Description" Sortable="true" Filterable="true"></TableColumn>
</ColumnsTemplete>
<RowButtonTemplate>
<TableCellButton Size="Size.ExtraSmall" Color="Color.Warning" Icon="fa fa-user" Text="分配用户" OnClick="() => OnAssignmentUsers(context)" />
<TableCellButton Size="Size.ExtraSmall" Color="Color.Info" Icon="fa fa-sitemap" Text="分配角色" OnClick="() => OnAssignmentRoles(context)" />
</RowButtonTemplate>
</BlazorTable>

View File

@ -1,6 +1,55 @@
namespace BootstrapAdmin.Web.Pages.Admin
using BootstrapAdmin.DataAccess.Models;
using BootstrapAdmin.Web.Components;
namespace BootstrapAdmin.Web.Pages.Admin
{
public partial class Groups
{
[Inject]
[NotNull]
private DialogService? DialogService { get; set; }
private async Task OnAssignmentUsers(Group group)
{
var option = new DialogOption()
{
Title = $"分配用户 - {group}",
Component = BootstrapDynamicComponent.CreateComponent<GroupUser>(new Dictionary<string, object>
{
[nameof(GroupUser.GroupId)] = group.Id!
}),
ShowFooter = false
};
await DialogService.Show(option);
}
private async Task OnAssignmentRoles(Group group)
{
var option = new DialogOption()
{
Title = $"分配角色 - {group}"
};
var items = new List<SelectedItem>() { new SelectedItem("1", "角色1"), new SelectedItem("2", "角色2") };
option.Component = BootstrapDynamicComponent.CreateComponent<CheckboxList<IEnumerable<string>>>(new Dictionary<string, object>
{
[nameof(CheckboxList<IEnumerable<string>>.Value)] = new List<string>() { "1" },
[nameof(CheckboxList<IEnumerable<string>>.Items)] = items
});
option.FooterTemplate = builder =>
{
builder.OpenComponent<Button>(0);
builder.AddAttribute(1, nameof(Button.Color), Color.Primary);
builder.AddAttribute(2, nameof(Button.Text), "保存");
builder.AddAttribute(3, nameof(Button.Icon), "fa fa-save");
builder.AddAttribute(4, nameof(Button.OnClickWithoutRender), async () =>
{
var t = items;
await option.Dialog.Close();
});
builder.CloseComponent();
};
await DialogService.Show(option);
}
}
}