2018-06-07 00:45:47 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
var $dialogRole = $('#dialogRole');
|
|
|
|
|
var $dialogRoleHeader = $('#myRoleModalLabel');
|
|
|
|
|
var $dialogRoleForm = $('#roleForm');
|
|
|
|
|
var $dialogGroup = $("#dialogGroup");
|
|
|
|
|
var $dialogGroupHeader = $('#myGroupModalLabel');
|
|
|
|
|
var $dialogGroupForm = $('#groupForm');
|
|
|
|
|
|
2018-09-02 00:50:13 +08:00
|
|
|
|
$('table').lgbTable({
|
2018-06-07 00:45:47 +08:00
|
|
|
|
url: User.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: "#userID",
|
|
|
|
|
UserName: "#userName",
|
|
|
|
|
Password: "#password",
|
|
|
|
|
DisplayName: "#displayName",
|
|
|
|
|
NewPassword: "#confirm"
|
|
|
|
|
},
|
|
|
|
|
events: {
|
|
|
|
|
'#btn_assignRole': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$.bc({
|
2018-09-13 19:21:35 +08:00
|
|
|
|
id: row.Id, url: Role.url, query: { type: "user" }, 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.RoleName, element.Checked, element.Description);
|
2018-09-02 00:50:13 +08:00
|
|
|
|
}).join('');
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName));
|
2018-08-03 19:40:01 +08:00
|
|
|
|
$dialogRoleForm.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
|
|
|
|
$dialogRole.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: "user" }, 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.DisplayName));
|
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
|
|
|
|
},
|
|
|
|
|
'#btnSubmitRole': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
var userId = row.Id;
|
|
|
|
|
var roleIds = $dialogRole.find(':checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
2018-09-13 19:21:35 +08:00
|
|
|
|
}).toArray();
|
|
|
|
|
$.bc({ id: userId, url: Role.url, method: 'put', data: roleIds, query: { type: "user" }, title: Role.title, modal: '#dialogRole' });
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
'#btnSubmitGroup': function (row) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
var userId = 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: userId, url: Group.url, method: 'put', data: groupIds, query: { type: "user" }, title: Group.title, modal: '#dialogGroup' });
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
callback: function (data) {
|
|
|
|
|
if (data && data.success && data.oper === 'save' && data.data.UserName === $('#userDisplayName').attr('data-userName')) {
|
|
|
|
|
$('#userDisplayName').text(data.data.DisplayName);
|
|
|
|
|
}
|
|
|
|
|
if (data && data.oper === 'create') {
|
|
|
|
|
$('#userName').prop('readonly', false).removeClass("ignore");
|
|
|
|
|
}
|
|
|
|
|
else if (data && data.oper === 'edit') {
|
|
|
|
|
$('#userName').prop('readonly', true).addClass("ignore");
|
|
|
|
|
}
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
2018-09-02 00:50:13 +08:00
|
|
|
|
},
|
|
|
|
|
smartTable: {
|
|
|
|
|
sortName: 'DisplayName',
|
|
|
|
|
sortOrder: "asc",
|
|
|
|
|
queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), displayName: $('#txt_display_name').val() }); }, //传递参数(*)
|
|
|
|
|
columns: [
|
|
|
|
|
{ title: "登陆名称", field: "UserName", sortable: true },
|
|
|
|
|
{ title: "显示名称", field: "DisplayName", sortable: true },
|
|
|
|
|
{ title: "注册时间", field: "RegisterTime", sortable: true },
|
|
|
|
|
{ title: "授权时间", field: "ApprovedTime", sortable: true },
|
|
|
|
|
{ title: "授权人", field: "ApprovedBy", sortable: true },
|
|
|
|
|
{ title: "说明", field: "Description", sortable: false }
|
|
|
|
|
]
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2016-10-22 20:55:07 +08:00
|
|
|
|
});
|