824 lines
31 KiB
JavaScript
824 lines
31 KiB
JavaScript
|
|
var example = null;
|
|||
|
|
var pers = null;
|
|||
|
|
var form = null;
|
|||
|
|
var roleLevel=null;
|
|||
|
|
var remarkShowLength = 30;//默认现实的字符串长度
|
|||
|
|
layui.use(['layer', 'laydate', 'form'], function () {
|
|||
|
|
form = layui.form;
|
|||
|
|
form.render();
|
|||
|
|
form.verify();
|
|||
|
|
getProject(form);
|
|||
|
|
getSubs(form);
|
|||
|
|
pers = checkPermission();
|
|||
|
|
getLoginUser();
|
|||
|
|
init(); // 初始化表格
|
|||
|
|
$("#searchBt").click(function () {
|
|||
|
|
example.ajax.reload();
|
|||
|
|
});
|
|||
|
|
$("#saveZipButton").click(function () {
|
|||
|
|
importExcel();
|
|||
|
|
});
|
|||
|
|
$("#exportData").click(function () {
|
|||
|
|
$("#import-excel").trigger('click');
|
|||
|
|
});
|
|||
|
|
$('#myModal_edit').on('show.bs.modal', centerModals);
|
|||
|
|
$("#checkall").change(function () {
|
|||
|
|
if ($(this).is(':checked')) {
|
|||
|
|
$('input[name="checked"]').each(function () {
|
|||
|
|
$(this).prop("checked", true);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$('input[name="checked"]').each(function () {
|
|||
|
|
$(this).prop("checked", false);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
function getLoginUser() {
|
|||
|
|
$.ajax({
|
|||
|
|
type : 'post',
|
|||
|
|
url : ctxPath + '/users/current',
|
|||
|
|
headers: {
|
|||
|
|
"token": token
|
|||
|
|
},
|
|||
|
|
async : false,
|
|||
|
|
success : function(data) {
|
|||
|
|
console.log(data);
|
|||
|
|
roleLevel=data.roleLevel;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
function init() {
|
|||
|
|
example =
|
|||
|
|
$('#dt-table').DataTable({
|
|||
|
|
"searching": false,
|
|||
|
|
"processing": true, //加载数据时显示进度状态
|
|||
|
|
"serverSide": true,
|
|||
|
|
'scrollY': "640px",
|
|||
|
|
'scroller': true,
|
|||
|
|
'scrollCollapse': true,
|
|||
|
|
'deferRender': true,
|
|||
|
|
"language": {
|
|||
|
|
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
|
|||
|
|
},
|
|||
|
|
"ajax": {
|
|||
|
|
"url": ctxPath + "/WorkRecord",
|
|||
|
|
"type": "get",
|
|||
|
|
"data": function (d) {
|
|||
|
|
console.log($("#subId").val());
|
|||
|
|
d.companyId = $("#orgId").val();
|
|||
|
|
d.proId = $("#proId").val();
|
|||
|
|
d.subIds = $("#subId").val();
|
|||
|
|
d.keyWord = $("#keyWord").val();
|
|||
|
|
d.einStatus = $("#einStatus").val();
|
|||
|
|
d.examineStatus = $("#examineStatus").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 = ctxPath + '/login.html';
|
|||
|
|
});
|
|||
|
|
} else if (code == 403) {
|
|||
|
|
console.log("未授权:" + message);
|
|||
|
|
layer.msg('未授权');
|
|||
|
|
} else if (code == 500) {
|
|||
|
|
console.log('系统错误:' + message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
"lengthMenu": [ [10, 20, 50], [10, 20, 50] ], // 设置每页显示数据量选项
|
|||
|
|
"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>><'dt-table-length'l>",
|
|||
|
|
"columns": [
|
|||
|
|
{
|
|||
|
|
"width":"3%",
|
|||
|
|
"data": null,
|
|||
|
|
"bSortable": false,
|
|||
|
|
render: function (data, type , full, meta) {
|
|||
|
|
var einStatus = full.einStatus;
|
|||
|
|
var exitTime = full.exitTime;
|
|||
|
|
var node = '';
|
|||
|
|
var checkedStatus = data['checkedStatus'];
|
|||
|
|
if (einStatus == '0') {
|
|||
|
|
|
|||
|
|
} else if (einStatus == '1') {
|
|||
|
|
if(exitTime !== null){
|
|||
|
|
|
|||
|
|
}else{
|
|||
|
|
node = '<input class="checkall" name="checked" value=\"' + full.idNumber + ',' + full.proId + ',' + full.orgId + ',' + full.subId + ',' + full.isCheck +'\" type="checkbox"/>';
|
|||
|
|
if (checkedStatus == 1) {
|
|||
|
|
node = '<input class="checkall" name="checked" checked="checked" value=\"' + full.idNumber + ',' + full.proId + ',' + full.orgId + ',' + full.subId + ',' + full.isCheck + '\" type="checkbox"/>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}else{
|
|||
|
|
node = '<input class="checkall" name="checked" value=\"' + full.idNumber + ',' + full.proId + ',' + full.orgId + ',' + full.subId +',' + full.isCheck + '\" type="checkbox"/>';
|
|||
|
|
if (checkedStatus == 1) {
|
|||
|
|
node = '<input class="checkall" name="checked" checked="checked" value=\"' + full.idNumber + ',' + full.proId + ',' + full.orgId + ',' + full.subId + ',' + full.isCheck + '\" type="checkbox"/>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return node;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
width: '4%',
|
|||
|
|
"orderable": false,
|
|||
|
|
data: function (row, type, set, meta) {
|
|||
|
|
var c = meta.settings._iDisplayStart + meta.row + 1;
|
|||
|
|
return c;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{"data": "name", "width": "5%"},
|
|||
|
|
{"data": "idNumber", "width": "6%"},
|
|||
|
|
{"data": "ethnic", "width": "6%"},
|
|||
|
|
{"data": "ages", "width": "6%"},
|
|||
|
|
|
|||
|
|
// {
|
|||
|
|
// "width": "2%",
|
|||
|
|
// "render": function (data, type, row) {
|
|||
|
|
// var idNumber = row['idNumber'];
|
|||
|
|
// var age = GetAge(idNumber);
|
|||
|
|
// return age;
|
|||
|
|
// }
|
|||
|
|
// },
|
|||
|
|
{"data": "postName", "width": "6%"},
|
|||
|
|
{"data": "proName", "width": "8%"},
|
|||
|
|
{"data": "subName", "width": "8%"},
|
|||
|
|
{"data": "teamName", "width": "6%"},
|
|||
|
|
{"data": "einTime", "width": "6%"},
|
|||
|
|
{"data": "exitTime", "width": "6%"},
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
"width": "4%",
|
|||
|
|
"orderable": false,
|
|||
|
|
"render": function (data, type, row) {
|
|||
|
|
var html = '';
|
|||
|
|
var einStatus = row['einStatus'];
|
|||
|
|
var exitTime = row['exitTime'];
|
|||
|
|
var examineStatus=row['examineStatus'];
|
|||
|
|
if (einStatus == '0') {
|
|||
|
|
html += '<span style="color:red">已出场</span>';
|
|||
|
|
} else if (einStatus == '1') {
|
|||
|
|
if(exitTime != null){
|
|||
|
|
html += '<span style="color:red">已出场</span>';
|
|||
|
|
}else{
|
|||
|
|
if(examineStatus=='1'){
|
|||
|
|
html += '<span style="color:forestgreen">已入场</span>';
|
|||
|
|
}else if(examineStatus=='0'){
|
|||
|
|
html += '<span style="color:forestgreen">待审核</span>';
|
|||
|
|
}else if(examineStatus=='2'){
|
|||
|
|
html += '<span style="color:forestgreen">审核未通过</span>';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}else{
|
|||
|
|
html += '<span style="color:#f7a00a;">未入场</span>';
|
|||
|
|
}
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
// {
|
|||
|
|
// "width": "4%",
|
|||
|
|
// "render": function (data, type, row) {
|
|||
|
|
// var html = '';
|
|||
|
|
// var isFull = row['isFull'];
|
|||
|
|
// html += '<span style="color:#000000;">'+isFull+'</span>';
|
|||
|
|
// return html;
|
|||
|
|
// }
|
|||
|
|
// },
|
|||
|
|
{
|
|||
|
|
"width": "8%",
|
|||
|
|
"defaultContent": "",
|
|||
|
|
"orderable": false,
|
|||
|
|
"render": function (data, type, row) {
|
|||
|
|
var proId = row['proId'];
|
|||
|
|
var subId = row['subId'];
|
|||
|
|
var orgId = row['orgId'];
|
|||
|
|
var id = row['idNumber'];
|
|||
|
|
var einStatus = row['einStatus'];
|
|||
|
|
var examineStatus = row['examineStatus'];
|
|||
|
|
var einTime = row['einTime'];
|
|||
|
|
var exitTime = row['exitTime'];
|
|||
|
|
|
|||
|
|
var isCheck = row['isCheck'];
|
|||
|
|
var html = '';
|
|||
|
|
if (einStatus == '0' ) {//已出场
|
|||
|
|
html += buttonView(id, orgId, proId, "", pers); // 详细信息查看
|
|||
|
|
html += rectifyCheck(id, orgId,"", pers); // 出入场记录
|
|||
|
|
} else if (einStatus == '1') {//已入场
|
|||
|
|
if(exitTime !== null){
|
|||
|
|
html += buttonView(id, orgId, proId, "", pers); // 详细信息查看
|
|||
|
|
html += rectifyCheck(id, orgId,"", pers); // 出入场记录
|
|||
|
|
}else{
|
|||
|
|
html += buttonEdits(id, proId, subId, orgId,einTime,isCheck, "", pers); // 出场
|
|||
|
|
|
|||
|
|
html += buttonView(id, orgId, proId, "", pers); // 详细信息查看
|
|||
|
|
html += rectifyCheck(id, orgId,"", pers); // 出入场记录
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
html += buttonView(id, orgId, proId, "", pers); // 详细信息查看
|
|||
|
|
html += rectifyCheck(id, orgId,"", pers); // 出入场记录
|
|||
|
|
// 未入场
|
|||
|
|
}
|
|||
|
|
html += buttonUpdate(id, proId, subId, orgId, "", pers); // 修改
|
|||
|
|
return html;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
],
|
|||
|
|
"order": [[2, "desc"],[3, "desc"],[4, "desc"],[5, "desc"],[6, "desc"],[7, "desc"],[8, "desc"],[9, "desc"], [10, "desc"]] //在栏目列上显示排序功能
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 出场
|
|||
|
|
*/
|
|||
|
|
function edit(id, proId, subId, orgId,einTime,isCheck) {
|
|||
|
|
$.ajax({
|
|||
|
|
type : 'post',
|
|||
|
|
url : ctxPath + '/WorkRecord/checkWorker',
|
|||
|
|
async : false,
|
|||
|
|
data:{idNumber:id},
|
|||
|
|
success : function(data) {
|
|||
|
|
if(data.code>0){
|
|||
|
|
isCheck=1;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error: function (e) {
|
|||
|
|
console.log(e.resMsg);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
if(isCheck == '1'){
|
|||
|
|
layer.msg('该人员今日已存在考勤,不能出场', {icon: 2, time: 4000});
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
localStorage.setItem("id", id);
|
|||
|
|
localStorage.setItem("proId", proId);
|
|||
|
|
localStorage.setItem("subId", subId);
|
|||
|
|
localStorage.setItem("orgId", orgId);
|
|||
|
|
localStorage.setItem("type", '1');
|
|||
|
|
localStorage.setItem("einTime", einTime);
|
|||
|
|
var height = '425px';
|
|||
|
|
var width = '525px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['出场', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: './accessFieldInform.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()为子页面的方法
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
var submited = formSubmit.find('button')[0];
|
|||
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|||
|
|
submited.click();
|
|||
|
|
},
|
|||
|
|
btn2: function (index, layero) {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 批量出场
|
|||
|
|
function out() {
|
|||
|
|
var id = [];
|
|||
|
|
var proId = [];
|
|||
|
|
var orgId = [];
|
|||
|
|
var subId = [];
|
|||
|
|
var isCheck = [];
|
|||
|
|
var oTable = $('#dt-table').dataTable();
|
|||
|
|
var rowcollection = oTable.$(".checkall:checked", {"page": "all"});
|
|||
|
|
rowcollection.each(function (index, elem) {
|
|||
|
|
var checkbox_value = $(elem).val();
|
|||
|
|
var strArr = checkbox_value.split(",");
|
|||
|
|
id.push(strArr[0]);
|
|||
|
|
proId.push(strArr[1]);
|
|||
|
|
orgId.push(strArr[2]);
|
|||
|
|
subId.push(strArr[3]);
|
|||
|
|
isCheck.push(strArr[4])
|
|||
|
|
});
|
|||
|
|
if (id.length == 0) {
|
|||
|
|
return layer.msg("请勾选要批量出场的数据", {icon: 2, time: 2000});
|
|||
|
|
}
|
|||
|
|
var checkstate=0;
|
|||
|
|
var msg="";
|
|||
|
|
$.ajax({
|
|||
|
|
type : 'post',
|
|||
|
|
url : ctxPath + '/WorkRecord/checkWorker',
|
|||
|
|
async : false,
|
|||
|
|
data:{idNumber:id.toString()},
|
|||
|
|
success : function(data) {
|
|||
|
|
if(data.code>0){
|
|||
|
|
checkstate=data.code;
|
|||
|
|
msg=data.msg;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error: function (e) {
|
|||
|
|
console.log(e.resMsg);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
if(checkstate>0){
|
|||
|
|
return layer.msg(msg + ' 人员今日已存在考勤,不能出场', {icon: 2, time: 4000});
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
localStorage.setItem("id", id.toString());
|
|||
|
|
localStorage.setItem("proId", proId.toString());
|
|||
|
|
localStorage.setItem("orgId", orgId.toString());
|
|||
|
|
localStorage.setItem("subId", subId.toString());
|
|||
|
|
localStorage.setItem("type", '2');
|
|||
|
|
var myDate = new Date((new Date).getTime() + 8*60*60*1000);
|
|||
|
|
var einTime = myDate.toJSON().split('T').join(' ').substr(0,19);
|
|||
|
|
localStorage.setItem("einTime", einTime);
|
|||
|
|
var height = '425px';
|
|||
|
|
var width = '525px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['批量出场', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: './accessFieldInform.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()为子页面的方法
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
var submited = formSubmit.find('button')[0];
|
|||
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|||
|
|
submited.click();
|
|||
|
|
},
|
|||
|
|
btn2: function (index, layero) {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function update(id, proId, subId, orgId) {
|
|||
|
|
localStorage.setItem("id", id);
|
|||
|
|
localStorage.setItem("proId", proId);
|
|||
|
|
localStorage.setItem("subId", subId);
|
|||
|
|
localStorage.setItem("orgId", orgId);
|
|||
|
|
localStorage.setItem("roleLevel",roleLevel);
|
|||
|
|
var companyId = $("#orgId").val();
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
contentType: "application/x-www-form-urlencoded",
|
|||
|
|
// url: ctxPath + '/WorkRecord/getWorkerInfoById',
|
|||
|
|
// data: {"id": id,"companyId":companyId},
|
|||
|
|
url: ctxPath + '/WorkRecord/getWorkerInfoById',
|
|||
|
|
data: {"id": id,"orgId": orgId,"proId": proId},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
var height = '700px';
|
|||
|
|
var width = '1050px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['修改', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: './inOutInfo.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['确定','关闭'],
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
myIframe.setData(data); //aaa()为子页面的方法
|
|||
|
|
// myIframe.getPostName(null);
|
|||
|
|
myIframe.cancelReadOnly(); //aaa()为子页面的方法
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
var submited = formSubmit.find('button')[0];
|
|||
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|||
|
|
submited.click();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 详情信息查看
|
|||
|
|
* */
|
|||
|
|
function view(id,orgId,proId) {
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
contentType: "application/x-www-form-urlencoded",
|
|||
|
|
url: ctxPath + '/WorkRecord/getWorkerInfoById',
|
|||
|
|
data: {"id": id,"orgId": orgId,"proId": proId},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
var height = '700px';
|
|||
|
|
var width = '1050px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['查看', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: 'inOutInfo.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 rectifyView(id,orgId) {
|
|||
|
|
localStorage.setItem("id", id);
|
|||
|
|
localStorage.setItem("orgId", orgId);
|
|||
|
|
var companyId = $("#orgId").val();
|
|||
|
|
localStorage.setItem("companyId", companyId);
|
|||
|
|
var height = '650px';
|
|||
|
|
var width = '1300px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['出入场记录', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: './workerAttendHistory.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['关闭'],
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function check(id) {
|
|||
|
|
localStorage.setItem("id", id);
|
|||
|
|
var height = '325px';
|
|||
|
|
var width = '525px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['入场审核', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: './admissionAuditForm.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['确定', '取消'],
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
var submited = formSubmit.find('button')[0];
|
|||
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|||
|
|
submited.click();
|
|||
|
|
},
|
|||
|
|
btn2: function (index, layero) {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function centerModals() {
|
|||
|
|
$('#myModal_edit').each(function (i) {
|
|||
|
|
var $clone = $(this).clone().css('display', 'block').appendTo('body');
|
|||
|
|
var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 3);
|
|||
|
|
top = top > 0 ? top : 0;
|
|||
|
|
$clone.remove();
|
|||
|
|
$(this).find('.modal-content').css("margin-top", top);
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 详情按钮
|
|||
|
|
function buttonView(id, orgId, proId, permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='详细信息查看' onclick='view(\"" + id + "\",\""+orgId+"\",\""+proId+"\")'><i class='layui-icon'></i></button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 出场按钮
|
|||
|
|
function buttonEdits(id, proId, subId, orgId, einTime,isCheck, permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='出场' onclick='edit(\"" + id + "\",\"" + proId + "\",\"" + subId + "\",\"" + orgId + "\" ,\"" + einTime + "\",\"" + isCheck + "\")'><img src='../../../img/chuchang.png' width='20px' height='20px'></button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 修改按钮
|
|||
|
|
function buttonUpdate(id, proId, subId, orgId, permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='修改' onclick='update(\"" + id + "\",\"" + proId + "\",\"" + subId + "\",\"" + orgId + "\")'><i class='layui-icon'></i></button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 入场审核
|
|||
|
|
function buttonCheck(data, permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='入场审核' onclick='check(\"" + data + "\")'><i class='layui-icon'></i></button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
// 出入场记录查看
|
|||
|
|
function rectifyCheck(data, orgId,permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='出入场记录查看' onclick='rectifyView(\"" + data + "\",\""+orgId+"\")'><i class=\"layui-icon\"></i></button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function centerModals() {
|
|||
|
|
$('#myModal_edit').each(function (i) {
|
|||
|
|
var $clone = $(this).clone().css('display', 'block').appendTo('body');
|
|||
|
|
var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 3);
|
|||
|
|
top = top > 0 ? top : 0;
|
|||
|
|
$clone.remove();
|
|||
|
|
$(this).find('.modal-content').css("margin-top", top);
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 下载模板
|
|||
|
|
function down() {
|
|||
|
|
window.location.href = ctxPath + "/download/download?filename=施工人员信息表模板入场信息.xlsx"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取年龄
|
|||
|
|
function IDCardChange(idCard) {
|
|||
|
|
if (idCard.length == 18) {
|
|||
|
|
//获取计算后出生日期
|
|||
|
|
var birthDateStr = getBirthDate(idCard);
|
|||
|
|
var nowDateStr = getNowTime();
|
|||
|
|
//获取计算后年龄(两个日期之间)
|
|||
|
|
var age = getAge(birthDateStr, nowDateStr);
|
|||
|
|
//设置年龄
|
|||
|
|
return age;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 获取当日时间
|
|||
|
|
*/
|
|||
|
|
function getNowTime() {
|
|||
|
|
var nowDate = new Date();
|
|||
|
|
var year = nowDate.getFullYear();
|
|||
|
|
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1)
|
|||
|
|
: nowDate.getMonth() + 1;
|
|||
|
|
var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
|
|||
|
|
var dateStr = year + "-" + month + "-" + day;
|
|||
|
|
return dateStr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//根据身份证号计算出生日期
|
|||
|
|
var getBirthDate = function (IDCard) {
|
|||
|
|
//获取身份证号的年、月、日
|
|||
|
|
var year = IDCard.substring(6, 10);
|
|||
|
|
var month = IDCard.substring(10, 12);
|
|||
|
|
var day = IDCard.substring(12, 14);
|
|||
|
|
//拼接成出生日期
|
|||
|
|
var birthDate = year + '-' + month + '-' + day;
|
|||
|
|
return birthDate;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//根据两个日期计算年龄(是否过生日)
|
|||
|
|
var getAge = function (startDateStr, endDateStr) {
|
|||
|
|
//计算两个日期相差多少年
|
|||
|
|
var startDate = new Date(startDateStr);
|
|||
|
|
var endDate = new Date(endDateStr);
|
|||
|
|
var yearNum = endDate.getFullYear() - startDate.getFullYear();
|
|||
|
|
//获取两个日期(月+日)部分
|
|||
|
|
var sStr = startDateStr.substring(5, 10);
|
|||
|
|
var eStr = endDateStr.substring(5, 10);
|
|||
|
|
//判断两个日期大小
|
|||
|
|
//判断是否过生日
|
|||
|
|
if (new Date(sStr) <= new Date(eStr)) {
|
|||
|
|
return yearNum + 1;
|
|||
|
|
} else {
|
|||
|
|
return yearNum;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
function out3() {
|
|||
|
|
var formUrl = ctxPath + "/accessFieldInfor/insertPersonOut";
|
|||
|
|
var selected = [];
|
|||
|
|
$('input:checkbox[name=checked]:checked').each(function (i) {
|
|||
|
|
selected.push($(this).val());
|
|||
|
|
});
|
|||
|
|
if (selected.length == 0) {
|
|||
|
|
layer.alert("请选择需要出场的人员!")
|
|||
|
|
} else {
|
|||
|
|
layer.open({
|
|||
|
|
content: '确定出场' + selected.length + '人?'
|
|||
|
|
, btn: ['确定', '取消']
|
|||
|
|
, yes: function (index, layero) {
|
|||
|
|
var loadIndex = layer.msg("上传中", {
|
|||
|
|
icon: 16,
|
|||
|
|
time: -1
|
|||
|
|
})
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'get',
|
|||
|
|
url: formUrl,
|
|||
|
|
async: false,
|
|||
|
|
data: {
|
|||
|
|
idNumber: selected.toString()
|
|||
|
|
},
|
|||
|
|
success: function (data) {
|
|||
|
|
layer.alert('出场成功', {icon: 1});
|
|||
|
|
layer.close(loadIndex);
|
|||
|
|
window.location.reload();//刷新父页面
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}, btn2: function (index, layero) {
|
|||
|
|
}
|
|||
|
|
, cancel: function () {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 获取分公司
|
|||
|
|
* */
|
|||
|
|
function getCompanys(orgId) {
|
|||
|
|
$("#orgId").empty();
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: ctxPath + '/WorkRecord/getCompanys',
|
|||
|
|
data: {},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if(data.length>0){
|
|||
|
|
var str = '<option selected value="">请选择分公司</option>';
|
|||
|
|
for(var i = 0; i < data.length; i++) {
|
|||
|
|
if(orgId == data[i].id) {
|
|||
|
|
str += '<option selected value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
|
|||
|
|
} else {
|
|||
|
|
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$("#orgId").append(str);
|
|||
|
|
layui.form.render('select'); //这里就是我们要渲染的地方了
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function GetAge(identityCard) {
|
|||
|
|
var len = (identityCard + "").length;
|
|||
|
|
if (len == 0) {
|
|||
|
|
return 0;
|
|||
|
|
} else {
|
|||
|
|
if ((len != 15) && (len != 18))//身份证号码只能为15位或18位其它不合法
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var strBirthday = "";
|
|||
|
|
if (len == 18)//处理18位的身份证号码从号码中得到生日和性别代码
|
|||
|
|
{
|
|||
|
|
strBirthday = identityCard.substr(6, 4) + "/" + identityCard.substr(10, 2) + "/" + identityCard.substr(12, 2);
|
|||
|
|
}
|
|||
|
|
if (len == 15) {
|
|||
|
|
strBirthday = "19" + identityCard.substr(6, 2) + "/" + identityCard.substr(8, 2) + "/" + identityCard.substr(10, 2);
|
|||
|
|
}
|
|||
|
|
//时间字符串里,必须是“/”
|
|||
|
|
var birthDate = new Date(strBirthday);
|
|||
|
|
var nowDateTime = new Date();
|
|||
|
|
var age = nowDateTime.getFullYear() - birthDate.getFullYear();
|
|||
|
|
//再考虑月、天的因素;.getMonth()获取的是从0开始的,这里进行比较,不需要加1
|
|||
|
|
if (nowDateTime.getMonth() < birthDate.getMonth() || (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime.getDate() < birthDate.getDate())) {
|
|||
|
|
age--;
|
|||
|
|
}
|
|||
|
|
return age;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//导入excel文件
|
|||
|
|
function importExcel() {
|
|||
|
|
var formData = new FormData($('form')[0]);
|
|||
|
|
var name = $("#articleImageFile").val();
|
|||
|
|
if (name == null || name == "") {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (!(name.endsWith(".xlsx"))) {
|
|||
|
|
layer.msg("请上传正确的Excel表格(.xlsx)!");
|
|||
|
|
$("#articleImageFile").val("");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
formData.append("file", $("#articleImageFile")[0].files[0]);
|
|||
|
|
var idx = layer.msg('正在提交数据,请稍等...', {
|
|||
|
|
icon: 16
|
|||
|
|
, shade: 0.01
|
|||
|
|
, time: '-1'
|
|||
|
|
});
|
|||
|
|
$.ajax({
|
|||
|
|
url: ctxPath + "/WorkRecord/workerInfoImport",
|
|||
|
|
type: 'POST',
|
|||
|
|
async: true,
|
|||
|
|
data: formData,
|
|||
|
|
timeout: 20000,
|
|||
|
|
// 告诉jQuery不要去处理发送的数据
|
|||
|
|
processData: false,
|
|||
|
|
// 告诉jQuery不要去设置Content-Type请求头
|
|||
|
|
contentType: false,
|
|||
|
|
success: function (data) {
|
|||
|
|
layer.close(idx);
|
|||
|
|
if(data.indexOf("导入成功") !=-1){
|
|||
|
|
layer.alert(data, {icon: 1});
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
}else if(data.indexOf("导入失败") !=-1){
|
|||
|
|
layer.alert(data, {icon: 2});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|||
|
|
console.log(JSON.stringify(errorThrown));
|
|||
|
|
layer.close(idx);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$("#articleImageFile").val("");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 导出
|
|||
|
|
*/
|
|||
|
|
function exportBtnOut() {
|
|||
|
|
var proId = $("#proId").val();
|
|||
|
|
var subIds = $("#subId").val();
|
|||
|
|
var keyWord = $("#keyWord").val();
|
|||
|
|
var einStatus = $("#einStatus").val();
|
|||
|
|
|
|||
|
|
var token = localStorage.getItem("token");
|
|||
|
|
var loadingMsg = layer.msg('下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
|||
|
|
var url = ctxPath + "/WorkRecord/exportBtnOut?proId=" + proId + "&subIds=" + subIds + "&keyWord=" + keyWord + "&einStatus=" + einStatus + "&token=" + token;
|
|||
|
|
var xhr = new XMLHttpRequest();
|
|||
|
|
xhr.open("get", url, true);
|
|||
|
|
xhr.responseType = "blob"; // 转换流
|
|||
|
|
xhr.onload = function () {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
if (this.status === 200) {
|
|||
|
|
var blob = this.response;
|
|||
|
|
var a = document.createElement("a");
|
|||
|
|
var url = window.URL.createObjectURL(blob);
|
|||
|
|
a.href = url;
|
|||
|
|
a.download = "出入场信息.xlsx"; // 文件名
|
|||
|
|
}else {
|
|||
|
|
layer.msg('发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
|
|||
|
|
}
|
|||
|
|
a.click()
|
|||
|
|
window.URL.revokeObjectURL(url)
|
|||
|
|
};
|
|||
|
|
xhr.send();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|