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

138 lines
5.3 KiB
Plaintext
Raw Normal View History

2023-05-23 23:54:28 +08:00
@*
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
2023-07-16 17:48:22 +08:00
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
2023-05-23 23:54:28 +08:00
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
2023-07-16 17:48:22 +08:00
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
2023-05-23 23:54:28 +08:00
// QQ群605534569
//------------------------------------------------------------------------------
*@
2023-08-07 15:09:53 +08:00
@page "/admin/openapiuser"
2023-03-04 18:41:11 +08:00
@using System.Linq.Expressions;
2023-08-07 15:09:53 +08:00
@using Microsoft.AspNetCore.Authorization;
@using ThingsGateway.Admin.Application;
@using Masa.Blazor.Presets;
2023-08-07 15:09:53 +08:00
@namespace ThingsGateway.Admin.Blazor
2023-03-04 18:41:11 +08:00
@attribute [Authorize]
@inject UserResoures UserResoures
2023-08-07 15:09:53 +08:00
@inherits BaseComponentBase
2023-03-04 18:41:11 +08:00
@layout MainLayout
<AppDataTable @ref="_datatable" TItem="OpenApiUser" SearchItem="OpenApiUserPageInput" AddItem="OpenApiUserAddInput" EditItem="OpenApiUserEditInput"
2023-05-22 18:40:50 +08:00
SearchModel="@search" Dense
2023-08-07 15:09:53 +08:00
QueryCallAsync="QueryCallAsync" AddCallAsync="AddCallAsync"
DeleteCallAsync="DeleteCallAsync" EditCallAsync="EditCallAsync"
IsShowQueryButton IsShowSearchKey IsShowDetailButton
IsShowAddButton=@UserResoures.IsHasButtonWithRole("openapiuseradd")
IsShowDeleteButton=@UserResoures.IsHasButtonWithRole("openapiuserdelete")
IsShowEditButton=@UserResoures.IsHasButtonWithRole("openapiuseredit")>
2023-03-04 18:41:11 +08:00
<AddTemplate>
2023-08-07 15:09:53 +08:00
@GetRenderFragment(context)
2023-03-04 18:41:11 +08:00
</AddTemplate>
<EditTemplate>
2023-08-07 15:09:53 +08:00
@GetRenderFragment(context)
2023-03-04 18:41:11 +08:00
</EditTemplate>
<ItemColOperTemplate>
<MList Dense>
@if (@UserResoures.IsHasButtonWithRole("openapiuserper"))
{
<MListItem OnClick="async()=>
{
ChoiceUserId=context.Item.Id;
2023-08-07 15:09:53 +08:00
RolesChoice=OpenApiPermissionTreeSelector.TreeToList( GetRouters()).Where(it=>context.Item.PermissionCodeList?.Contains(it.ApiRoute)==true).ToList() ;
2023-03-04 18:41:11 +08:00
IsShowRoles=true;
}">
2023-08-07 15:09:53 +08:00
<MListItemTitle Class="ml-2">Api权限</MListItemTitle>
2023-03-04 18:41:11 +08:00
</MListItem>
}
</MList>
</ItemColOperTemplate>
<ItemColTemplate>
@switch (context.Header.Value)
{
2023-08-07 15:09:53 +08:00
case nameof(context.Item.UserEnable):
<MSimpleCheckbox ValueChanged=@(a=>UserStatusChangeAsync(context.Item,a))
Value="context.Item.UserEnable">
</MSimpleCheckbox>
2023-03-04 18:41:11 +08:00
break;
default:
2023-08-07 15:09:53 +08:00
@if (context.Header.CellClass?.Contains("text-truncate") == true)
{
<span title=@context.Value>
@context.Value
</span>
}
else
{
@context.Value
}
2023-03-04 18:41:11 +08:00
break;
}
</ItemColTemplate>
</AppDataTable>
<PDrawer @bind-Value="IsShowRoles" OnCancel="() => IsShowRoles = false"
2023-08-07 15:09:53 +08:00
Title=Api权限
Width=@(IsMobile?"100%":"500")
MaxWidth="500" OnSave="OnRolesSaveAsync">
2023-03-04 18:41:11 +08:00
@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"
2023-05-22 18:40:50 +08:00
Outlined Label=@typeof(OpenApiPermissionTreeSelector).GetDescription(nameof(OpenApiPermissionTreeSelector.ApiName)) />
2023-03-04 18:41:11 +08:00
</MCardTitle>
<MTreeview Class="my-1" Search="@SearchName" Dense OpenAll TItem="OpenApiPermissionTreeSelector" TKey="OpenApiPermissionTreeSelector" Selectable @bind-Value="RolesChoice" Items="AllRouters"
2023-05-22 18:40:50 +08:00
ItemText="r=>r.PermissionName" ItemChildren="r=>r.Children"
ItemKey=@(r=>r)>
2023-08-07 15:09:53 +08:00
<LabelContent>
<span title=@context.Item.PermissionName>
@context.Item.PermissionName
</span>
</LabelContent>
2023-03-04 18:41:11 +08:00
</MTreeview>
</MCard>
}
</PDrawer>
@code {
2023-08-07 15:09:53 +08:00
RenderFragment GetRenderFragment(OpenApiUser context)
2023-03-04 18:41:11 +08:00
{
2023-08-07 15:09:53 +08:00
RenderFragment renderFragment =
@<div>
<MSubheader Class="mt-4 font-weight-black"> @(context.Description(x => x.Account)) </MSubheader>
<MTextField Dense Outlined HideDetails="@("auto")" @bind-Value=@context.Account />
2023-03-04 18:41:11 +08:00
2023-08-07 15:09:53 +08:00
<MSubheader Class="mt-4 font-weight-black"> @(context.Description(x => x.Password)) </MSubheader>
<MTextField Dense Outlined HideDetails="@("auto")" @bind-Value=@context.Password />
2023-03-04 18:41:11 +08:00
2023-08-07 15:09:53 +08:00
<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;
2023-03-04 18:41:11 +08:00
}
2023-08-07 15:09:53 +08:00
}