function ComplaintLayer2(options) {
|
//时间选择器
|
this.timePicker;
|
//分析结果
|
this.epwResult;
|
//网格绘制信息
|
this.points = [];
|
this.factor = 'VOC'
|
|
this.gridAnalysis = new GridAnalysis();
|
}
|
|
ComplaintLayer2.prototype = {
|
init: function () {
|
this.searchBox();
|
},
|
enable: function () {
|
this.isEnable = true;
|
this.uiChange(true);
|
},
|
disable: function () {
|
this.isEnable = false;
|
this.uiChange(false);
|
},
|
/**
|
* UI显示隐藏变化
|
*/
|
uiChange: function (isShow) {
|
if (isShow) {
|
$('#epw_model').slideDown('fast');
|
}
|
},
|
|
searchBox: function () {
|
var that = this;
|
|
this.timePicker = DPicker.timePicker(
|
'epw_date_2',
|
function (startTime, endTime) {
|
$('#epw_starttime_text').text(startTime);
|
$('#epw_endtime_text').text(endTime);
|
}
|
);
|
var m = moment();
|
var now = m.format('YYYY-MM-DD HH:mm:ss');
|
var hourago = m.add(-1, 'hours').format('YYYY-MM-DD HH:mm:ss');
|
$('#epw_starttime_text').text(hourago);
|
$('#epw_endtime_text').text(now);
|
this.timePicker.setStartDate(hourago);
|
this.timePicker.setEndDate(now);
|
|
//选择显示的因子
|
$('.epw_f_radio_2').on('click', function () {
|
if (that.factor != this.value) {
|
that.factor = this.value;
|
if (that.searched) {
|
that.refreshEPW();
|
}
|
}
|
});
|
//开始分析
|
$('#btn_search_epw_2').on('click', function () {
|
that.searched = true;
|
that.getEPWResult();
|
});
|
//清空分析结果
|
$('#btn_clear_epw_2').on('click', function () {
|
that.gridAnalysis.clear()
|
});
|
//网格透明度切换
|
$('#epw_transparent_grid').on('click', function () {
|
if (this.checked) {
|
that.gridAnalysis.changeOpacity(false)
|
} else {
|
that.gridAnalysis.changeOpacity(true)
|
}
|
})
|
//文本显示切换
|
$('#epw_text').on('click', function () {
|
if (this.checked) {
|
that.gridAnalysis.toggleText(true)
|
} else {
|
that.gridAnalysis.toggleText(false)
|
}
|
})
|
//获取设备编号
|
HttpService.getDeviceInfo(function (data) {
|
var s = $('#epw_device_code');
|
s.empty();
|
data.forEach((element) => {
|
var op = $('<option></option>');
|
op.text(element.deviceCode);
|
s.append(op);
|
});
|
});
|
},
|
|
getEPWResult: function () {
|
var that = this;
|
var st = $('#epw_starttime_text').text();
|
var et = $('#epw_endtime_text').text();
|
var deviceCode = $('#epw_device_code').val();
|
|
DataUtil.toggleProcessing();
|
HttpService.getGridEPWResult(deviceCode, st, et, 100.0, function (data) {
|
DataUtil.toggleProcessing();
|
if (data.length == 0) {
|
alert('无数据');
|
} else {
|
that.epwResult = data;
|
that.refreshEPW(true);
|
}
|
}.bind(this)
|
);
|
},
|
|
refreshEPW: function (force) {
|
var centerData = this.epwResult[Math.ceil(this.epwResult.length / 2)];
|
MapUtil.setCenter([centerData.ciLongitude, centerData.ciLatitude]);
|
|
if (force || this.points.length == 0) {
|
this.points = []
|
this.epwResult.forEach((r) => {
|
this.points.push({
|
c: [r.ciLongitude, r.ciLatitude],
|
lb: [r.lb.first, r.lb.second],
|
rt: [r.rt.first, r.rt.second],
|
factor: this.factor,
|
value: r.result[this.factor],
|
level: r.level[this.factor],
|
});
|
});
|
} else {
|
for (let i = 0; i < this.epwResult.length; i++) {
|
const r = this.epwResult[i];
|
this.points[i].factor = this.factor;
|
this.points[i].value = r.result[this.factor];
|
this.points[i].level = r.level[this.factor];
|
}
|
}
|
this.gridAnalysis.drawRectangle(this.points);
|
},
|
};
|