IntelligentRecognition/ah-jjsp-web/.svn/pristine/f5/f5787240e44fdb8b3c0914baef5...

438 lines
14 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let table, form, layer, laydate, util, user = getUser();
let pageNum = 1, limitSize = 30; // 默认第一页分页数量为10
$(function () {
layui.config({
base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径
}).extend({
formSelects: 'formSelects-v4'
}).use(['layer', 'laydate', 'formSelects', 'form', 'table', 'util'], function () {
layer = layui.layer;
form = layui.form;
laydate = layui.laydate;
var today = getNowTime();
var dayValue = today + " ~ " + today;
table = layui.table;
util = layui.util;
formSelects = layui.formSelects;
form.render();
//日期范围
laydate.render({
elem: '#startTime'
, type: 'date'
, range: '~'
, format: 'yyyy-MM-dd',
value: dayValue,
max: Date.parse(new Date()),
});
util.event('lay-active', {
query: function () {
pages(1, limitSize);
},
reset: function () {
$('#project').val('');
$('#unit').val('');
$('#foreman').val('');
$('#code').val('');
$('#keyword').val('');
$('#startTime').val(getNowTime() + ' ~ ' + getNowTime());
formSelects.value('regulatory', []);
formSelects.value('risk', []);
form.render();
pages(1, limitSize);
},
export: function () {
exportData();
}
});
getOrgSelect();
getSelectParams();
pages(1, 30, 1);
table.on("rowDouble(classTable)", function (res) {
let obj = res.data;
openRemotePatrol(obj.classId, obj.puid, obj.tCode, obj.twCode, obj.tdCode, obj.passWay, obj.bidCode);
});
});
});
function pages(pageNum, pageSize) {
let params = getReqParams(pageNum, pageSize);
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/team/getClassList" + '?token=' + token,
data: params,
type: 'POST',
async: false,
success: function (result) {
if (result.code === 200) {
if (result.rows) {
initTable(result.rows, limitSize, pageNum)
laypages(result.total, pageNum, limitSize)
}
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
} else if (result.code === 401) {
logout(1);
}
}, error: function () {
}
});
}
function laypages(total, page, limit) {
layui.use(['laypage'], function () {
let laypage = layui.laypage;
laypage.render({
elem: 'voi-page',
count: total,
curr: page,
limit: limit,
limits: [30,50,100],
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
groups: 5,
jump: function (obj, first) {
if (!first) {
pageNum = obj.curr, limitSize = obj.limit;
pages(obj.curr, obj.limit, null);
}
}
});
})
}
function initTable(dataList, limit, page) {
console.log(dataList);
table.render({
elem: "#classTable",
id: "classTable",
height: "full-175",
data: dataList,
cols: [
[//表头
{
title: "序号",
width: 100,
unresize: true,
align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{
field: "org",
title: "建管单位",
unresize: false,
minWidth: 120,
sort: true,
align: "center"
},
{
field: "bidName",
title: "标段工程名称",
unresize: false,
minWidth: 180,
sort: true,
align: "center",
},
{
field: "sgdw",
title: "施工单位",
unresize: false,
minWidth: 120,
sort: true,
align: "center"
},
{
field: "riskLevel",
title: "风险等级",
unresize: false,
minWidth: 120,
sort: true,
align: "center",
templet: function (d) {
return setRiskLevelColor(d.riskLevel);
}
}, {
title: "监控",
width: 100,
unresize: false,
align: "center",
sort: true,
templet: function (d) {
console.log(d);
let html = '';
if (d.ballStatus != null) {
if (d.ballStatus === '1' && d.workDay === getDate()) {
html += '<img src="../../img/common-icon/ball-online.png">'
} else {
html += '<img src="../../img/common-icon/ball-offline.png">'
}
}
return html;
}
},
{
title: "状态",
unresize: false,
minWidth: 50,
sort: true,
align: "center",
templet: function (d) {
if (d.delFlag === '1') {
return "<span style='color: red'>已删除</span>";
} else {
return "<span>" + transformNull(d.sgStatus) + "</span>";
}
},
},
{
field: 'workManager',
title: "班组长",
unresize: false,
minWidth: 150,
sort: true,
align: "center",
templet: function (d) {
return "<span>" + setValue2(d.workManager) + "</span><br><span>" + transformNull(d.workManagerPhone) + "</span>";
},
}
,
{
field: 'workDay',
title: "施工日期",
unresize: false,
minWidth: 120,
sort: true,
align: "center",
},
{
field: 'sgNum',
title: "人数",
unresize: false,
minWidth: 120,
sort: true,
align: "center",
},
{
field: 'workPosition',
title: "作业类型工序及部位",
minWidth: 300,
sort: true,
align: "center",
templet: function (d) {
if (d.workPosition) {
if (d.workPosition.length > 60) {
return '<span title="' + d.workPosition + '">' + d.workPosition.substring(0, 60) + '...</span>'
} else {
return '<span title="' + d.workPosition + '">' + d.workPosition + '</span>'
}
} else {
return '';
}
}
},
{
field: 'macId',
title: "球机编码",
unresize: false,
minWidth: 200,
sort: true,
align: "center",
}
],
],
limit: limit,
done: function (res, curr, count) {
$(".layui-laypage-skip").css("display", "none");
}
});
}
/*打开远程巡视页面*/
function openRemotePatrol(id, puid, tCode, twCode, tdCode, passWay, bidNo) {
if (user.isSup !== '3') {
addSuper(id, "1");
}
let layerIndex = layer.open({
id: "remotePatrol",
title: false,
type: 2,
maxmin: false,
content: '../dutyTask/remotePatrol/remotePatrol.html',
area: ['100%', '100%'],
closeBtn: 0,
success: function (layero, index) {
let iframeWin = window["layui-layer-iframe" + layerIndex];
iframeWin.setParams(id, puid, tCode, twCode, tdCode, passWay, user.isSup, 2, bidNo);
},
end: function () {
if (user.isSup !== '3') {
addSuper(id, "2");
}
}
});
}
/*添加督查时间*/
function addSuper(classId, type) {
let params = {
classId: classId,
type: type
}
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + 'proteam/pot/supervision/insertSupervision?token=' + token,
data: params,
type: 'POST',
async: true,
success: function (result) {
}, error: function () {
}
});
}
// 刷新表格页面
function reloadData() {
pages(pageNum, limitSize);
resetContent();
}
// 获取参数
function getReqParams(page, limit) {
let startTime = isEmpty($('#startTime').val().split('~')[0]) ? "" : $('#startTime').val().split('~')[0];
let endTime = isEmpty($('#startTime').val().split('~')[1]) ? "" : $('#startTime').val().split('~')[1];
return {
pageNum: page + "",
pageSize: limit + "",
org: formSelects.value('regulatory', 'val').toString(),
bidName: $('#project').val(),
sgdw: $('#unit').val(),
riskLevel: formSelects.value('risk', 'val').toString(),
workManager: $('#foreman').val(),
macId: $('#code').val(),
startTime: startTime.trim(),
endTime: endTime.trim(),
currentUserId: user.userId + "",
isSup: user.isSup,
currentUserOrgId: user.orgId
};
}
//组织机构下拉选
function getOrgSelect() {
let keys = [];
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify({}))
},
url: dataUrl + 'proteam/pot/team/getOrgSelected' + '?token=' + token,
type: 'post',
success: function (data) {
$.each(data.data, function (index, item) {
let temp = {
"name": item.name,
"value": item.code
};
keys.push(temp);
})
formSelects.data('regulatory', 'local', {
arr: keys
});
form.render();
}
});
}
//组织机构下拉选
function getSelectParams() {
let keys = [];
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify({
code: 'risk_level'
}))
},
url: dataUrl + 'proteam/pot/team/getSelectParams' + '?token=' + token,
type: 'post',
data: {
code: 'risk_level'
},
success: function (data) {
let html = '<option value="-1" selected>全部</option>';
$.each(data.data, function (index, item) {
let temp = {
"name": item.value,
"value": item.key
};
keys.push(temp);
})
formSelects.data('risk', 'local', {
arr: keys
});
form.render();
}
});
}
//导出
function exportData() {
let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
let url = dataUrl + "proteam/pot/team/exportClassData?" + setData(getReqParams(pageNum, limitSize)) + '&token=' + token;
let xhr = new XMLHttpRequest();
let a = document.createElement("a");
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader("encrypt",
sm3(JSON.stringify(
getReqParams(pageNum, limitSize)
)));
xhr.onload = function () {
layer.close(loadingMsg);
if (this.status === 200) {
let url = window.URL.createObjectURL(new Blob([this.response]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', "站班会记录.xlsx")
document.body.appendChild(link)
link.click()
// 释放URL对象所占资源
window.URL.revokeObjectURL(url)
// 用完即删
document.body.removeChild(link)
} else {
layer.msg("数据发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
}
};
xhr.send();
}
function getDate() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (month < 10) {
month = "0" + month;
}
if (day < 10) {
day = "0" + day;
}
return year + "-" + month + "-" + day;
}
function setValue2(value) {
if (!value) {
return '';
}
return value;
}