400 lines
14 KiB
JavaScript
400 lines
14 KiB
JavaScript
|
|
var example = null;
|
|||
|
|
var pers = null;
|
|||
|
|
var isSelected = [];
|
|||
|
|
|
|||
|
|
var id = localStorage.getItem("id");
|
|||
|
|
var year = localStorage.getItem("year");
|
|||
|
|
var month = localStorage.getItem("month");
|
|||
|
|
var proId = localStorage.getItem("proId");
|
|||
|
|
var proName = localStorage.getItem("proName");
|
|||
|
|
|
|||
|
|
var teamId = localStorage.getItem("teamId");
|
|||
|
|
var teamName = localStorage.getItem("teamName");
|
|||
|
|
var subId = localStorage.getItem("subId");
|
|||
|
|
var subName = localStorage.getItem("subName");
|
|||
|
|
$(function () {
|
|||
|
|
layui.use(['layer', 'laydate', 'form'], function () {
|
|||
|
|
var layer = layui.layer;
|
|||
|
|
var laydate = layui.laydate;
|
|||
|
|
var form = layui.form;
|
|||
|
|
$("#years").html(year+"年"+month+"月");
|
|||
|
|
$("#proName").html("工程名称:"+proName);
|
|||
|
|
$("#subName").html(subName+" "+teamName);
|
|||
|
|
init();
|
|||
|
|
pers = checkPermission();
|
|||
|
|
$("#searchBt").click(function () {
|
|||
|
|
example.ajax.reload();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#download").click(function () {
|
|||
|
|
var token = localStorage.getItem("token");
|
|||
|
|
var keyWord = $("#keyWord").val();
|
|||
|
|
var loadingMsg = layer.msg('下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
|||
|
|
var url = ctxPath + "/wagesInfoConvey/exportWagesConvey?id=" + id + "&keyWord=" + keyWord + "&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;
|
|||
|
|
console.log(url)
|
|||
|
|
a.download = "农民工实名制工资信息报审表财务系统导入模板-"+ proName +"-"+teamName+ "-"+ year+ "-"+ month + ".xlsx"; // 文件名
|
|||
|
|
}else {
|
|||
|
|
layer.msg('导出发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
|
|||
|
|
}
|
|||
|
|
a.click()
|
|||
|
|
window.URL.revokeObjectURL(url)
|
|||
|
|
};
|
|||
|
|
xhr.send();
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
function init() {
|
|||
|
|
example =
|
|||
|
|
$('#dt-table').DataTable({
|
|||
|
|
"sort": false,
|
|||
|
|
'paging':false, //取消分页
|
|||
|
|
"searching": false,
|
|||
|
|
"processing": true, //加载数据时显示进度状态
|
|||
|
|
"serverSide": true,
|
|||
|
|
"language": {
|
|||
|
|
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
|
|||
|
|
},
|
|||
|
|
"ajax": {
|
|||
|
|
"url": ctxPath + "/wagesInfoConvey/getTeamConveyByTeamPro",
|
|||
|
|
"type": "get",
|
|||
|
|
"data": function (d) {
|
|||
|
|
d.id = id;
|
|||
|
|
d.keyWord = $("#keyWord").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);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
"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%',
|
|||
|
|
data: function (row, type, set, meta) {
|
|||
|
|
var c = meta.settings._iDisplayStart + meta.row + 1;
|
|||
|
|
return c;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{"data": "proNum",width: '8%'},
|
|||
|
|
{"data": "subNum",width: '8%'},
|
|||
|
|
{"data": "purchaseNum",width: '5%'},
|
|||
|
|
{"data": "contractNum",width: '5%'},
|
|||
|
|
{"data": "year",width: '5%'},
|
|||
|
|
|
|||
|
|
{"data": "month",width: '8%'},
|
|||
|
|
{"data": "teamMembers",width: '8%'},
|
|||
|
|
{"data": "idNumber",width: '5%'},
|
|||
|
|
{"data": "teamName",width: '5%'},
|
|||
|
|
{"data": "postName",width: '5%'},
|
|||
|
|
|
|||
|
|
{"data": "checkNum",width: '8%'},
|
|||
|
|
{"data": "payNum",width: '8%'},
|
|||
|
|
{"data": "withhold",width: '5%'},
|
|||
|
|
{"data": "realPay",width: '5%'},
|
|||
|
|
{"data": "bankCardNum",width: '5%'},
|
|||
|
|
],
|
|||
|
|
"order": [ [1, "asc"]] //在栏目列上显示排序功能
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getNums(that) {
|
|||
|
|
// that.value = that.value.replace(/^0\.[5]$|^[1]d*$/,'');
|
|||
|
|
var str = that.value;
|
|||
|
|
if(str =="0.5" || str ==0.5){
|
|||
|
|
that.value = str;
|
|||
|
|
}else if(str =="1" || str ==1){
|
|||
|
|
that.value = str;
|
|||
|
|
}else{
|
|||
|
|
that.value = "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 详情
|
|||
|
|
* */
|
|||
|
|
function detailsView(id) {
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
contentType: "application/x-www-form-urlencoded",
|
|||
|
|
url: ctxPath + '/noSignalTeamApply/getNoSignalTeamApplyById',
|
|||
|
|
data: {"id": id},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
var height = '750px';
|
|||
|
|
var width = '850px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['无信号班组申请web端打卡', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: 'noSignalTeamApplyForm.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['确定', '关闭'],
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
myIframe.setData(data);
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
console.log(formSubmit.find('button')[2]);
|
|||
|
|
var submited = formSubmit.find('button')[2];
|
|||
|
|
submited.click();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 详情
|
|||
|
|
function detailsBtn(id, permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='detailsView(" + id + ")'>详情</button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
//考勤打卡
|
|||
|
|
function recordsBt(){
|
|||
|
|
var flagWorkHours = 1;
|
|||
|
|
var flagOverHours = 1;
|
|||
|
|
var flagRemark = 1;
|
|||
|
|
|
|||
|
|
var startTime = $("#startTime").val();
|
|||
|
|
var stopTime = $("#stopTime").val();
|
|||
|
|
var time = $("#attendanceDate").val();
|
|||
|
|
var num = $("#num").text();
|
|||
|
|
var proId = $("#proId").val();
|
|||
|
|
var id = $("#teamId").val();
|
|||
|
|
if(num == "已选0人"){
|
|||
|
|
parent.layer.msg("请选择勾选需要补卡的人员", {icon: 2, time: 2000});
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if((time < startTime) || (time > stopTime)){
|
|||
|
|
parent.layer.msg("请选择" + startTime + "~" + stopTime + "之间的日期", {icon: 2, time: 2000});
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var teamId = $("#id").val();
|
|||
|
|
var attendanceNum = $("#num").text().split("选")[1].split("人")[0];
|
|||
|
|
var attendanceDate = $("#attendanceDate").val();
|
|||
|
|
|
|||
|
|
var names = [];
|
|||
|
|
var idNumber = []; //考勤人员身份证 id_number
|
|||
|
|
var workHourss = []; //工作时长
|
|||
|
|
var overHourss = []; //加班时长
|
|||
|
|
var remarks = []; //备注
|
|||
|
|
var oTable = $('#dt-table').dataTable();
|
|||
|
|
var rowcollection = oTable.$(".checkall:checked", {"page": "all"});
|
|||
|
|
rowcollection.each(function (index, elem) {
|
|||
|
|
var name = $(elem).parent().next().next().text();
|
|||
|
|
var workHours = $(elem).parent().next().next().next().next().children().val();
|
|||
|
|
if(workHours == "" || workHours == null){
|
|||
|
|
flagWorkHours = 2;
|
|||
|
|
}
|
|||
|
|
var overHours = $(elem).parent().next().next().next().next().next().children().val();
|
|||
|
|
if(overHours == "" || overHours == null){
|
|||
|
|
flagOverHours = 2;
|
|||
|
|
}
|
|||
|
|
var remark = $(elem).parent().next().next().next().next().next().next().children().val();
|
|||
|
|
if(remark == "" || remark == null){
|
|||
|
|
flagRemark = 2;
|
|||
|
|
}
|
|||
|
|
var checkbox_value = $(elem).val();
|
|||
|
|
var strArr = checkbox_value.split(",");
|
|||
|
|
|
|||
|
|
names.push(name);
|
|||
|
|
idNumber.push(strArr[0]);
|
|||
|
|
workHourss.push(workHours);
|
|||
|
|
overHourss.push(overHours);
|
|||
|
|
remarks.push(remark);
|
|||
|
|
});
|
|||
|
|
if(flagWorkHours == 2){
|
|||
|
|
parent.layer.msg("请填写上班时长", {icon: 2, time: 2000});
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if(flagOverHours == 2){
|
|||
|
|
parent.layer.msg("请填写加班时长", {icon: 2, time: 2000});
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if(flagRemark == 2){
|
|||
|
|
parent.layer.msg("请填写备注", {icon: 2, time: 2000});
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
async: true, // 默认异步true,false表示同步
|
|||
|
|
url: ctxPath + "/noSignalTeamRecords/clockIn", // 请求地址
|
|||
|
|
data: {
|
|||
|
|
"proId": proId,
|
|||
|
|
"fcTeamId": id,
|
|||
|
|
"name": names,
|
|||
|
|
"teamId": teamId,
|
|||
|
|
"attendanceNum": attendanceNum,
|
|||
|
|
"attendanceDate": attendanceDate,
|
|||
|
|
"idNumber": idNumber.toString(),
|
|||
|
|
"workHours":workHourss.toString(),
|
|||
|
|
"overHours":overHourss.toString(),
|
|||
|
|
"remarks":remarks.toString(),
|
|||
|
|
}, //获取提交的表单字段
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.obj == "打卡成功") {
|
|||
|
|
parent.layer.msg('打卡成功', {icon: 1, time: 2000});
|
|||
|
|
setTimeout("reloading()", 2100);
|
|||
|
|
} else if (data.obj == "打卡失败") {
|
|||
|
|
parent.layer.msg('打卡失败', {icon: 2, time: 2000});
|
|||
|
|
} else {
|
|||
|
|
parent.layer.msg(data, {icon: 2, time: 2000});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error: function (XMLHttpRequest, textStatus, e) {
|
|||
|
|
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//附件查看
|
|||
|
|
function fileBt(){
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: ctxPath + '/noSignalTeamRecords/getFile',
|
|||
|
|
data: {
|
|||
|
|
teamId: teamId
|
|||
|
|
},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['附件查看', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: 'noSignalTeamRecordsFile.html',
|
|||
|
|
area: ["80%", "90%"],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['确定', '取消'],
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
myIframe.initFile(data,teamId);
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
console.log(formSubmit.find('button')[1]);
|
|||
|
|
var submited = formSubmit.find('button')[1];
|
|||
|
|
submited.click();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function showCheck(data){
|
|||
|
|
var num = 0;
|
|||
|
|
var checkall = $(".checkall");
|
|||
|
|
for(var i = 0;i < checkall.length;i++){
|
|||
|
|
var flag = checkall[i].checked;
|
|||
|
|
if(flag){
|
|||
|
|
num++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$("#num").text("已选" + num + "人");
|
|||
|
|
}
|
|||
|
|
function getPro(proId) {
|
|||
|
|
$("#proId").empty();
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: ctxPath + '/noSignalTeamRecords/getPro',
|
|||
|
|
data: {},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if(data.length>0){
|
|||
|
|
var str = '<option selected value="-1">请选择工程</option>';
|
|||
|
|
for(var i = 0; i < data.length; i++) {
|
|||
|
|
if(proId == 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>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$("#proId").append(str);
|
|||
|
|
layui.form.render('select'); //这里就是我们要渲染的地方了
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
function getTeam(proId,teamId) {
|
|||
|
|
|
|||
|
|
$("#teamId").empty();
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: ctxPath + '/noSignalTeamRecords/getTeam',
|
|||
|
|
data: {
|
|||
|
|
id: proId
|
|||
|
|
},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if(data.length>0){
|
|||
|
|
var str = '<option selected value="-1">请选择班组</option>';
|
|||
|
|
for(var i = 0; i < data.length; i++) {
|
|||
|
|
if(teamId == 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>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$("#teamId").append(str);
|
|||
|
|
layui.form.render('select'); //这里就是我们要渲染的地方了
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 获得当前时间 yyyy-MM-dd
|
|||
|
|
* @returns {string}
|
|||
|
|
*/
|
|||
|
|
function getNowTime() {
|
|||
|
|
var time = new Date();
|
|||
|
|
var year = time.getFullYear();
|
|||
|
|
var month = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1);
|
|||
|
|
var day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate();
|
|||
|
|
return year + "-" + month + "-" + day;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设置弹窗关闭
|
|||
|
|
function reloading() {
|
|||
|
|
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
|||
|
|
parent.layer.close(index); //再执行关闭
|
|||
|
|
window.parent.location.reload();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
function display() {
|
|||
|
|
$("#import").css("display","none");
|
|||
|
|
$("#addBtn").css("display","none");
|
|||
|
|
|
|||
|
|
}
|