184 lines
6.9 KiB
JavaScript
184 lines
6.9 KiB
JavaScript
|
|
var example = null;
|
|||
|
|
var pers = null;
|
|||
|
|
var noSignalTeamRecordsId = localStorage.getItem("noSignalTeamRecordsId");
|
|||
|
|
var attendanceId = localStorage.getItem("attendanceId");
|
|||
|
|
$(function () {
|
|||
|
|
layui.use(['layer', 'laydate', 'form'], function () {
|
|||
|
|
var layer = layui.layer;
|
|||
|
|
var laydate = layui.laydate;
|
|||
|
|
var form = layui.form;
|
|||
|
|
|
|||
|
|
pers = checkPermission();
|
|||
|
|
init();
|
|||
|
|
basicInformation(attendanceId); //基础信息
|
|||
|
|
$("#searchBt").click(function () {
|
|||
|
|
|
|||
|
|
example.ajax.reload();
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
//加载基础信息
|
|||
|
|
function basicInformation(attendanceId){
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: ctxPath + '/noSignalTeamRecords/getBasicInformation',
|
|||
|
|
data: {
|
|||
|
|
"attendanceId": attendanceId
|
|||
|
|
},
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
$("#proName").text(data[0].proName + "(" + data[0].teamName + ")");
|
|||
|
|
$("#attendanceNum").text(data[0].attendanceNum);
|
|||
|
|
$("#attendanceDate").text(data[0].attendanceDate);
|
|||
|
|
$("#attendanceDays").text(data[0].attendanceDays);
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function init() {
|
|||
|
|
example =
|
|||
|
|
$('#dt-table').DataTable({
|
|||
|
|
"sort": false,
|
|||
|
|
"searching": false,
|
|||
|
|
"processing": true, //加载数据时显示进度状态
|
|||
|
|
"serverSide": true,
|
|||
|
|
"language": {
|
|||
|
|
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
|
|||
|
|
},
|
|||
|
|
"ajax": {
|
|||
|
|
"url": ctxPath + "/noSignalTeamRecords/getNoSignalTeamRecordsDetails",
|
|||
|
|
"type": "get",
|
|||
|
|
"data": function (d) {
|
|||
|
|
d.id = noSignalTeamRecordsId;
|
|||
|
|
d.attendanceId = attendanceId;
|
|||
|
|
},
|
|||
|
|
"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: '5%',
|
|||
|
|
data: function (row, type, set, meta) {
|
|||
|
|
var c = meta.settings._iDisplayStart + meta.row + 1;
|
|||
|
|
return c;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{"data": "name",width: '8%'},
|
|||
|
|
{"data": "attendanceDate",width: '6%'},
|
|||
|
|
{"data": "workHours",width: '6%'},
|
|||
|
|
{"data": "overHours",width: '10%'},
|
|||
|
|
{"data": "remarks",width: '10%'},
|
|||
|
|
],
|
|||
|
|
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 详情
|
|||
|
|
* */
|
|||
|
|
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 height = '750px';
|
|||
|
|
var width = '1650px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['考勤打卡', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: 'noSignalTeamRecordsForm.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|