227 lines
9.0 KiB
JavaScript
227 lines
9.0 KiB
JavaScript
|
|
var example = null;
|
|||
|
|
var pers = null;
|
|||
|
|
$(function () {
|
|||
|
|
layui.use(['layer'], function () {
|
|||
|
|
var layer = layui.layer;
|
|||
|
|
});
|
|||
|
|
pers = checkPermission();
|
|||
|
|
init();
|
|||
|
|
$("#searchBt").click(function () {
|
|||
|
|
example.ajax.reload();
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
function init() {
|
|||
|
|
example =
|
|||
|
|
$('#dt-table').DataTable({
|
|||
|
|
"sort": false,
|
|||
|
|
"searching": false,
|
|||
|
|
"processing": true, //加载数据时显示进度状态
|
|||
|
|
"serverSide": true,
|
|||
|
|
"pagingType": "full_numbers", //首页|尾页
|
|||
|
|
"language": {
|
|||
|
|
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
|
|||
|
|
},
|
|||
|
|
"ajax": {
|
|||
|
|
"url": ctxPath + "/migrant/getWorkInfoReleaseList",
|
|||
|
|
"type": "post",
|
|||
|
|
"data": function (d) {
|
|||
|
|
d.keyWord = $("#keyWord").val();
|
|||
|
|
d.auditResult = $("#auditResult").val();
|
|||
|
|
d.isOnline = $("#isOnline").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() {
|
|||
|
|
// alert( '表格重绘了' );
|
|||
|
|
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: '40px',
|
|||
|
|
data: function (row, type, set, meta) {
|
|||
|
|
var c = meta.settings._iDisplayStart + meta.row + 1;
|
|||
|
|
return c;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{"data": "number",'width': '40px'},
|
|||
|
|
{"data": "holder",'width': '50px'},
|
|||
|
|
{"data": "typeWork",'width': '40px'},
|
|||
|
|
{"data": "teamType",'width': '100px'},
|
|||
|
|
{"data": "teamMonitor",'width': '40px'},
|
|||
|
|
{"data": "idCard",'width': '120px'},
|
|||
|
|
{"data": "teamTelep",'width': '50px'},
|
|||
|
|
{"data": "remark",'width': '110px'},
|
|||
|
|
{"data": "releaseTime",'width': '80px'},
|
|||
|
|
{
|
|||
|
|
"data": "",
|
|||
|
|
'width': '60px',
|
|||
|
|
"defaultContent": "",
|
|||
|
|
"orderable": false,
|
|||
|
|
"render": function (data, type, row) {
|
|||
|
|
var html = '';
|
|||
|
|
var auditResult = row['auditResult'];
|
|||
|
|
if(auditResult == 0){
|
|||
|
|
html = "<span style='color: orange;cursor: pointer;' title=''>待审核</span>";
|
|||
|
|
}else if(auditResult == 1){
|
|||
|
|
html = "<span style='color: green;cursor: pointer;' title=''>已通过</span>";
|
|||
|
|
}else if(auditResult == 2){
|
|||
|
|
html = "<span style='color: red;cursor: pointer;' title=''>未通过</span>";
|
|||
|
|
}
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{"data": "",
|
|||
|
|
'width': '110px',
|
|||
|
|
"render": function (data, type, row) {
|
|||
|
|
var effectiveDate = row['auditTime'];
|
|||
|
|
var html = '';
|
|||
|
|
if(effectiveDate != null){
|
|||
|
|
html += dateFormat(effectiveDate, "yyyy-MM-dd");
|
|||
|
|
}
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"data": "",
|
|||
|
|
'width': '60px',
|
|||
|
|
"defaultContent": "",
|
|||
|
|
"orderable": false,
|
|||
|
|
"render": function (data, type, row) {
|
|||
|
|
var html = '';
|
|||
|
|
var isOnline = row['isOnline'];
|
|||
|
|
if(isOnline == 0){
|
|||
|
|
html = "<span style=';cursor: pointer;' title=''>是</span>";
|
|||
|
|
}else if(isOnline == 1){
|
|||
|
|
html = "<span style=';cursor: pointer;' title=''>否</span>";
|
|||
|
|
}
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"data": "",
|
|||
|
|
'width': '80px',
|
|||
|
|
"defaultContent": "",
|
|||
|
|
"orderable": false,
|
|||
|
|
"render": function (data, type, row) {
|
|||
|
|
var id = row['id'];
|
|||
|
|
var html = '';
|
|||
|
|
html += buttonView(id, "", pers);
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
],
|
|||
|
|
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 查看
|
|||
|
|
* */
|
|||
|
|
function view(id) {
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
contentType: "application/x-www-form-urlencoded",
|
|||
|
|
url: ctxPath + '/migrant/getWorkInfoReleaseById',
|
|||
|
|
data:{"id":id},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
var height = '90%';
|
|||
|
|
var width = '70%';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['查看','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: 'workInfoReleaseView.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['关闭'],
|
|||
|
|
success:function(layero,index){
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
var fnc = myIframe.setData(data); //aaa()为子页面的方法
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 详情按钮
|
|||
|
|
function buttonView(id, permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='view(\""+id+"\")'>查看</button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 日期格式化
|
|||
|
|
* @param {*} date
|
|||
|
|
* @param {*} fmt
|
|||
|
|
*/
|
|||
|
|
const dateFormat = (date, fmt) => {
|
|||
|
|
date = new Date(date)
|
|||
|
|
var a = ['日', '一', '二', '三', '四', '五', '六']
|
|||
|
|
var o = {
|
|||
|
|
'M+': date.getMonth() + 1, // 月份
|
|||
|
|
'd+': date.getDate(), // 日
|
|||
|
|
'h+': date.getHours(), // 小时
|
|||
|
|
'm+': date.getMinutes(), // 分
|
|||
|
|
's+': date.getSeconds(), // 秒
|
|||
|
|
'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
|
|||
|
|
'S': date.getMilliseconds(), // 毫秒
|
|||
|
|
'w': date.getDay(), // 周
|
|||
|
|
'W': a[date.getDay()], // 大写周
|
|||
|
|
'T': 'T'
|
|||
|
|
}
|
|||
|
|
if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) }
|
|||
|
|
for (var k in o) {
|
|||
|
|
if (new RegExp('(' + k + ')').test(fmt)) { fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) }
|
|||
|
|
}
|
|||
|
|
return fmt
|
|||
|
|
}
|