feat: 格式化用户显示名称

This commit is contained in:
Argo Zhang 2020-02-06 13:33:16 +08:00
parent 36d71bfb89
commit e510054076
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
2 changed files with 11 additions and 1 deletions

View File

@ -40,7 +40,7 @@
<AssignModal @ref="AssignUserModal" TItem="Bootstrap.DataAccess.User" Id="role-user" Title="用户授权窗口" OnSave="SaveUsers">
<ItemTemplate>
<Checkbox TItem="Bootstrap.DataAccess.User" Item="@context" Text="@context.DisplayName" SetCheckCallback="SetUserCheck" OnClick="OnUserClick" />
<Checkbox TItem="Bootstrap.DataAccess.User" Item="@context" Text="@FormatDisplayName(context)" SetCheckCallback="SetUserCheck" OnClick="OnUserClick" />
</ItemTemplate>
</AssignModal>

View File

@ -60,6 +60,16 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
/// </summary>
protected AssignModalBase<User>? AssignUserModal { get; set; }
/// <summary>
/// 获得/设置 Modal 实例
/// </summary>
protected string FormatDisplayName(User item)
{
var displayName = item.DisplayName;
if (string.IsNullOrEmpty(displayName)) displayName = item.UserName;
return displayName;
}
/// <summary>
/// 弹窗分配角色方法
/// </summary>