142 lines
5.5 KiB
JavaScript
142 lines
5.5 KiB
JavaScript
var example = null;
|
||
var pers = null;
|
||
var layer, form
|
||
$(function () {
|
||
layui.use(['layer', 'form'], function () {
|
||
layer = layui.layer;
|
||
form = layui.form;
|
||
pers = checkPermission();
|
||
$("#searchBt").click(function(){
|
||
example.ajax.reload();
|
||
});
|
||
init();
|
||
});
|
||
});
|
||
|
||
function init() {
|
||
example =
|
||
$('#dt-table').DataTable({
|
||
"searching": false,
|
||
"processing": true, //加载数据时显示进度状态
|
||
"serverSide": true,
|
||
"language": {
|
||
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
|
||
},
|
||
"ajax": {
|
||
"url": ctxPath + "/WorkerDepartFaceContrast/getFaceChangeList",
|
||
"type": "get",
|
||
"data": function (d) {
|
||
d.name = $("#name").val();
|
||
d.idNumber = $("#idNumber").val();
|
||
},
|
||
"error": function (xhr, textStatus, errorThrown) {
|
||
var msg = xhr.responseText;
|
||
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 = ctxPath + '/login.html';
|
||
});
|
||
} else if (code == 403) {
|
||
console.log("未授权:" + message);
|
||
layer.msg('未授权');
|
||
} else if (code == 500) {
|
||
console.log('系统错误:' + message);
|
||
}
|
||
}
|
||
},
|
||
"drawCallback": function() {
|
||
|
||
var thisDataTable = $('#dt-table').DataTable();
|
||
$(".pagination").append("<li>" +
|
||
"<a class='paginate_button' style='padding:4px;' href='#' tabindex='0'>到 <input style='margin:0px;width:40px;' id='changePage'> 页</a>" +
|
||
"<a class='paginate_button' style='margin-bottom:1px' href='#' tabindex='0' id='dataTable-btn'>确认</a></li>");
|
||
//点击按钮跳转指定页数
|
||
$('#dataTable-btn').click(function (e) {
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
});
|
||
//敲击回车键跳转指定页数
|
||
$("#changePage").keypress(function (e) {
|
||
if(event.keyCode==13){
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
}
|
||
});
|
||
},
|
||
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-4 col-xs-4 hidden-xs'i><'col-xs-8 col-sm-8' p v>>",
|
||
"columns": [
|
||
{
|
||
width: '5%',
|
||
"orderable": false,
|
||
data: function (row, type, set, meta) {
|
||
var c = meta.settings._iDisplayStart + meta.row + 1;
|
||
return c;
|
||
}
|
||
},
|
||
{"data": "name",width: '6%'},
|
||
{"data": "idNumber",width: '8%'},
|
||
{"data": "createTime",width: '6%'},
|
||
{"data": "state",width: '10%'},
|
||
{"data": "opinion",width: '10%'},
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",width: '5%',
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var workerId = row['workerId'];
|
||
var filePath = row['filePath'];
|
||
var yzpPath = row['yzpPath'];
|
||
var state = row['state'];
|
||
var html = '';
|
||
if(state =="待审核"){
|
||
html += buttonView(id,workerId,filePath,yzpPath);
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
|
||
],
|
||
"order": [[1, "desc"], [2, "desc"], [3, "desc"], [4, "desc"], [5, "desc"]] //在栏目列上显示排序功能
|
||
});
|
||
}
|
||
|
||
|
||
/**
|
||
* 查看
|
||
* */
|
||
function view(id,workerId,filePath,yzpPath) {
|
||
localStorage.setItem("id", id);
|
||
localStorage.setItem("filePath", dataPath +"/"+ filePath);
|
||
localStorage.setItem('yzpPath',dataPath +"/"+ yzpPath)
|
||
var index = layer.open({
|
||
title: false,
|
||
type: 2,
|
||
content: 'faceChangeExam.html',
|
||
area: ['700px', '500px'],
|
||
maxmin: false,
|
||
});
|
||
}
|
||
|
||
|
||
// 详情按钮
|
||
function buttonView(id,workerId,filePath,yzpPath) {
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='view(\"" + id + "\",\"" + workerId + "\",\"" + filePath + "\",\"" + yzpPath + "\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
|
||
|