// map
|
var isInitialized = false;
|
|
var mode = 1; //走航监测或污染溯源
|
var factorMode = 'type0'; //type0: 无人机和车载;type1:无人船
|
|
function toggleLoading() {
|
var l = $('#loading');
|
l.toggle();
|
}
|
|
function initModeChange() {
|
$('#btn_more').on('click', function () {
|
$('#mode_others').toggle();
|
});
|
$('.mode-btn').on('click', function () {
|
DataUtil.hideAll();
|
$(this).removeClass('btn-unselected');
|
$(this).addClass('btn-selected');
|
switch ($(this).attr('id')) {
|
case 'btn_history':
|
mode = 1;
|
$('#web_title').text('飞羽生态环境智能走航监测系统');
|
break;
|
case 'btn_realtime':
|
mode = 0;
|
$('#web_title').text('飞羽生态环境智能走航监测系统');
|
break;
|
case 'btn_gridmonitor':
|
mode = 2;
|
$('#web_title').text('飞羽生态环境智能监测平台');
|
break;
|
case 'btn_electricity':
|
mode = 3;
|
$('#web_title').text('飞羽生态环境智能监测平台');
|
break;
|
case 'btn_weight':
|
mode = 4;
|
$('#web_title').text('飞羽生态环境智能监测平台');
|
break;
|
default:
|
break;
|
}
|
mapController.modeChange(mode);
|
});
|
$('.mode-btn-other').on('click', function () {
|
let more = $('#btn_more');
|
more.removeClass('btn-unselected');
|
more.addClass('btn-selected');
|
// more.text()
|
$('#mode_others').toggle();
|
});
|
}
|
|
function onCheckMap(obj) {
|
var o = obj.value.split(',');
|
var factorType = parseInt(o[0]) - 1;
|
mapController.setFactorType(factorType, this.factorMode, o[1]);
|
}
|
|
function initToggleEvent() {
|
var btnList = $('.ff-toggle-btn');
|
var blockList = $('.ff-toggle-block');
|
for (let i = 0; i < btnList.length; i++) {
|
var b = btnList[i];
|
$(b).on('click', function () {
|
$(blockList[i]).toggle('fast');
|
});
|
}
|
}
|
|
function initSetRangeEvent() {
|
$('#in_min').on('input', function () {
|
onConfirm();
|
});
|
$('#in_max').on('input', function () {
|
onConfirm();
|
});
|
onConfirm();
|
}
|
|
function onConfirm() {
|
$('#btn_set_range').text('确定');
|
$('#btn_set_range').off('click');
|
$('#btn_set_range').on('click', function () {
|
var minData1 = parseFloat($('#in_min').val());
|
var maxData1 = parseFloat($('#in_max').val());
|
onCancel();
|
mapController.setRange([minData1, maxData1]);
|
});
|
}
|
|
function onCancel() {
|
$('#btn_set_range').text('清空');
|
$('#btn_set_range').off('click');
|
$('#btn_set_range').on('click', function () {
|
onConfirm();
|
mapController.resetRange();
|
});
|
}
|
|
// otherView
|
var cboxInit = true; //是否需要初始化复选框
|
|
function initCheckBox(force) {
|
if (!cboxInit && force != true) {
|
cboxInit = true;
|
return;
|
}
|
CheckBox.newRadioBox(
|
'factorbox',
|
'factorType',
|
Util.selectOptions2[factorMode],
|
['1'],
|
onCheckMap
|
);
|
}
|
|
var timePicker = DPicker.timePicker('datetime', function (startTime, endTime) {
|
$('#starttime_text').text(startTime);
|
$('#endtime_text').text(endTime);
|
});
|
|
function initSearchBox() {
|
//todo 获取所有的设备编号
|
|
var time = new Date();
|
var day = ('0' + time.getDate()).slice(-2);
|
var month = ('0' + (time.getMonth() + 1)).slice(-2);
|
var today = time.getFullYear() + '-' + month + '-' + day;
|
$('#starttime_text').text(today + ' 00:00:00');
|
$('#endtime_text').text(today + ' 23:59:59');
|
|
$('#select_device_type').on('change', function () {
|
var type = $(this).val();
|
var tD = $('#select_device_code');
|
tD.empty();
|
var options2 = [];
|
switch (type) {
|
case '0a':
|
options2.push('0a0000000001');
|
options2.push('0a0000000002');
|
options2.push('0a0000000003');
|
break;
|
case '0b':
|
options2.push('0b0000000001');
|
options2.push('0b0000000002');
|
break;
|
case '0c':
|
options2.push('0c0000000001');
|
break;
|
default:
|
options2.push('0a0000000001');
|
options2.push('0a0000000002');
|
options2.push('0a0000000003');
|
break;
|
}
|
|
options2.forEach((element) => {
|
var op = $('<option></option>');
|
op.text(element);
|
tD.append(op);
|
});
|
|
refreshMission();
|
});
|
}
|
|
function refreshMission() {
|
var type = $('#select_device_type').val();
|
var tS = $('#select_task');
|
tS.empty();
|
HttpService.getMission(type, 1, 30, function (result) {
|
for (let i = 0; i < result.length; i++) {
|
const d = result[i];
|
var op = $('<option></option>');
|
op.text(d.missionCode);
|
var v =
|
moment(d.startTime).format('YYYY-MM-DD HH:mm:ss') +
|
';' +
|
moment(d.endTime).format('YYYY-MM-DD HH:mm:ss') +
|
';' +
|
d.deviceCode;
|
op.attr('value', v);
|
tS.append(op);
|
}
|
var times = tS.val().split(';');
|
$('#starttime_text').text(times[0]);
|
$('#endtime_text').text(times[1]);
|
$('#select_device_code').val(times[2])
|
timePicker.setStartDate(times[0]);
|
timePicker.setEndDate(times[1]);
|
});
|
}
|
|
function refreshFactorMode(deviceCode) {
|
var lastFactorMode = factorMode;
|
switch (deviceCode.substring(0, 2)) {
|
case '0a':
|
case '0b':
|
factorMode = 'type0';
|
break;
|
case '0c':
|
factorMode = 'type1';
|
break;
|
default:
|
factorMode = 'type0';
|
break;
|
}
|
if (lastFactorMode == factorMode) {
|
cboxInit = false;
|
}
|
}
|
|
function initBackgroundBox() {
|
var time = new Date();
|
var day = ('0' + time.getDate()).slice(-2);
|
var month = ('0' + (time.getMonth() + 1)).slice(-2);
|
var today =
|
time.getFullYear() +
|
'-' +
|
month +
|
'-' +
|
day +
|
' ' +
|
time.getHours() +
|
':' +
|
time.getMinutes() +
|
':' +
|
time.getSeconds();
|
$('#bg_time').append(today);
|
}
|
|
function MapController() {
|
this.mapMaker = new MapMaker();
|
|
this.hMode = new HistoryMode({
|
mapMaker: this.mapMaker,
|
});
|
this.rMode = new RealTimeMode({
|
mapMaker: this.mapMaker,
|
});
|
this.gridMonitor = new GridMonitor({
|
historyMode: this.hMode,
|
timePicker: timePicker,
|
});
|
// this.companyLayer = new CompanyLayer()
|
this.companyLayer = new ComplaintLayer2();
|
this.complaintLayer = new ComplaintLayer();
|
this.electricMode = new ElectrictyMode({
|
historyMode: this.hMode,
|
timePicker: timePicker,
|
});
|
|
this.modes = [];
|
this.modes.push(
|
this.hMode,
|
this.rMode,
|
this.gridMonitor,
|
this.companyLayer,
|
this.complaintLayer,
|
this.electricMode
|
);
|
|
this.mode = 1; //0: 走航模式;1:溯源模式;2:网格化监测;3:用电量监测;4:风险模型;
|
}
|
|
MapController.prototype = {
|
init: function () {
|
this.hMode.init();
|
// this.rMode.init();
|
// this.gridMonitor.init();
|
// this.companyLayer.init();
|
// this.complaintLayer.init();
|
// this.electricMode.init();
|
|
this.hMode.enable();
|
},
|
// 切换模式
|
modeChange: function (mode) {
|
switch (this.mode) {
|
case 0:
|
this.rMode.disable();
|
break;
|
case 1:
|
this.hMode.disable();
|
break;
|
case 2:
|
this.gridMonitor.disable();
|
break;
|
case 3:
|
this.electricMode.disable();
|
break;
|
case 4:
|
this.companyLayer.disable();
|
break;
|
default:
|
break;
|
}
|
this.mode = mode;
|
switch (mode) {
|
case 0:
|
this.rMode.enable();
|
break;
|
case 1:
|
this.hMode.enable();
|
if (this.rMode.originData.length > 0) {
|
this.setFactorData(this.rMode.originData, factorMode);
|
}
|
break;
|
case 2:
|
this.gridMonitor.enable();
|
break;
|
case 3:
|
this.electricMode.enable();
|
break;
|
case 4:
|
this.companyLayer.enable();
|
break;
|
default:
|
break;
|
}
|
},
|
// 设置绘图范围
|
setRange: function (range) {
|
switch (this.mode) {
|
case 0:
|
this.rMode.setRange(range);
|
break;
|
case 1:
|
this.hMode.setRange(range);
|
break;
|
default:
|
break;
|
}
|
},
|
// 还原绘图范围
|
resetRange: function () {
|
switch (this.mode) {
|
case 0:
|
this.rMode.standardRange();
|
break;
|
case 1:
|
this.hMode.standardRange();
|
break;
|
default:
|
break;
|
}
|
},
|
//设置3d地图当前展示的监测因子
|
setFactorType: function (factorType, factorMode, factorName) {
|
switch (this.mode) {
|
case 0:
|
this.rMode.setFactorType(factorType, factorMode, factorName);
|
break;
|
case 1:
|
this.hMode.setFactorType(factorType, factorMode, factorName);
|
break;
|
default:
|
break;
|
}
|
},
|
// 更新当前历史数据
|
setFactorData: function (data) {
|
switch (this.mode) {
|
case 0:
|
break;
|
case 1:
|
initCheckBox();
|
this.hMode.setFactorData(data, factorMode);
|
break;
|
default:
|
break;
|
}
|
},
|
//
|
addFactorData: function (data) {
|
switch (this.mode) {
|
case 0:
|
break;
|
case 1:
|
this.hMode.addFactorData(data);
|
break;
|
default:
|
break;
|
}
|
},
|
// 轨迹动画
|
startAnimation: function (speed, onStopCallback) {
|
switch (this.mode) {
|
case 0:
|
break;
|
case 1:
|
this.hMode.setOnStopAnimationCallback(onStopCallback);
|
this.hMode.startAnimation(speed);
|
$('#searchbox').slideUp('fast');
|
$('#rangeset').slideUp('fast');
|
$('#mode_change').slideUp('fast');
|
$('#animation_status').slideDown('fast');
|
break;
|
default:
|
break;
|
}
|
},
|
changeSpeed: function (speed) {
|
switch (this.mode) {
|
case 0:
|
break;
|
case 1:
|
this.hMode.changeSpeed(speed);
|
break;
|
default:
|
break;
|
}
|
},
|
pauseAnimation: function () {
|
switch (this.mode) {
|
case 0:
|
break;
|
case 1:
|
this.hMode.pauseAnimation();
|
break;
|
default:
|
break;
|
}
|
},
|
stopAnimation: function () {
|
switch (this.mode) {
|
case 0:
|
break;
|
case 1:
|
this.hMode.stopAnimation(true);
|
break;
|
default:
|
break;
|
}
|
},
|
//
|
setPage: function (pageSize) {
|
switch (this.mode) {
|
case 0:
|
break;
|
case 1:
|
this.hMode.setPage(pageSize);
|
break;
|
case 3:
|
this.electricMode.setPage(pageSize);
|
default:
|
break;
|
}
|
},
|
toggleCompany: function () {
|
this.complaintLayer.toggleComplaint();
|
},
|
toggleCompany2: function () {
|
this.complaintLayer.toggleComplaint2();
|
},
|
toggleCompany3: function () {
|
this.complaintLayer.toggleComplaint3();
|
},
|
toggleCompany4: function () {
|
this.complaintLayer.toggleComplaint4();
|
},
|
toggleCompany5: function () {
|
this.complaintLayer.toggleComplaint5();
|
},
|
// toggleGridMonitor: function(...deviceCodes) {
|
// this.gridMonitor.showData(...deviceCodes)
|
// }
|
};
|
|
var mapController = new MapController();
|
var taskManager = new TaskManage();
|
jQuery(function () {
|
mapController.init();
|
taskManager.init();
|
|
$('#realtimebox').slideUp('fast');
|
$('#realtimebox2').slideUp('fast');
|
$('#historybox').hide();
|
$('#history_table_box').hide();
|
// $('#backgroundbox').slideUp("fast")
|
$('#rmode_type').slideUp('fast');
|
$('#searchbox').slideDown('fast');
|
|
if (!isInitialized) {
|
MapUtil.init3D('map');
|
isInitialized = true;
|
}
|
|
initModeChange();
|
initSearchBox();
|
initCheckBox();
|
// initRealtimeBox()
|
initBackgroundBox();
|
initToggleEvent();
|
initSetRangeEvent();
|
|
/************************表格表头宽度动态计算***********************************/
|
$('#btn_history_table').on('click', function () {
|
Table.refreshHeadWidth('history_table');
|
});
|
$('#btn_task_manage').on('click', function () {
|
Table.refreshHeadWidth('task_table');
|
});
|
|
/************************折线图分页***********************************/
|
$('#select_page_size').on('change', function () {
|
t = $('#select_page_size').val();
|
pageSize = t == undefined ? 200 : parseInt(t);
|
mapController.setPage(pageSize);
|
});
|
|
/************************地图工具箱等***********************************/
|
$('#btn_point').on('click', function () {
|
var text = MapUtil.setFeatures();
|
var b = $(this);
|
b.toggleClass('btn-outline-secondary');
|
b.toggleClass('btn-outline-info');
|
$(b.children('span').get(0)).text(text);
|
});
|
$('#btn_map_mode').on('click', function () {
|
var text = MapUtil.toggleLayer();
|
var b = $(this);
|
b.toggleClass('btn-outline-secondary');
|
b.toggleClass('btn-outline-info');
|
$(b.children('span').get(0)).text(text);
|
});
|
|
$('#btn_luo_pan').on('click', function () {
|
var text = MapUtil.toggleControlbar();
|
var b = $(this);
|
b.toggleClass('btn-outline-secondary');
|
b.toggleClass('btn-outline-info');
|
$(b.children('span').get(0)).text(text);
|
});
|
$('#btn_location_mark').on('click', function () {
|
var text = MapUtil.locationMark();
|
var b = $(this);
|
b.toggleClass('btn-outline-secondary');
|
b.toggleClass('btn-outline-info');
|
$(b.children('span').get(0)).text(text);
|
});
|
$('#btn_data_mark').on('click', function () {
|
var text = MapUtil.toggleDataMarker();
|
var b = $(this);
|
b.toggleClass('btn-outline-secondary');
|
b.toggleClass('btn-outline-info');
|
$(b.children('span').get(0)).text(text);
|
});
|
$('#btn_data_dialog').on('click', function () {
|
var text = DialogUtil.toggleDataDialog();
|
var b = $(this);
|
b.toggleClass('btn-outline-secondary');
|
b.toggleClass('btn-outline-info');
|
$(b.children('span').get(0)).text(text);
|
});
|
|
/************************历史轨迹动画***********************************/
|
$('#btn_stop').on('click', function () {
|
mapController.stopAnimation();
|
$('#btn_play').removeClass('fa-pause');
|
$('#btn_play').addClass('fa-play');
|
});
|
$('#btn_play').on('click', function () {
|
$(this).toggleClass('fa-play');
|
$(this).toggleClass('fa-pause');
|
if ($(this).attr('class').indexOf('fa-play') != -1) {
|
mapController.pauseAnimation();
|
} else {
|
var speed = parseInt($('#select_speed').val());
|
mapController.startAnimation(speed, function () {
|
$('#btn_play').removeClass('fa-pause');
|
$('#btn_play').addClass('fa-play');
|
$('#searchbox').slideDown('fast');
|
$('#rangeset').slideDown('fast');
|
$('#mode_change').slideDown('fast');
|
$('#animation_status').slideUp('fast');
|
});
|
}
|
});
|
$('#select_speed').on('change', function () {
|
var speed = parseInt($(this).val());
|
mapController.changeSpeed(speed);
|
});
|
|
/************************任务管理***********************************/
|
$('#btn_task_manage').on('click', function () {
|
Nav.newPage({
|
close: 'btn_task_close',
|
page: 'task_manage',
|
});
|
});
|
$('#btn_new_task').on('click', function () {
|
Nav.newPage({
|
close: 'btn_task_create_close',
|
page: 'task_create',
|
});
|
});
|
$('#btn_import').on('click', function () {
|
Nav.newPage({
|
close: 'btn_task_import_close',
|
page: 'task_import',
|
});
|
});
|
$('#btn_download').on('click', function () {
|
taskManager.downloadTemplate();
|
});
|
$('#btn_task_import').on('click', function () {
|
var code = $('#import_device_code').val();
|
var $file1 = $('#file_path').val(); //用户文件内容(文件)
|
// 判断文件是否为空
|
if ($file1 == '') {
|
alert('请选择上传的目标文件! ');
|
return false;
|
}
|
var file = $('#file_path')[0].files[0];
|
taskManager.importData(code, factorMode, file, () => refreshMission());
|
});
|
$('#btn_task_create').on('click', function () {
|
taskManager.createTask({
|
taskcode: $('#taskcode').val(),
|
devicetype: $('#devicetype').val(),
|
deviceCode: $('#deviceCode').val(),
|
starttime: $('#task_starttime_text').text(),
|
endtime: $('#task_endtime_text').text(),
|
});
|
});
|
$('#devicetype').on('change', function () {
|
var code = $('#deviceCode');
|
var type = $(this).val();
|
code.val(type + '0000000001');
|
});
|
$('#select_task').on('change', function () {
|
var times = $(this).val().split(';');
|
$('#starttime_text').text(times[0]);
|
$('#endtime_text').text(times[1]);
|
$('#select_device_code').val(times[2])
|
timePicker.setStartDate(times[0]);
|
timePicker.setEndDate(times[1]);
|
});
|
|
/************************网格化监测***********************************/
|
$('#complaint_drop_1').on('click', function () {
|
mapController.toggleCompany();
|
});
|
$('#complaint_drop_2').on('click', function () {
|
mapController.toggleCompany2();
|
});
|
$('#complaint_drop_3').on('click', function () {
|
mapController.toggleCompany3();
|
});
|
$('#c_area_drop_1').on('click', function () {
|
mapController.toggleCompany4();
|
});
|
$('#c_area_drop_2').on('click', function () {
|
mapController.toggleCompany5();
|
});
|
// $('#monitor_1').on('click', function() {
|
// var code = $(this).val()
|
// mapController.toggleGridMonitor(code)
|
// })
|
|
refreshMission();
|
});
|