308 lines
9.1 KiB
JavaScript
308 lines
9.1 KiB
JavaScript
let table, layer, form;
|
|
let myChart = null, myChart2 = null;
|
|
layui.use(['layer', 'table', 'form'], function () {
|
|
layer = layui.layer;
|
|
table = layui.table;
|
|
form = layui.form;
|
|
let bidCode = parent.parent.$('#bidPro').val()
|
|
initTable(bidCode,"");
|
|
initEcharts(bidCode);
|
|
});
|
|
|
|
|
|
function initTable(bidCode,name) {
|
|
const url = commonUrl + "screen/largeScreen/engineeringSafetyAnalysis/list";
|
|
table.render({
|
|
elem: '#demo2',
|
|
url: url,
|
|
id: 'demo2',
|
|
skin: 'line',
|
|
page: true,
|
|
height: 'full-400',
|
|
headers: {
|
|
"decrypt": "decrypt",
|
|
"Authorization": token
|
|
},
|
|
where: {
|
|
bidCode: bidCode,
|
|
name:name
|
|
},
|
|
response: {
|
|
statusName: "code",
|
|
statusCode: 200,
|
|
countName: "count",
|
|
dataName: "rows",
|
|
},
|
|
cols: [[
|
|
{ type: 'numbers', title: '序号', width: '10%' }, // 添加序号列
|
|
{ field: 'monitoringPointId', title: '监测点编号', align: 'center', width: '10%' },
|
|
{ field: 'name', title: '监测点名称', align: 'center', width: '20%' },
|
|
{ field: 'temperature', title: '当前温度', align: 'center', width: '10%' },
|
|
{ field: 'humidity', title: '当前湿度', align: 'center', width: '10%' },
|
|
{ field: 'windSpeed', title: '当前风速', align: 'center', width: '10%' },
|
|
{ field: 'gasValue', title: '当前气体值', align: 'center', width: '10%' },
|
|
{
|
|
field: 'rateLevel', title: '最高隐患等级', align: 'center', width: '20%',
|
|
templet: function (d) {
|
|
let color = '';
|
|
if (d.level == "一般隐患") {
|
|
color = 'green';
|
|
} else if (d.level == '较大隐患') {
|
|
color = 'yellow';
|
|
} else if (d.level == '重大隐患') {
|
|
color = 'red';
|
|
}
|
|
return '<p style="color:' + color + '">' + d.level + '</p>';
|
|
}
|
|
}
|
|
]],
|
|
initComplete: function () {
|
|
// 在表格渲染完成后,重新渲染序号列
|
|
var that = this.elem.next();
|
|
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
|
|
tool.find("tr").each(function (index, item) {
|
|
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
|
|
});
|
|
},
|
|
done: function (res, curr, count, origin) {
|
|
// console.log(res);
|
|
}
|
|
})
|
|
}
|
|
|
|
function query(type) {
|
|
let name = $('#name').val();
|
|
let bidCode = parent.parent.$('#bidPro').val()
|
|
initTable(bidCode,name);
|
|
}
|
|
|
|
// 初始化 echarts
|
|
function initEcharts(bidCode) {
|
|
if(myChart && myChart2){
|
|
myChart.dispose();
|
|
myChart2.dispose();
|
|
}
|
|
myChart = echarts.init(document.getElementById("environmentChart"));
|
|
myChart2 = echarts.init(document.getElementById("riskChart"));
|
|
|
|
// let oneList = oneDataList.filter(item => {
|
|
// return item.bidCode === bidCode;
|
|
// });
|
|
|
|
const url = commonUrl + "screen/largeScreen/engineeringSafetyAnalysis/environmental";
|
|
$.ajax({
|
|
url: url,
|
|
type: "get",
|
|
headers: {
|
|
authorization: sessionStorage.getItem("zhgd_token"),
|
|
},
|
|
data: {
|
|
bidCode: bidCode,
|
|
},
|
|
success: function (data) {
|
|
console.log(data, "图表数据1===折线图");
|
|
|
|
if (data.rows && data.rows.length > 0) {
|
|
console.log(data.rows)
|
|
initEchartsOne(data.rows);
|
|
}
|
|
},
|
|
});
|
|
|
|
const url2 = commonUrl + "screen/largeScreen/engineeringSafetyAnalysis/hazards";
|
|
$.ajax({
|
|
url: url2,
|
|
type: "get",
|
|
headers: {
|
|
authorization: sessionStorage.getItem("zhgd_token"),
|
|
},
|
|
data: {
|
|
bidCode: bidCode,
|
|
},
|
|
success: function (data) {
|
|
console.log(data, "图表数据2===折线图");
|
|
if (data.rows && data.rows.length > 0) {
|
|
initEchartsTwo(data.rows);
|
|
}
|
|
},
|
|
});
|
|
}
|
|
|
|
function initEchartsOne(data) {
|
|
|
|
const dates = data.map(item => item.date);
|
|
const temperatures = data.map(item => item.temperature);
|
|
const humidities = data.map(item => item.humidity);
|
|
const windSpeeds = data.map(item => item.windSpeed);
|
|
|
|
const environmentOption = {
|
|
animation: false,
|
|
tooltip: {
|
|
trigger: 'axis'
|
|
},
|
|
legend: {
|
|
data: ['温度', '湿度', '风速'],
|
|
textStyle: {
|
|
color: "#fff", // 图例文本白色
|
|
},
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
data: dates,
|
|
axisLabel: {
|
|
color: "#fff", // X轴标签白色
|
|
},
|
|
axisLine: {
|
|
lineStyle: {
|
|
color: "#444", // X轴线颜色
|
|
},
|
|
},
|
|
splitLine: {
|
|
show: false, // 不显示X轴网格线
|
|
},
|
|
},
|
|
yAxis: [
|
|
{
|
|
type: 'value',
|
|
name: '温度/湿度',
|
|
nameTextStyle: {
|
|
color: "#fff", // Y轴名称白色
|
|
},
|
|
min: 0,
|
|
max: 100,
|
|
axisLabel: {
|
|
color: "#fff", // Y轴标签白色
|
|
},
|
|
axisLine: {
|
|
lineStyle: {
|
|
color: "#444", // Y轴线颜色
|
|
},
|
|
},
|
|
splitLine: {
|
|
lineStyle: {
|
|
color: "#333", // Y轴网格线颜色
|
|
type: "dashed", // 网格线样式
|
|
},
|
|
},
|
|
},
|
|
{
|
|
type: 'value',
|
|
name: '风速',
|
|
nameTextStyle: {
|
|
color: "#fff", // Y轴名称白色
|
|
},
|
|
min: 0,
|
|
max: 20,
|
|
axisLabel: {
|
|
color: "#fff", // 第二Y轴标签白色
|
|
},
|
|
axisLine: {
|
|
lineStyle: {
|
|
color: "#444", // 第二Y轴线颜色
|
|
},
|
|
},
|
|
splitLine: {
|
|
show: false, // 不显示第二Y轴网格线
|
|
},
|
|
}
|
|
],
|
|
series: [
|
|
{
|
|
name: '温度',
|
|
type: 'line',
|
|
data: temperatures,
|
|
itemStyle: {
|
|
color: "#4A90E2", // 蓝色
|
|
},
|
|
lineStyle: {
|
|
width: 2,
|
|
},
|
|
symbol: "circle", // 数据点为圆形
|
|
symbolSize: 8, // 数据点大小
|
|
},
|
|
{
|
|
name: '湿度',
|
|
type: 'line',
|
|
data: humidities,
|
|
itemStyle: {
|
|
color: "#50E3C2", // 绿色
|
|
},
|
|
lineStyle: {
|
|
width: 2,
|
|
},
|
|
symbol: "circle",
|
|
symbolSize: 8,
|
|
},
|
|
{
|
|
name: '风速',
|
|
type: 'line',
|
|
yAxisIndex: 1,
|
|
data: windSpeeds,
|
|
itemStyle: {
|
|
color: "#F5A623", // 橙黄色
|
|
},
|
|
lineStyle: {
|
|
width: 2,
|
|
},
|
|
symbol: "circle",
|
|
symbolSize: 8,
|
|
}
|
|
]
|
|
};
|
|
myChart.setOption(environmentOption, true);
|
|
window.addEventListener("resize", function () {
|
|
myChart.resize();
|
|
});
|
|
}
|
|
|
|
function initEchartsTwo(data) {
|
|
|
|
|
|
const seriesData = data.map(item => ({
|
|
name: item.level,
|
|
value: parseInt(item.count, 10),
|
|
itemStyle: {
|
|
color: getColorByLevel(item.level)
|
|
}
|
|
}));
|
|
|
|
function getColorByLevel(level) {
|
|
switch (level) {
|
|
case '一般隐患': return "#4A90E2";
|
|
case '较大隐患': return "#50E3C2";
|
|
case '重大隐患': return "#F5A623";
|
|
default: return "#ccc";
|
|
}
|
|
}
|
|
|
|
const riskOption = {
|
|
animation: false,
|
|
tooltip: {
|
|
trigger: 'item'
|
|
},
|
|
legend: {
|
|
orient: 'vertical',
|
|
left: 'left',
|
|
textStyle: {
|
|
color: "#fff", // 图例文本白色
|
|
},
|
|
},
|
|
series: [
|
|
{
|
|
name: '隐患分布',
|
|
type: 'pie',
|
|
radius: '50%',
|
|
data: seriesData,
|
|
emphasis: {
|
|
itemStyle: {
|
|
shadowBlur: 10,
|
|
shadowOffsetX: 0,
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
}
|
|
},
|
|
}
|
|
]
|
|
}
|
|
myChart2.setOption(riskOption, true)
|
|
}
|