IntelligentRecognition/ah-jjsp-web/bns/js/dutyTask/abnormalRepStatistics.js

356 lines
12 KiB
JavaScript
Raw Permalink 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 form, layer, table, rightPopup4, formSelects, tableIns, laydate, user = getUser();
let riskLevelList;
let pageNum = 1, limitSize = 50; // 默认第一页分页数量为10
layui.config({
base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径
}).extend({
rightPopup4: "rightPopup4",
formSelects: 'formSelects-v4'
}).use(['form', 'layer', 'table', 'laydate', "rightPopup4", 'formSelects'], function () {
form = layui.form;
layer = layui.layer;
table = layui.table;
laydate = layui.laydate;
laydate.render({
elem: '#createTime', //指定元素 元素选择器
type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
trigger: 'click',
range: true,
format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
btns: ['now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
done: function (value, date) { //时间回调
}
});
$('#createTime').val(getStartTime() + " - " + getEndTime())
rightPopup4 = layui.rightPopup4;
formSelects = layui.formSelects;
riskLevelList = getRiskLevelSelect('risk_level');
setRiskLevel();
pages(1, 50, 1);
})
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/abnormalRep/getAbnormalRepList?token=" + token,
data: params,
type: 'POST',
async: false,
success: function (result) {
if (result.code === 200) {
if (result.data) {
initTable(result.data, result.limit, result.curr)
laypages(result.count, result.curr, result.limit)
}
} 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) {
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
tableIns = table.render({
elem: "#violationStatisticsTable",
height: "full-170",
data: dataList,
limit: limit,
cols: [
[
//表头
{
title: "序号",
width: 80,
unresize: true,
align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{
field: "proName",
title: "工程名称",
width: 300,
unresize: true,
align: "center",
sort: true
},
{
field: "ticketNo",
title: "作业票编号",
width: 250,
unresize: true,
align: "center",
sort: true,
// style: "word-break: break-all;",
},
{
field: "riskLevel",
title: "风险等级",
width: 140,
unresize: true,
align: "center",
sort: true,
templet: function (d) {
return setRiskLevelColor(d.riskLevel);
}
},
{
field: "workTeam",
title: "施工班组",
width: 190,
unresize: true,
align: "center",
sort: true
},
{
field: "teamLeader",
title: "班组长",
width: 140,
unresize: true,
align: "center",
sort: true,
templet: function (d) {
return '<span>' + setValue2(d.teamLeader) + '</span><br><span>' + setValue2(d.teamLeaderPhone) + '</span>'
}
},
{
field: "content",
title: "异常内容",
width: 260,
unresize: true,
align: "center",
sort: true,
templet: function (d) {
if (d.content) {
if (d.content.length > 100) {
return '<span title="' + d.content + '">' + d.content.substring(0, 100) + '...</span>'
} else {
return '<span title="' + d.content + '">' + d.content + '</span>'
}
} else {
return '';
}
}
},
{
field: "num",
title: "异常照片",
width: 150,
unresize: true,
align: "center",
sort: true,
templet: function (d) {
if (d.num === 0) {
return '0';
}
return '<div style="width: 40px;height: 40px;line-height:40px;cursor: pointer;color: #2F82FB" ' +
'onclick="getAbnormalImg(\'' + d.id + '\')"><span>' + d.num + '</span></div>';
}
},
{
field: "uploadTime",
title: "异常上报时间",
width: 200,
unresize: true,
align: "center",
sort: true
},
{
field: "inspector",
title: "督查人",
width: 150,
unresize: true,
align: "center",
sort: true
}
],
],
done: function (res, curr, count) {
layer.close(loadingMsg);
table.resize("violationStatisticsTable");
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
},
});
}
// 获取参数
function getReqParams(page, limit, type) {
let obj = {};
if (!type) {
obj = {
page: page + "",
limit: limit + "",
keyWord: $("#keyWord").val(),
ticketNo: $("#ticketNo").val(),
proName: $("#proName").val(),
riskLevel: formSelects.value('riskLevel', 'val').toString(),
inspector: $("#inspector").val(),
date: $("#createTime").val(),
};
} else {
obj = {
page: '1',
limit: '50',
keyWord: '',
ticketNo: '',
proName: '',
riskLevel: '',
inspector: '',
date: getStartTime() + " - " + getEndTime()
};
}
return obj;
}
// 查询
function query() {
let pattern = new RegExp("[%_<>]");
if (pattern.test($("#keyWord").val())) {
$("#keyWord").val('');
return layer.msg('关键字查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
if (pattern.test($("#ticketNo").val())) {
$("#ticketNo").val('');
return layer.msg('作业票查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
if (pattern.test($("#proName").val())) {
$("#proName").val('');
return layer.msg('工程名称查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
if (pattern.test($("#inspector").val())) {
$("#inspector").val('');
return layer.msg('督查人查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
pageNum = 1;
pages(1, limitSize)
}
function getAbnormalImg(id) {
let params = {
'id': id,
}
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/abnormalRep/getAbnormalImgById?token=" + token,
data: params,
type: 'POST',
async: false,
success: function (result) {
console.log(result)
if (result.code === 200) {
if (result.data) {
openImg(result.data);
}
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
} else if (result.code === 401) {
logout(1);
}
}, error: function () {
}
});
}
/*异常照片*/
function openImg(data) {
let width = getChooseWidth().toFixed(0) + "px";
let height = getChooseHeight().toFixed(0) + "px";
let layerIndex = layer.open({
id: "voiImg",
title: ['<div style="border-left: 3px solid #2F82FB;display: flex;align-items: center;height: 20px;padding: 0 10px;">异常照片</div>', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'],
type: 1,
maxmin: false,
content: setHtml(data),
area: [width, height],
move: false,
shade: 0.1,
success: function (layero, index) {
let viewer = new Viewer(document.getElementById('main-box'), {
url: 'data-original',
show: function () {
viewer.update();
}
});
$(window).resize(function () {
if (autoChooseResizeWidth) autoChooseResizeWidth(index);
if (autoChooseResizeHeight) autoChooseResizeHeight(index);
});
},
});
}
function setHtml(data) {
let html = '<div id="main-box" class="layout">';
$.each(data, function (index, item) {
let imgPath;
if (item.type === '1') {
imgPath = photoUrl + item.path + '?token=' + token
} else { // oss
imgPath = item.path
}
html += '<img class="voiImg" src="' + imgPath + '" data-original = "' + imgPath + '">'
})
html += '</div>';
return html;
}
/* 风险等级赋值 */
function setRiskLevel() {
let keys = [];
$.each(riskLevelList, function (index, item) {
let temp = {
"name": item.name,
"value": item.code
};
keys.push(temp);
})
formSelects.data('riskLevel', 'local', {
arr: keys
});
layui.form.render();
}