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';
|
2020-05-12 19:07:48 +08:00
|
|
|
import { loadNewMapDataByGroup, loadMapDataById } from '@/utils/loaddata';
|
2020-05-06 16:57:07 +08:00
|
|
|
import { EventBus } from '@/scripts/event-bus';
|
|
|
|
import { mapGetters } from 'vuex';
|
2020-05-11 18:15:49 +08:00
|
|
|
import { creatSubscribe, clearSubscribe, displayTopic} from '@/utils/stomp';
|
|
|
|
import { getToken } from '@/utils/auth';
|
2020-05-06 16:57:07 +08:00
|
|
|
|
|
|
|
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-11 18:15:49 +08:00
|
|
|
this.subscribe();
|
|
|
|
},
|
|
|
|
'$store.state.socket.equipmentStatus': function (val) {
|
2020-05-12 19:07:48 +08:00
|
|
|
if (val.length && this.$route.query.group) {
|
2020-05-11 18:15:49 +08:00
|
|
|
this.statusMessage(val);
|
|
|
|
}
|
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() { // 加载地图数据
|
2020-05-11 18:15:49 +08:00
|
|
|
if (this.$route.query.group) {
|
|
|
|
await loadNewMapDataByGroup(this.$route.query.group);
|
2020-05-06 16:57:07 +08:00
|
|
|
} else {
|
2020-05-12 19:07:48 +08:00
|
|
|
await loadMapDataById(this.$route.params.mapId);
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
|
|
|
},
|
2020-05-11 18:15:49 +08:00
|
|
|
async statusMessage(list) {
|
|
|
|
await this.$store.dispatch('training/updateMapState', list);
|
|
|
|
await this.$store.dispatch('socket/setEquipmentStatus');
|
|
|
|
},
|
2020-05-06 16:57:07 +08:00
|
|
|
// 通过id加载地图数据
|
|
|
|
async loadMapDataById(mapId) {
|
2020-05-11 18:15:49 +08:00
|
|
|
// 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();
|
|
|
|
// }
|
2020-05-06 16:57:07 +08:00
|
|
|
},
|
|
|
|
// 结束加载状态
|
|
|
|
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-12 18:23:56 +08:00
|
|
|
this.$refs.jlmapVisual.handleStateLoaded();
|
2020-05-11 17:36:21 +08:00
|
|
|
},
|
|
|
|
back() {
|
|
|
|
this.$store.dispatch('training/over').then(() => {
|
|
|
|
EventBus.$emit('runPlanStop');
|
|
|
|
EventBus.$emit('chatSubscribeStop');
|
|
|
|
history.go(-1);
|
|
|
|
});
|
2020-05-11 18:15:49 +08:00
|
|
|
},
|
|
|
|
async subscribe() {
|
|
|
|
this.clearSubscribe();
|
|
|
|
const header = { group: this.$route.query.group || '', 'X-Token': getToken() };
|
|
|
|
creatSubscribe(`${displayTopic}\/${this.$route.query.group}`, header);
|
|
|
|
|
|
|
|
await this.$store.dispatch('training/setHasSubscribed');
|
|
|
|
},
|
|
|
|
clearSubscribe() {
|
|
|
|
clearSubscribe(`${displayTopic}\/${this.$route.query.group}`);
|
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>
|