2016-10-24 20:53:05 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
var bsa = new BootstrapAdmin({
|
|
|
|
|
url: '../api/Groups',
|
|
|
|
|
dataEntity: new DataEntity({
|
|
|
|
|
map: {
|
|
|
|
|
ID: "groupID",
|
|
|
|
|
GroupName: "groupName",
|
2016-11-10 00:47:42 +08:00
|
|
|
|
Description: "groupDesc"
|
2016-10-24 20:53:05 +08:00
|
|
|
|
}
|
2016-10-27 17:56:00 +08:00
|
|
|
|
}),
|
|
|
|
|
click: {
|
|
|
|
|
assign: [{
|
|
|
|
|
id: 'btn_assignRole',
|
|
|
|
|
click: function (row) {
|
|
|
|
|
Role.getRolesByGroupId(row.ID, function (data) {
|
|
|
|
|
$("#dialogRole .modal-title").text($.format('{0}-角色授权窗口', row.GroupName));
|
|
|
|
|
$('#dialogRole form').html(data);
|
|
|
|
|
$('#dialogRole').modal('show');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
2016-10-29 17:38:23 +08:00
|
|
|
|
id: 'btn_assignUser',
|
2016-10-27 17:56:00 +08:00
|
|
|
|
click: function (row) {
|
2016-10-29 17:38:23 +08:00
|
|
|
|
User.getUsersByGroupeId(row.ID, function (data) {
|
2016-10-31 15:55:31 +08:00
|
|
|
|
$("#dialogUser .modal-title").text($.format('{0}-用户授权窗口', row.GroupName));
|
2016-10-29 17:38:23 +08:00
|
|
|
|
$('#dialogUser form').html(data);
|
|
|
|
|
$('#dialogUser').modal('show');
|
|
|
|
|
});
|
2016-10-27 17:56:00 +08:00
|
|
|
|
}
|
|
|
|
|
}, {
|
2016-10-31 11:13:46 +08:00
|
|
|
|
id: 'btnSubmitRole',
|
2016-10-27 17:56:00 +08:00
|
|
|
|
click: function (row) {
|
2016-10-29 17:38:23 +08:00
|
|
|
|
var groupId = row.ID;
|
2016-10-27 17:56:00 +08:00
|
|
|
|
var roleIds = $('#dialogRole :checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
|
|
|
|
}).toArray().join(',');
|
2016-10-29 17:38:23 +08:00
|
|
|
|
Role.saveRolesByGroupId(groupId, roleIds, { modal: 'dialogRole' });
|
|
|
|
|
}
|
2016-11-10 00:47:42 +08:00
|
|
|
|
}, {
|
2016-10-31 11:13:46 +08:00
|
|
|
|
id: 'btnSubmitUser',
|
2016-10-29 17:38:23 +08:00
|
|
|
|
click: function (row) {
|
|
|
|
|
var groupId = row.ID;
|
|
|
|
|
var userIds = $('#dialogUser :checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
|
|
|
|
}).toArray().join(',');
|
|
|
|
|
User.saveUsersByGroupId(groupId, userIds, { modal: 'dialogUser' });
|
2016-10-27 17:56:00 +08:00
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
}
|
2016-10-24 20:53:05 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('table').smartTable({
|
|
|
|
|
url: '../api/Groups', //请求后台的URL(*)
|
|
|
|
|
sortName: 'GroupName',
|
|
|
|
|
queryParams: function (params) { return $.extend(params, { groupName: $("#txt_search_name").val(), description: $("#txt_group_desc").val() }); }, //传递参数(*)
|
|
|
|
|
columns: [{ checkbox: true },
|
|
|
|
|
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
|
|
|
|
|
{ title: "部门名称", field: "GroupName", sortable: true },
|
2016-10-24 22:10:17 +08:00
|
|
|
|
{ title: "部门描述", field: "Description", sortable: false }
|
2016-10-24 20:53:05 +08:00
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// validate
|
|
|
|
|
$('#dataForm').autoValidate({
|
|
|
|
|
groupName: {
|
|
|
|
|
required: true,
|
|
|
|
|
maxlength: 50
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|