2016-10-22 20:55:07 +08:00
|
|
|
|
$(function () {
|
2016-10-24 19:12:22 +08:00
|
|
|
|
var bsa = new BootstrapAdmin({
|
2016-10-22 20:55:07 +08:00
|
|
|
|
url: '../api/Users',
|
2016-10-24 20:53:05 +08:00
|
|
|
|
dataEntity: new DataEntity({
|
|
|
|
|
map: {
|
|
|
|
|
ID: "userID",
|
|
|
|
|
UserName: "userName",
|
|
|
|
|
Password: "password",
|
|
|
|
|
DisplayName: "displayName"
|
|
|
|
|
}
|
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-10-28 14:45:09 +08:00
|
|
|
|
Role.getRolesByUserId(row.ID, function (data) {
|
2016-10-25 18:47:33 +08:00
|
|
|
|
$("#dialogRole .modal-title").text($.format('{0}-角色授权窗口', row.DisplayName));
|
|
|
|
|
$('#dialogRole form').html(data);
|
|
|
|
|
$('#dialogRole').modal('show');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
id: 'btn_assignGroup',
|
|
|
|
|
click: function (row) {
|
2016-10-28 21:46:48 +08:00
|
|
|
|
Group.getGroupsByUserId(row.ID, function (data) {
|
|
|
|
|
$("#dialogGroup .modal-title").text($.format('{0}-部门授权窗口', row.DisplayName));
|
|
|
|
|
$('#dialogGroup form').html(data);
|
|
|
|
|
$('#dialogGroup').modal('show');
|
|
|
|
|
});
|
2016-10-25 18:47:33 +08:00
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
id: 'btnSubmitUserRole',
|
|
|
|
|
click: function (row) {
|
|
|
|
|
var userId = row.ID;
|
|
|
|
|
var roleIds = $('#dialogRole :checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
|
|
|
|
}).toArray().join(',');
|
2016-10-28 21:26:13 +08:00
|
|
|
|
Role.saveRolesByUserId(userId, roleIds, { modal: 'dialogRole' });
|
2016-10-25 18:47:33 +08:00
|
|
|
|
}
|
2016-10-28 21:46:48 +08:00
|
|
|
|
}, {
|
|
|
|
|
id: 'btnSubmitUserGroup',
|
|
|
|
|
click: function (row) {
|
|
|
|
|
var userId = row.ID;
|
|
|
|
|
var groupIds = $('#dialogGroup :checked').map(function (index, element) {
|
|
|
|
|
return $(element).val();
|
|
|
|
|
}).toArray().join(',');
|
|
|
|
|
Group.saveGroupsByUserId(userId, groupIds, { modal: 'dialogGroup' });
|
|
|
|
|
}
|
2016-10-25 18:47:33 +08:00
|
|
|
|
}]
|
|
|
|
|
},
|
2016-10-25 12:16:00 +08:00
|
|
|
|
success: function (src, data) {
|
|
|
|
|
if (src === 'save' && data.ID === $('#userId').val()) {
|
|
|
|
|
$('.username').text(data.DisplayName);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-22 20:55:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
2016-10-24 10:11:38 +08:00
|
|
|
|
$('table').smartTable({
|
2016-10-22 20:55:07 +08:00
|
|
|
|
url: '../api/Users', //请求后台的URL(*)
|
|
|
|
|
sortName: 'UserName',
|
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 },
|
|
|
|
|
{ title: "显示名称", field: "DisplayName", sortable: false }
|
2016-10-22 20:55:07 +08:00
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// validate
|
|
|
|
|
$('#dataForm').autoValidate({
|
|
|
|
|
userName: {
|
|
|
|
|
required: true,
|
|
|
|
|
maxlength: 50
|
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|