2025-11-27 16:55:35 +08:00
|
|
|
|
var example = null;
|
|
|
|
|
|
var pers = null;
|
|
|
|
|
|
var form = null;
|
|
|
|
|
|
var lumpSumProId = localStorage.getItem("lumpSumProId");
|
|
|
|
|
|
var lumpSumType = localStorage.getItem("lumpSumType");
|
|
|
|
|
|
|
|
|
|
|
|
var selectedRows = []; // 用于记录需要回显的行标识
|
|
|
|
|
|
layui.use(['layer', 'laydate', 'form'], function () {
|
|
|
|
|
|
form = layui.form;
|
|
|
|
|
|
form.render();
|
|
|
|
|
|
form.verify();
|
|
|
|
|
|
pers = checkPermission();
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
init(); // 初始化表格
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#searchBt").click(function () {
|
|
|
|
|
|
example.ajax.reload();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("#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);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
form.on('submit(formDemo)', function (data) {
|
|
|
|
|
|
var id = [];
|
|
|
|
|
|
var gx = [];
|
|
|
|
|
|
var pilePosition = [];
|
|
|
|
|
|
var gxList = [];
|
|
|
|
|
|
var groupedData = {};
|
|
|
|
|
|
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(",").map(item => item.trim()); // 去除空格
|
|
|
|
|
|
id.push(strArr[0]);
|
|
|
|
|
|
gx.push(strArr[1]);
|
|
|
|
|
|
pilePosition.push(strArr[2]);
|
|
|
|
|
|
|
|
|
|
|
|
const gxId = strArr[0];
|
|
|
|
|
|
const gxName = strArr[1];
|
|
|
|
|
|
const gxZw = strArr[2];
|
|
|
|
|
|
|
|
|
|
|
|
gxList.push({
|
|
|
|
|
|
gxId: gxId,
|
|
|
|
|
|
gxName: gxName,
|
|
|
|
|
|
gxZw: gxZw
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!groupedData[strArr[1]]) {
|
|
|
|
|
|
groupedData[strArr[1]] = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
groupedData[strArr[1]].push(strArr[2]);
|
|
|
|
|
|
});
|
|
|
|
|
|
if (id.length == 0) {
|
|
|
|
|
|
layer.msg("请先勾选", {icon: 2, time: 2000})
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 构建字符串列表
|
|
|
|
|
|
var resultStrings = [];
|
|
|
|
|
|
for (var gxName in groupedData) {
|
|
|
|
|
|
var positions = groupedData[gxName].join(',');
|
|
|
|
|
|
var formattedStr = `${gxName}工序${positions}桩位`;
|
|
|
|
|
|
resultStrings.push(formattedStr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 将数据传给父页面
|
|
|
|
|
|
var index = parent.layer.getFrameIndex(window.name); // 获取当前iframe层索引
|
|
|
|
|
|
parent.layer.close(index); // 关闭当前弹窗
|
|
|
|
|
|
|
|
|
|
|
|
// 向父页面传递数据
|
|
|
|
|
|
window.parent.receiveDataFromChild(JSON.stringify(gxList),JSON.stringify(resultStrings));
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
|
|
example = $('#dt-table').DataTable({
|
|
|
|
|
|
"searching": false, // 禁用搜索
|
|
|
|
|
|
"processing": true, // 加载数据时显示进度状态
|
|
|
|
|
|
"serverSide": false,
|
|
|
|
|
|
'scrollY': "640px",
|
|
|
|
|
|
'scroller': true,
|
|
|
|
|
|
'scrollCollapse': true,
|
|
|
|
|
|
'deferRender': true,
|
|
|
|
|
|
"language": {
|
2025-12-02 14:22:34 +08:00
|
|
|
|
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
|
2025-11-27 16:55:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
"ajax": {
|
|
|
|
|
|
"url": ctxPath + "/commonSelect/getGxPilePositions",
|
|
|
|
|
|
"type": "get",
|
|
|
|
|
|
"dataSrc": function (res) {
|
|
|
|
|
|
if (res.res === 1) {
|
|
|
|
|
|
return res.obj; // 使用 obj 作为数据源
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.msg(res.resMsg || '数据加载失败');
|
|
|
|
|
|
return [];
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"data": function (d) {
|
|
|
|
|
|
d.proId = lumpSumProId;
|
|
|
|
|
|
d.type = lumpSumType;
|
|
|
|
|
|
d.gxName = $("#gxName").val();
|
|
|
|
|
|
d.pilePosition = $("#pilePosition").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] ], // 设置每页显示数据量选项
|
|
|
|
|
|
"paging": false, // 禁用分页
|
|
|
|
|
|
"ordering": false, // 禁用排序
|
|
|
|
|
|
"drawCallback": function() {
|
|
|
|
|
|
// 这里可以根据需要进行额外的处理
|
|
|
|
|
|
},
|
|
|
|
|
|
"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) {
|
|
|
|
|
|
if (!full || typeof full.id === 'undefined') {
|
|
|
|
|
|
return '<input class="checkall" name="checked" type="checkbox"/>';
|
|
|
|
|
|
}
|
|
|
|
|
|
return '<input class="checkall" name="checked" value="' + full.id + ' , '+ full.gx +' , '+ full.pilePosition +'" type="checkbox"/>';
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"data": "gx",
|
|
|
|
|
|
"width": "5%",
|
|
|
|
|
|
"defaultContent": "" // 如果字段缺失,默认显示空字符串
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"data": "pilePosition",
|
|
|
|
|
|
"width": "6%",
|
|
|
|
|
|
"defaultContent": "" // 如果字段缺失,默认显示空字符串
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
"order": [], // 在栏目列上显示排序功能
|
|
|
|
|
|
"drawCallback": function () {
|
|
|
|
|
|
const table = $('#dt-table').DataTable();
|
|
|
|
|
|
table.rows().every(function () {
|
|
|
|
|
|
const data = this.data();
|
|
|
|
|
|
const rowValue = `${data.id},${data.gx},${data.pilePosition}`;
|
|
|
|
|
|
if (selectedRows.includes(rowValue)) {
|
|
|
|
|
|
const checkbox = $(this.node()).find('.checkall');
|
|
|
|
|
|
checkbox.prop('checked', true);
|
|
|
|
|
|
// checkbox.prop('disabled', true); // 禁止用户取消
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 批量出场
|
|
|
|
|
|
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 receiveDataFromParent(gxListStr) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const parsed = JSON.parse(gxListStr);
|
|
|
|
|
|
selectedRows = parsed.map(item => `${item.gxId},${item.gxName},${item.gxZw}`);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error("解析失败", e);
|
|
|
|
|
|
selectedRows = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log("接收到的数据:", selectedRows)
|
|
|
|
|
|
}
|