2025-11-27 16:55:35 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
|
init();
|
|
|
|
|
|
})
|
|
|
|
|
|
layui.use([ 'layer' ], function() {
|
|
|
|
|
|
var layer = layui.layer;
|
|
|
|
|
|
});
|
|
|
|
|
|
var userStatus = showDictSelect("status", "userStatus", true);
|
|
|
|
|
|
|
|
|
|
|
|
var pers = checkPermission();
|
|
|
|
|
|
|
|
|
|
|
|
var example;
|
|
|
|
|
|
function init(){
|
|
|
|
|
|
example =
|
|
|
|
|
|
$('#dt-table').DataTable({
|
|
|
|
|
|
"searching": false,
|
|
|
|
|
|
"processing": false,
|
|
|
|
|
|
"serverSide" : true,
|
|
|
|
|
|
"language": {
|
2025-12-02 14:22:34 +08:00
|
|
|
|
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
|
2025-11-27 16:55:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
"ajax": {
|
|
|
|
|
|
"url" : ctxPath + "/users",
|
|
|
|
|
|
"type":"get",
|
|
|
|
|
|
"data":function(d){
|
|
|
|
|
|
d.username = $('#username').val();
|
|
|
|
|
|
d.nickname = $('#nickname').val();
|
|
|
|
|
|
d.status = $('#status').val();
|
|
|
|
|
|
},
|
|
|
|
|
|
"error":function(xhr, textStatus, errorThrown){
|
|
|
|
|
|
var msg = xhr.responseText;
|
|
|
|
|
|
console.log(msg);
|
|
|
|
|
|
var response = JSON.parse(msg);
|
|
|
|
|
|
var code = response.code;
|
|
|
|
|
|
var message = response.message;
|
|
|
|
|
|
if (code == 400) {
|
|
|
|
|
|
layer.msg(message);
|
|
|
|
|
|
} else if (code == 401) {
|
|
|
|
|
|
localStorage.removeItem("token");
|
|
|
|
|
|
layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function(){
|
|
|
|
|
|
location.href = '/login.html';
|
|
|
|
|
|
});
|
|
|
|
|
|
} else if (code == 403) {
|
|
|
|
|
|
console.log("未授权:" + message);
|
|
|
|
|
|
layer.msg('未授权');
|
|
|
|
|
|
} else if (code == 500) {
|
|
|
|
|
|
layer.msg('系统错误:' + message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
|
|
|
|
|
|
"columns": [
|
|
|
|
|
|
{ "data": "username", "defaultContent": ""},
|
|
|
|
|
|
{ "data": "phone", "defaultContent": ""},
|
|
|
|
|
|
{ "data": "email", "defaultContent": ""},
|
|
|
|
|
|
{
|
|
|
|
|
|
"data": "status",
|
|
|
|
|
|
"defaultContent": "",
|
|
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
|
|
return userStatus[data];
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"data": "",
|
|
|
|
|
|
"defaultContent": "",
|
|
|
|
|
|
"orderable":false,
|
|
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
|
|
var id = row['id'];
|
|
|
|
|
|
var href = "updateUser.html?id=" + id;
|
|
|
|
|
|
var edit = buttonEdit(href, "", pers);
|
|
|
|
|
|
return edit;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
"order": [[ 0, "desc" ],[1, "asc"]]
|
|
|
|
|
|
} );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$("#searchBt").click(function(){
|
|
|
|
|
|
example.ajax.reload();
|
|
|
|
|
|
});
|