2020-05-06 16:57:07 +08:00
|
|
|
<template>
|
|
|
|
<div class="map-view">
|
2020-05-13 16:29:10 +08:00
|
|
|
<div v-show="maskOpen" class="mask" :style="{'width': maskWidth}" />
|
2020-05-06 16:57:07 +08:00
|
|
|
<jlmap-visual ref="jlmapVisual" />
|
2020-05-13 17:34:38 +08:00
|
|
|
<div v-show="disPlay" class="display-draft">
|
2020-05-11 17:36:21 +08:00
|
|
|
<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-11-27 17:37:13 +08:00
|
|
|
import {loadMapDataById } from '@/utils/loaddata';
|
2020-05-13 17:34:38 +08:00
|
|
|
import { clearSimulation } from '@/api/simulation';
|
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 {
|
2020-05-13 16:29:10 +08:00
|
|
|
maskOpen: false,
|
2020-07-22 14:26:51 +08:00
|
|
|
maskWidth: 'calc(100% - 450px)',
|
2020-05-13 17:34:38 +08:00
|
|
|
disPlay: false
|
2020-05-06 16:57:07 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
mapId() {
|
|
|
|
return this.$route.params.mapId;
|
|
|
|
},
|
|
|
|
height() {
|
2020-07-06 17:02:13 +08:00
|
|
|
return this.$store.state.app.height - 50 - 40;
|
2020-05-06 16:57:07 +08:00
|
|
|
},
|
2020-05-13 16:29:10 +08:00
|
|
|
...mapGetters('map', [
|
2020-07-06 17:02:13 +08:00
|
|
|
'bigScreenConfig'
|
2020-05-13 16:29:10 +08:00
|
|
|
]),
|
2020-05-06 16:57:07 +08:00
|
|
|
...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-07-06 17:02:13 +08:00
|
|
|
// this.$jlmap.off('pan');
|
2020-05-07 09:04:28 +08:00
|
|
|
this.handleUpdateScreen();
|
2020-05-13 17:34:38 +08:00
|
|
|
if (this.$route.query.group) {
|
|
|
|
this.subscribe();
|
|
|
|
}
|
2020-05-11 18:15:49 +08:00
|
|
|
},
|
|
|
|
'$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-07-22 14:59:00 +08:00
|
|
|
},
|
|
|
|
'$store.state.socket.simulationOver':function(val) {
|
|
|
|
this.backOut();
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async beforeDestroy() {
|
|
|
|
await this.$store.dispatch('map/mapClear');
|
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
await this.setWindowSize();
|
|
|
|
await this.initLoadData();
|
2020-05-13 17:34:38 +08:00
|
|
|
this.disPlay = true;
|
2020-07-22 14:59:00 +08:00
|
|
|
if (this.$route.path.includes('design/bigScreen') || this.$route.query.noPreLogout || this.$route.query.projectDevice) {
|
2020-05-13 17:34:38 +08:00
|
|
|
this.disPlay = false;
|
|
|
|
}
|
2020-05-06 16:57:07 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async initLoadData() { // 加载地图数据
|
2020-05-11 18:15:49 +08:00
|
|
|
if (this.$route.query.group) {
|
2020-11-27 17:37:13 +08:00
|
|
|
// await loadNewMapDataByGroup(this.$route.query.group);
|
|
|
|
await loadMapDataById(this.$route.query.mapId, 'Group');
|
2020-05-06 16:57:07 +08:00
|
|
|
} else {
|
2020-05-13 17:34:38 +08:00
|
|
|
this.loadMapDataById(this.$route.params.mapId);
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
// 通过id加载地图数据
|
|
|
|
async loadMapDataById(mapId) {
|
2020-05-13 17:34:38 +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
|
|
|
}
|
2020-05-13 17:34:38 +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
|
|
|
},
|
|
|
|
setWindowSize() {
|
|
|
|
this.$nextTick(() => {
|
2020-05-09 20:13:32 +08:00
|
|
|
if (this.widthLeft) {
|
2020-09-09 10:28:56 +08:00
|
|
|
const width = this.$store.state.app.width - (this.widthLeft) - 2;
|
|
|
|
this.maskWidth = `calc(100% - ${this.widthLeft}px)`;
|
2020-05-09 20:13:32 +08:00
|
|
|
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;
|
2020-08-03 10:16:10 +08:00
|
|
|
this.maskWidth = `100%`;
|
2020-05-09 20:13:32 +08:00
|
|
|
this.$store.dispatch('config/resize', { width, height });
|
|
|
|
}
|
2020-05-13 17:58:39 +08:00
|
|
|
this.handleUpdateScreen();
|
2020-05-06 16:57:07 +08:00
|
|
|
});
|
2020-05-07 09:04:28 +08:00
|
|
|
},
|
|
|
|
handleUpdateScreen() {
|
2020-05-13 16:29:10 +08:00
|
|
|
this.maskOpen = false;
|
2020-07-06 17:02:13 +08:00
|
|
|
if (this.bigScreenConfig.bigScreenSplitConfig && this.bigScreenConfig.bigScreenSplitConfig.length) {
|
|
|
|
const offsetList = this.bigScreenConfig.offsetList;
|
|
|
|
const width = this.bigScreenConfig.width;
|
|
|
|
const height = this.bigScreenConfig.height;
|
2020-05-13 16:29:10 +08:00
|
|
|
if (this.widthLeft) {
|
|
|
|
const size = {
|
2020-07-06 17:02:13 +08:00
|
|
|
width: (this.$store.state.app.width - (this.widthLeft || 450) - 2) * width,
|
|
|
|
height: this.height * height,
|
|
|
|
list: this.bigScreenConfig.bigScreenSplitConfig.map(ele => ele.position),
|
|
|
|
offsetList: offsetList
|
2020-05-13 16:29:10 +08:00
|
|
|
};
|
|
|
|
this.$jlmap.setUpdateScreen(size);
|
|
|
|
} else {
|
|
|
|
const size = {
|
2020-07-06 17:02:13 +08:00
|
|
|
width: (this.$store.state.app.width - 2) * width,
|
|
|
|
height: this.$store.state.app.height * height,
|
|
|
|
list: this.bigScreenConfig.bigScreenSplitConfig.map(ele => ele.position),
|
|
|
|
offsetList: offsetList
|
2020-05-13 16:29:10 +08:00
|
|
|
};
|
|
|
|
this.$jlmap.setUpdateScreen(size);
|
|
|
|
}
|
|
|
|
this.$refs.jlmapVisual.handleStateLoaded();
|
2020-05-09 20:13:32 +08:00
|
|
|
} else {
|
2020-05-13 16:29:10 +08:00
|
|
|
this.maskOpen = true;
|
2020-05-13 18:00:37 +08:00
|
|
|
// this.$messageBox('该线路没有大屏切割位置信息, 请前往地图绘制编辑');
|
2020-05-09 20:13:32 +08:00
|
|
|
}
|
2020-05-11 17:36:21 +08:00
|
|
|
},
|
2020-05-13 17:34:38 +08:00
|
|
|
async back() {
|
|
|
|
if (this.$route.query.group) {
|
|
|
|
await clearSimulation(this.$route.query.group);
|
|
|
|
this.clearSubscribe();
|
|
|
|
}
|
2020-05-11 17:36:21 +08:00
|
|
|
this.$store.dispatch('training/over').then(() => {
|
|
|
|
history.go(-1);
|
|
|
|
});
|
2020-05-11 18:15:49 +08:00
|
|
|
},
|
2020-07-22 14:59:00 +08:00
|
|
|
backOut() {
|
|
|
|
if (this.$route.query.projectDevice) {
|
|
|
|
this.$store.dispatch('LogOut').then(() => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
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);
|
2020-11-30 10:23:32 +08:00
|
|
|
// await this.$store.dispatch('training/setHasSubscribed');
|
2020-05-11 18:15:49 +08:00
|
|
|
},
|
|
|
|
clearSubscribe() {
|
|
|
|
clearSubscribe(`${displayTopic}\/${this.$route.query.group}`);
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.map-view {
|
2020-07-22 14:03:40 +08:00
|
|
|
// float: left;
|
2020-05-06 16:57:07 +08:00
|
|
|
width: auto;
|
2020-07-06 17:02:13 +08:00
|
|
|
overflow: hidden;
|
2020-05-13 16:29:10 +08:00
|
|
|
}
|
|
|
|
.mask{
|
|
|
|
opacity: 1;
|
|
|
|
background: #000;
|
|
|
|
position: absolute;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
z-index: 9;
|
2020-05-06 16:57:07 +08:00
|
|
|
}
|
2020-05-11 17:36:21 +08:00
|
|
|
.display-draft {
|
|
|
|
position: absolute;
|
|
|
|
float: right;
|
|
|
|
right: 15px;
|
|
|
|
bottom: 15px;
|
2020-05-13 17:34:38 +08:00
|
|
|
z-index: 19;
|
2020-05-11 17:36:21 +08:00
|
|
|
}
|
2020-05-06 16:57:07 +08:00
|
|
|
</style>
|