Commit 1bb82ffc by 张杰

修复勾选问题

1 parent 0d8c37a4
...@@ -316,21 +316,19 @@ export default { ...@@ -316,21 +316,19 @@ export default {
}, },
handleCheckChange(data, checked, indeterminate) { handleCheckChange(data, checked, indeterminate) {
//console.log(data, checked, indeterminate); //console.log(data, checked, indeterminate);
console.log(checked);
if (checked) { if (checked) {
//console.log(this.$refs.tree.getNode(data)) //console.log(this.$refs.tree.getNode(data))
let node = this.$refs.tree.getNode(data); //let node = this.$refs.tree.getNode(data);
//this.getAllChild(node) //this.getAllChild(node)
//this.$refs.tree.store.defaultExpandAll = true //this.$refs.tree.store.defaultExpandAll = true
//this.$refs.tree.setCheckedKeys(['u8121']) //this.$refs.tree.setCheckedKeys(['u8121'])
} }
this.isTreeChecked = checked; this.isTreeChecked = checked;
this.expandedKeys = []; //this.expandedKeys = [];
}, },
// 勾选树 // 勾选树
handleCheck(data, node) { handleCheck(data, node) {
console.log("node", data);
let list = this.monitorList.itemArr; let list = this.monitorList.itemArr;
// 最多同时监控100台数据 // 最多同时监控100台数据
...@@ -390,6 +388,8 @@ export default { ...@@ -390,6 +388,8 @@ export default {
params = { uId: data.id }; params = { uId: data.id };
} }
console.log('勾选树:',data)
params.termType = this.searchType; params.termType = this.searchType;
params.term = this.searchText; params.term = this.searchText;
this.treeLoading = true; this.treeLoading = true;
...@@ -437,7 +437,8 @@ export default { ...@@ -437,7 +437,8 @@ export default {
if (data.children !== undefined) { if (data.children !== undefined) {
data.children.forEach((item, i) => { data.children.forEach((item, i) => {
this.$refs.tree.setChecked(item, false, true); //this.$refs.tree.setChecked(item, false, true);
this.checkedKeys.push(item.id)
}); });
} }
} }
...@@ -750,7 +751,7 @@ export default { ...@@ -750,7 +751,7 @@ export default {
console.log('keys',keys) console.log('keys',keys)
//_this.$refs.tree.setCheckedKeys(keys); //_this.$refs.tree.setCheckedKeys(keys);
_this.checkedKeys.push(item.id); _this.checkedKeys.push(item.id);
console.log(_this.checkedKeys) console.log('勾选key:',_this.checkedKeys)
this.addMonitor({ this.addMonitor({
sn: item.label, sn: item.label,
name: item.label1, name: item.label1,
...@@ -761,7 +762,9 @@ export default { ...@@ -761,7 +762,9 @@ export default {
sourceType: item.source, sourceType: item.source,
}); });
} else { } else {
console.log('展开节点',item)
this.expandedKeys.push(item.id); this.expandedKeys.push(item.id);
console.log(this.expandedKeys)
} }
if (item.children && item.children.length) { if (item.children && item.children.length) {
this.expandTreeItems( this.expandTreeItems(
...@@ -873,7 +876,6 @@ export default { ...@@ -873,7 +876,6 @@ export default {
obj.count++; obj.count++;
obj.itemArr.unshift(item.sn); obj.itemArr.unshift(item.sn);
} }
console.log(obj.itemArr);
this.getPositionData(); this.getPositionData();
}, },
// standNoMonitor(item){ // standNoMonitor(item){
...@@ -914,14 +916,12 @@ export default { ...@@ -914,14 +916,12 @@ export default {
}); });
let arr = this.monitorList.itemArr || []; let arr = this.monitorList.itemArr || [];
console.log(arr.length);
filterList.forEach((item) => { filterList.forEach((item) => {
item.eLocateType = "gpsLocation"; item.eLocateType = "gpsLocation";
this.monitorList[item.sn] = item; this.monitorList[item.sn] = item;
this.monitorList.count++; this.monitorList.count++;
arr.unshift(item.sn); arr.unshift(item.sn);
}); });
console.log(arr);
this.$set(this.monitorList, "itemArr", arr); this.$set(this.monitorList, "itemArr", arr);
this.getPositionData(); this.getPositionData();
} }
...@@ -934,24 +934,19 @@ export default { ...@@ -934,24 +934,19 @@ export default {
if (obj[item.sn]) { if (obj[item.sn]) {
delete obj[item.sn]; delete obj[item.sn];
} }
console.log(list);
this.monitorList.itemArr = list.filter((k) => k != item.sn); this.monitorList.itemArr = list.filter((k) => k != item.sn);
//this.monitorList.itemArr.splice(this.monitorList.itemArr.indexOf(item.sn||item), 1) //this.monitorList.itemArr.splice(this.monitorList.itemArr.indexOf(item.sn||item), 1)
this.monitorList = Object.assign({}, obj); this.monitorList = Object.assign({}, obj);
if (this.monitorList.count > 0) { if (this.monitorList.count > 0) {
this.monitorList.count--; this.monitorList.count--;
} }
console.log(item);
EventBus.$emit( EventBus.$emit(
"uiMap.monitor.destroy", "uiMap.monitor.destroy",
`${item.sn || item}:${item.source || item}` `${item.sn || item}:${item.source || item}`
); );
//console.log(this.monitorList);
if (ifUpdateTreeKeys) { if (ifUpdateTreeKeys) {
console.log(item);
let checkedKeys = this.$refs.tree.getCheckedKeys(); let checkedKeys = this.$refs.tree.getCheckedKeys();
let arr = checkedKeys.filter((id) => id !== item.id); let arr = checkedKeys.filter((id) => id !== item.id);
//console.log(arr);
this.$refs.tree.setCheckedKeys(arr); this.$refs.tree.setCheckedKeys(arr);
} }
}, },
...@@ -959,12 +954,10 @@ export default { ...@@ -959,12 +954,10 @@ export default {
// 批量删除 监控列表 // 批量删除 监控列表
removeMonitorByGroup(arr) { removeMonitorByGroup(arr) {
let _this = this; let _this = this;
console.log(arr);
let o = this.monitorList; let o = this.monitorList;
o.itemArr = []; o.itemArr = [];
arr.forEach((item) => { arr.forEach((item) => {
let n = o[item.sn || item]; let n = o[item.sn || item];
console.log(n);
if (n) { if (n) {
_this.removeMonitor(n); _this.removeMonitor(n);
} }
...@@ -981,7 +974,6 @@ export default { ...@@ -981,7 +974,6 @@ export default {
/* let _this = this; /* let _this = this;
arr = arr.filter((item)=>this.monitorList[item.sn]); */ arr = arr.filter((item)=>this.monitorList[item.sn]); */
let snStr = this.monitorList.itemArr.join(","); //arr.map((item)=>item.sn).join(','); let snStr = this.monitorList.itemArr.join(","); //arr.map((item)=>item.sn).join(',');
console.log(snStr)
if (!snStr) return; if (!snStr) return;
if (this.resetRefreshCount || this.remainSearchSnStr != snStr) { if (this.resetRefreshCount || this.remainSearchSnStr != snStr) {
this.refreshCount = 1; this.refreshCount = 1;
...@@ -1038,7 +1030,6 @@ export default { ...@@ -1038,7 +1030,6 @@ export default {
}, },
filterGpsBase(item) { filterGpsBase(item) {
//item.bsLocation = {} //item.bsLocation = {}
console.log(item);
let gpsLocation = item.gpsLocation; let gpsLocation = item.gpsLocation;
let bsLocation = item.bsLocation; let bsLocation = item.bsLocation;
/* 如果基站,gps其中一个没数据,自动切换到另一个,如果都没有eLocateType为null */ /* 如果基站,gps其中一个没数据,自动切换到另一个,如果都没有eLocateType为null */
...@@ -1136,8 +1127,6 @@ export default { ...@@ -1136,8 +1127,6 @@ export default {
// 展示更多 // 展示更多
showMore(node, data) { showMore(node, data) {
let o = this.treeDataList["u" + data.parentId]; let o = this.treeDataList["u" + data.parentId];
console.log(node);
console.log(o);
// 不存在 // 不存在
if (!o || o.length <= 0) { if (!o || o.length <= 0) {
return false; return false;
...@@ -1154,8 +1143,6 @@ export default { ...@@ -1154,8 +1143,6 @@ export default {
// 加载下一页 // 加载下一页
loadNext(node, data) { loadNext(node, data) {
console.log(node);
console.log(data);
let _this = this; let _this = this;
let id = "u" + node.data.parentId; let id = "u" + node.data.parentId;
let pageNumber = this.pageSizeList[id]; let pageNumber = this.pageSizeList[id];
......
...@@ -256,8 +256,7 @@ MapService.prototype = { ...@@ -256,8 +256,7 @@ MapService.prototype = {
EventBus.$emit('uiMap.copySuccess'); EventBus.$emit('uiMap.copySuccess');
}); });
clipboard.on('error', function (e) { clipboard.on('error', function (e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
}); });
if (isInfoOpen) { if (isInfoOpen) {
...@@ -276,7 +275,6 @@ MapService.prototype = { ...@@ -276,7 +275,6 @@ MapService.prototype = {
// 车辆监控-查看位置点 // 车辆监控-查看位置点
bindMonitorInfoWindow: function (marker, map, info, isInfoOpen, isInfoAutoMove) { bindMonitorInfoWindow: function (marker, map, info, isInfoOpen, isInfoAutoMove) {
console.log(info)
var self = this; var self = this;
var infoDiv = document.createElement('div'); var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createMonitorInfo(info); infoDiv.innerHTML = self.createMonitorInfo(info);
...@@ -316,7 +314,6 @@ MapService.prototype = { ...@@ -316,7 +314,6 @@ MapService.prototype = {
} }
baseBtn && (baseBtn.onclick = function (e) { baseBtn && (baseBtn.onclick = function (e) {
console.log(info)
if (info.eLocateType === 'bsLocation') return; if (info.eLocateType === 'bsLocation') return;
info.eLocateType = 'bsLocation' info.eLocateType = 'bsLocation'
eLocation = info[info.eLocateType]; eLocation = info[info.eLocateType];
...@@ -434,7 +431,6 @@ MapService.prototype = { ...@@ -434,7 +431,6 @@ MapService.prototype = {
} }
} }
console.log(historyBtn)
const snSourceType = `${info.sn}:${info.isSource}` const snSourceType = `${info.sn}:${info.isSource}`
/* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{ /* EventBus.$on(`uiMap.monitor.changeStatus.${snSourceType}`, (status)=>{
...@@ -552,7 +548,6 @@ MapService.prototype = { ...@@ -552,7 +548,6 @@ MapService.prototype = {
let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`; let queryCode = `sn=${info.sn}&name=${encodeURI(info.name)}&standno=${info.standNo}`;
var _html = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`; var _html = `<h3 class="map-infowindow-title">${info.name}/${info.standNo}</h3>`;
_html += `<div class="map-infowindow-ct map_info_window">`; _html += `<div class="map-infowindow-ct map_info_window">`;
console.log(zhongliType);
if (zhongliType == 'yes') { if (zhongliType == 'yes') {
_html += `<div>`; _html += `<div>`;
if (info.shopName) { if (info.shopName) {
...@@ -574,7 +569,6 @@ MapService.prototype = { ...@@ -574,7 +569,6 @@ MapService.prototype = {
let list = vue.prototype.$parentCommon.getAuthData(); let list = vue.prototype.$parentCommon.getAuthData();
let o = list.find(k => k.origin.permissionTag == 'oEshield_monitor_store_name'); let o = list.find(k => k.origin.permissionTag == 'oEshield_monitor_store_name');
let n = list.find(k => k.origin.permissionTag == 'oEshield_monitor_plate_number'); let n = list.find(k => k.origin.permissionTag == 'oEshield_monitor_plate_number');
console.log(list)
if (o && info.shopName) { if (o && info.shopName) {
_html += `<p><i class="icon_info_shop"></i> 店面名称: <span class="des">${info.shopName || '--'}</span></p>`; _html += `<p><i class="icon_info_shop"></i> 店面名称: <span class="des">${info.shopName || '--'}</span></p>`;
} }
...@@ -822,7 +816,6 @@ MapService.prototype = { ...@@ -822,7 +816,6 @@ MapService.prototype = {
content: div, content: div,
autoMove: !!isInfoAutoMove, autoMove: !!isInfoAutoMove,
}) })
console.log(infoWindow)
marker.infoWindow = infoWindow marker.infoWindow = infoWindow
if (isInfoOpen) { if (isInfoOpen) {
infoWindow.open(map, marker.getPosition()) infoWindow.open(map, marker.getPosition())
......
...@@ -12,7 +12,6 @@ const MAPGEO = { ...@@ -12,7 +12,6 @@ const MAPGEO = {
}) })
}, },
transferAddressByGroup(obj, cb){ transferAddressByGroup(obj, cb){
console.log(this.geocoder)
if(!this.geocoder){ if(!this.geocoder){
this.getGeocoder().then(()=>{ this.getGeocoder().then(()=>{
this.transfer(obj, cb) this.transfer(obj, cb)
...@@ -22,7 +21,6 @@ const MAPGEO = { ...@@ -22,7 +21,6 @@ const MAPGEO = {
} }
}, },
transfer(obj, cb){ transfer(obj, cb){
console.log(obj.data)
const data = obj.data; const data = obj.data;
obj.len = data.length; obj.len = data.length;
obj.times = obj.len>20?Math.ceil(obj.len/20):1; obj.times = obj.len>20?Math.ceil(obj.len/20):1;
...@@ -49,13 +47,11 @@ const MAPGEO = { ...@@ -49,13 +47,11 @@ const MAPGEO = {
const timeoutId = window.setTimeout(()=>{ const timeoutId = window.setTimeout(()=>{
MAPGEO.geocoder.getAddress(arr, function(status, result) { MAPGEO.geocoder.getAddress(arr, function(status, result) {
console.log(result)
if (status === 'complete' && result.info === 'OK') {//获取地址成功 if (status === 'complete' && result.info === 'OK') {//获取地址成功
result.regeocodes.forEach((item, idx)=>{ result.regeocodes.forEach((item, idx)=>{
data[initIdx+idx].transferAddress = item.formattedAddress; data[initIdx+idx].transferAddress = item.formattedAddress;
obj.totalNum++; obj.totalNum++;
}); });
console.log(obj.totalNum +'----'+ obj.realNum)
if(obj.totalNum === obj.realNum){ if(obj.totalNum === obj.realNum){
cb && cb(data) cb && cb(data)
//ifPlay && obj.init(data) //ifPlay && obj.init(data)
......
...@@ -2,7 +2,7 @@ import EventBus from '../event-bus' ...@@ -2,7 +2,7 @@ import EventBus from '../event-bus'
import mapService from './mapService.js' import mapService from './mapService.js'
import MAPGEO from './mapgeo' import MAPGEO from './mapgeo'
import { Message } from "element-ui"; import { Message } from "element-ui";
import {services} from '../api' import { services } from '../api'
const MONITOR_SERVICE = services.monitor; const MONITOR_SERVICE = services.monitor;
//车辆监控 //车辆监控
...@@ -15,27 +15,36 @@ const monitor = { ...@@ -15,27 +15,36 @@ const monitor = {
isCompare: false, isCompare: false,
compareLine: null, compareLine: null,
compareText: null, compareText: null,
bindEvent(){ bindEvent() {
EventBus.$on('uiMap.monitor.draw', (data, autoOpenLastInfoWindow)=>{ EventBus.$on('uiMap.monitor.draw', (data, autoOpenLastInfoWindow) => {
this.draw(data, autoOpenLastInfoWindow); this.draw(data, autoOpenLastInfoWindow);
}); });
EventBus.$on('uiMap.monitor.destroy', (snSourceType)=>{ EventBus.$on('uiMap.monitor.destroy', (snSourceType) => {
const MAP = mapService.map; const MAP = mapService.map;
if(snSourceType){ if (snSourceType) {
if (this.markers[snSourceType]) {
MAP.remove(this.markers[snSourceType]) MAP.remove(this.markers[snSourceType])
}
if (this.infowins[snSourceType]) {
MAP.remove(this.infowins[snSourceType]) MAP.remove(this.infowins[snSourceType])
}
delete this.markers[snSourceType]; delete this.markers[snSourceType];
delete this.infowins[snSourceType]; delete this.infowins[snSourceType];
EventBus.$off(`uiMap.monitor.changeStatus.${snSourceType}`) EventBus.$off(`uiMap.monitor.changeStatus.${snSourceType}`)
}else{ } else {
for(let snSourceType in this.markers){ for (let snSourceType in this.markers) {
if (this.markers[snSourceType]) {
MAP.remove(this.markers[snSourceType]) MAP.remove(this.markers[snSourceType])
} }
for(let snSourceType in this.infowins){ }
for (let snSourceType in this.infowins) {
if (this.markers[snSourceType]) {
MAP.remove(this.infowins[snSourceType]) MAP.remove(this.infowins[snSourceType])
EventBus.$off(`uiMap.monitor.changeStatus.${snSourceType}`) EventBus.$off(`uiMap.monitor.changeStatus.${snSourceType}`)
} }
}
this.markers = {}; this.markers = {};
this.infowins = {}; this.infowins = {};
this.data = []; this.data = [];
...@@ -44,37 +53,37 @@ const monitor = { ...@@ -44,37 +53,37 @@ const monitor = {
} }
}); });
EventBus.$on('uiMap.monitor.compareDestroy', ()=>{ EventBus.$on('uiMap.monitor.compareDestroy', () => {
this.compareDestroy() this.compareDestroy()
}) })
EventBus.$on('uiMap.monitor.changeSourceType', (sourceType)=>{ EventBus.$on('uiMap.monitor.changeSourceType', (sourceType) => {
const MAP = mapService.map; const MAP = mapService.map;
let rourceReg = /^\d+\:(\d)$/; let rourceReg = /^\d+\:(\d)$/;
if(sourceType === ''){ if (sourceType === '') {
for(let snSourceType in this.markers){ for (let snSourceType in this.markers) {
this.markers[snSourceType].show(); this.markers[snSourceType].show();
} }
}else{ } else {
for(let snSourceType in this.markers){ for (let snSourceType in this.markers) {
let execResult = rourceReg.exec(snSourceType); let execResult = rourceReg.exec(snSourceType);
if(execResult){ if (execResult) {
if(execResult[1] === sourceType){ if (execResult[1] === sourceType) {
this.markers[snSourceType].show(); this.markers[snSourceType].show();
}else{ } else {
this.markers[snSourceType].hide(); this.markers[snSourceType].hide();
} }
} }
} }
for(let snSourceType in this.infowins){ for (let snSourceType in this.infowins) {
this.infowins[snSourceType].close(); this.infowins[snSourceType].close();
} }
} }
}); });
EventBus.$on('uiMap.monitor.openInfoWindow', (snSourceType)=>{ EventBus.$on('uiMap.monitor.openInfoWindow', (snSourceType) => {
if(this.markers[snSourceType]){ if (this.markers[snSourceType]) {
const MAP = mapService.map; const MAP = mapService.map;
const lnglat = this.markers[snSourceType].getPosition(); const lnglat = this.markers[snSourceType].getPosition();
this.infowins[snSourceType].open(MAP, lnglat); this.infowins[snSourceType].open(MAP, lnglat);
...@@ -83,10 +92,10 @@ const monitor = { ...@@ -83,10 +92,10 @@ const monitor = {
}); });
EventBus.$on('uiMap.monitor.changeELocate', (item)=>{ EventBus.$on('uiMap.monitor.changeELocate', (item) => {
const snSourceType = `${item.sn}:${item.isSource}` const snSourceType = `${item.sn}:${item.isSource}`
let eLocation = item[item.eLocateType]; let eLocation = item[item.eLocateType];
if(this.markers[snSourceType]){ if (this.markers[snSourceType]) {
this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
} }
...@@ -94,29 +103,29 @@ const monitor = { ...@@ -94,29 +103,29 @@ const monitor = {
this.isCompare && this.compareLocation() this.isCompare && this.compareLocation()
}) })
EventBus.$on('uiMap.monitor.compareLocation', (data)=>{ EventBus.$on('uiMap.monitor.compareLocation', (data) => {
this.compareDestroy() this.compareDestroy()
this.isCompare = true this.isCompare = true
}); });
EventBus.$on('uiMap.monitor.wifiLocate', (data) => { EventBus.$on('uiMap.monitor.wifiLocate', (data) => {
EventBus.$emit('uiMap.monitor.terminate'); EventBus.$emit('uiMap.monitor.terminate');
const {info, infoDiv, gpsBtn, baseBtn, wifiBtn} = data const { info, infoDiv, gpsBtn, baseBtn, wifiBtn } = data
MONITOR_SERVICE.getWifiLocationBySn({ MONITOR_SERVICE.getWifiLocationBySn({
apType: 5, apType: 5,
sn: info.sn sn: info.sn
}).then((res)=>{ }).then((res) => {
if(res.returnCode == 0){ if (res.returnCode == 0) {
const data = res.data const data = res.data
if(data){ if (data) {
const transferObj = {elat: data.wifiLat, elng: data.wifiLng} const transferObj = { elat: data.wifiLat, elng: data.wifiLng }
MAPGEO.transferAddressByGroup({data: [transferObj]}, ()=>{ MAPGEO.transferAddressByGroup({ data: [transferObj] }, () => {
infoDiv.querySelector('[data-transferAddress]').textContent = transferObj.transferAddress; infoDiv.querySelector('[data-transferAddress]').textContent = transferObj.transferAddress;
infoDiv.querySelector('[data-time]').textContent = data.lastReportTime; infoDiv.querySelector('[data-time]').textContent = data.lastReportTime;
}) })
const snSourceType = `${info.sn}:${info.isSource}` const snSourceType = `${info.sn}:${info.isSource}`
if(this.markers[snSourceType]){ if (this.markers[snSourceType]) {
this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat))); this.markers[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat)));
this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat))); this.infowins[snSourceType].setPosition(mapService.getLngLat(parseFloat(transferObj.elng), parseFloat(transferObj.elat)));
} }
...@@ -125,7 +134,7 @@ const monitor = { ...@@ -125,7 +134,7 @@ const monitor = {
wifiBtn && wifiBtn.classList.add('el-button--primary'); wifiBtn && wifiBtn.classList.add('el-button--primary');
info.eLocateType = 'wifi' info.eLocateType = 'wifi'
}else{ } else {
Message({ Message({
type: 'info', type: 'info',
message: '暂无wifi数据' message: '暂无wifi数据'
...@@ -139,53 +148,53 @@ const monitor = { ...@@ -139,53 +148,53 @@ const monitor = {
// 激活位置点 // 激活位置点
EventBus.$on("uiMap.monitor.drawMaker", this.drawMaker); EventBus.$on("uiMap.monitor.drawMaker", this.drawMaker);
}, },
draw(data, autoOpenLastInfoWindow){ draw(data, autoOpenLastInfoWindow) {
const MAP = mapService.map; const MAP = mapService.map;
this.data = data; this.data = data;
const transferObj = [] const transferObj = []
data.forEach((item)=>{ data.forEach((item) => {
if(item.gpsLocation && item.gpsLocation.elat && item.gpsLocation.elng){ if (item.gpsLocation && item.gpsLocation.elat && item.gpsLocation.elng) {
transferObj.push(item.gpsLocation) transferObj.push(item.gpsLocation)
} }
if(item.bsLocation && item.bsLocation.elat && item.bsLocation.elng){ if (item.bsLocation && item.bsLocation.elat && item.bsLocation.elng) {
transferObj.push(item.bsLocation) transferObj.push(item.bsLocation)
} }
}) })
MAPGEO.transferAddressByGroup({data: transferObj}, ()=>{ MAPGEO.transferAddressByGroup({ data: transferObj }, () => {
this.data.forEach((item, idx)=>{ this.data.forEach((item, idx) => {
let eLocation = item[item.eLocateType]; let eLocation = item[item.eLocateType];
if(!eLocation.elng && !eLocation.elat) return; if (!eLocation.elng && !eLocation.elat) return;
let isInfoOpen = false; let isInfoOpen = false;
let tag = `${item.sn}:${item.isSource}`; let tag = `${item.sn}:${item.isSource}`;
if(this.infowins[tag] && this.infowins[tag].getIsOpen()){ if (this.infowins[tag] && this.infowins[tag].getIsOpen()) {
isInfoOpen = true; isInfoOpen = true;
} }
let infoWindow; let infoWindow;
let snSourceType = `${item.sn}:${item.isSource}` let snSourceType = `${item.sn}:${item.isSource}`
if(this.markers[tag]){ if (this.markers[tag]) {
this.markers[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); this.markers[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
//this.infowins[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat))); //this.infowins[tag].setPosition(mapService.getLngLat(parseFloat(eLocation.elng), parseFloat(eLocation.elat)));
//infoWindow = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen); //infoWindow = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen);
this.infowins[tag] = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen, this.isCompare?true:false); this.infowins[tag] = mapService.bindMonitorInfoWindow(this.markers[tag], MAP, item, isInfoOpen, this.isCompare ? true : false);
EventBus.$emit(`uiMap.monitor.changeStatus.${snSourceType}`) EventBus.$emit(`uiMap.monitor.changeStatus.${snSourceType}`)
}else{ } else {
this.infowins[tag] && MAP.remove(this.infowins[tag]); this.infowins[tag] && MAP.remove(this.infowins[tag]);
let marker = mapService.createCarMarker([parseFloat(eLocation.elng), parseFloat(eLocation.elat)], MAP); let marker = mapService.createCarMarker([parseFloat(eLocation.elng), parseFloat(eLocation.elat)], MAP);
infoWindow = mapService.bindMonitorInfoWindow(marker, MAP, item, isInfoOpen, this.isCompare?true:false); infoWindow = mapService.bindMonitorInfoWindow(marker, MAP, item, isInfoOpen, this.isCompare ? true : false);
this.markers[tag] = marker; this.markers[tag] = marker;
this.infowins[tag] = infoWindow; this.infowins[tag] = infoWindow;
} }
if(item.alarmModelList && item.alarmModelList.length){ if (item.alarmModelList && item.alarmModelList.length) {
mapService.setAlarmIcon(this.markers[tag]) mapService.setAlarmIcon(this.markers[tag])
}else{ } else {
mapService.setDefaultIcon(this.markers[tag]) mapService.setDefaultIcon(this.markers[tag])
} }
if(autoOpenLastInfoWindow && idx===0){ if (autoOpenLastInfoWindow && idx === 0) {
EventBus.$emit('uiMap.monitor.openInfoWindow', snSourceType) EventBus.$emit('uiMap.monitor.openInfoWindow', snSourceType)
} }
...@@ -194,29 +203,31 @@ const monitor = { ...@@ -194,29 +203,31 @@ const monitor = {
mapService.setFitView(MAP); mapService.setFitView(MAP);
this.allData = this.allData.concat(data); this.allData = this.allData.concat(data);
EventBus.$emit('uiMap.monitor.drawDone'); EventBus.$emit('uiMap.monitor.drawDone');
if(this.isCompare){ if (this.isCompare) {
this.compareLocation(true) this.compareLocation(true)
} }
}); });
}, },
compareLocation(isFitView){ compareLocation(isFitView) {
if(this.data.length <2) return if (this.data.length < 2) return
const MAP = mapService.map; const MAP = mapService.map;
if(!this.compareLine){ if (!this.compareLine) {
this.compareLine = new AMap.Polyline({ this.compareLine = new AMap.Polyline({
map: MAP, map: MAP,
strokeColor:'#80d8ff', strokeColor: '#80d8ff',
isOutline:true, isOutline: true,
outlineColor:'white' outlineColor: 'white'
}); });
} }
if(!this.compareText){ if (!this.compareText) {
this.compareText = new AMap.Text({ this.compareText = new AMap.Text({
map: MAP, map: MAP,
text:'', text: '',
style:{'background-color':'#29b6f6', style: {
'border-color':'#e1f5fe', 'background-color': '#29b6f6',
'font-size':'12px'} 'border-color': '#e1f5fe',
'font-size': '12px'
}
}); });
} }
...@@ -228,10 +239,10 @@ const monitor = { ...@@ -228,10 +239,10 @@ const monitor = {
var textPos = p1.divideBy(2).add(p2.divideBy(2)); var textPos = p1.divideBy(2).add(p2.divideBy(2));
var distance = Math.round(p1.distance(p2)); var distance = Math.round(p1.distance(p2));
var path = [p1,p2]; var path = [p1, p2];
this.compareLine.setPath(path); this.compareLine.setPath(path);
this.compareText.setText(`两点相距${distance>1000?(distance/1000+'k'):distance}m`) this.compareText.setText(`两点相距${distance > 1000 ? (distance / 1000 + 'k') : distance}m`)
this.compareText.setPosition(textPos) this.compareText.setPosition(textPos)
mapService.setFitView(MAP); mapService.setFitView(MAP);
...@@ -247,16 +258,16 @@ const monitor = { ...@@ -247,16 +258,16 @@ const monitor = {
//MAP.setFitView(ms.concat(infos)) //MAP.setFitView(ms.concat(infos))
//isFitView && mapService.setFitView(MAP) //isFitView && mapService.setFitView(MAP)
}, },
intervalDraw(){ intervalDraw() {
}, },
compareDestroy: function(){ compareDestroy: function () {
const MAP = mapService.map; const MAP = mapService.map;
for(let snSourceType in this.markers){ for (let snSourceType in this.markers) {
MAP.remove(this.markers[snSourceType]) MAP.remove(this.markers[snSourceType])
} }
for(let snSourceType in this.infowins){ for (let snSourceType in this.infowins) {
MAP.remove(this.infowins[snSourceType]) MAP.remove(this.infowins[snSourceType])
} }
this.markers = {}; this.markers = {};
...@@ -272,8 +283,8 @@ const monitor = { ...@@ -272,8 +283,8 @@ const monitor = {
this.compareText = null; this.compareText = null;
this.clearTimeoutIds(); this.clearTimeoutIds();
}, },
clearTimeoutIds(){ clearTimeoutIds() {
this.timeoutIds && this.timeoutIds.forEach((item)=>{ this.timeoutIds && this.timeoutIds.forEach((item) => {
item && window.clearTimeout(item); item && window.clearTimeout(item);
}); });
this.timeoutIds = [] this.timeoutIds = []
...@@ -284,7 +295,7 @@ const monitor = { ...@@ -284,7 +295,7 @@ const monitor = {
let tag = `${data.sn}-${data.standNo}`; let tag = `${data.sn}-${data.standNo}`;
const MAP = mapService.map const MAP = mapService.map
const marker = mapService.createCarMarker( const marker = mapService.createCarMarker(
[parseFloat(data.lng ||data.bsLng), parseFloat(data.lat||data.bsLat)], [parseFloat(data.lng || data.bsLng), parseFloat(data.lat || data.bsLat)],
MAP MAP
) )
const infoWindow = mapService.bindActiveLocationInfoWindow( const infoWindow = mapService.bindActiveLocationInfoWindow(
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!