优化角色相关脚本代码
This commit is contained in:
parent
dbcf7899cf
commit
8164f816c8
|
@ -1,4 +1,13 @@
|
|||
$(function () {
|
||||
var $dialogUser = $("#dialogUser");
|
||||
var $dialogGroup = $("#dialogGroup");
|
||||
var $dialogMenu = $('#dialogMenu');
|
||||
var $dialogSubMenu = $('#dialogSubMenu').find('.modal-content');
|
||||
var $btnSubmitMenu = $('#btnSubmitMenu');
|
||||
var $nestMenu = $('#nestable_menu');
|
||||
var $nestMenuInput = $nestMenu.find('div.dd3-content');
|
||||
$nestMenuInput.find('label:last').hide();
|
||||
|
||||
var bsa = new BootstrapAdmin({
|
||||
url: '../api/Roles',
|
||||
dataEntity: new DataEntity({
|
||||
|
@ -13,25 +22,25 @@
|
|||
id: 'btn_assignUser',
|
||||
click: function (row) {
|
||||
User.getUsersByRoleId(row.ID, function (data) {
|
||||
$("#dialogUser .modal-title").text($.format('{0}-用户授权窗口', row.RoleName));
|
||||
$('#dialogUser form').html(data);
|
||||
$('#dialogUser').modal('show');
|
||||
$dialogUser.find("div.modal-header").find('h4').text($.format('{0}-用户授权窗口', row.RoleName));
|
||||
$dialogUser.find('form').html(data);
|
||||
$dialogUser.modal('show');
|
||||
})
|
||||
}
|
||||
}, {
|
||||
id: 'btn_assignGroup',
|
||||
click: function (row) {
|
||||
Group.getGroupsByRoleId(row.ID, function (data) {
|
||||
$("#dialogGroup .modal-title").text($.format('{0}-部门授权窗口', row.RoleName));
|
||||
$('#dialogGroup form').html(data);
|
||||
$('#dialogGroup').modal('show');
|
||||
$dialogGroup.find("div.modal-header").find("h4").text($.format('{0}-部门授权窗口', row.RoleName));
|
||||
$dialogGroup.find('form').html(data);
|
||||
$dialogGroup.modal('show');
|
||||
})
|
||||
}
|
||||
}, {
|
||||
id: 'btnSubmitUser',
|
||||
click: function (row) {
|
||||
var roleId = row.ID;
|
||||
var userIds = $('#dialogUser :checked').map(function (index, element) {
|
||||
var userIds = $dialogUser.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
User.saveUsersByRoleId(roleId, userIds, { modal: 'dialogUser' });
|
||||
|
@ -41,7 +50,7 @@
|
|||
id: 'btnSubmitGroup',
|
||||
click: function (row) {
|
||||
var roleId = row.ID;
|
||||
var groupIds = $('#dialogGroup :checked').map(function (index, element) {
|
||||
var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
Group.saveGroupsByRoleId(roleId, groupIds, { modal: 'dialogGroup' });
|
||||
|
@ -51,17 +60,17 @@
|
|||
id: 'btn_assignMenu',
|
||||
click: function (row) {
|
||||
Menu.getMenusByRoleId(row.ID, function (data) {
|
||||
$(".menu-content .modal-header .modal-title").text($.format('{0}-菜单授权窗口', row.RoleName));
|
||||
$('.menu-content button:last').data('type', 'menu');
|
||||
$dialogSubMenu.find("div.modal-header").find('h4').text($.format('{0}-菜单授权窗口', row.RoleName));
|
||||
$btnSubmitMenu.data('type', 'menu');
|
||||
// set checkbox status
|
||||
var menus = $('#nestable_menu').find('input:checkbox');
|
||||
var menus = $nestMenu.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();
|
||||
$dialogSubMenu.show();
|
||||
$dialogMenu.modal('show');
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -69,10 +78,10 @@
|
|||
id: 'btnSubmitMenu',
|
||||
click: function (row) {
|
||||
var roleId = row.ID;
|
||||
var type = $('.menu-content button:last').data('type');
|
||||
var type = $btnSubmitMenu.data('type');
|
||||
switch (type) {
|
||||
case "menu":
|
||||
var menuIds = $('.dd3-content :checkbox:checked').map(function (index, element) {
|
||||
var menuIds = $nestMenuInput.find('input:checkbox:checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
break;
|
||||
|
@ -85,10 +94,6 @@
|
|||
}
|
||||
});
|
||||
|
||||
var $nestMenu = $('#nestable_menu');
|
||||
var $nestMenuInput = $nestMenu.find('div.dd3-content');
|
||||
$nestMenuInput.find('label:last').hide();
|
||||
|
||||
$nestMenu.nestable();
|
||||
|
||||
$('table').smartTable({
|
||||
|
|
Loading…
Reference in New Issue