2018-06-07 00:45:47 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
var $dialogUser = $("#dialogUser");
|
|
|
|
|
var $dialogUserHeader = $('#myUserModalLabel');
|
|
|
|
|
var $dialogUserForm = $('#userForm');
|
|
|
|
|
var $dialogGroup = $("#dialogGroup");
|
|
|
|
|
var $dialogGroupHeader = $('#myGroupModalLabel');
|
|
|
|
|
var $dialogGroupForm = $('#groupForm');
|
|
|
|
|
var $dialogMenu = $('#dialogMenu');
|
|
|
|
|
var $dialogMenuHeader = $('#myMenuModalLabel');
|
|
|
|
|
var $dialogSubMenu = $('#dialogSubMenu').find('.modal-content');
|
|
|
|
|
var $btnSubmitMenu = $('#btnSubmitMenu');
|
|
|
|
|
var $nestMenu = $('#nestable_menu');
|
|
|
|
|
var $nestMenuInput = $nestMenu.find('div.dd3-content');
|
|
|
|
|
|
2018-09-02 00:50:13 +08:00
|
|
|
|
$('table').lgbTable({
|
2018-06-07 00:45:47 +08:00
|
|
|
|
url: Role.url,
|
2018-09-02 00:50:13 +08:00
|
|
|
|
dataBinder: {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
map: {
|
2018-09-02 00:50:13 +08:00
|
|
|
|
Id: "#roleID",
|
|
|
|
|
RoleName: "#roleName",
|
|
|
|
|
Description: "#roleDesc"
|
|
|
|
|
},
|
|
|
|
|
events: {
|
|
|
|
|
'#btn_assignUser': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$.bc({
|
2018-09-13 19:21:35 +08:00
|
|
|
|
id: row.Id, url: User.url, query: { type: "role" }, method: "post",
|
2018-06-07 00:45:47 +08:00
|
|
|
|
callback: function (result) {
|
|
|
|
|
var htmlTemplate = this.htmlTemplate;
|
|
|
|
|
var html = $.map(result, function (element, index) {
|
|
|
|
|
return $.format(htmlTemplate, element.Id, element.DisplayName, element.Checked, element.UserName);
|
|
|
|
|
}).join('');
|
|
|
|
|
$dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName));
|
2018-08-03 19:40:01 +08:00
|
|
|
|
$dialogUserForm.html(html).find('[data-toggle="tooltip"]').each(function (index, label) {
|
2018-09-02 00:50:13 +08:00
|
|
|
|
if (label.title === "") label.title = "未设置";
|
2018-08-03 18:12:35 +08:00
|
|
|
|
}).tooltip();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$dialogUser.modal('show');
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
'#btn_assignGroup': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$.bc({
|
2018-09-13 19:21:35 +08:00
|
|
|
|
id: row.Id, url: Group.url, query: { type: "role" }, method: "post",
|
2018-06-07 00:45:47 +08:00
|
|
|
|
callback: function (result) {
|
|
|
|
|
var htmlTemplate = this.htmlTemplate;
|
|
|
|
|
var html = $.map(result, function (element, index) {
|
|
|
|
|
return $.format(htmlTemplate, element.Id, element.GroupName, element.Checked, element.Description);
|
|
|
|
|
}).join('');
|
|
|
|
|
$dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName));
|
2018-08-03 19:40:01 +08:00
|
|
|
|
$dialogGroupForm.html(html).find('[data-toggle="tooltip"]').each(function (index, label) {
|
2018-09-02 00:50:13 +08:00
|
|
|
|
if (label.title === "") label.title = "未设置";
|
2018-08-03 18:12:35 +08:00
|
|
|
|
}).tooltip();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$dialogGroup.modal('show');
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
'#btn_assignMenu': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$.bc({
|
2018-09-13 19:21:35 +08:00
|
|
|
|
id: row.Id, url: Menu.url, query: { type: "role" }, method: "post",
|
2018-06-07 00:45:47 +08:00
|
|
|
|
callback: function (result) {
|
|
|
|
|
$dialogMenuHeader.text($.format('{0}-菜单授权窗口', row.RoleName));
|
|
|
|
|
$btnSubmitMenu.data('type', 'menu');
|
|
|
|
|
// set checkbox status
|
|
|
|
|
var menus = $nestMenu.find('input:checkbox');
|
2018-09-09 01:59:43 +08:00
|
|
|
|
menus.attr('checked', false);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$.each(result, function (index, item) {
|
|
|
|
|
var selector = $.format('[value={0}]', item.Id);
|
2018-09-09 01:59:43 +08:00
|
|
|
|
menus.filter(selector).attr('checked', true);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
});
|
|
|
|
|
$dialogSubMenu.show();
|
|
|
|
|
$dialogMenu.modal('show');
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
'#btnSubmitUser': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
var roleId = row.Id;
|
|
|
|
|
var userIds = $dialogUser.find(':checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
2018-09-13 19:21:35 +08:00
|
|
|
|
}).toArray();
|
|
|
|
|
$.bc({ id: roleId, url: User.url, method: "put", data: userIds, query: { type: "role" }, modal: '#dialogUser', title: User.title });
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
'#btnSubmitGroup': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
var roleId = row.Id;
|
|
|
|
|
var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
2018-09-13 19:21:35 +08:00
|
|
|
|
}).toArray();
|
|
|
|
|
$.bc({ id: roleId, url: Group.url, method: "put", data: groupIds, query: { type: "role" }, modal: '#dialogGroup', title: Group.title });
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
'#btnSubmitMenu': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
var roleId = row.Id;
|
2018-09-13 17:55:24 +08:00
|
|
|
|
var menuIds = $nestMenuInput.find('input:checkbox:checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
|
|
|
|
}).toArray();
|
|
|
|
|
$.bc({ id: roleId, url: Menu.url, method: "put", data: menuIds, modal: '#dialogMenu', title: Menu.title });
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
2018-09-02 00:50:13 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
smartTable: {
|
|
|
|
|
sortName: 'RoleName',
|
|
|
|
|
queryParams: function (params) { return $.extend(params, { roleName: $("#txt_search_name").val(), description: $("#txt_role_desc").val() }); }, //传递参数(*)
|
|
|
|
|
columns: [
|
|
|
|
|
{ title: "角色名称", field: "RoleName", sortable: true },
|
|
|
|
|
{ title: "角色描述", field: "Description", sortable: false }
|
|
|
|
|
]
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|
}
|
|
|
|
|
}).children('.radio').hide();
|
|
|
|
|
});
|
2016-10-24 22:10:17 +08:00
|
|
|
|
});
|