BootstrapAdmin/Bootstrap.Admin/Scripts/Groups.js

70 lines
2.8 KiB
JavaScript
Raw Normal View History

$(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-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) {
$("#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
}
}, {
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
}, {
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
}
}]
}
});
$('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 },
{ title: "部门描述", field: "Description", sortable: false }
]
});
// validate
$('#dataForm').autoValidate({
groupName: {
required: true,
maxlength: 50
}
});
});