diff --git a/src/admin/Bootstrap.Admin/Components/SelectBase.cs b/src/admin/Bootstrap.Admin/Components/SelectBase.cs index a8a8ce50..91b23653 100644 --- a/src/admin/Bootstrap.Admin/Components/SelectBase.cs +++ b/src/admin/Bootstrap.Admin/Components/SelectBase.cs @@ -8,6 +8,12 @@ namespace Bootstrap.Admin.Components /// public class SelectBase : ComponentBase { + /// + /// + /// + [Parameter] + public string Id { get; set; } = ""; + /// /// /// @@ -25,6 +31,18 @@ namespace Bootstrap.Admin.Components /// public SelectItemBase? SelectedItem { get; set; } + /// + /// + /// + [Parameter] + public int SelectedValue { get; set; } + + /// + /// + /// + [Parameter] + public EventCallback SelectedValueChanged { get; set; } + /// /// /// diff --git a/src/admin/Bootstrap.Admin/Components/TableBase.cs b/src/admin/Bootstrap.Admin/Components/TableBase.cs index c903b107..588fe2b9 100644 --- a/src/admin/Bootstrap.Admin/Components/TableBase.cs +++ b/src/admin/Bootstrap.Admin/Components/TableBase.cs @@ -1,5 +1,7 @@ -using Microsoft.AspNetCore.Components; +using Bootstrap.Admin.Extensions; +using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; +using System; using System.Collections.Generic; namespace Bootstrap.Admin.Components @@ -15,12 +17,6 @@ namespace Bootstrap.Admin.Components [Inject] protected IJSRuntime? JSRuntime { get; set; } - /// - /// - /// - [Parameter] - public string Id { get; set; } = ""; - /// /// /// @@ -39,6 +35,12 @@ namespace Bootstrap.Admin.Components [Parameter] public RenderFragment? TableFooter { get; set; } + /// + /// + /// + [Parameter] + public bool ShowToolBar { get; set; } = true; + /// /// /// @@ -46,9 +48,20 @@ namespace Bootstrap.Admin.Components public IEnumerable Items { get; set; } = new TItem[0]; /// - /// 数据 + /// /// - [Parameter] - public int ItemsCount { get; set; } = 0; + public Action AddCallback { get; set; } = new Action(() => { }); + /// + /// + /// + public Action EditCallback { get; set; } = new Action(() => { }); + + /// + /// + /// + public void Delete() + { + + } } } diff --git a/src/admin/Bootstrap.Admin/Extensions/JSRuntimeExtensions.cs b/src/admin/Bootstrap.Admin/Extensions/JSRuntimeExtensions.cs index 2b476ecc..a6c529ea 100644 --- a/src/admin/Bootstrap.Admin/Extensions/JSRuntimeExtensions.cs +++ b/src/admin/Bootstrap.Admin/Extensions/JSRuntimeExtensions.cs @@ -52,5 +52,12 @@ namespace Bootstrap.Admin.Extensions /// /// public static void InitModal(this IJSRuntime? jSRuntime) => jSRuntime.InvokeVoidAsync("$.initModal"); + + /// + /// 弹出 Modal 组件 + /// + /// + /// + public static void ToggleModal(this IJSRuntime? jSRuntime, string modalId) => jSRuntime.InvokeVoidAsync("$.toggleModal", modalId); } } diff --git a/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor b/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor index a6f12c24..8992e481 100644 --- a/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor +++ b/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor @@ -1,4 +1,6 @@ -
+@inject IJSRuntime JSRuntime + +
查询条件
@@ -26,41 +28,28 @@
-
-
- - -
-
- - - -
-
查询结果
- - - - - - - - - - - - - -
字典标签字典名称字典代码字典类型@context.Category@context.Name@context.Code@context.Define
- +
+ + + + + + + + + + + + + +
字典标签字典名称字典代码字典类型@context.Category@context.Name@context.Code@context.Define
+ +
@@ -70,34 +59,29 @@
- - - +
-
- +
- - + +
- +
- +
@@ -107,7 +91,7 @@ 关闭 - @@ -131,6 +115,10 @@ protected Pagination? Pagination { get; set; } + protected Table? Table { get; set; } + + protected BootstrapDict Model { get; set; } = new BootstrapDict(); + protected override void OnInitialized() { Query(1); @@ -138,21 +126,35 @@ protected override void OnAfterRender(bool firstRender) { - if (firstRender && Pagination != null) + if (firstRender) { - Pagination.ClickPageCallback = pageIndex => + if (Pagination != null) { - if (pageIndex != PageIndex) + Pagination.ClickPageCallback = pageIndex => { - Query(pageIndex); + if (pageIndex != PageIndex) + { + Query(pageIndex); + StateHasChanged(); + } + }; + Pagination.PageItemsChangeCallback = () => + { + Query(1); StateHasChanged(); - } - }; - Pagination.PageItemsChangeCallback = () => + }; + } + if (Table != null) { - Query(1); - StateHasChanged(); - }; + Table.AddCallback = () => + { + JSRuntime.ToggleModal("#DialogDict"); + }; + Table.EditCallback = () => + { + + }; + } } } @@ -167,4 +169,9 @@ PageCount = (int)Math.Ceiling(data.Count() * 1.0d / pageItems); PageIndex = pageIndex; } + + protected void Save() + { + JSRuntime.ToggleModal("#DialogDict"); + } } diff --git a/src/admin/Bootstrap.Admin/Shared/Select.razor b/src/admin/Bootstrap.Admin/Shared/Select.razor index b316cd3e..f0a96464 100644 --- a/src/admin/Bootstrap.Admin/Shared/Select.razor +++ b/src/admin/Bootstrap.Admin/Shared/Select.razor @@ -1,7 +1,7 @@ @inherits SelectBase