2019-07-25 10:30:30 +08:00
|
|
|
<template>
|
|
|
|
<transition name="el-zoom-in-center">
|
|
|
|
<div class="mapPaint">
|
|
|
|
<div class="map-view">
|
|
|
|
<jlmap-visual ref="jlmapVisual" @onSelect="clickEvent" @onMenu="onContextmenu" />
|
|
|
|
</div>
|
|
|
|
<div class="map-draft">
|
|
|
|
<div v-if="viewDraft==='draft'">
|
|
|
|
<map-operate
|
|
|
|
ref="mapOperate"
|
|
|
|
:card-height="cardHeight"
|
|
|
|
:map-info="mapInfo"
|
|
|
|
:selected="selected"
|
|
|
|
:map-saveing="mapSaveing"
|
|
|
|
@handleSelectLogicalView="handleSelectLogicalView"
|
|
|
|
@handleSelectPhysicalView="handleSelectPhysicalView"
|
|
|
|
@handleSelectView="handleSelectView"
|
|
|
|
@saveMapEvent="saveMapEvent"
|
|
|
|
@verifyMapEvent="verifyMapEvent"
|
|
|
|
@addOrUpdateMapModel="addOrUpdateMapModel"
|
|
|
|
@delMapModel="delMapModel"
|
2019-07-25 15:44:23 +08:00
|
|
|
@setCenter="setCenter"
|
2019-07-25 10:30:30 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="viewDraft==='route'">
|
|
|
|
<route-operate
|
|
|
|
ref="routeOperate"
|
|
|
|
:card-height="cardHeight+25"
|
|
|
|
:map-info="mapInfo"
|
|
|
|
:selected="selected"
|
|
|
|
@handleSelectView="handleSelectView"
|
2019-07-25 15:44:23 +08:00
|
|
|
@setCenter="setCenter"
|
2019-07-25 10:30:30 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="viewDraft==='routing'">
|
|
|
|
<routing-operate
|
|
|
|
ref="routingOperate"
|
|
|
|
:card-height="cardHeight+25"
|
|
|
|
:map-info="mapInfo"
|
|
|
|
:selected="selected"
|
|
|
|
@handleSelectView="handleSelectView"
|
2019-07-25 15:44:23 +08:00
|
|
|
@setCenter="setCenter"
|
2019-07-25 10:30:30 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="viewDraft==='automatic'">
|
|
|
|
<automatic-operate
|
|
|
|
ref="automaticOperate"
|
|
|
|
:card-height="cardHeight+25"
|
|
|
|
:map-info="mapInfo"
|
|
|
|
:selected="selected"
|
|
|
|
@handleSelectView="handleSelectView"
|
2019-07-25 15:44:23 +08:00
|
|
|
@setCenter="setCenter"
|
2019-07-25 10:30:30 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="viewDraft==='swtich'">
|
|
|
|
<switch-operate
|
|
|
|
ref="SwitchOperate"
|
|
|
|
:card-height="cardHeight+25"
|
|
|
|
:map-info="mapInfo"
|
|
|
|
:selected="selected"
|
|
|
|
@handleSelectView="handleSelectView"
|
2019-07-25 15:44:23 +08:00
|
|
|
@setCenter="setCenter"
|
2019-07-25 10:30:30 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="viewDraft==='path'">
|
|
|
|
<path-operate
|
|
|
|
ref="pathOperate"
|
|
|
|
:card-height="cardHeight+25"
|
|
|
|
:map-info="mapInfo"
|
|
|
|
:selected="selected"
|
|
|
|
@handleSelectView="handleSelectView"
|
2019-07-25 15:44:23 +08:00
|
|
|
@setCenter="setCenter"
|
2019-07-25 10:30:30 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { saveMap, getMapDetail, verifyMap } from '@/api/jmap/mapdraft';
|
|
|
|
import { ViewMode, TrainingMode, getDeviceMenuByDeviceType } from '@/scripts/ConstDic';
|
|
|
|
import { checkLoginLine } from '@/api/login';
|
|
|
|
import JlmapVisual from '@/views/jlmap/index';
|
|
|
|
import RouteOperate from './routeoperate/index';
|
|
|
|
import RoutingOperate from './routingoperate/index';
|
|
|
|
import AutomaticOperate from './automaticoperate/index';
|
|
|
|
import MapOperate from './mapoperate/index';
|
|
|
|
import SwitchOperate from './switchoperate/index';
|
|
|
|
import pathOperate from './pathoperate/index';
|
|
|
|
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
2019-08-02 10:58:28 +08:00
|
|
|
import { EventBus } from '@/scripts/event-bus';
|
2019-07-25 10:30:30 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'MapView',
|
|
|
|
components: {
|
|
|
|
JlmapVisual,
|
|
|
|
MapOperate,
|
|
|
|
RouteOperate,
|
|
|
|
RoutingOperate,
|
|
|
|
SwitchOperate,
|
|
|
|
pathOperate,
|
|
|
|
AutomaticOperate
|
|
|
|
},
|
|
|
|
mixins: [
|
|
|
|
WindowResizeHandler
|
|
|
|
],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mapSaveing: false,
|
|
|
|
cardHeight: 400,
|
|
|
|
ViewMode: ViewMode,
|
|
|
|
viewDraft: 'draft',
|
|
|
|
autoSaveTask: null,
|
|
|
|
selected: null,
|
|
|
|
mapInfo: { name: '请选择地图' },
|
|
|
|
timeDemon: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$store.state.map.mapDataLoadedCount': function (val) {
|
|
|
|
this.initAutoSaveTask();
|
|
|
|
},
|
|
|
|
'viewDraft': function () {
|
|
|
|
this.initAutoSaveTask();
|
|
|
|
},
|
|
|
|
$route() {
|
|
|
|
this.loadInitPage();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.resizeHandler();
|
|
|
|
this.loadInitPage();
|
|
|
|
this.timeDemon = setInterval(() => {
|
|
|
|
checkLoginLine();
|
|
|
|
}, 5000 * 60);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.clearAutoSave();
|
|
|
|
this.$store.dispatch('map/mapClear');
|
|
|
|
if (this.timeDemon) {
|
|
|
|
clearTimeout(this.timeDemon);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
resizeHandler: function () {
|
|
|
|
this.cardHeight = this._clientHeight - 195;
|
|
|
|
},
|
|
|
|
endViewLoading(isSuccess) {
|
|
|
|
if (!isSuccess) {
|
|
|
|
this.$store.dispatch('map/mapClear');
|
|
|
|
}
|
2019-08-02 10:36:17 +08:00
|
|
|
|
2019-07-31 09:13:37 +08:00
|
|
|
this.$nextTick(() => {
|
2019-08-02 10:36:17 +08:00
|
|
|
EventBus.$emit('viewLoading', false);
|
|
|
|
});
|
2019-07-25 10:30:30 +08:00
|
|
|
},
|
|
|
|
loadInitPage() {
|
|
|
|
this.$store.dispatch('training/changeMode', { mode: TrainingMode.MAP_EDIT });
|
|
|
|
this.viewDraft = this.$route.params.view;
|
|
|
|
this.mapInfo = { name: '请选择地图', id: this.$route.params.mapId };
|
|
|
|
if (parseInt(this.mapInfo.id)) {
|
|
|
|
this.mapInfo.name = this.$route.query.name;
|
|
|
|
getMapDetail(this.$route.params.mapId).then(response => {
|
2019-07-30 12:37:31 +08:00
|
|
|
this.$store.dispatch('map/setMapData', response.data);
|
|
|
|
this.setDelayUnlockStatus(response.data, '00');
|
|
|
|
this.initAutoSaveTask();
|
2019-07-25 10:30:30 +08:00
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox('加载地图数据失败');
|
|
|
|
this.endViewLoading();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.endViewLoading();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
initAutoSaveTask() {
|
|
|
|
const timeout = 1000 * 60 * 3;
|
|
|
|
this.clearAutoSave(this.autoSaveTask);
|
|
|
|
if (this.viewDraft == 'draft') {
|
|
|
|
this.autoSaveTask = setInterval(this.saveMapEvent, timeout);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clearAutoSave() {
|
|
|
|
if (this.autoSaveTask) {
|
|
|
|
clearInterval(this.autoSaveTask);
|
|
|
|
this.autoSaveTask = null;
|
|
|
|
}
|
|
|
|
},
|
2019-07-26 10:38:57 +08:00
|
|
|
handleSelectControlPage (model) {
|
2019-07-25 10:30:30 +08:00
|
|
|
if (this.$refs && this.$refs.mapOperate) {
|
|
|
|
this.$refs.mapOperate.handleSelectControlPage(model);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleSelectView(handle) {
|
|
|
|
if (this.$refs && this.$refs.jlmapVisual) {
|
2019-07-25 15:44:23 +08:00
|
|
|
this.$refs.jlmapVisual.setLayerVisible(handle);
|
2019-07-25 10:30:30 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
handleSelectLogicalView(handle) {
|
|
|
|
if (this.$refs && this.$refs.jlmapVisual) {
|
2019-07-25 15:44:23 +08:00
|
|
|
this.$refs.jlmapVisual.setLevelVisible(handle);
|
2019-07-25 10:30:30 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
handleSelectPhysicalView(handle) {
|
|
|
|
if (this.$refs && this.$refs.jlmapVisual) {
|
2019-07-25 15:44:23 +08:00
|
|
|
this.$refs.jlmapVisual.setLevelVisible(handle);
|
2019-07-25 10:30:30 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
clickEvent(em) {
|
2019-07-26 10:38:57 +08:00
|
|
|
var device = this.getDeviceByEm(em);
|
|
|
|
this.onSelect(device);
|
2019-07-25 10:30:30 +08:00
|
|
|
switch (this.viewDraft) {
|
|
|
|
case 'route':
|
2019-07-26 10:38:57 +08:00
|
|
|
this.$refs.routeOperate.setSelected(device);
|
2019-07-25 10:30:30 +08:00
|
|
|
break;
|
|
|
|
case 'routing':
|
2019-07-26 10:38:57 +08:00
|
|
|
this.$refs.routingOperate.setSelected(device);
|
2019-07-25 10:30:30 +08:00
|
|
|
break;
|
|
|
|
case 'automatic':
|
2019-07-26 10:38:57 +08:00
|
|
|
this.$refs.automaticOperate.setSelected(device);
|
2019-07-25 10:30:30 +08:00
|
|
|
break;
|
|
|
|
case 'swtich':
|
2019-07-26 10:38:57 +08:00
|
|
|
this.$refs.SwitchOperate.setSelected(device);
|
2019-07-25 10:30:30 +08:00
|
|
|
break;
|
|
|
|
case 'path':
|
2019-07-26 10:38:57 +08:00
|
|
|
this.$refs.pathOperate.setSelected(device);
|
2019-07-25 10:30:30 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 获取设备数据
|
|
|
|
getDeviceByEm(em) {
|
2019-07-26 10:38:57 +08:00
|
|
|
var device = this.$store.getters['map/getDeviceByCode'](em.deviceCode) || null;
|
|
|
|
if (device) {
|
|
|
|
device._viewVal = em.val;
|
2019-07-25 10:30:30 +08:00
|
|
|
}
|
2019-07-26 10:38:57 +08:00
|
|
|
return device;
|
2019-07-25 10:30:30 +08:00
|
|
|
},
|
2019-07-26 10:38:57 +08:00
|
|
|
onSelect(device) {
|
|
|
|
this.selected = device || null;
|
|
|
|
this.selected && this.handleSelectControlPage(device);
|
2019-07-25 10:30:30 +08:00
|
|
|
},
|
|
|
|
onContextmenu(em) {
|
|
|
|
this.point = {
|
|
|
|
x: em.clientX,
|
|
|
|
y: em.clientY
|
|
|
|
};
|
|
|
|
var menu = getDeviceMenuByDeviceType('Cancel');
|
|
|
|
|
|
|
|
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
|
|
|
|
},
|
|
|
|
saveMapEvent() {
|
|
|
|
if (this.$refs.jlmapVisual) {
|
|
|
|
const map = this.$store.state.map.map;
|
|
|
|
if (map && parseInt(this.$route.params.mapId)) {
|
|
|
|
for (const i in map.sectionList) {
|
|
|
|
if (map.sectionList[i].points.length > 0) {
|
|
|
|
for (let index = 0; index < map.sectionList[i].points.length; index++) {
|
|
|
|
if (String(map.sectionList[i].points[index].x) == 'undefined' || String(map.sectionList[i].points[index].y) == 'undefined') {
|
|
|
|
this.$messageBox('区段坐标缺失');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.$messageBox('区段坐标缺失');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.mapSaveing = true;
|
2019-08-06 17:00:24 +08:00
|
|
|
this.$store.dispatch('map/saveMapDeviceDefaultRelations').then(() => {
|
2019-07-25 10:30:30 +08:00
|
|
|
saveMap(Object.assign(map, { mapId: this.$route.params.mapId })).then(response => {
|
|
|
|
this.$message.success('保存成功');
|
|
|
|
this.mapSaveing = false;
|
|
|
|
this.initAutoSaveTask();
|
|
|
|
}).catch(error => {
|
2019-07-30 13:29:54 +08:00
|
|
|
console.log(error);
|
2019-07-25 10:30:30 +08:00
|
|
|
this.$messageBox('保存失败');
|
|
|
|
this.mapSaveing = false;
|
|
|
|
if (error.code === 40004 || error.code === 40005 || error.code === 40003) {
|
|
|
|
this.clearAutoSave();
|
|
|
|
} else {
|
|
|
|
this.initAutoSaveTask();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
verifyMapEvent() {
|
|
|
|
if (this.$refs.jlmapVisual) {
|
|
|
|
const map = this.$store.state.map.map;
|
|
|
|
if (map && this.$route.params.mapId) {
|
|
|
|
verifyMap(this.$route.params.mapId).then(res => {
|
|
|
|
if (res.data.length) {
|
|
|
|
this.tableToExcel(res.data);
|
|
|
|
this.$messageBox('数据校验不通过');
|
|
|
|
} else {
|
|
|
|
this.$message.success('数据校验通过!');
|
|
|
|
}
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox('请求失败');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
tableToExcel(data) {
|
|
|
|
const filterVal = ['index'];
|
|
|
|
const arr = [];
|
|
|
|
data.forEach(item => {
|
|
|
|
arr.push({ index: item });
|
|
|
|
});
|
|
|
|
const dataList = this.formatJson(filterVal, arr);
|
2019-07-25 15:48:51 +08:00
|
|
|
import('@/utils/Export2Excel').then(excel => {
|
|
|
|
excel.export_json_to_excel(['有问题数据'], dataList, '数据列表');
|
|
|
|
});
|
2019-07-25 10:30:30 +08:00
|
|
|
},
|
|
|
|
formatJson(filterVal, jsonData) {
|
|
|
|
return jsonData.map(v => filterVal.map(j => v[j]));
|
|
|
|
},
|
|
|
|
|
|
|
|
setDelayUnlockStatus(data, status) {
|
|
|
|
if (data && data.delayShowList) {
|
|
|
|
data.delayShowList.forEach(elem => {
|
|
|
|
elem.status = status;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 增加数据数据 给vuex map对象中
|
|
|
|
addOrUpdateMapModel(obj) {
|
2019-08-07 16:23:04 +08:00
|
|
|
this.$store.dispatch('map/updateMapDevices', obj);
|
2019-07-25 10:30:30 +08:00
|
|
|
},
|
|
|
|
// 删除数据 同时del map
|
|
|
|
delMapModel(obj) {
|
2019-08-07 16:23:04 +08:00
|
|
|
this.$store.dispatch('map/deleteMapDevices', obj).then(() => {
|
2019-07-25 10:30:30 +08:00
|
|
|
this.selected = null;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 设置显示中心
|
2019-07-25 15:44:23 +08:00
|
|
|
setCenter(code) {
|
|
|
|
this.$refs.jlmapVisual.setCenter(code);
|
2019-07-25 10:30:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
|
|
|
|
|
|
|
.map-view {
|
|
|
|
float: left;
|
|
|
|
width: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.map-draft {
|
|
|
|
float: right;
|
|
|
|
width: 520px;
|
|
|
|
|
|
|
|
/deep/ .el-scrollbar__view {
|
|
|
|
width: 510px !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.physical-view {
|
|
|
|
line-height: 25px;
|
|
|
|
height: 60px;
|
|
|
|
padding-left: 12px;
|
|
|
|
|
|
|
|
.el-checkbox {
|
|
|
|
width: 70px;
|
|
|
|
margin: 0;
|
|
|
|
margin-right: 12px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|