hn_cloud_web/smz-web/js/user/user.js

81 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$(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": {
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
},
"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();
});