diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index b1a083ab..99ef379b 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -244,8 +244,9 @@ function success(result) { if ($.isFunction(data.callback)) { if ($.isArray(result)) { - var html = data.html(result); - data.callback(html); + var formatData = result; + if ($.isFunction(data.html)) formatData = data.html(result); + data.callback(formatData); $('div.checkbox label.tooltips').tooltip(); return; } @@ -335,15 +336,10 @@ //Menus Menu = { url: '../api/Menus/', - title: "授权菜单", - html: function (result) { - return $.map(result, function (element, index) { - return $.format(htmlTemplateForMenu, element.ID, element.Name, element.Active); - }).join(''); - } + title: "授权菜单" } Menu.getMenusByRoleId = function (roleId, callback) { - processData.call(this, { Id: roleId, callback: callback, remote: false }); + processData.call(this, { Id: roleId, callback: callback, data: { type: "role" } }); }; Menu.saveMenusByRoleId = function (roleId, menuIds, callback) { processData.call(this, { Id: roleId, callback: callback, method: "PUT", data: { type: "role", menuIds: menuIds } }); diff --git a/Bootstrap.Admin/Scripts/Roles.js b/Bootstrap.Admin/Scripts/Roles.js index 75ba52bc..d8ca23dd 100644 --- a/Bootstrap.Admin/Scripts/Roles.js +++ b/Bootstrap.Admin/Scripts/Roles.js @@ -53,6 +53,13 @@ Menu.getMenusByRoleId(row.ID, function (data) { $(".menu-content .modal-header .modal-title").text($.format('{0}-菜单授权窗口', row.RoleName)); $('.menu-content button:last').data('type', 'menu'); + // set checkbox status + var menus = $('#nestable_menu').find('input:checkbox'); + menus.removeProp('checked'); + $.each(data, function (index, item) { + var selector = $.format('[value={0}]', item.ID); + menus.filter(selector).prop('checked', 'checked'); + }); $('#dialogMenu').modal('show'); $('.menu-content').show(); $('div.dd3-content :radio').hide(); diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs index 85f6ef53..a3ff16e6 100644 --- a/Bootstrap.DataAccess/MenuHelper.cs +++ b/Bootstrap.DataAccess/MenuHelper.cs @@ -166,7 +166,7 @@ namespace Bootstrap.DataAccess List