$(function () {
var $btnRefreshUser = $('#refreshUsers');
var htmlNewUsersHeader = '
';
var htmlNewUsers = '';
function listData() {
$btnRefreshUser.toggleClass('fa-spin');
var $taskUsers = $('#tasks-users');
$taskUsers.html(htmlNewUsersHeader);
$.bc({
Id: 'newusers', url: Notifications.url, method: 'GET', swal: false,
callback: function (result) {
if (result) {
var content = result.Users.map(function (noti) {
return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.Id, noti.DisplayName);
}).join('');
$taskUsers.append(content);
$('#tasks-users').find('[role="tooltip"]').tooltip();
}
$btnRefreshUser.toggleClass('fa-spin');
}
});
}
listData();
$btnRefreshUser.tooltip().on('click', function () {
listData();
});
$('#tasks-users').on('click', 'button', function () {
var id = $(this).attr('data-id');
var result = $(this).attr('data-result');
$.bc({
Id: id, url: User.url, method: "PUT", data: { type: "user", userIds: result }, title: result == "1" ? "授权用户" : "拒绝用户",
callback: function (result) {
listData({ ctl: $('#refreshUsers') });
}
});
});
});