jjsp_web/bns/js/dutyTask/dailyDutyReport.js

726 lines
19 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, laydate, checkedDate;
let myChart4 = echarts.init(document.getElementById("voi-echarts"));
layui.use(["form", "laydate", "layer"], function () {
layer = layui.layer;
form = layui.form;
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
max: Date.parse(new Date()),
btns: ["now", "confirm"], //选择框右下角显示的按钮 清除-现在-确定
done: function (value, date) {
//时间回调
let dateArr = value.split(" - ");
setDateData(getAllDate(dateArr[0], dateArr[1]));
getDaily(dateArr[1]);
},
});
checkedDate = getNowTime();
$("#createTime").val(getBeforeDate(9) + " - " + getNowTime());
setDateData(getAllDate(getBeforeDate(9), getNowTime()));
getDaily(getNowTime());
});
// 设置日期数据
function setDateData(data) {
let reverseData = data.reverse();
let html = "";
reverseData.forEach((item, index) => {
if (index === 0) {
html +=
'<p class="p-checked date' +
(index + 1) +
'" id="lastDate" tabindex="' +
(index + 1) +
'" onclick="dailyDetail(\'' +
item +
"','" +
(index + 1) +
"')\">" +
item +
"</p> ";
} else {
html +=
'<p class="date' +
(index + 1) +
'" tabindex="' +
(index + 1) +
'" onclick="dailyDetail(\'' +
item +
"','" +
(index + 1) +
"')\">" +
item +
"</p> ";
}
});
$(".date-box").empty().append(html);
}
function dailyDetail(data, index) {
$(".date-box")
.find("p")
.each(function () {
if ($(this).hasClass("p-checked")) {
$(this).removeClass("p-checked");
}
});
$(".date" + index).addClass("p-checked");
$(".daily-box").css("display", "none");
$(".download-btn").css("display", "none");
getDaily(data);
checkedDate = data;
}
// 刷新数据
function refreshData() {
let loadingMsg = layer.msg("数据同步中,请稍候...", {
icon: 16,
scrollbar: false,
time: 0,
});
reloadDaily(getNowTime(), loadingMsg);
}
// 下载日报
function downloadDaily() {
let loadingMsg = layer.msg("日报下载中,请稍候...", {
icon: 16,
scrollbar: false,
time: 0,
});
let url =
dataUrl +
"proteam/pot/newDailyDutyReport/downloadDaily?currentDay=" +
checkedDate +
"&chineseDate=" +
setDate(checkedDate) +
"&token=" +
token;
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader(
"encrypt",
sm3(
JSON.stringify({
currentDay: checkedDate,
chineseDate: setDate(checkedDate),
})
)
);
xhr.onload = function () {
layer.close(loadingMsg);
if (this.status === 200) {
let blob = this.response;
var a = document.createElement("a");
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = "国网安徽电力基建安全日报" + setDate(checkedDate) + ".docx"; // 文件名
} else {
layer.msg("服务异常,请稍后重试", {
icon: 16,
scrollbar: false,
time: 2000,
});
}
a.click();
window.URL.revokeObjectURL(url);
};
xhr.send();
}
// 加载日报数据
function getDaily(currentDay) {
let loadingMsg = layer.msg("数据加载中,请稍候...", {
icon: 16,
scrollbar: false,
time: 0,
});
$.ajax({
headers: {
encrypt: sm3(
JSON.stringify({
currentDay: currentDay,
})
),
},
type: "POST",
url: dataUrl + "proteam/pot/newDailyDutyReport/getDailyData?token=" + token,
data: {
currentDay: currentDay,
},
async: false,
dataType: "json",
success: function (result) {
layer.close(loadingMsg);
if (result.code === 500) {
setDailyData(currentDay, null);
return layer.alert(data.msg, { icon: 2 });
} else if (result.code === 401) {
logout(1);
} else if (result.code === 200) {
if (result.data) {
setDailyData(currentDay, result.data);
} else {
setDailyData(currentDay, null);
}
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.close(loadingMsg); // 关闭提示层
layer.msg("数据加载发生异常,请稍后重试", {
icon: 16,
scrollbar: false,
time: 2000,
});
setDailyData(currentDay, null);
},
});
}
/* 重载日报数据 */
function reloadDaily(currentDay, loadingMsg) {
$.ajax({
headers: {
encrypt: sm3(
JSON.stringify({
currentDay: currentDay,
})
),
},
type: "POST",
url: dataUrl + "proteam/pot/newDailyDutyReport/getDailyData?token=" + token,
data: {
currentDay: currentDay,
},
async: false,
dataType: "json",
success: function (result) {
console.error(result);
layer.close(loadingMsg);
if (result.code === 500) {
setDailyData(currentDay, null);
return layer.alert(data.msg, { icon: 2 });
} else if (result.code === 401) {
logout(1);
} else if (result.code === 200) {
layer.msg("数据同步完成", { icon: 1, time: 2000 });
if (result.data) {
setDailyData(currentDay, result.data);
} else {
setDailyData(currentDay, null);
}
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.close(loadingMsg); // 关闭提示层
setDailyData(currentDay, null);
},
});
}
// 日报赋值
function setDailyData(data, dataMap) {
$(".daily-date").html(setDate(data));
$(".daily-box").css("display", "block");
$(".download-btn").css("display", "block");
if (data === getNowTime()) {
$(".refresh-btn").css("display", "block");
} else {
$(".refresh-btn").css("display", "none");
}
console.error(dataMap);
if (dataMap != null) {
setModuleOneData(dataMap);
setModuleTwoData(dataMap);
setModuleThreeData(dataMap);
setModuleFourData(dataMap);
//
//
//
// setModuleSevenData(dataMap);
// setModuleEightData(dataMap);
// setModuleNineData(dataMap);
// setModuleTenData(dataMap);
// setModuleElevenData(dataMap);
// initEchartsTwo(dataMap.moduleTwelve);
// setModuleThirteenData(dataMap);
}
/*安全质量检查总体情况*/
function setModuleOneData(data) {
$("#one_num").html(data.one_num);
$("#one_num2").html(data.one_num2);
$("#one_num3").html(data.one_num3);
$("#one_num4").html(data.one_num4);
$("#one_num5").html(data.one_num5);
$("#one_num6").html(data.one_num6);
$("#one_num7").html(data.one_num7);
}
/*班组及人员情况*/
function setModuleTwoData(data) {
$("#two_num").html(data.two_num);
$("#two_num2").html(data.two_num2);
$("#two_num3").html(data.two_num3);
}
/*作业计划执行情况*/
function setModuleThreeData(data) {
//日计划实施
$("#three_num").html(data.three_num);
$("#three_num2").html(data.three_num2);
$("#three_num3").html(data.three_num3);
$("#three_num4").html(data.three_num4);
$("#three_num5").html(data.three_num5);
// 今日视频监控接入情况
$("#four_num").html(data.four_num);
$("#four_num2").html(data.four_num2);
$("#four_num3").html(data.four_num3);
$("#four_num4").html(data.four_num4);
$("#four_num5").html(data.four_num5);
$("#four_rate").html(data.four_rate);
// 明日作业计划
$("#five_num").html(data.five_num);
$("#five_num2").html(data.five_num2);
$("#five_num3").html(data.five_num3);
$("#five_num4").html(data.five_num4);
$("#work_plan").html(data.work_plan);
// 明日作业计划-二级风险
let html = "";
if (data.twoRisks && data.twoRisks.length > 0) {
$.each(data.twoRisks, function (index, item) {
const str = item.content;
html += "<p class='module-content'>" + str + "</p>";
});
$("#twoRisksDiv").empty().append(html);
}
}
/*督查情况*/
function setModuleFourData(data) {
$("#six_num").html(data.six_num);
$("#six_num2").html(data.six_num2);
$("#six_num3").html(data.six_num3);
$("#six_num4").html(data.six_num4);
$("#six_num5").html(data.six_num5);
$("#six_num6").html(data.six_num6);
$("#six_num6").html(data.six_num6);
$("#seven_num").html(data.seven_num);
$("#seven_num2").html(data.seven_num2);
// 远程督查情况
setModuleElevenData(data);
// 整改情况
let html = "";
if (data.zgList && data.zgList.length > 0) {
$.each(data.zgList, function (index, item) {
const str = item.zg;
html += "<p class='module-content'>" + str + "</p>";
});
$("#zgListDiv").empty().append(html);
}
// 地市公司自查违章情况
$("#eight_num").html(data.eight_num);
$("#eight_num2").html(data.eight_num3);
$("#eight_num3").html(data.eight_num4);
initEchartsTwo(data.exceList);
// 关键措施照片上传和日报质量评价情况
if (data.tableList && data.tableList.length > 0) {
let cent = "";
$.each(data.tableList, function (index, item) {
cent +=
"<tr><td>" +
(index + 1) +
"</td><td>" +
item.name +
"</td><td>" +
item.num +
"</td><td>" +
item.hgs +
"</td><td>" +
item.lv +
"</td><td>" +
item.pj +
"</td></tr>";
});
$(".two-table tbody").empty().append(cent);
}
// 远程抽查情况
$("#cc_num").html(data.cc_num);
if (data.tableList2 && data.tableList2.length > 0) {
let cent = "";
$.each(data.tableList2, function (index, item) {
cent +=
"<tr><td>" +
(index + 1) +
"</td><td>" +
item.name +
"</td><td>" +
item.org +
"</td><td>" +
item.name2 +
"</td><td>" +
item.post +
"</td><td>" +
item.pj +
"</td></tr>";
});
$(".two2-table tbody").empty().append(cent);
}
// 二级风险明细
if (data.tableList3 && data.tableList3.length > 0) {
let cent = "";
$.each(data.tableList3, function (index, item) {
cent +=
"<tr><td>" +
(index + 1) +
"</td><td>" +
item.name +
"</td><td>" +
item.org +
"</td><td>" +
item.content +
"</td></tr>";
});
$(".two3-table tbody").empty().append(cent);
}
// 二级风险到岗到位抽查情况
if (data.tableList4 && data.tableList4.length > 0) {
let cent = "";
$.each(data.tableList4, function (index, item) {
cent +=
"<tr><td>" +
(index + 1) +
"</td><td>" +
item.name +
"</td><td>" +
item.yz +
"</td><td>" +
item.jl +
"</td><td>" +
item.sg +
"</td></tr>";
});
$(".seven-table tbody").empty().append(cent);
}
}
function setModuleElevenData(data) {
let html = "";
if (data.vioList && data.vioList.length > 0) {
$.each(data.vioList, function (index, item) {
html +=
'<table class="general-voi" id="general-voi' +
index +
'">' +
'<colgroup><col style="width: 20%;"></col><col style="width: 80%;"></col></colgroup>' +
'<tr style="color:#FF0000;"><td colspan="2" style="text-align: initial;padding-left: 40px;">' +
item.wzlx +
"</td></tr>" +
'<tr style="color:#FF0000;"><td>违章现场</td><td>' +
item.name +
"</td></tr>" +
'<tr style="height: 300px;color:#FF0000;"><td>违章照片</td><td>' +
setVoiPhotos(item) +
"</td></tr>" +
'<tr style="color:#FF0000;"><td>违章内容</td><td>' +
item.content +
"</td></tr>" +
'<tr style="color:#0000FF;"><td>违章依据</td><td>' +
item.yj +
"</td></tr>" +
'<tr style="color:#0000FF;"><td>违章处理情况</td><td>' +
item.dealwith +
"</td></tr>" +
'<tr style="height: 300px;color:#0000FF;"><td>整改照片</td><td>' +
setVoizgPhotos(item) +
"</td></tr>" +
"</table>";
});
} else {
html +=
'<table class="general-voi">' +
'<colgroup><col style="width: 20%;"></col><col style="width: 80%;"></col></colgroup>' +
'<tr style="color:#FF0000;"><td colspan="2" style="text-align: initial;padding-left: 40px;">一般违章</td></tr>' +
'<tr style="color:#FF0000;"><td>违章现场</td><td></td></tr>' +
'<tr style="height: 300px;color:#FF0000;"><td>违章照片</td><td></td></tr>' +
'<tr style="color:#FF0000;"><td>违章内容</td><td></td></tr>' +
'<tr style="color:#0000FF;"><td>违章依据</td><td></td></tr>' +
'<tr style="color:#0000FF;"><td>违章处理情况</td><td></td></tr>' +
'<tr style="height: 300px;color:#0000FF;"><td>整改照片</td><td></td></tr>' +
"</table>";
}
$(".general-voi-box").empty().append(html);
if (data.moduleEleven && data.moduleEleven.length > 0) {
$.each(data.moduleEleven, function (index, item) {
let viewer = new Viewer(
document.getElementById("general-voi" + index + ""),
{
url: "data-original",
show: function () {
viewer.update();
},
}
);
});
}
}
/* 违章照片 */
function setVoiPhotos(obj) {
let cent = '';
let voiImgList = obj.voiImgList;
$.each(voiImgList, function (index, item) {
let path = photoUrl + item.img2 + "?token=" + token;
cent +=
'<img src="' +
path +
'" width="530" height="350" style="margin-bottom:10px;" data-original = "' +
path +
'">';
});
return cent;
}
/* 整改图片 */
function setVoizgPhotos(obj) {
let cent = '';
if (obj.hasWord == 1) {
let voizgFileList = obj.voizgFileList;
$.each(voizgFileList, function (index, item) {
let path = '../../img/word.png';
cent +=
'<img src="' +
path +
'" width="200" height="200" style="margin-bottom:10px;" data-original = "' +
path +
'">';
});
} else {
let voizgImgList = obj.voizgImgList;
$.each(voizgImgList, function (index, item) {
let path = photoUrl + item.img2 + "?token=" + token;
cent +=
'<img src="' +
path +
'" width="530" height="350" style="margin-bottom:10px;" data-original = "' +
path +
'">';
});
}
return cent;
}
/*周风险echarts*/
function initEchartsTwo(dataList) {
let xAxisList = [];
let data = [];
let data2 = [];
let data3 = [];
$.each(dataList, function (index, item) {
xAxisList.push(item.cityName);
data.push(item.zbhNum);
data2.push(item.yzwzNum);
data3.push(item.ybwzNum);
});
let fontSize = "14";
// 基于准备好的dom初始化echarts图表
let option = {
backgroundColor: "transparent",
tooltip: {
show: false,
},
legend: {
// right: '3%',
top: "92%",
itemWidth: 10,
itemHeight: 10,
itemGap: 15,
// 环图之间间隔,图例防抖动
inactiveBorderWidth: 0,
itemStyle: {
borderWidth: 0,
},
selectedMode: false,
},
grid: {
left: "3%",
right: "3%",
bottom: "10%",
top: "15%",
containLabel: true,
},
calculable: true,
xAxis: [
{
type: "category",
axisLabel: {
interval: 0, // 解决x轴名称过长问题
rotate: 45,
textStyle: {
color: "#262626",
fontSize: 14,
fontFamily: "Alibaba PuHuiTi R",
},
},
axisLine: {
show: false,
lineStyle: {
//y轴网格线设置
color: "#262626",
width: 1,
},
},
data: xAxisList,
},
],
yAxis: [
{
type: "value",
// name: "单位/个",
nameGap: 8,
nameTextStyle: {
color: "#262626",
},
axisTick: {
show: false,
},
axisLine: {
show: false,
lineStyle: {
//y轴网格线设置
color: "#2c2c2c",
width: 1,
},
},
splitLine: {
//保留网格线
show: true,
lineStyle: {
//y轴网格线设置
color: "#101C4A",
width: 1,
},
},
axisLabel: {
show: true,
textStyle: {
fontSize: 16,
color: "#262626", //字体颜色
fontFamily: "Alibaba PuHuiTi R",
},
},
},
],
series: [
{
name: "作业现场",
type: "bar",
z: 1,
barWidth: 6,
barGap: "100%",
label: {
show: true,
position: "top",
textStyle: {
color: "#262626",
},
},
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
{
offset: 0,
color: "#4472c4",
},
{
offset: 1,
color: "#4c87ef",
},
]),
},
},
data: data,
},
{
name: "严重违章",
type: "bar",
barGap: "100%",
z: 1,
barWidth: 6,
label: {
show: true,
position: "top",
textStyle: {
color: "#262626",
},
},
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
{
offset: 0,
color: "#618b35",
},
{
offset: 1,
color: "#97ec3e",
},
]),
},
},
data: data2,
},
{
name: "一般违章",
type: "bar",
barGap: "100%",
z: 1,
barWidth: 6,
label: {
show: true,
position: "top",
textStyle: {
color: "#262626",
},
},
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
{
offset: 0,
color: "#a83232",
},
{
offset: 1,
color: "#d02020",
},
]),
},
},
data: data3,
},
],
};
myChart4.setOption(option, true);
window.addEventListener("resize", function () {
myChart4.resize();
});
}
}