BA后台增加菜单所属应用程序配置功能
This commit is contained in:
parent
0efb962554
commit
8071d7baea
|
@ -10,6 +10,7 @@ namespace Bootstrap.Admin.Models
|
|||
public NavigatorBarModel(string url)
|
||||
{
|
||||
Navigations = MenuHelper.RetrieveNavigationsByUserName(UserName).Where(m => m.IsResource == 0);
|
||||
Applications = DictHelper.RetrieveApps();
|
||||
ActiveMenu(null, Navigations.ToList(), url);
|
||||
HomeUrl = "~/Admin/Index";
|
||||
}
|
||||
|
@ -27,5 +28,9 @@ namespace Bootstrap.Admin.Models
|
|||
///
|
||||
/// </summary>
|
||||
public IEnumerable<Menu> Navigations { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<KeyValuePair<string, string>> Applications { get; set; }
|
||||
}
|
||||
}
|
|
@ -34,7 +34,8 @@
|
|||
Url: "url",
|
||||
Category: "category",
|
||||
Target: "target",
|
||||
IsResource: "isRes"
|
||||
IsResource: "isRes",
|
||||
ApplicationCode: "app"
|
||||
}
|
||||
}),
|
||||
click: {
|
||||
|
|
|
@ -160,6 +160,21 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="app">所属应用</label>
|
||||
<div class="dropdown lgbDropdown dropup">
|
||||
<a id="app" class="btn btn-info" data-toggle="dropdown" data-default-val="0">
|
||||
<span>未设置</span>
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
@foreach (var kv in Model.Applications)
|
||||
{
|
||||
<li><a href="#" data-val="@kv.Key">@kv.Value</a></li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -215,5 +215,14 @@ namespace Bootstrap.DataAccess
|
|||
var settings = RetrieveDicts();
|
||||
return (settings.FirstOrDefault(d => d.Name == "前台首页" && d.Category == "网站设置" && d.Define == 0) ?? new Dict() { Code = "~/Home/Index" }).Code;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<KeyValuePair<string, string>> RetrieveApps()
|
||||
{
|
||||
var settings = RetrieveDicts();
|
||||
return settings.Where(d => d.Category == "应用程序" && d.Define == 0).Select(d => new KeyValuePair<string, string>(d.Code, d.Name)).OrderBy(d => d.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,10 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public int IsResource { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 所属应用程序
|
||||
/// </summary>
|
||||
public string ApplicationCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<Menu> Menus { get; set; }
|
||||
|
|
|
@ -49,8 +49,9 @@ namespace Bootstrap.DataAccess
|
|||
Category = (string)reader[6],
|
||||
Target = (string)reader[7],
|
||||
IsResource = (bool)reader[8] ? 1 : 0,
|
||||
CategoryName = (string)reader[9],
|
||||
ParentName = LgbConvert.ReadValue(reader[10], string.Empty)
|
||||
ApplicationCode = reader.IsDBNull(9) ? string.Empty : (string)reader[9],
|
||||
CategoryName = (string)reader[10],
|
||||
ParentName = LgbConvert.ReadValue(reader[11], string.Empty)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -141,8 +142,8 @@ namespace Bootstrap.DataAccess
|
|||
if (p.Icon != null && p.Icon.Length > 50) p.Icon.Substring(0, 50);
|
||||
if (p.Url != null && p.Url.Length > 50) p.Url.Substring(0, 50);
|
||||
string sql = p.ID == 0 ?
|
||||
"Insert Into Navigations (ParentId, Name, [Order], Icon, Url, Category, Target, IsResource) Values (@ParentId, @Name, @Order, @Icon, @Url, @Category, @Target, @IsResource)" :
|
||||
"Update Navigations set ParentId = @ParentId, Name = @Name, [Order] = @Order, Icon = @Icon, Url = @Url, Category = @Category, Target = @Target, IsResource = @IsResource where ID = @ID";
|
||||
"Insert Into Navigations (ParentId, Name, [Order], Icon, Url, Category, Target, IsResource, [Application]) Values (@ParentId, @Name, @Order, @Icon, @Url, @Category, @Target, @IsResource, @ApplicationCode)" :
|
||||
"Update Navigations set ParentId = @ParentId, Name = @Name, [Order] = @Order, Icon = @Icon, Url = @Url, Category = @Category, Target = @Target, IsResource = @IsResource, Application = @ApplicationCode where ID = @ID";
|
||||
try
|
||||
{
|
||||
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
|
||||
|
@ -156,6 +157,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category, ParameterDirection.Input));
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Target", p.Target, ParameterDirection.Input));
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@IsResource", p.IsResource, ParameterDirection.Input));
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode, ParameterDirection.Input));
|
||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||
}
|
||||
CacheCleanUtility.ClearCache(menuIds: p.ID == 0 ? string.Empty : p.ID.ToString());
|
||||
|
|
|
@ -9,6 +9,7 @@ SET IDENTITY_INSERT [dbo].[Users] OFF
|
|||
DELETE From Dicts
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'菜单', N'系统菜单', N'0', 0)
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'菜单', N'外部菜单', N'1', 0)
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'应用程序', N'未设置', N'0', 0)
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'网站标题', N'后台管理系统', 0)
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'网站页脚', N'2016 © 通用后台管理系统', 0)
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统通知', N'用户注册', N'0', 0)
|
||||
|
|
|
@ -175,6 +175,7 @@ CREATE TABLE [dbo].[Navigations](
|
|||
[Category] [nvarchar](50) NOT NULL,
|
||||
[Target] [varchar](10) NOT NULL,
|
||||
[IsResource] [bit] NOT NULL,
|
||||
[Application] [nvarchar](200) NOT NULL,
|
||||
CONSTRAINT [PK_Navigations] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ID] ASC
|
||||
|
@ -320,6 +321,9 @@ GO
|
|||
ALTER TABLE [dbo].[Navigations] ADD CONSTRAINT [DF_Navigations_IsResource] DEFAULT ((0)) FOR [IsResource]
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Navigations] ADD CONSTRAINT [DF_Navigations_Application] DEFAULT ((0)) FOR [Application]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[Messages] Script Date: 11/14/2016 13:59:21 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
|
|
@ -126,11 +126,11 @@ BEGIN
|
|||
SET XACT_ABORT ON;
|
||||
-- Insert statements for procedure here
|
||||
if @userName = '' or @userName is null
|
||||
select n.*, d.Name as CategoryName, ln.Name as ParentName
|
||||
select n.ID, n.ParentId, n.Name, n.[Order], n.Icon, n.Url, n.Category, n.Target, n.IsResource, n.[Application], d.Name as CategoryName, ln.Name as ParentName
|
||||
from Navigations n inner join Dicts d on n.Category = d.Code and d.Category = N'菜单' and d.Define = 0
|
||||
left join Navigations ln on n.ParentId = ln.ID
|
||||
else
|
||||
select n.*, d.Name as CategoryName, ln.Name as ParentName
|
||||
select n.ID, n.ParentId, n.Name, n.[Order], n.Icon, n.Url, n.Category, n.Target, n.IsResource, n.[Application], d.Name as CategoryName, ln.Name as ParentName
|
||||
from Navigations n inner join Dicts d on n.Category = d.Code and d.Category = N'菜单' and d.Define = 0
|
||||
left join Navigations ln on n.ParentId = ln.ID
|
||||
inner join (
|
||||
|
|
Loading…
Reference in New Issue