From c28ef26e8e40028a0b93d0394fdba675c8dcd12a Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Thu, 6 Jan 2022 03:54:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8F=9C=E5=8D=95=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Navigation.cs | 1 + .../Components/MenusSearch.razor | 20 +++++ .../Components/MenusSearch.razor.cs | 50 +++++++++++ .../Models/MenusSearchModel.cs | 82 +++++++++++++++++++ .../Pages/Admin/Menus.razor | 52 ++++++++++-- .../Pages/Admin/Menus.razor.cs | 9 ++ 6 files changed, 207 insertions(+), 7 deletions(-) create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor.cs create mode 100644 src/blazor/admin/BootstrapAdmin.Web/Models/MenusSearchModel.cs diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.Models/Navigation.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/Navigation.cs index 4d6bc9ed..a9d9c4f6 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.Models/Navigation.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/Navigation.cs @@ -12,6 +12,7 @@ namespace BootstrapAdmin.DataAccess.Models /// /// 获得/设置 菜单主键ID /// + [NotNull] public string? Id { set; get; } /// diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor b/src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor new file mode 100644 index 00000000..c6e3c366 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor @@ -0,0 +1,20 @@ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor.cs new file mode 100644 index 00000000..bbbef8a5 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/MenusSearch.razor.cs @@ -0,0 +1,50 @@ +using BootstrapAdmin.DataAccess.Models; +using BootstrapAdmin.Web.Core; +using BootstrapAdmin.Web.Extensions; +using BootstrapAdmin.Web.Models; +using BootstrapAdmin.Web.Utils; + +namespace BootstrapAdmin.Web.Components; + +public partial class MenusSearch +{ + [NotNull] + [Inject] + private IDict? DictService { get; set; } + + private IEnumerable? CategoryItems { get; set; } + + private IEnumerable? ResourceItems { get; set; } + + private List? AppItems { get; set; } + + private List? TargetItems { get; set; } + + [Parameter] + [NotNull] + public MenusSearchModel? Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + + + protected override void OnInitialized() + { + base.OnInitialized(); + + TargetItems = new List() + { + new SelectedItem("", "全部") + }; + TargetItems.AddRange(LookupHelper.GetTargets()); + + AppItems = new List() + { + new SelectedItem("", "全部") + }; + AppItems.AddRange(DictService.GetApps().ToSelectedItemList()); + + ResourceItems = typeof(EnumResource).ToSelectList(new SelectedItem("", "全部")); + CategoryItems = typeof(EnumNavigationCategory).ToSelectList(new SelectedItem("", "全部")); + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Models/MenusSearchModel.cs b/src/blazor/admin/BootstrapAdmin.Web/Models/MenusSearchModel.cs new file mode 100644 index 00000000..eed876c8 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Models/MenusSearchModel.cs @@ -0,0 +1,82 @@ +using BootstrapAdmin.DataAccess.Models; +using System.ComponentModel.DataAnnotations; + +namespace BootstrapAdmin.Web.Models; + +public class MenusSearchModel : ITableSearchModel +{ + [Display(Name = "名称")] + public string? Name { get; set; } + + [Display(Name = "地址")] + public string? Url { get; set; } + + /// + /// 获得/设置 菜单分类, 0 表示系统菜单 1 表示用户自定义菜单 + /// + [Display(Name = "类别")] + public EnumNavigationCategory? Category { get; set; } + + /// + /// 获得/设置 链接目标 + /// + [Display(Name = "目标")] + public string? Target { get; set; } + + /// + /// 获得/设置 是否为资源文件, 0 表示菜单 1 表示资源 2 表示按钮 + /// + [Display(Name = "类型")] + public EnumResource? IsResource { get; set; } + + /// + /// 获得/设置 所属应用程序,此属性由BA后台字典表分配 + /// + [Display(Name = "所属应用")] + public string? Application { get; set; } + + public IEnumerable GetSearchs() + { + var ret = new List(); + if (!string.IsNullOrEmpty(Name)) + { + ret.Add(new SearchFilterAction(nameof(Navigation.Name), Name)); + } + + if (!string.IsNullOrEmpty(Url)) + { + ret.Add(new SearchFilterAction(nameof(Navigation.Url), Url)); + } + + if (Category.HasValue) + { + ret.Add(new SearchFilterAction(nameof(Navigation.Category), Category.Value)); + } + + if (!string.IsNullOrEmpty(Application)) + { + ret.Add(new SearchFilterAction(nameof(Navigation.Application), Application)); + } + + if (IsResource.HasValue) + { + ret.Add(new SearchFilterAction(nameof(Navigation.IsResource), IsResource.Value)); + } + + if (!string.IsNullOrEmpty(Target)) + { + ret.Add(new SearchFilterAction(nameof(Navigation.Target), Target)); + } + return ret; + } + + public void Reset() + { + Name = null; + Url = null; + Category = null; + IsResource = null; + Target = null; + Application = null; + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor index 0912dc7c..74491924 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor @@ -1,13 +1,14 @@ @page "/Admin/Menus" - + - - + +