Files
ThingsGateway/framework/ThingsGateway.Admin.Blazor/Page/User.razor

138 lines
5.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@*
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
*@
@page "/admin/user"
@namespace ThingsGateway.Admin.Blazor
@using Masa.Blazor.Presets;
@using Microsoft.AspNetCore.Authorization;
@using ThingsGateway.Admin.Application;
@attribute [Authorize]
@inherits BaseComponentBase
@layout MainLayout
@inject UserResoures UserResoures
<AppDataTable @ref="_datatable" TItem="SysUser" SearchItem="UserPageInput"
AddItem="UserAddInput" EditItem="UserEditInput" SearchModel="@search"
QueryCallAsync="QueryCallAsync" AddCallAsync="AddCallAsync" EditCallAsync="EditCallAsync" DeleteCallAsync="DeleteCallAsync"
IsShowQueryButton IsShowDetailButton IsShowSearchKey
IsShowAddButton=@UserResoures.IsHasButtonWithRole("sysuseradd")
IsShowDeleteButton=@UserResoures.IsHasButtonWithRole("sysuserdelete")
IsShowEditButton=@UserResoures.IsHasButtonWithRole("sysuseredit")>
<AddTemplate>
@GetRenderFragment(context)
</AddTemplate>
<EditTemplate>
@GetRenderFragment(context)
</EditTemplate>
<ItemColOperTemplate>
<MList Dense>
@if (UserResoures.IsHasButtonWithRole("sysuserresetpassword"))
{
<MListItem OnClick="async()=>await ResetPasswordAsync(context.Item)">
<MListItemTitle Class="ml-2">重置密码</MListItemTitle>
</MListItem>
}
@if (@UserResoures.IsHasButtonWithRole("sysuserperrole"))
{
<MListItem OnClick="async()=>
{
ChoiceUserId=context.Item.Id;
await RoleInitAsync();
IsShowRoles=true;
}">
<MListItemTitle Class="ml-2">角色授权</MListItemTitle>
</MListItem>
}
</MList>
</ItemColOperTemplate>
<ItemColTemplate>
@switch (context.Header.Value)
{
case nameof(context.Item.UserEnable):
<MSimpleCheckbox ValueChanged=@((a)=> UserStatusChangeAsync(context.Item,a))
Value="context.Item.UserEnable">
</MSimpleCheckbox>
break;
default:
@if (context.Header.CellClass?.Contains("text-truncate") == true)
{
<span title=@context.Value>
@context.Value
</span>
}
else
{
@context.Value
}
break;
}
</ItemColTemplate>
</AppDataTable>
<PDrawer @bind-Value="IsShowRoles" OnCancel="() => IsShowRoles = false"
Title=角色授权
Width=@(IsMobile?"100%":"500")
MaxWidth="500" OnSave="OnRolesSaveAsync">
@if (IsShowRoles)
{
<MCard Flat Class="ma-0 pa-4">
<MCardTitle Class="py-2">
<MTextField Clearable Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 ml-3" @bind-Value="SearchName"
Outlined Label=@typeof(SysRole).GetDescription(nameof(SysRole.Name)) />
</MCardTitle>
<MTreeview Class="my-1" Dense OpenAll TItem="SysRole" TKey="SysRole" Selectable
@bind-Value="RolesChoice" Search="@SearchName" ItemKey=@(r=>r)
Items="AllRoles" ItemText="r=>r.Name" ItemChildren="r=>null">
<LabelContent>
<span title=@context.Item.Name>
@context.Item.Name
</span>
</LabelContent>
</MTreeview>
</MCard>
}
</PDrawer>
@code {
RenderFragment GetRenderFragment(UserAddInput context)
{
RenderFragment renderFragment =
@<div>
<MSubheader Class="mt-4 font-weight-black"> @(context.Description(x => x.Account)) </MSubheader>
<MTextField Disabled=@(context.Account == RoleConst.SuperAdmin) Dense Outlined HideDetails="@("auto")" @bind-Value=@context.Account />
<MSubheader Class="mt-4 font-weight-black"> @(context.Description(x => x.Phone))</MSubheader>
<MTextField Dense Outlined HideDetails="@("auto")" @bind-Value=@context.Phone />
<MSubheader Class="mt-4 font-weight-black"> @(context.Description(x => x.Email)) </MSubheader>
<MTextField Dense Outlined HideDetails="@("auto")" @bind-Value=@context.Email />
<MSubheader Class="mt-4 mb-5 font-weight-black">@(context.Description(x => x.SortCode)) </MSubheader>
<MSlider @bind-Value=@context.SortCode Class="mb-5" TValue=int ThumbLabel="@("always")" Dense />
</div>
;
return renderFragment;
}
}