BootstrapAdmin/Bootstrap.Admin/wwwroot/js/groups.js

87 lines
4.2 KiB
JavaScript
Raw Normal View History

2018-06-07 00:45:47 +08:00
$(function () {
var $dialogUser = $("#dialogUser");
var $dialogUserHeader = $('#myUserModalLabel');
var $dialogUserForm = $('#userForm');
var $dialogRole = $('#dialogRole');
var $dialogRoleHeader = $('#myRoleModalLabel');
var $dialogRoleForm = $('#roleForm');
var bsa = new BootstrapAdmin({
url: Group.url,
dataEntity: new DataEntity({
map: {
Id: "groupID",
GroupName: "groupName",
Description: "groupDesc"
}
}),
click: {
assign: [{
id: 'btn_assignRole',
click: function (row) {
$.bc({
2018-06-07 14:39:45 +08:00
id: row.Id, url: Role.url, data: { type: "group" }, swal: false,
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.RoleName, element.Checked, element.Description);
}).join('')
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName));
$dialogRoleForm.html(html).find('[data-toggle="tooltip"]').each(function (index, label) {
2018-06-07 00:45:47 +08:00
if (label.title == "") label.title = "未设置";
2018-08-03 18:12:35 +08:00
}).tooltip();
2018-06-07 00:45:47 +08:00
$dialogRole.modal('show');
}
});
}
}, {
id: 'btn_assignUser',
click: function (row) {
$.bc({
2018-06-07 14:39:45 +08:00
id: row.Id, url: User.url, data: { type: "group" }, swal: false,
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.GroupName));
$dialogUserForm.html(html).find('[data-toggle="tooltip"]').each(function (index, label) {
2018-06-07 00:45:47 +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');
}
});
}
}, {
id: 'btnSubmitRole',
click: function (row) {
var groupId = row.Id;
var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
2018-06-08 20:13:52 +08:00
$.bc({ id: groupId, url: Role.url, method: "PUT", data: { type: "group", roleIds: roleIds }, title: Role.title, modal: '#dialogRole' });
2018-06-07 00:45:47 +08:00
}
}, {
id: 'btnSubmitUser',
click: function (row) {
var groupId = row.Id;
var userIds = $dialogUser.find(':checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
2018-06-08 20:13:52 +08:00
$.bc({ id: groupId, url: User.url, method: "PUT", data: { type: "group", userIds: userIds }, title: User.title, modal: '#dialogUser' });
2018-06-07 00:45:47 +08:00
}
}]
}
});
$('table').smartTable({
url: Group.url, //请求后台的URL*
sortName: 'GroupName',
queryParams: function (params) { return $.extend(params, { groupName: $("#txt_search_name").val(), description: $("#txt_group_desc").val() }); }, //传递参数(*
columns: [{ checkbox: true },
{ title: "编辑", field: "Id", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "部门名称", field: "GroupName", sortable: true },
{ title: "部门描述", field: "Description", sortable: false }
2018-06-07 00:45:47 +08:00
]
});
});