'+params[i].marker+params[i].seriesName+':'+params[i].value+ unit+''
}
html += ''+valSeltm1[params[0].dataIndex]+'
'
return html;
}
},
legend: {
type:'scroll',
top:'5',
orient: 'horizontal',
// data:legendData,
data:newLegendDataArr,
selected:selected,
textStyle : {color:'#fff'},
pageTextStyle:{color:'#fff'},
pageIconColor:'#fff',
pageIconInactiveColor:'#fff',
top:topVal,
itemWidth:14
},
grid: {
left: '12',
right: '4%',
bottom: '0',
top:'15%',
containLabel: true
},
dataZoom: dataZooms,
xAxis: {
show:true,
type: 'category',
nameTextStyle:{color:'#fff'},
axisLabel: {
textStyle: {
padding:[0, 0, 0, 8],
color: '#fff'
}
},
axisLine:{
show:true,
lineStyle:{color:'#fff'},
},
axisTick:{
show:false
},
data:hosName,
axisLabel: {
interval: 0,
fontSize:11,
formatter:function(value){
var ret = "", start = "";//拼接加\n返回的类目项
var maxLength = 4;//每项显示文字个数
var rowN = Math.ceil(value.length / maxLength); //类目项需要换行的行数
if (rowN > 1){
for (var i = 0; i < rowN; i++) {
start = i * maxLength;//开始截取的位置
if(i == 0){
ret += value.substring(start, (start + maxLength)); //凭借最终的字符串
}else{
ret += "\n"+value.substring(start, (start + maxLength)); //凭借最终的字符串
}
}
return ret;
}else{
return value;
}
}
}
},
yAxis: [{
show:true,
name: '',
type: 'value',
axisLine:{
lineStyle:{color:'#fff'},
},
axisTick:{
show:false
},
axisLabel: {
margin: 10,
textStyle: {
fontSize: 12,
color: '#fff'
}
},
splitLine:{
lineStyle:{color:'#fff'},
show:false
},
},{
show:true,
name: '',
type: 'value',
axisLine:{
lineStyle:{color:'#fff'},
},
axisTick:{
show:false
},
axisLabel: {
margin: 10,
textStyle: {
fontSize: 12,
color: '#fff'
}
},
splitLine:{
lineStyle:{color:'#fff'},
show:false
},
}],
series: seriesData,
};
waterHistory.setOption(waterOption);
$(window).resize(waterHistory.resize);
//先解除事件监听,再添加
waterHistory.off('legendselectchanged');
waterHistory.on('legendselectchanged', function(params) {
clickName = params.name;
for(var x in legendData){
if(legendData[x] == clickName){
var index = x;
}
}
var keys;
//获取第一个元素
for(var i in params.selected){
keys = i;
break;
}
for(var z in params.selected){
//如果选中元素是第一个,则不进行其他元素操作
if(params.name == keys){
break;
}
//不是选中元素且不是第一个元素的元素都取消选中
if(z != params.name && z != keys){
params.selected[z] = false;
}
}
if(index == 0){
if(num == 1){
if(params.selected[clickName]){
waterOption.legend.data[index].icon = 'image://./images/c1.png';
}else{
waterOption.legend.data[index].icon = 'image://./images/f1.png'
}
}else if(num == 2){
if(params.selected[clickName]){
waterOption.legend.data[index].icon = 'image://./images/c2.png';
}else{
waterOption.legend.data[index].icon = 'image://./images/f2.png'
}
}else if(num == 3){
if(params.selected[clickName]){
waterOption.legend.data[index].icon = 'image://./images/c4.png';
}else{
waterOption.legend.data[index].icon = 'image://./images/f4.png'
}
}else if(num == 4){
if(params.selected[clickName]){
waterOption.legend.data[index].icon = 'image://./images/c3.png';
}else{
waterOption.legend.data[index].icon = 'image://./images/f3.png'
}
}
}else{
if(num == 1){
if(params.selected[clickName]){
for(var s in waterOption.legend.data){
if(s == index){
waterOption.legend.data[index].icon = 'image://./images/s1.png';
}else{
if(s != 0){
waterOption.legend.data[s].icon = 'image://./images/d1.png';
}
}
}
}else{
waterOption.legend.data[index].icon = 'image://./images/d1.png'
}
}else if(num == 2){
if(params.selected[clickName]){
for(var s in waterOption.legend.data){
if(s == index){
waterOption.legend.data[index].icon = 'image://./images/s2.png';
}else{
if(s != 0){
waterOption.legend.data[s].icon = 'image://./images/d2.png';
}
}
}
}else{
waterOption.legend.data[index].icon = 'image://./images/d2.png'
}
}else if(num == 3){
if(params.selected[clickName]){
for(var s in waterOption.legend.data){
if(s == index){
waterOption.legend.data[index].icon = 'image://./images/s4.png';
}else{
if(s != 0){
waterOption.legend.data[s].icon = 'image://./images/d4.png';
}
}
}
}else{
waterOption.legend.data[index].icon = 'image://./images/d4.png'
}
}else if(num == 4){
if(params.selected[clickName]){
for(var s in waterOption.legend.data){
if(s == index){
waterOption.legend.data[index].icon = 'image://./images/s3.png';
}else{
if(s != 0){
waterOption.legend.data[s].icon = 'image://./images/d3.png';
}
}
}
}else{
waterOption.legend.data[index].icon = 'image://./images/d3.png'
}
}
}
naturalEchart(this, hosName, legendData, seriesData, params.selected, mold, valSeltm1, unitData, newLegendDataArr, num);
})
}
//******************** 实时数据 -- 更多 *******************
$(".acreage-close").unbind().click(function(){
//关闭弹窗
$('.history-query-box').hide();
});
$('.acreage-more').unbind().click(function(){
//更多 --- 打开弹窗
$(".history-query").hide();
$(".history-query-title h3").html($(this).attr("data-html"));
$('.history-query-box').show();
$("#stationInputTitle").val($(this).attr('data-id'));
$("#stationInputJc").val("");
$("#querySelects5").find("option").each(function(){
$(this).removeAttr("selected");
if($(this).val() == ""){
$(this).attr("selected","selected");
findStnmJc("");
}
})
layui.use('form', function(){ //监听站点选中事件 动态更新站点
var form = layui.form;
form.render();
});
historyQueryEchartJc.dispose(); //销毁图表
$(window).off('resize'); //移除已销毁图表的resize事件
historyMoreQueryJc();
});
//******************** 实时数据 -- 查询 *******************
$("#hisToryQueryBtnJc").unbind().click(function(){
historyQueryEchartJc.dispose(); //销毁图表
$(window).off('resize'); //移除已销毁图表的resize事件
historyMoreQueryJc(historyQueryEchartJc);
});
$("#hisToryClearBtnJc").unbind().click(function(){
$("#stationInputJc").val("");
$("#querySelects5").find("option").each(function(){
$(this).removeAttr("selected");
if($(this).val() == ""){
$(this).attr("selected","selected");
findStnmJc("");
}
})
layui.use('form', function(){ //监听站点选中事件 动态更新站点
var form = layui.form;
form.render();
});
historyQueryEchartJc.dispose(); //销毁图表
$(window).off('resize'); //移除已销毁图表的resize事件
historyMoreQueryJc();
});
$("#hisToryDownLoadBtnJc").unbind().click(function(){
var type = $('.history-query-title h3').html();
if(type == '水文与环境监测'){
var sendType = 'T_DATA_WATER';
}else if(type == '空气环境监测'){
var sendType = 'T_DATA_AIR';
}else if(type == '气象监测'){
var sendType = 'T_DATA_WEATHER';
}else if(type == '土壤监测'){
var sendType = 'T_DATA_SOIL';
}
type = encodeURI(type, "UTF-8");
$.ajax({
url:getNativePath() + "naturalFactors/booleanExcelExportEleDataByStcdOrEleName.do?eleName=" + sendType + "&stcd=",
success:function(res){
if(res && res.success){
window.open(getNativePath() + "naturalFactors/excelExportEleDataByStcdOrEleName.do?eleName=" + sendType + "&title=" + type + "&stcd=");
}else{
layer.msg('暂无数据,无法下载!');
}
}
});
})
function historyMoreQueryJc(){
$(".his-loding").show();
$(".histor-tip").hide();
var dataId = $("#stationInputTitle").val();
var stcd = $("#stationInputJc").val();
historyQueryEchartJc = echarts.init(document.getElementById('historyQueryEchartJc')); //初始化图表
if(dataId == "T_DATA_WATER"){
WaterElement(dataId, stcd, historyQueryEchartJc, 1, 2);
}else if(dataId == "T_DATA_AIR"){
WaterElement(dataId, stcd, historyQueryEchartJc, 2, 2);
}else if(dataId == "T_DATA_SOIL"){
WaterElement(dataId, stcd, historyQueryEchartJc, 3, 2);
}else if(dataId == "T_DATA_WEATHER"){
WaterElement(dataId, stcd, historyQueryEchartJc, 4, 2);
}
}
//******************** 历史数据 *******************
$.ajax({
url: getNativePath() + "fieldsdict/findAllEleInfoGroupByType.do",
type: "get",
dataType: "json",
success: function(data) {
$('.tes').hide();
selectData(data.data.T_DATA_WATER, "waterSelect", waterHistory);
selectData(data.data.T_DATA_AIR, "airSelect", airHistory);
selectData(data.data.T_DATA_SOIL, "soilSelect", soilHistory);
selectData(data.data.T_DATA_WEATHER, "weatherSelect", weatherHistory);
renderForm();
}
});
function renderForm(){
layui.use('form', function(){
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
form.render();
form.on('select(wateraihao)', function(e){
$(".main-bottom .monit-history:nth-child(1) .monit-tip").hide();
historyData(e.value,"waterSelect", waterHistory);
});
form.on('select(airaihao)', function(e){
$(".main-bottom .monit-history:nth-child(2) .monit-tip").hide();
historyData(e.value, "airSelect", airHistory);
});
form.on('select(soilaihao)', function(e){
$(".main-bottom .monit-history:nth-child(4) .monit-tip").hide();
historyData(e.value, "soilSelect", soilHistory);
});
form.on('select(weatheraihao)', function(e){
$(".main-bottom .monit-history:nth-child(3) .monit-tip").hide();
historyData(e.value, "weatherSelect", weatherHistory);
});
});
}
function selectData(datas, selId, echartBox){
var html = "";
//-----------------------------------------
if(selId == "airSelect"){
var datasList = [];
for(var i=0; i'+
datas[i].fieldName+'';
}else{
html += '';
}
}
$('#'+selId).html(html);
}
function historyData(field, selId, echartBox){
$(window).resize(waterHistory.resize);
$(window).resize(airHistory.resize);
$(window).resize(soilHistory.resize);
$(window).resize(weatherHistory.resize);
echartBox.clear();
var datas = {}, unit="";
for(var k in actualImgParam){
if(k == field){
unit = actualImgParam[k].unit;
}
};
if(selId != "querySelects"){
var nowtime = new Date();
var endtime = times(nowtime);
var starttime = nowtime.getFullYear()+'-'+p(nowtime.getMonth()+1)+"-"+p(nowtime.getDate())+" 00:00:00";
$("#historyStratTime").val(starttime);
$("#historyEndTime").val(endtime);
datas = {"startTime":starttime, "endTime":endtime, "elementId":field, "stcd":""};
}else{
var endtime = $("#historyEndTime").val();
var starttime = $("#historyStratTime").val();
var stationInput = $("#stationInput").val();
datas = {"startTime":starttime, "endTime":endtime, "elementId":field, "stcd":stationInput};
}
datas.endTime = getToday("e", 0);
$.ajax({
url: getNativePath() + "naturalFactors/findElementStationInfo.do",
type: "get",
data:datas,
dataType: "json",
success: function(data) {
$(".his-loding").hide();
$(".histor-tip").hide();
// console.log(data)
if(data.data.length > 0){
//-------------------------------------------
if(data.data.length == 1){
var dataList = data.data;
}else{
var dataList = [];
for(var i=0; i 4){
seriesData = seriesData.slice(0,4);
legendData = legendData.slice(0,4);
}
}
historyEchart(echartBox, time, legendData, seriesData, selected, selId, unit);
}
function historyEchart(waterHistory, time, legendData, seriesData, selected, selId, unit){
if(unit){
unit = "("+unit+")";
}
var colorData = ['#FC9E17', '#08f67c', '#50a37d', '#2ac2de', '#FC9E17', '#f8da0f', '#a63535', '#f89c00', '#a06602', '#189f5a'];
var dataZooms = [];
if(selId == "querySelects"){
dataZooms = [{
type: 'inside',
start: 0,
end: 100
}, {
start: 0,
end: 10,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
bottom:'35',
height:8,
handleColor: '#ff8c80',
handleStyle: {
borderColor: '#ff8c80',
borderWidth: "1",
shadowBlur: 0,
background: '#ff8c80',
shadowColor: '#ff8c80',
},
}]
}
var waterOption = {
color:colorData,
tooltip: {
trigger: 'axis',
},
legend: {
type:'scroll',
orient: 'horizontal',
data:legendData,
selected:selected,
textStyle : {color:'#fff'},
pageTextStyle:{color:'#fff'},
pageIconColor:'#fff',
pageIconInactiveColor:'#fff',
right:'90',
left:'10',
top:'5',
itemWidth:14
},
grid: {
left: '12',
right: '4%',
bottom: '1%',
top:'45',
containLabel: true
},
dataZoom: dataZooms,
xAxis: {
type: 'category',
show:true,
boundaryGap: false,
nameTextStyle:{color:'#fff'},
axisLabel: {
textStyle: {
color: '#fff'
}
},
axisLine:{
lineStyle:{
color:"#fff"
}
},
splitLine:{
lineStyle:{color:'#fff'},
interval:false
},
data:time.map(function(str) {
return str.replace(' ', '\n')
})
},
yAxis: {
name: unit,
type: 'value',
nameGap:8,
show:true,
axisLine:{
lineStyle:{
color:"#fff"
}
},
axisTick:{
show:false
},
axisLabel: {
margin: 10,
textStyle: {
fontSize: 12,
color: '#fff'
}
},
splitLine:{
lineStyle:{color:'#fff'},
show:false
},
},
series: seriesData
};
waterHistory.setOption(waterOption);
$(window).resize(waterHistory.resize);
}
//******************** 历史数据 ----- 更多 *******************
$(".his-close").unbind().click(function(){
//关闭更多
$(".history-query").hide();
$(".history-query").removeClass('on');
});
$('.history-more').unbind().click(function(){
$('.history-query-box').hide();
var dataId = $(this).attr('data-id');
$("#historyType").val(dataId);
strTime = getToday("s", 0);
endTime = getToday("e", 0);
$("#historyStratTime").val(strTime);
$("#historyEndTime").val(endTime);
$(".history-query-date span").removeClass('on');
$(".history-query-date span").eq(0).addClass('on');
$(".history-query-title h3").html($(this).attr("data-html"));
$("#stationInput").val("");
$("#querySelects1").find("option").each(function(){
$(this).removeAttr("selected");
if($(this).val() == ""){
$(this).attr("selected","selected");
findStnm("");
}
})
layui.use('form', function(){ //监听站点选中事件 动态更新站点
var form = layui.form;
form.render();
});
historyMoreQuery(dataId);
});
function historyMoreQuery(dataId){
$(".his-loding").show();
$('.histor-tip').hide();
var stcd = $("#searchScid").val();
var starttime = $("#historyStratTime").val();
var endtime = $("#historyEndTime").val();
if(starttime.length < 14){
starttime = starttime +" 00:00:00";
endtime = endtime+" 23:59:59"
}
$(".history-query").show();
$(".history-query").addClass('on');
historyQueryEchart.dispose(); //销毁图表
$(window).off('resize'); //移除已销毁图表的resize事件
historyQueryEchart = echarts.init(document.getElementById('historyQueryEchart')); //初始化图表
$.ajax({
url: getNativePath() + "fieldsdict/findAllEleInfoGroupByType.do",
type: "get",
dataType: "json",
success: function(data) {
var jsons = [], html="";
if(dataId == "host1"){
jsons = data.data.T_DATA_WATER;
}else if(dataId == "host2"){
jsons = data.data.T_DATA_AIR;
//-----------------------------------
var datasList = [];
for(var i=0; i'+
jsons[i].fieldName+'';
}else{
html += '';
}
}
$('#querySelects3').html(html);
layui.use('form', function(){
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
form.render();
form.on('select(querySelect3)', function(e){
$("#actualInput").val(e.value);
});
});
}
});
}
//******************** 历史数据 ----- 查询 *******************
$("#hisToryQueryBtn").unbind().click(function(){
$(".his-loding").show();
$('.histor-tip').hide();
var values = $("#actualInput").val();
historyQueryEchart.dispose(); //销毁图表
$(window).off('resize'); //移除已销毁图表的resize事件
historyQueryEchart = echarts.init(document.getElementById('historyQueryEchart')); //初始化图表
historyData(values,"querySelects", historyQueryEchart);
});
$("#hisToryClearBtn").unbind().click(function(){
$("#stationInput").val("");
$("#querySelects1").find("option").each(function(){
$(this).removeAttr("selected");
if($(this).val() == ""){
$(this).attr("selected","selected");
findStnm("");
}
})
layui.use('form', function(){ //监听站点选中事件 动态更新站点
var form = layui.form;
form.render();
});
$(".history-query-date span").removeClass('on').eq(0).addClass('on');
var nowtime = new Date();
var endtime = times(nowtime);
var starttime = nowtime.getFullYear()+'-'+p(nowtime.getMonth()+1)+"-"+p(nowtime.getDate())+" 00:00:00";
$("#historyStratTime").val(starttime);
$("#historyEndTime").val(endtime);
var values = $("#actualInput").val();
historyQueryEchart.dispose(); //销毁图表
$(window).off('resize'); //移除已销毁图表的resize事件
historyQueryEchart = echarts.init(document.getElementById('historyQueryEchart')); //初始化图表
historyData(values,"querySelects", historyQueryEchart);
});
$("#hisToryDownLoadBtn").unbind().click(function(){
var nowtime = new Date();
var endtime = times(nowtime);
var starttime = $('#historyStratTime').val();
if(starttime.length<19){
starttime += " 00:00:00";
}
$.ajax({
url:getNativePath() + "naturalFactors/booleanExcelExportMonitorElements.do?stcd=" + selectstcd + "&startTime=" + starttime + "&endTime=" + endtime + "&elementId=" + $("#actualInput").val() + "&title=" + encodeURI($('.history-query-title h3').html(), "UTF-8") + "",
success:function(res){
if(res && res.success){
window.open(getNativePath() + "naturalFactors/excelExportMonitorElements.do?stcd=" + selectstcd + "&startTime=" + starttime + "&endTime=" + endtime + "&elementId=" + $("#actualInput").val() + "&title=" + encodeURI($('.history-query-title h3').html(), "UTF-8") + "")
}else{
layer.msg('暂无数据,无法下载!');
}
}
});
})
$(".history-query-date span").unbind().click(function(){
$(".his-loding").show();
$('.histor-tip').hide();
var type = $(this).attr("data-txt");
var strTime = "", endTime = "";
var values = $("#actualInput").val();
$(this).addClass('on').siblings().removeClass('on');
if(type == "day"){
strTime = getToday("s", 0);
endTime = getToday("e", 0);
}else if(type == "week"){
strTime = getMonday("s", 0);
endTime = getToday("e", 0).substr(0,10);
}else if(type == "month"){
strTime = getMonth("s", 0);
endTime = getToday("e", 0).substr(0,10);
}
$("#historyStratTime").val(strTime);
$("#historyEndTime").val(endTime);
historyQueryEchart.dispose(); //销毁图表
$(window).off('resize'); //移除已销毁图表的resize事件
historyQueryEchart = echarts.init(document.getElementById('historyQueryEchart')); //初始化图表
historyData(values,"querySelects", historyQueryEchart);
});
function max(arr){
var num = arr[0];
for(var i=0;i