2020-07-06 17:02:13 +08:00
|
|
|
<template>
|
2021-04-22 10:52:48 +08:00
|
|
|
<div class="bigSplitScreen">
|
|
|
|
<div v-show="maskOpen" class="bigSplitScreenMask" />
|
|
|
|
<div v-show="disPlay" class="bigSplitScreenSelect">
|
2020-07-06 17:02:13 +08:00
|
|
|
<el-select v-model="value" placeholder="请选择" style="width: 125px;" @change="changeSplit">
|
|
|
|
<el-option
|
|
|
|
v-for="item in optionsList"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</div>
|
|
|
|
<jlmap-visual ref="jlmapVisual" />
|
2021-04-22 10:52:48 +08:00
|
|
|
<div v-show="disPlay" class="bigSplitScreenBack">
|
2020-07-06 17:02:13 +08:00
|
|
|
<el-button-group>
|
2021-04-22 10:52:48 +08:00
|
|
|
<el-button type="primary" @click="back">返回</el-button>
|
2020-07-06 17:02:13 +08:00
|
|
|
</el-button-group>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import JlmapVisual from '@/views/newMap/jlmapNew/index';
|
2020-11-27 17:37:13 +08:00
|
|
|
import { loadMapDataById } from '@/utils/loaddata';
|
2020-07-06 17:02:13 +08:00
|
|
|
import { clearSimulation } from '@/api/simulation';
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { creatSubscribe, clearSubscribe, displayTopic} from '@/utils/stomp';
|
|
|
|
import { getToken } from '@/utils/auth';
|
2020-07-07 17:37:45 +08:00
|
|
|
import { getSessionStorage } from '@/utils/auth';
|
2020-07-06 17:02:13 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'MapPreview',
|
|
|
|
components: {
|
|
|
|
JlmapVisual
|
|
|
|
},
|
|
|
|
props: {
|
2020-07-06 18:16:49 +08:00
|
|
|
|
2020-07-06 17:02:13 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
maskOpen: false,
|
|
|
|
disPlay: false,
|
|
|
|
value: 1,
|
|
|
|
optionsList: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
mapId() {
|
|
|
|
return this.$route.params.mapId;
|
|
|
|
},
|
|
|
|
...mapGetters('map', [
|
|
|
|
'bigScreenConfig'
|
|
|
|
]),
|
|
|
|
...mapGetters('config', [
|
|
|
|
'canvasId'
|
|
|
|
])
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.initLoadData();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
'$store.state.app.windowSizeCount': function() {
|
|
|
|
this.setWindowSize();
|
|
|
|
},
|
|
|
|
'$store.state.map.mapViewLoadedCount':function() {
|
|
|
|
this.$store.dispatch('map/setTrainWindowShow', false);
|
|
|
|
this.$jlmap.off('zoom');
|
|
|
|
this.$jlmap.off('pan');
|
|
|
|
this.handleUpdateScreen();
|
|
|
|
if (this.$route.query.group) {
|
|
|
|
this.subscribe();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'$store.state.socket.equipmentStatus': function (val) {
|
|
|
|
if (val.length && this.$route.query.group) {
|
|
|
|
this.statusMessage(val);
|
|
|
|
}
|
2020-07-08 10:41:28 +08:00
|
|
|
},
|
|
|
|
'$store.state.socket.simulationOver':function(val) {
|
|
|
|
this.backOut();
|
2020-07-06 17:02:13 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async beforeDestroy() {
|
|
|
|
await this.$store.dispatch('map/mapClear');
|
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
await this.setWindowSize();
|
|
|
|
await this.initLoadData();
|
|
|
|
this.disPlay = true;
|
|
|
|
if (this.$route.path.includes('design/bigScreen')) {
|
|
|
|
this.disPlay = false;
|
|
|
|
}
|
2020-07-07 17:37:45 +08:00
|
|
|
if (this.$route.query.projectDevice) {
|
|
|
|
this.disPlay = false;
|
|
|
|
const data = JSON.parse(JSON.parse(getSessionStorage('projectDevice')).config);
|
|
|
|
this.changeSplit(data.quadrant);
|
|
|
|
}
|
2020-07-06 17:02:13 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async initLoadData() { // 加载地图数据
|
|
|
|
if (this.$route.query.group) {
|
2020-12-24 15:33:06 +08:00
|
|
|
await loadMapDataById(this.$route.query.mapId, 'simulation');
|
2020-07-06 17:02:13 +08:00
|
|
|
} else {
|
2020-12-24 15:33:06 +08:00
|
|
|
this.$store.dispatch('training/changeMode', { mode: null });
|
|
|
|
loadMapDataById(this.$route.params.mapId, 'preview');
|
2020-07-06 17:02:13 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async statusMessage(list) {
|
|
|
|
await this.$store.dispatch('training/updateMapState', list);
|
|
|
|
await this.$store.dispatch('socket/setEquipmentStatus');
|
|
|
|
},
|
|
|
|
setWindowSize() {
|
|
|
|
this.$nextTick(() => {
|
2020-07-06 18:16:49 +08:00
|
|
|
const width = this.$store.state.app.width;
|
|
|
|
const height = this.$store.state.app.height;
|
|
|
|
this.$store.dispatch('config/resize', { width, height });
|
2020-07-06 17:02:13 +08:00
|
|
|
this.handleUpdateScreen();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
changeSplit(data) {
|
|
|
|
const width = this.bigScreenConfig.width;
|
|
|
|
const height = this.bigScreenConfig.height;
|
2020-07-07 18:33:43 +08:00
|
|
|
const num = width * height;
|
2020-07-06 17:02:13 +08:00
|
|
|
const size = {
|
2020-07-06 18:16:49 +08:00
|
|
|
width: this.$store.state.app.width * width,
|
|
|
|
height: this.$store.state.app.height * height
|
2020-07-06 17:02:13 +08:00
|
|
|
};
|
2021-01-08 16:50:50 +08:00
|
|
|
const obj = {
|
|
|
|
width: width,
|
|
|
|
height: height
|
|
|
|
};
|
|
|
|
this.$refs.jlmapVisual.setOffset(size, data, num, obj);
|
2020-07-06 17:02:13 +08:00
|
|
|
},
|
|
|
|
handleUpdateScreen() {
|
|
|
|
this.maskOpen = false;
|
|
|
|
if (this.bigScreenConfig.bigScreenSplitConfig && this.bigScreenConfig.bigScreenSplitConfig.length) {
|
|
|
|
const offsetList = this.bigScreenConfig.offsetList;
|
|
|
|
const width = this.bigScreenConfig.width;
|
|
|
|
const height = this.bigScreenConfig.height;
|
|
|
|
const num = width * height;
|
|
|
|
this.optionsList = [];
|
|
|
|
for (let index = 0; index < num; index++) {
|
|
|
|
const param = { value: index + 1, label: `第${index + 1}屏` };
|
|
|
|
this.optionsList.push(param);
|
|
|
|
}
|
2021-04-22 10:52:48 +08:00
|
|
|
// console.log(this.optionsList, '======');
|
2020-07-06 18:16:49 +08:00
|
|
|
const size = {
|
|
|
|
width: this.$store.state.app.width * width,
|
|
|
|
height: this.$store.state.app.height * height,
|
|
|
|
list: this.bigScreenConfig.bigScreenSplitConfig.map(ele => ele.position),
|
|
|
|
offsetList: offsetList
|
|
|
|
};
|
|
|
|
this.$jlmap.setUpdateScreen(size);
|
2020-07-06 17:02:13 +08:00
|
|
|
this.$refs.jlmapVisual.handleStateLoaded();
|
2020-07-08 10:33:15 +08:00
|
|
|
if (this.$route.query.projectDevice) {
|
|
|
|
this.disPlay = false;
|
|
|
|
const data = JSON.parse(JSON.parse(getSessionStorage('projectDevice')).config);
|
|
|
|
this.changeSplit(data.quadrant);
|
|
|
|
}
|
2020-07-06 17:02:13 +08:00
|
|
|
} else {
|
|
|
|
this.maskOpen = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async back() {
|
|
|
|
if (this.$route.query.group) {
|
|
|
|
await clearSimulation(this.$route.query.group);
|
|
|
|
this.clearSubscribe();
|
|
|
|
}
|
|
|
|
this.$store.dispatch('training/over').then(() => {
|
|
|
|
history.go(-1);
|
|
|
|
});
|
|
|
|
},
|
2020-07-08 10:41:28 +08:00
|
|
|
backOut() {
|
|
|
|
if (this.$route.query.projectDevice) {
|
|
|
|
this.$store.dispatch('LogOut').then(() => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-07-06 17:02:13 +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-07-06 17:02:13 +08:00
|
|
|
},
|
|
|
|
clearSubscribe() {
|
|
|
|
clearSubscribe(`${displayTopic}\/${this.$route.query.group}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 10:52:48 +08:00
|
|
|
.bigSplitScreen {
|
2020-07-06 17:02:13 +08:00
|
|
|
float: left;
|
|
|
|
width: auto;
|
|
|
|
}
|
2021-04-22 10:52:48 +08:00
|
|
|
.bigSplitScreenMask{
|
2020-07-06 17:02:13 +08:00
|
|
|
opacity: 1;
|
|
|
|
background: #000;
|
|
|
|
position: absolute;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
z-index: 9;
|
|
|
|
}
|
2021-04-22 10:52:48 +08:00
|
|
|
.bigSplitScreenBack,.bigSplitScreenSelect {
|
2020-07-06 17:02:13 +08:00
|
|
|
position: absolute;
|
|
|
|
float: right;
|
|
|
|
right: 15px;
|
|
|
|
bottom: 15px;
|
|
|
|
z-index: 19;
|
|
|
|
}
|
2021-04-22 10:52:48 +08:00
|
|
|
.bigSplitScreenSelect {
|
2020-07-06 17:02:13 +08:00
|
|
|
top: 15px;
|
|
|
|
}
|
|
|
|
</style>
|