2020-05-06 16:57:07 +08:00
|
|
|
<template>
|
|
|
|
<div class="map-view">
|
|
|
|
<jlmap-visual ref="jlmapVisual" />
|
2020-05-11 17:36:21 +08:00
|
|
|
<div class="display-draft">
|
|
|
|
<el-button-group>
|
|
|
|
<el-button type="primary" @click="back">{{ $t('scriptRecord.scriptBack') }}</el-button>
|
|
|
|
</el-button-group>
|
|
|
|
</div>
|
2020-05-06 16:57:07 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import JlmapVisual from '@/views/newMap/jlmapNew/index';
|
|
|
|
import { loadMapDataById } from '@/utils/loaddata';
|
|
|
|
import { EventBus } from '@/scripts/event-bus';
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'MapPreview',
|
|
|
|
components: {
|
|
|
|
JlmapVisual
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
widthLeft: {
|
|
|
|
type: Number,
|
2020-05-09 20:13:32 +08:00
|
|
|
default: 0
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
size: {
|
|
|
|
width: document.documentElement.clientWidth - 400,
|
|
|
|
height: document.documentElement.clientHeight - 80
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
mapId() {
|
|
|
|
return this.$route.params.mapId;
|
|
|
|
},
|
|
|
|
height() {
|
|
|
|
return this.$store.state.app.height - 50 - 30;
|
|
|
|
},
|
|
|
|
...mapGetters('config', [
|
|
|
|
'canvasId'
|
|
|
|
])
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
widthLeft(val) {
|
|
|
|
this.setWindowSize();
|
|
|
|
},
|
|
|
|
$route() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.initLoadData();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
'$store.state.app.windowSizeCount': function() {
|
|
|
|
this.setWindowSize();
|
|
|
|
},
|
|
|
|
'$store.state.map.mapViewLoadedCount':function() {
|
|
|
|
this.$store.dispatch('map/setTrainWindowShow', false);
|
2020-05-06 17:18:06 +08:00
|
|
|
this.$jlmap.off('zoom');
|
2020-05-06 16:57:07 +08:00
|
|
|
this.$jlmap.off('pan');
|
2020-05-07 09:04:28 +08:00
|
|
|
this.handleUpdateScreen();
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async beforeDestroy() {
|
|
|
|
await this.$store.dispatch('map/mapClear');
|
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
await this.setWindowSize();
|
|
|
|
await this.initLoadData();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async initLoadData() { // 加载地图数据
|
|
|
|
if (parseInt(this.mapId)) {
|
|
|
|
await this.loadMapDataById(this.mapId);
|
|
|
|
} else {
|
|
|
|
this.endViewLoading();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 通过id加载地图数据
|
|
|
|
async loadMapDataById(mapId) {
|
|
|
|
try {
|
|
|
|
await this.$store.dispatch('training/changeMode', { mode: null });
|
|
|
|
loadMapDataById(mapId).then(()=>{
|
|
|
|
this.$store.dispatch('training/over');
|
|
|
|
this.$store.dispatch('training/setMapDefaultState');
|
|
|
|
this.$store.dispatch('map/clearJlmapTrainView');
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
this.$messageBox(`获取地图数据失败: ${error.message}`);
|
|
|
|
this.endViewLoading();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 结束加载状态
|
|
|
|
endViewLoading(isSuccess) {
|
|
|
|
if (!isSuccess) {
|
|
|
|
this.$store.dispatch('map/mapClear');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
EventBus.$emit('viewLoading', false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
setWindowSize() {
|
|
|
|
this.$nextTick(() => {
|
2020-05-09 20:13:32 +08:00
|
|
|
if (this.widthLeft) {
|
|
|
|
const width = this.$store.state.app.width - (this.widthLeft || 450) - 2;
|
|
|
|
const height = this.height;
|
|
|
|
this.$store.dispatch('config/resize', { width, height });
|
|
|
|
} else {
|
|
|
|
const width = this.$store.state.app.width - 2;
|
|
|
|
const height = this.$store.state.app.height;
|
|
|
|
this.$store.dispatch('config/resize', { width, height });
|
|
|
|
}
|
2020-05-06 16:57:07 +08:00
|
|
|
});
|
2020-05-07 09:04:28 +08:00
|
|
|
},
|
|
|
|
handleUpdateScreen() {
|
2020-05-09 20:13:32 +08:00
|
|
|
if (this.widthLeft) {
|
|
|
|
const size = {
|
|
|
|
width: this.$store.state.app.width - (this.widthLeft || 450) - 2,
|
|
|
|
height: this.height,
|
|
|
|
num: this.$theme.loadPropConvert(this.$store.state.map.map.skinVO.code).screenLine
|
|
|
|
};
|
|
|
|
this.$jlmap.setUpdateScreen(size);
|
|
|
|
} else {
|
|
|
|
const size = {
|
|
|
|
width: this.$store.state.app.width - 2,
|
|
|
|
height: this.$store.state.app.height,
|
|
|
|
num: this.$theme.loadPropConvert(this.$store.state.map.map.skinVO.code).screenLine
|
|
|
|
};
|
|
|
|
this.$jlmap.setUpdateScreen(size);
|
|
|
|
}
|
2020-05-11 17:36:21 +08:00
|
|
|
},
|
|
|
|
back() {
|
|
|
|
this.$store.dispatch('training/over').then(() => {
|
|
|
|
EventBus.$emit('runPlanStop');
|
|
|
|
EventBus.$emit('chatSubscribeStop');
|
|
|
|
history.go(-1);
|
|
|
|
Notification.closeAll();
|
|
|
|
});
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.map-view {
|
|
|
|
float: left;
|
|
|
|
width: auto;
|
|
|
|
}
|
2020-05-11 17:36:21 +08:00
|
|
|
.display-draft {
|
|
|
|
position: absolute;
|
|
|
|
float: right;
|
|
|
|
right: 15px;
|
|
|
|
bottom: 15px;
|
|
|
|
}
|
2020-05-06 16:57:07 +08:00
|
|
|
</style>
|