" + '时间: ' + site.data.times[site.data.times.length - 1])
// 遍历站点数据中的每一项监测因子,生成页面
content += "
"
var _contents = new Map()
Object.keys(site.data.factor).forEach(k => {
var f = site.data.factor[k]
// 删选不显示的因子
if (f.factorName == 'NOI' || f.factorName == 'LNG' || f.factorName == 'LAT' || f.factorName == 'VELOCITY' ||
f.factorName == 'TIME' || f.factorName == 'HEIGHT') {
return
}
var d = f.datas[f.datas.length - 1]
var factor = Util.factorName[f.factorName]
var n = 1
if (f.factorName == 'WIND_DIRECTION') {
n = 0
}
var v = d.factorData.toFixed(n)
var unit = Util.factorUnit2[f.factorName]
if (f.factorName == 'CO') {
unit = 'μg/m³'
}
if (f.factorName == 'WIND_DIRECTION') {
unit += '(' + Util.windDir(d.factorData) + ')'
}
var c = ""
if (f.factorName == 'H2S' || f.factorName == 'PM10') {
c = "
"
}
c += "" + factor + " | "
c += "" + ': ' + " | "
c += "" + v + " | "
c += "" + unit + " | "
c += "
"
_contents.set(f.factorName, c)
})
var orderList = ['VOC', 'H2S', 'NO2', 'CO', 'SO2', 'O3', 'PM25', 'PM10', 'TEMPERATURE', 'HUMIDITY', 'WIND_SPEED', 'WIND_DIRECTION']
orderList.forEach(e => {
content += _contents.get(e)
});
content += "
"
var info = document.createElement("div");
// info.className = "custom-info input-card content-window-card";
info.className = "flexbox-col";
//可以通过下面的方式修改自定义窗体的宽高
//info.style.width = "400px";
// 定义顶部标题
var top = document.createElement("div");
// top.className = "info-top";
top.className = "ff-content ff-content-top-left ff-content-small-borderless-t info-top";
var top_b = document.createElement("div");
top_b.className = "ff-border-bottom"
var top_t = document.createElement("div");
top_t.className = "ff-border-top"
var top_c = document.createElement("div");
top_c.className = "ff-border-content flexbox flex-space-between"
var titleD = document.createElement("div");
var closeX = document.createElement("i");
titleD.innerHTML = title;
closeX.className = "fa fa-times"
$(closeX).attr('aria-hidden', 'true')
closeX.onclick = function () {
that.closeInfoWindow(site);
}
top_c.appendChild(titleD);
top_c.appendChild(closeX);
top_t.appendChild(top_c)
top.appendChild(top_b)
top.appendChild(top_t)
info.appendChild(top);
// 定义中部内容
var refreshV = document.createElement("div");
refreshV.className = 'refresh-btn'
var refresh = document.createElement("i");
refresh.className = 'fa fa-refresh'
$(refresh).attr('aria-hidden', 'true')
$(refresh).css('color', '#ffffffc0')
$(refresh).css('cursor', 'pointer')
refresh.onclick = function () {
$(this).addClass('fa-spin')
that.fetchingData(site.code, function () {
setTimeout(() => {
$(this).removeClass('fa-spin')
}, 1000);
}.bind(this))
}
var m_top = document.createElement("div");
m_top.className = "ff-content ff-content-left ff-content-medium";
var m_top_b = document.createElement("div");
m_top_b.className = "ff-border-bottom"
var m_top_t = document.createElement("div");
m_top_t.className = "ff-border-top"
var m_top_c = document.createElement("div");
m_top_c.className = "ff-border-content"
var m_top_f = document.createElement("div");
m_top_f.className = "ff-footer flexbox-col flex-center"
var m_top_tr = document.createElement("div");
m_top_tr.className = "ff-triangle"
var m_top_trb = document.createElement("div");
m_top_trb.className = "ff-triangle-border"
// $(refresh).on('click', site.code, function(event) {
// $(this).addClass('loading-pic')
// that.fetchingData(event.data, function() {
// $(this).removeClass('loading-pic')
// })
// });
refreshV.appendChild(refresh)
m_top_c.appendChild(refreshV);
var middle = document.createElement("div");
middle.className = "info-middle";
middle.innerHTML = content;
m_top_f.innerHTML = tag
m_top_c.appendChild(middle);
m_top_t.appendChild(m_top_c)
m_top_tr.appendChild(m_top_trb)
m_top.appendChild(m_top_b)
m_top.appendChild(m_top_t)
m_top.appendChild(m_top_f)
m_top.appendChild(m_top_tr)
info.appendChild(m_top);
// 定义底部内容
var bottom = document.createElement("div");
bottom.className = "info-bottom";
bottom.style.position = 'relative';
bottom.style.top = '0px';
bottom.style.margin = '0 auto';
var sharp = document.createElement("img");
sharp.src = "https://webapi.amap.com/images/sharp.png";
bottom.appendChild(sharp);
info.appendChild(bottom);
return info;
},
closeInfoWindow: function (site) {
site.infoWindow.close()
},
refreshInfoWindow: function (site, infoWindow) {
return this.createInfoWindow(site)
},
/**
* UI显示隐藏变化
*/
uiChange: function (isShow) {
// var g = $('#btn_gridmonitor')
// g.addClass('btn-unselected')
if (isShow) {
this.historyMode.setFactorMode('type2')
setTimeout(() => {
// g.removeClass()
// g.addClass('btn-selected margin-left-8')
$('#historybox').slideDown("fast")
$('#history_table_box').slideDown("fast")
$('#searchbox').slideDown("fast")
$('#table_title').html(" 监
测
数
据
详
情")
this.searchBox()
}, 500)
} else {
// DataUtil.hideAll()
$('.gMode').hide()
}
},
/**
* 搜索框重新初始化
*/
searchBox: function () {
var that = this
$('.hMode').hide()
$('.gMode').show()
var tD = $('#select_device_code')
tD.empty()
var options2 = ['0d0000000001']
var op = $('
')
options2.forEach(element => {
var op = $('
')
op.text(element)
tD.append(op)
});
$('#btn_search').off()
$('#btn_search').on('click', function () {
var deviceCode = $('#select_device_code').val()
var startTime = $('#starttime_text').text()
var endTime = $('#endtime_text').text()
var type = $('#select_data_type').val()
DataUtil.toggleLoading()
that.getHistoryData(deviceCode, startTime, endTime, 1, true, type)
})
this.getRealtimeData()
},
getRealtimeData: function () {
var that = this
DataUtil.toggleLoading()
HttpService.getRealtimeData("0d0000000001", 100, function (data) {
DataUtil.toggleLoading()
if (data.length == 0) {
alert("数据库没有任何数据")
return
}
var code = data[0].deviceCode
var factorMode = DataUtil.refreshFactorMode(code)
$('#starttime_text').text(data[0].time)
$('#endtime_text').text(data[data.length - 1].time)
that.timePicker.setStartDate(data[0].time)
that.timePicker.setEndDate(data[data.length - 1].time)
that.historyMode.setFactorData(data, factorMode, true)
MapUtil.clear3D()
that._showSite("0d0000000001")
}, {}, 1)//默认获取分钟数据
},
getHistoryData: function (deviceCode, startTime, endTime, page, loading, type) {
var that = this
HttpService.getHistoryData(deviceCode, startTime, endTime, page, 100000, function (data) {
if (loading) {
DataUtil.toggleLoading()
}
if (data.length == 0) {
alert('未查询到数据')
return
}
var factorMode = DataUtil.refreshFactorMode(deviceCode)
if (loading) {
that.historyMode.setFactorData(data, factorMode, true)
} else {
that.historyMode.addFactorData(data, true)
}
that._showSite(deviceCode)
}, function (head) {
setTimeout(() => {
if (page < head.totalPage) {
that.getHistoryData(deviceCode, startTime, endTime, page + 1, false, type)
}
}, 500);
}, type)
}
}