feat: 基础 table 是否显示添加删除编辑按钮

This commit is contained in:
zhangpeihang 2022-01-19 15:08:16 +08:00
parent cacea459c1
commit 3a0525f11f
2 changed files with 26 additions and 4 deletions

View File

@ -7,10 +7,11 @@
ShowEmpty="ShowEmpty" EmptyText="暂无数据" EmptyImage="images/empty.svg" SortList="SortList"
OnQueryAsync="OnQueryAsync!" OnDeleteAsync="OnDeleteAsync!" OnSaveAsync="OnSaveAsync!"
ShowSkeleton="true" ShowLoading="ShowLoading" ShowSearch="ShowSearch"
ShowToolbar="ShowToolbar" ShowExtendButtons="ShowExtendButtons"
ShowToolbar="ShowToolbar" ShowExtendButtons="ShowExtendButtons" ShowAddButton="@AuthorizeButton("add")"
ShowDeleteButton="@AuthorizeButton("del")" ShowEditButton="@AuthorizeButton("edit")"
ShowCardView="true" ShowColumnList="true" ExtendButtonColumnWidth="@ExtendButtonColumnWidth"
CustomerSearchModel="CustomerSearchModel" SelectedRows="SelectedRows"
ShowEditButtonCallback="ShowEditButtonCallback!" ShowDeleteButtonCallback="ShowDeleteButtonCallback!"
CustomerSearchModel="CustomerSearchModel" SelectedRows="SelectedRows"
ShowEditButtonCallback="ShowEditButtonCallback!" ShowDeleteButtonCallback="ShowDeleteButtonCallback!"
TableToolbarTemplate="TableToolbarTemplate" TableColumns="TableColumns" EditTemplate="EditTemplate!"
CustomerSearchTemplate="CustomerSearchTemplate!" RowButtonTemplate="RowButtonTemplate!">
</Table>

View File

@ -1,4 +1,6 @@
using BootstrapAdmin.Web.Models;
using BootstrapAdmin.Web.Core;
using BootstrapAdmin.Web.Models;
using BootstrapAdmin.Web.Services;
namespace BootstrapAdmin.Web.Components
{
@ -189,5 +191,24 @@ namespace BootstrapAdmin.Web.Components
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task QueryAsync() => Instance.QueryAsync();
[Inject]
[NotNull]
private INavigation? NavigationService { get; set; }
[Inject]
[NotNull]
private NavigationManager? NavigationManager { get; set; }
[Inject]
[NotNull]
private BootstrapAppContext? AppContext { get; set; }
private bool AuthorizeButton(string operate)
{
var url = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
return NavigationService.AuthorizationBlock(url, AppContext.UserName, operate);
}
}
}