重构菜单结构,以及相关导航条设置,面包屑导航更改到js脚本中,更改Navigations数据库结构
This commit is contained in:
parent
02cfbfd8bd
commit
f111f3bc4e
|
@ -396,6 +396,10 @@ a.logo {
|
|||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.modal-dialog .modal-body .form-inline .form-group input {
|
||||
padding-right: 30px;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
background-color: #f5f5f5;
|
||||
border-top-left-radius: 6px;
|
||||
|
@ -456,7 +460,7 @@ input.valid {
|
|||
padding-left: 6px;
|
||||
}
|
||||
|
||||
.lgbBreadcrumb {
|
||||
ul.breadcrumb {
|
||||
position: absolute;
|
||||
top: 56px;
|
||||
left: 15px;
|
||||
|
@ -464,20 +468,19 @@ input.valid {
|
|||
border-color: #ddd;
|
||||
border-width: 1px 0 0 0;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
.lgbBreadcrumb > ul {
|
||||
background-color: transparent;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
.lgbBreadcrumb > ul > li.active {
|
||||
ul.breadcrumb > li.active {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.lgbBreadcrumb > ul > li.load {
|
||||
ul.breadcrumb > li.load {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.lgbBreadcrumb > ul > li > a > i {
|
||||
ul.breadcrumb > li > a > i {
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
|
|
@ -164,6 +164,11 @@
|
|||
})(jQuery);
|
||||
|
||||
$(function () {
|
||||
// breadcrumb
|
||||
var breadcrumb = $('.sidebar-menu > li > a.active > span').text();
|
||||
if (breadcrumb === "") $('.breadcrumb > li + li').hide();
|
||||
else $('.breadcrumb > li + li').text(breadcrumb);
|
||||
|
||||
if ($.isFunction($.validator)) {
|
||||
jQuery.validator.addMethod("ip", function (value, element) {
|
||||
return this.optional(element) || /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/.test(value);
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace Bootstrap.Admin.Controllers
|
|||
public ActionResult Users()
|
||||
{
|
||||
var v = new NavigatorBarModel();
|
||||
v.BreadcrumbName = "用户管理";
|
||||
v.ShowMenu = "hide";
|
||||
v.Menus[1].Active = "active";
|
||||
v.HomeUrl = "~/Admin";
|
||||
|
@ -39,7 +38,6 @@ namespace Bootstrap.Admin.Controllers
|
|||
public ActionResult Groups()
|
||||
{
|
||||
var v = new NavigatorBarModel();
|
||||
v.BreadcrumbName = "部门管理";
|
||||
v.ShowMenu = "hide";
|
||||
v.Menus[3].Active = "active";
|
||||
v.HomeUrl = "~/Admin";
|
||||
|
@ -48,7 +46,6 @@ namespace Bootstrap.Admin.Controllers
|
|||
public ActionResult Roles()
|
||||
{
|
||||
var v = new NavigatorBarModel();
|
||||
v.BreadcrumbName = "角色管理";
|
||||
v.ShowMenu = "hide";
|
||||
v.Menus[2].Active = "active";
|
||||
v.HomeUrl = "~/Admin";
|
||||
|
@ -57,7 +54,6 @@ namespace Bootstrap.Admin.Controllers
|
|||
public ActionResult Menus()
|
||||
{
|
||||
var v = new NavigatorBarModel();
|
||||
v.BreadcrumbName = "菜单管理";
|
||||
v.ShowMenu = "hide";
|
||||
v.Menus[0].Active = "active";
|
||||
v.HomeUrl = "~/Admin";
|
||||
|
|
|
@ -26,10 +26,6 @@ namespace Bootstrap.Admin.Models
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BreadcrumbName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ShowMenu { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.Admin.Models
|
||||
{
|
||||
|
@ -7,7 +8,8 @@ namespace Bootstrap.Admin.Models
|
|||
{
|
||||
public NavigatorBarModel()
|
||||
{
|
||||
Menus = Menu.RetrieveMenus();
|
||||
Menus = MenuHelper.RetrieveMenus().ToList();
|
||||
Menus.ForEach(m => m.Active = null);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -20,16 +20,11 @@ namespace Bootstrap.Admin.Models
|
|||
|
||||
public QueryData<Menu> RetrieveData()
|
||||
{
|
||||
// int limit, int offset, string name, string price, string sort, string order
|
||||
var data = MenuHelper.RetrieveMenus(string.Empty);
|
||||
var data = MenuHelper.RetrieveMenus();
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
{
|
||||
data = data.Where(t => t.Name.Contains(Name));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Category))
|
||||
{
|
||||
data = data.Where(t => t.Category.Contains(Category));
|
||||
}
|
||||
var ret = new QueryData<Menu>();
|
||||
ret.total = data.Count();
|
||||
// TODO: 通过option.Sort属性判断对那列进行排序,现在统一对名称列排序
|
||||
|
|
|
@ -48,6 +48,4 @@
|
|||
maxlength: 50
|
||||
}
|
||||
});
|
||||
|
||||
//TODO: 客户端点击保存用户后,要更新页面右上角用户显示名称
|
||||
});
|
|
@ -48,15 +48,10 @@
|
|||
<!--search & user info end-->
|
||||
</div>
|
||||
<!--breadcrumbs start -->
|
||||
<div class="lgbBreadcrumb">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="@Url.Content(Model.HomeUrl)"><i class="fa fa-home"></i>首页</a></li>
|
||||
@if (!string.IsNullOrEmpty(Model.BreadcrumbName))
|
||||
{
|
||||
<li>@Model.BreadcrumbName</li>
|
||||
}
|
||||
<li></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--breadcrumbs end -->
|
||||
</header>
|
||||
<!--header end-->
|
||||
|
|
|
@ -5,12 +5,7 @@
|
|||
<ul class="sidebar-menu" id="nav-accordion">
|
||||
@foreach (var menu in Model.Menus)
|
||||
{
|
||||
<li>
|
||||
<a href="@menu.Url" class="@menu.Active">
|
||||
<i class="fa @menu.Icon"></i>
|
||||
<span>@menu.Name</span>
|
||||
</a>
|
||||
</li>
|
||||
<li><a href="@Url.Content(menu.Url)" class="@menu.Active"><i class="@menu.Icon"></i><span>@menu.Name</span></a></li>
|
||||
}
|
||||
</ul>
|
||||
<!-- sidebar menu end-->
|
||||
|
|
|
@ -34,23 +34,10 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
/// 获得/设置 菜单分类
|
||||
/// </summary>
|
||||
public string Category { get; set; }
|
||||
public int Category { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 是否当前被选中 active为选中
|
||||
/// </summary>
|
||||
public string Active { get; set; }
|
||||
|
||||
public static List<Menu> RetrieveMenus()
|
||||
{
|
||||
return new List<Menu>() {
|
||||
new Menu() { Name = "菜单管理", Icon = "fa-dashboard", Url="/Admin/Menus", Active = "" },
|
||||
new Menu() { Name = "用户管理", Icon = "fa-user", Url="/Admin/Users", Active = "" },
|
||||
new Menu() { Name = "角色管理", Icon = "fa-sitemap", Url="/Admin/Roles", Active = "" },
|
||||
new Menu() { Name = "部门管理", Icon = "fa-home", Url="/Admin/Groups", Active = "" },
|
||||
new Menu() { Name = "字典表维护", Icon = "fa-book", Url="javascript:;", Active = "" },
|
||||
new Menu() { Name = "个性化维护", Icon = "fa-pencil", Url="javascript:;", Active = "" },
|
||||
new Menu() { Name = "系统日志", Icon = "fa-lock", Url="javascript:;", Active = "" }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ namespace Bootstrap.DataAccess
|
|||
ID = (int)reader[0],
|
||||
ParentId = (int)reader[1],
|
||||
Name = (string)reader[2],
|
||||
Order = LgbConvert.ReadValue((int)reader[3],0),
|
||||
Order = (int)reader[3],
|
||||
Icon = (string)reader[4],
|
||||
Url = LgbConvert.ReadValue((string)reader[5], string.Empty),
|
||||
Category = (string)reader[6]
|
||||
Category = (int)reader[6]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,16 @@ namespace Bootstrap.DataAccess
|
|||
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.ID.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Menu> RetrieveMenusByUserId(int userId)
|
||||
{
|
||||
//UNDONE: 通过用户ID获得到当前用户配置的菜单
|
||||
return RetrieveMenus();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除菜单信息
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
|
@ -86,7 +96,6 @@ namespace Bootstrap.DataAccess
|
|||
if (p.Name.Length > 50) p.Name.Substring(0, 50);
|
||||
if (p.Icon.Length > 50) p.Icon.Substring(0, 50);
|
||||
if (p.Url != null) { if (p.Url.Length > 50) p.Url.Substring(0, 50); }
|
||||
if (p.Category.Length > 50) p.Category.Substring(0, 50);
|
||||
string sql = p.ID == 0 ?
|
||||
"Insert Into Navigations (ParentId, Name, [Order], Icon, Url, Category) Values (@ParentId, @Name, @Order, @Icon, @Url, @Category)" :
|
||||
"Update Navigations set ParentId = @ParentId, Name = @Name, [Order] = @Order, Icon = @Icon, Url = @Url, Category = @Category where ID = @ID";
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Bootstrap.DataAccess.Tests
|
|||
p.Order = 0;
|
||||
p.Icon = "测试菜单Icon";
|
||||
p.Url = "urlTestAdd";
|
||||
p.Category = "测试菜单分组";
|
||||
p.Category = 1;
|
||||
var result = MenuHelper.SaveMenu(p);
|
||||
Assert.IsTrue(result, "增加菜单出错");
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace Bootstrap.DataAccess.Tests
|
|||
p1.Order = 0;
|
||||
p1.Icon = "测试菜单Icon1";
|
||||
p1.Url = "urlTestUpdate";
|
||||
p1.Category = "测试菜单分组1";
|
||||
p1.Category = 1;
|
||||
result = MenuHelper.SaveMenu(p1);
|
||||
Assert.IsTrue(result, "更新菜单出错");
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace Bootstrap.DataAccess.Tests
|
|||
Order = 0,
|
||||
Icon = "测试菜单Icon1",
|
||||
Url = "urlTestUpdate",
|
||||
Category = "测试菜单分组1"
|
||||
Category = 1
|
||||
});
|
||||
var menu = MenuHelper.RetrieveMenus().FirstOrDefault(m => m.Name == "菜单删除测试");
|
||||
Assert.IsTrue(MenuHelper.DeleteMenu(menu.ID.ToString()),"删除菜单失败");
|
||||
|
|
|
@ -148,10 +148,10 @@ CREATE TABLE [dbo].[Navigations](
|
|||
[ID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ParentId] [int] NOT NULL,
|
||||
[Name] [nvarchar](50) NOT NULL,
|
||||
[Order] [int] NULL,
|
||||
[Order] [int] NOT NULL,
|
||||
[Icon] [varchar](50) NOT NULL,
|
||||
[Url] [varchar](50) NULL,
|
||||
[Category] [varchar](50) NOT NULL,
|
||||
[Category] [int] NOT NULL,
|
||||
CONSTRAINT [PK_Navigations] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ID] ASC
|
||||
|
@ -163,5 +163,24 @@ GO
|
|||
SET ANSI_PADDING OFF
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Navigations] ADD CONSTRAINT [DF_Navigations_ParentId] DEFAULT ((0)) FOR [ParentId]
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Navigations] ADD CONSTRAINT [DF_Navigations_Order] DEFAULT ((0)) FOR [Order]
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Navigations] ADD CONSTRAINT [DF_Navigations_Icon] DEFAULT ('none') FOR [Icon]
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Navigations] ADD CONSTRAINT [DF_Navigations_Category] DEFAULT ((0)) FOR [Category]
|
||||
GO
|
||||
|
||||
SET IDENTITY_INSERT Navigations ON
|
||||
insert into Navigations (ID, Name, [Order], Icon, Url) values (1, '菜单管理', 10, 'fa fa-dashboard', '~/Admin/Menus')
|
||||
insert into Navigations (ID, Name, [Order], Icon, Url) values (2, '用户管理', 20, 'fa fa-user', '~/Admin/Users')
|
||||
insert into Navigations (ID, Name, [Order], Icon, Url) values (3, '角色管理', 30, 'fa fa-sitemap', '~/Admin/Roles')
|
||||
insert into Navigations (ID, Name, [Order], Icon, Url) values (4, '部门管理', 40, 'fa fa-home', '~/Admin/Groups')
|
||||
insert into Navigations (ID, Name, [Order], Icon, Url) values (5, '字典表维护', 50, 'fa fa-book', '~/Admin/Dict')
|
||||
insert into Navigations (ID, Name, [Order], Icon, Url) values (6, '个性化维护', 60, 'fa fa-pencil', '~/Admin/Profiles')
|
||||
insert into Navigations (ID, Name, [Order], Icon, Url) values (7, '系统日志', 70, 'fa fa-gears', '~/Admin/EventLog')
|
||||
SET IDENTITY_INSERT Navigations OFF
|
Loading…
Reference in New Issue