2019-07-29 13:45:38 +08:00
|
|
|
<template>
|
2019-09-04 19:00:22 +08:00
|
|
|
<div>
|
|
|
|
<pop-menu ref="popMenu" :menu="menu" />
|
|
|
|
</div>
|
2019-07-29 13:45:38 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-09-04 19:00:22 +08:00
|
|
|
import PopMenu from '@/components/PopMenu';
|
|
|
|
import { Notification } from 'element-ui';
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { DeviceMenu } from '@/scripts/ConstDic';
|
|
|
|
import { exitFullscreen } from '@/utils/screen';
|
2019-07-29 13:45:38 +08:00
|
|
|
|
2019-09-04 19:00:22 +08:00
|
|
|
export default {
|
|
|
|
name: 'CancelMenu',
|
|
|
|
components: {
|
|
|
|
PopMenu
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
menu: [],
|
|
|
|
menuNormal: [],
|
|
|
|
menuScreen: [
|
|
|
|
{
|
2019-09-12 16:03:03 +08:00
|
|
|
label: this.$t('menu.menuCancle.zoomIn'),
|
2019-09-04 19:00:22 +08:00
|
|
|
handler: this.magnifyMap,
|
|
|
|
disabled: false
|
|
|
|
},
|
|
|
|
{
|
2019-09-12 16:03:03 +08:00
|
|
|
label: this.$t('menu.menuCancle.zoomOut'),
|
2019-09-04 19:00:22 +08:00
|
|
|
handler: this.shrinkMap,
|
|
|
|
disabled: false
|
|
|
|
},
|
|
|
|
{
|
2019-09-12 16:03:03 +08:00
|
|
|
label: this.$t('menu.menuCancle.back'),
|
2019-09-04 19:00:22 +08:00
|
|
|
handler: this.back,
|
|
|
|
disabled: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters('map', [
|
|
|
|
'stationList'
|
|
|
|
]),
|
|
|
|
isScreen() { // 大屏隐藏所有菜单
|
|
|
|
return this.$route.params.mode === 'dp' ||
|
|
|
|
this.$store.state.training.roles == 'BigScreen';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$store.state.menuOperation.buttonOperation': function (val, old) {
|
|
|
|
if (!this.isScreen && this.menu && this.menu.length > 1) {
|
|
|
|
// this.menu[0].disabled = (this.menu[0] && val) ? true : true;
|
|
|
|
// this.menu[1].disabled = !((this.menu[1] && val));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'$store.state.menuOperation.menuCount': function (val) {
|
|
|
|
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Cancel)) {
|
|
|
|
this.doShow(this.$store.state.menuOperation.menuPosition);
|
|
|
|
} else {
|
|
|
|
this.doClose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clickEvent() {
|
|
|
|
const self = this;
|
|
|
|
window.onclick = function (e) {
|
|
|
|
self.doClose();
|
|
|
|
};
|
|
|
|
},
|
|
|
|
initMenu() {
|
|
|
|
this.menuNormal = [];
|
|
|
|
this.stationList.forEach(station => {
|
|
|
|
if (station.code === station.concentrateStationCode) {
|
|
|
|
const node = {
|
|
|
|
label: station.name,
|
|
|
|
children: []
|
|
|
|
};
|
2019-07-29 13:45:38 +08:00
|
|
|
|
2019-09-04 19:00:22 +08:00
|
|
|
this.stationList.forEach(elem => {
|
|
|
|
if (elem.visible) {
|
|
|
|
let next = elem;
|
|
|
|
while (next.code != next.concentrateStationCode || !next.concentrateStationCode) {
|
|
|
|
next = this.$store.getters['map/getDeviceByCode'](next.concentrateStationCode);
|
|
|
|
}
|
2019-07-29 13:45:38 +08:00
|
|
|
|
2019-09-04 19:00:22 +08:00
|
|
|
if (station.code == next.code) {
|
|
|
|
node.children.push({
|
|
|
|
code: elem.code,
|
|
|
|
label: elem.name,
|
|
|
|
handler: this.mapLocation
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-07-29 13:45:38 +08:00
|
|
|
|
2019-09-04 19:00:22 +08:00
|
|
|
this.menuNormal.push(node);
|
|
|
|
}
|
|
|
|
});
|
2019-07-29 13:45:38 +08:00
|
|
|
|
2019-09-04 19:00:22 +08:00
|
|
|
if (this.isScreen) {
|
|
|
|
this.menu = [...this.menuScreen];
|
|
|
|
} else {
|
|
|
|
this.menu = [...this.menuNormal];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
doShow(point) {
|
|
|
|
this.clickEvent();
|
|
|
|
this.initMenu();
|
|
|
|
if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) {
|
|
|
|
this.$refs.popMenu.resetShowPosition(point);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
doClose() {
|
|
|
|
if (this.$refs && this.$refs.popMenu) {
|
|
|
|
this.$refs.popMenu.close();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 设置地图定位
|
|
|
|
mapLocation(item) {
|
|
|
|
if (item) {
|
|
|
|
this.$store.dispatch('training/updateOffsetStationCode', { offsetStationCode: item.code });
|
|
|
|
this.doClose();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 放大地图
|
|
|
|
magnifyMap() {
|
|
|
|
this.$store.dispatch('menuOperation/handleMagnifyCount');
|
|
|
|
},
|
|
|
|
// 缩小地图
|
|
|
|
shrinkMap() {
|
|
|
|
this.$store.dispatch('menuOperation/handleShrinkCount');
|
|
|
|
},
|
|
|
|
// 返回
|
|
|
|
async back() {
|
|
|
|
history.go(-1);
|
|
|
|
Notification.closeAll();
|
|
|
|
exitFullscreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|