diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj
index ec4c7450..bbe3c979 100644
--- a/Bootstrap.Admin/Bootstrap.Admin.csproj
+++ b/Bootstrap.Admin/Bootstrap.Admin.csproj
@@ -309,8 +309,6 @@
-
-
diff --git a/Bootstrap.Admin/Content/css/jquery.nestable.css b/Bootstrap.Admin/Content/css/jquery.nestable.css
index 06e69695..7dd94220 100644
--- a/Bootstrap.Admin/Content/css/jquery.nestable.css
+++ b/Bootstrap.Admin/Content/css/jquery.nestable.css
@@ -182,6 +182,12 @@
cursor: pointer;
}
+ .dd3-content > span {
+ position: absolute;
+ right: 15px;
+ top: 6px;
+ }
+
.dd-dragel > .dd3-item > .dd3-content {
margin: 0;
}
diff --git a/Bootstrap.Admin/Content/js/common-scripts.js b/Bootstrap.Admin/Content/js/common-scripts.js
index 5524bf56..18efd56d 100644
--- a/Bootstrap.Admin/Content/js/common-scripts.js
+++ b/Bootstrap.Admin/Content/js/common-scripts.js
@@ -1,4 +1,43 @@
-$(function () {
+(function ($) {
+ var cascadeMenu = function (menus) {
+ var html = "";
+ $.each(menus, function (index, menu) {
+ if (menu.Menus.length == 0) {
+ html += $.format('
{4}
', menu.ID, menu.Icon, menu.Name, menu.Category, menu.Order);
+ }
+ else {
+ html += $.format('{5}
{4}
', menu.ID, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order);
+ }
+ });
+ return html;
+ };
+
+ var cascadeSubMenu = function (menus) {
+ var html = ""
+ $.each(menus, function (index, menu) {
+ html += $.format('{4}
', menu.ID, menu.Icon, menu.Name, menu.Category, menu.Order);
+ });
+ return html;
+ };
+
+ $.fn.extend({
+ nestMenu: function (callback) {
+ var $this = $(this);
+ $.bc({
+ Id: 0, url: Menu.url, data: { type: "user" }, swal: false,
+ callback: function (result) {
+ var html = "";
+ if ($.isArray(result)) html = cascadeMenu(result);
+ $this.find('ol:first').html(html);
+ $this.nestable();
+ callback();
+ }
+ });
+ }
+ });
+})(jQuery);
+
+$(function () {
var $sidebar = $("#sidebar");
var $main = $('#main-content');
var $breadNav = $('#breadNav');
diff --git a/Bootstrap.Admin/Scripts/Menus.js b/Bootstrap.Admin/Scripts/Menus.js
index 01a8f441..206eacba 100644
--- a/Bootstrap.Admin/Scripts/Menus.js
+++ b/Bootstrap.Admin/Scripts/Menus.js
@@ -16,10 +16,14 @@
var $parentMenuID = $('#parentId');
var $parentMenuName = $('#parentName');
var $category = $('#category');
- $nestMenuInput.find('label:first').hide();
+
+ var initNestMenu = function () {
+ $nestMenuInput = $nestMenu.find('div.dd3-content');
+ $nestMenuInput.find('label:first').hide();
+ }
var bsa = new BootstrapAdmin({
- url: '../api/Menus',
+ url: Menu.url,
dataEntity: new DataEntity({
map: {
ID: "menuID",
@@ -64,41 +68,11 @@
callback: function (result) {
if (!result.success) return;
if ((result.oper == "save") || result.oper == "del") {
- $.bc({
- Id: 0, url: Menu.url, data: { type: "user" }, swal: false,
- callback: function (result) {
- var html = "";
- if ($.isArray(result)) html = cascadeMenu(result);
- $nestMenu.find('ol:first').html(html);
- $nestMenuInput = $nestMenu.find('div.dd3-content');
- $nestMenuInput.find('label:first').hide();
- }
- });
+ $nestMenu.nestMenu(initNestMenu);
}
}
});
- var cascadeMenu = function (menus) {
- var html = "";
- $.each(menus, function (index, menu) {
- if (menu.Menus.length == 0) {
- html += $.format('', menu.ID, menu.Icon, menu.Name, menu.Category);
- }
- else {
- html += $.format('{4}
', menu.ID, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus));
- }
- });
- return html;
- };
-
- var cascadeSubMenu = function (menus) {
- var html = ""
- $.each(menus, function (index, menu) {
- html += $.format('', menu.ID, menu.Icon, menu.Name, menu.Category);
- });
- return html;
- }
-
$('table').smartTable({
url: Menu.url, //请求后台的URL(*)
sortName: 'Order',
@@ -178,8 +152,8 @@
$dialogIcon.find('div.modal-footer').on('click', 'button:last', function () {
var icon = $pickIcon.attr('class');
- $('#icon').val(icon);
- $('#btnIcon').find('i').attr('class', icon);
+ $inputIcon.val(icon);
+ $btnPickIcon.find('i').attr('class', icon);
});
// 排序按钮
@@ -196,7 +170,7 @@
var menuName = $('#name').val();
var menuCate = $category.selectval();
if (menuName == "") menuName = "新建菜单-未命名";
- $nestMenu.find('ol.dd-list:first').append($.format('', menuName, menuCate));
+ $nestMenu.find('ol.dd-list:first').append($.format('', menuName, menuCate));
}
$nestMenu.find('li[data-id="' + did + '"] > div.dd3-content span').addClass('active');
$dialogMenu.show().adjustDialog();
@@ -227,15 +201,17 @@
var type = $(this).data('type');
switch (type) {
case "parent":
- $('#parentId').val($('.dd3-content :radio:checked').val());
- $('#parentName').val($('.dd3-content :radio:checked').next('span').text());
+ $parentMenuID.val($('.dd3-content :radio:checked').val());
+ $parentMenuName.val($('.dd3-content :radio:checked').next('span').text());
break;
case "order":
- var data = $('#nestable_menu').nestable('serialize');
+ var data = $nestMenu.find('li:visible');
var mid = $('#menuID').val();
for (index in data) {
- if (data[index].id == mid || data[index] == 0) {
- $('#order').val(10 + index * 10);
+ var $data = $(data[index]);
+ if ($data.attr('data-id') == mid || $data.attr('data-id') == 0) {
+ if (index > 0) index--;
+ $('#order').val($(data[index]).attr('data-order'));
break;
}
}
@@ -251,7 +227,8 @@
if (icon == "") icon = "fa fa-dashboard";
$btnPickIcon.find('i').attr('class', icon);
});
- $nestMenu.nestable();
+
+ $nestMenu.nestMenu(initNestMenu);
// select
$('.btn-select').select();
});
\ No newline at end of file
diff --git a/Bootstrap.Admin/Scripts/Roles.js b/Bootstrap.Admin/Scripts/Roles.js
index ef66a349..6ad54ea0 100644
--- a/Bootstrap.Admin/Scripts/Roles.js
+++ b/Bootstrap.Admin/Scripts/Roles.js
@@ -11,7 +11,6 @@
var $btnSubmitMenu = $('#btnSubmitMenu');
var $nestMenu = $('#nestable_menu');
var $nestMenuInput = $nestMenu.find('div.dd3-content');
- $nestMenuInput.find('label:last').hide();
var bsa = new BootstrapAdmin({
url: Role.url,
@@ -113,8 +112,6 @@
}
});
- $nestMenu.nestable();
-
$('table').smartTable({
url: Role.url, //请求后台的URL(*)
sortName: 'RoleName',
@@ -134,11 +131,14 @@
}
});
- $nestMenuInput.on('click', ':checkbox', function () {
- var val = $(this).prop('checked');
- var child = $(this).parent().parent().next();
- if (child.hasClass('dd-list')) {
- child.find(':checkbox').prop('checked', val);
- }
+ $nestMenu.nestMenu(function () {
+ $nestMenuInput = $nestMenu.find('div.dd3-content');
+ $nestMenuInput.on('click', ':checkbox', function () {
+ var val = $(this).prop('checked');
+ var child = $(this).parent().parent().next();
+ if (child.hasClass('dd-list')) {
+ child.find(':checkbox').prop('checked', val);
+ }
+ }).find('label:last').hide();
});
});
\ No newline at end of file
diff --git a/Bootstrap.Admin/Views/Admin/Menus.cshtml b/Bootstrap.Admin/Views/Admin/Menus.cshtml
index b35073d4..15d2c750 100644
--- a/Bootstrap.Admin/Views/Admin/Menus.cshtml
+++ b/Bootstrap.Admin/Views/Admin/Menus.cshtml
@@ -99,6 +99,7 @@
+
@@ -162,5 +163,5 @@
- @Html.Partial("MenuTree", Model.Navigations.Union(Model.Menus))
+ @Html.Partial("MenuTree")
}
diff --git a/Bootstrap.Admin/Views/Admin/Roles.cshtml b/Bootstrap.Admin/Views/Admin/Roles.cshtml
index e43730c1..d9e6e9b4 100644
--- a/Bootstrap.Admin/Views/Admin/Roles.cshtml
+++ b/Bootstrap.Admin/Views/Admin/Roles.cshtml
@@ -81,5 +81,5 @@
@section customModal{
@Html.Partial("UserConfig")
@Html.Partial("GroupConfig")
- @Html.Partial("NavigatorConfig", Model.Navigations.Union(Model.Menus))
+ @Html.Partial("NavigatorConfig")
}
diff --git a/Bootstrap.Admin/Views/Shared/MenuTree.cshtml b/Bootstrap.Admin/Views/Shared/MenuTree.cshtml
index b979eb8e..91f4c6fe 100644
--- a/Bootstrap.Admin/Views/Shared/MenuTree.cshtml
+++ b/Bootstrap.Admin/Views/Shared/MenuTree.cshtml
@@ -1,17 +1,13 @@
-@model IEnumerable