2016-10-22 20:55:07 +08:00
|
|
|
|
$(function () {
|
2016-11-18 20:49:44 +08:00
|
|
|
|
var $dialogRole = $('#dialogRole');
|
|
|
|
|
var $dialogRoleHeader = $('#myRoleModalLabel');
|
|
|
|
|
var $dialogRoleForm = $('#roleForm');
|
|
|
|
|
var $dialogGroup = $("#dialogGroup");
|
|
|
|
|
var $dialogGroupHeader = $('#myGroupModalLabel');
|
|
|
|
|
var $dialogGroupForm = $('#groupForm');
|
|
|
|
|
|
2016-10-24 19:12:22 +08:00
|
|
|
|
var bsa = new BootstrapAdmin({
|
2016-11-18 20:49:44 +08:00
|
|
|
|
url: User.url,
|
2016-10-24 20:53:05 +08:00
|
|
|
|
dataEntity: new DataEntity({
|
|
|
|
|
map: {
|
|
|
|
|
ID: "userID",
|
|
|
|
|
UserName: "userName",
|
|
|
|
|
Password: "password",
|
2016-11-17 16:36:53 +08:00
|
|
|
|
DisplayName: "displayName",
|
|
|
|
|
NewPassword: "confirm"
|
2016-10-24 20:53:05 +08:00
|
|
|
|
}
|
2016-10-25 12:16:00 +08:00
|
|
|
|
}),
|
2016-10-25 18:47:33 +08:00
|
|
|
|
click: {
|
|
|
|
|
assign: [{
|
|
|
|
|
id: 'btn_assignRole',
|
|
|
|
|
click: function (row) {
|
2016-11-18 20:49:44 +08:00
|
|
|
|
$.bc({
|
|
|
|
|
Id: row.ID, url: Role.url, data: { type: "user" }, swal: false,
|
|
|
|
|
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.DisplayName));
|
2017-01-14 16:45:12 +08:00
|
|
|
|
$dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) {
|
2016-12-26 13:16:13 +08:00
|
|
|
|
if (label.title == "") label.title = "未设置";
|
2017-01-14 16:45:12 +08:00
|
|
|
|
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } });
|
2016-11-18 20:49:44 +08:00
|
|
|
|
$dialogRole.modal('show');
|
|
|
|
|
}
|
2016-10-25 18:47:33 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
id: 'btn_assignGroup',
|
|
|
|
|
click: function (row) {
|
2016-11-18 20:49:44 +08:00
|
|
|
|
$.bc({
|
|
|
|
|
Id: row.ID, url: Group.url, data: { type: "user" }, swal: false,
|
|
|
|
|
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));
|
2017-01-14 16:45:12 +08:00
|
|
|
|
$dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) {
|
2016-12-26 13:16:13 +08:00
|
|
|
|
if (label.title == "") label.title = "未设置";
|
2017-01-14 16:45:12 +08:00
|
|
|
|
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } });
|
2016-11-18 20:49:44 +08:00
|
|
|
|
$dialogGroup.modal('show');
|
|
|
|
|
}
|
2016-10-28 21:46:48 +08:00
|
|
|
|
});
|
2016-10-25 18:47:33 +08:00
|
|
|
|
}
|
|
|
|
|
}, {
|
2016-10-31 11:13:46 +08:00
|
|
|
|
id: 'btnSubmitRole',
|
2016-10-25 18:47:33 +08:00
|
|
|
|
click: function (row) {
|
|
|
|
|
var userId = row.ID;
|
2016-11-18 20:49:44 +08:00
|
|
|
|
var roleIds = $dialogRole.find(':checked').map(function (index, element) {
|
2016-10-25 18:47:33 +08:00
|
|
|
|
return $(element).val();
|
|
|
|
|
}).toArray().join(',');
|
2016-11-18 20:49:44 +08:00
|
|
|
|
$.bc({ Id: userId, url: Role.url, method: 'PUT', data: { type: "user", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
|
2016-10-25 18:47:33 +08:00
|
|
|
|
}
|
2016-10-28 21:46:48 +08:00
|
|
|
|
}, {
|
2016-10-31 11:13:46 +08:00
|
|
|
|
id: 'btnSubmitGroup',
|
2016-10-28 21:46:48 +08:00
|
|
|
|
click: function (row) {
|
|
|
|
|
var userId = row.ID;
|
2016-11-18 20:49:44 +08:00
|
|
|
|
var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
|
2016-10-28 21:46:48 +08:00
|
|
|
|
return $(element).val();
|
|
|
|
|
}).toArray().join(',');
|
2016-11-18 20:49:44 +08:00
|
|
|
|
$.bc({ Id: userId, url: Group.url, method: 'PUT', data: { type: "user", groupIds: groupIds }, title: Group.title, modal: 'dialogGroup' });
|
2016-10-28 21:46:48 +08:00
|
|
|
|
}
|
2016-10-25 18:47:33 +08:00
|
|
|
|
}]
|
|
|
|
|
},
|
2016-11-17 16:36:53 +08:00
|
|
|
|
callback: function (data) {
|
|
|
|
|
if (data && data.success && data.oper === 'save' && data.data.ID === $('#userId').val()) {
|
|
|
|
|
$('#userDisplayName').text(data.data.DisplayName);
|
2016-10-25 12:16:00 +08:00
|
|
|
|
}
|
2016-12-22 19:16:28 +08:00
|
|
|
|
if (data && data.oper === 'create') {
|
2016-12-23 13:53:19 +08:00
|
|
|
|
$('#userName').prop('readonly', false).removeClass("ignore");
|
2016-12-22 19:16:28 +08:00
|
|
|
|
}
|
|
|
|
|
else if (data && data.oper === 'edit') {
|
|
|
|
|
$('#userName').prop('readonly', true).addClass("ignore");
|
|
|
|
|
}
|
2016-10-25 12:16:00 +08:00
|
|
|
|
}
|
2016-10-22 20:55:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
2016-10-24 10:11:38 +08:00
|
|
|
|
$('table').smartTable({
|
2016-11-18 20:49:44 +08:00
|
|
|
|
url: User.url, //请求后台的URL(*)
|
|
|
|
|
sortName: 'DisplayName',
|
2016-10-24 20:53:05 +08:00
|
|
|
|
queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), displayName: $('#txt_display_name').val() }); }, //传递参数(*)
|
2016-10-22 20:55:07 +08:00
|
|
|
|
columns: [{ checkbox: true },
|
2016-10-24 19:12:22 +08:00
|
|
|
|
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
|
2016-10-24 20:53:05 +08:00
|
|
|
|
{ title: "登陆名称", field: "UserName", sortable: true },
|
2016-11-18 20:49:44 +08:00
|
|
|
|
{ title: "显示名称", field: "DisplayName", sortable: true }
|
2016-10-22 20:55:07 +08:00
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// validate
|
|
|
|
|
$('#dataForm').autoValidate({
|
|
|
|
|
userName: {
|
|
|
|
|
required: true,
|
2016-11-27 14:21:21 +08:00
|
|
|
|
maxlength: 50,
|
|
|
|
|
remote: {
|
|
|
|
|
url: "../api/Users/",
|
|
|
|
|
type: "PUT",
|
|
|
|
|
data: {
|
|
|
|
|
UserStatus: 9
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-22 20:55:07 +08:00
|
|
|
|
},
|
|
|
|
|
password: {
|
|
|
|
|
required: true,
|
|
|
|
|
maxlength: 50
|
|
|
|
|
},
|
|
|
|
|
confirm: {
|
|
|
|
|
required: true,
|
|
|
|
|
equalTo: "#password"
|
2016-10-24 13:35:58 +08:00
|
|
|
|
},
|
|
|
|
|
displayName: {
|
|
|
|
|
required: true,
|
|
|
|
|
maxlength: 50
|
2016-10-22 20:55:07 +08:00
|
|
|
|
}
|
2016-11-27 14:21:21 +08:00
|
|
|
|
}, {
|
|
|
|
|
userName: {
|
|
|
|
|
remote: "此登陆名称已存在"
|
|
|
|
|
}
|
2016-10-22 20:55:07 +08:00
|
|
|
|
});
|
|
|
|
|
});
|