rt-sim-training-client/src/jmapNew/theme/chengdu_01/menus/menuSignal.vue

480 lines
18 KiB
Vue
Raw Normal View History

2019-11-29 12:51:58 +08:00
<template>
<div>
2020-01-10 18:51:57 +08:00
<pop-menu ref="popMenu" :menu="menu" :pop-class="popClass" />
<notice-info ref="noticeInfo" />
2020-01-08 09:41:55 +08:00
<create-device-label ref="createDeviceLabel" />
</div>
2019-11-29 12:51:58 +08:00
</template>
<script>
import PopMenu from '@/components/PopMenu';
import NoticeInfo from './dialog/childDialog/childDialog/noticeInfo';
2020-01-08 09:41:55 +08:00
import CreateDeviceLabel from './dialog/createDeviceLabel';
import { mapGetters } from 'vuex';
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
import { DeviceMenu, OperateMode } from '@/scripts/ConstDic';
import CMD from '@/scripts/cmdPlugin/CommandEnum';
import MenuContextHandler from '@/scripts/cmdPlugin/MenuContextHandler';
2019-11-29 12:51:58 +08:00
export default {
name: 'SignalMenu',
components: {
PopMenu,
2020-01-08 09:41:55 +08:00
NoticeInfo,
CreateDeviceLabel
},
props: {
selected: {
type: Object,
default: () => {
return null;
2019-11-29 12:51:58 +08:00
}
}
},
data() {
return {
menu: [],
2020-01-10 18:51:57 +08:00
popClass: 'chengdou-01__select-option',
menuNormal: {
Local: [
{
label: '始端/终端选择',
2020-01-09 17:48:25 +08:00
handler: this.arrangementRoute,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_SET_ROUTE
},
{
label: '取消进路',
handler: this.cancelTrainRoute,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_CANCEL_ROUTE
},
{
label: '开放自动进路',
2020-01-09 17:48:25 +08:00
handler: this.atsAutoControl,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_OPEN_AUTO_SETTING
},
{
label: '关闭自动进路',
2020-01-09 17:48:25 +08:00
handler: this.humanControl,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_CLOSE_AUTO_SETTING
},
{
label: '终端信号封锁',
handler: this.lock,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_BLOCK
},
{
label: '终端信号解封',
handler: this.unlock,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_UNBLOCK
},
{
label: '引导信号',
2020-01-09 17:48:25 +08:00
handler: this.guide,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_ROUTE_GUIDE
},
{
label: '设备标签',
handler: '',
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_ROUTE_GUIDE,
children: [
{
label: '创建设备标签',
handler: '',
cmdType: ''
}
]
},
{
label: '模拟',
handler: '',
cmdType: ''
},
{
label: '选择设备',
handler: '',
cmdType: ''
},
{
label: '帮助',
handler: '',
cmdType: ''
}
],
Center: [
{
label: '始端/终端选择',
2020-01-09 17:48:25 +08:00
handler: this.arrangementRoute,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_SET_ROUTE
},
{
label: '取消进路',
handler: this.cancelTrainRoute,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_CANCEL_ROUTE
},
{
label: '开放自动进路',
2020-01-09 17:48:25 +08:00
handler: this.atsAutoControl,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_OPEN_AUTO_SETTING
},
{
label: '关闭自动进路',
2020-01-09 17:48:25 +08:00
handler: this.humanControl,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_CLOSE_AUTO_SETTING
},
{
label: '终端信号封锁',
handler: this.lock,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_BLOCK
},
{
label: '终端信号解封',
handler: this.unlock,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_UNBLOCK
},
{
label: '引导信号',
2020-01-09 17:48:25 +08:00
handler: this.guide,
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_ROUTE_GUIDE
},
{
label: '设备标签',
handler: '',
2020-01-08 09:41:55 +08:00
cmdType: CMD.Signal.CMD_SIGNAL_ROUTE_GUIDE,
children: [
{
label: '创建设备标签',
handler: this.createDeviceLabel,
cmdType: ''
}
]
},
2019-11-29 12:51:58 +08:00
{
label: '模拟',
handler: '',
cmdType: ''
2019-11-29 12:51:58 +08:00
},
{
label: '选择设备',
handler: '',
cmdType: ''
2019-11-29 12:51:58 +08:00
},
{
label: '帮助',
handler: '',
cmdType: ''
2019-11-29 12:51:58 +08:00
}
]
},
menuForce: [
{
label: '信号关灯',
handler: this.signalClose,
cmdType: CMD.Signal.CMD_SIGNAL_CLOSE_SIGNAL
},
{
label: '设置故障',
handler: this.setStoppage,
cmdType: CMD.Signal.CMD_SIGNAL_ADD_FAULT
},
{
label: '取消故障',
handler: this.cancelStoppage,
cmdType: CMD.Signal.CMD_SIGNAL_REMOVE_FAULT
}
]
};
},
computed: {
...mapGetters('training', [
'mode',
'operatemode'
]),
...mapGetters('menuOperation', [
'buttonOperation'
]),
...mapGetters('map', [
'routeList'
]),
group() {
return this.$route.query.group;
}
},
watch: {
'$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Signal) && !this.buttonOperation) {
this.doShow(this.$store.state.menuOperation.menuPosition);
} else {
this.doClose();
2019-11-29 12:51:58 +08:00
}
}
},
methods: {
clickEvent() {
const self = this;
window.onclick = function (e) {
self.doClose();
};
2019-11-29 12:51:58 +08:00
},
initMenu() {
// 编辑模式菜单列表
this.menu = MenuContextHandler.covert(this.menuNormal);
// 故障模式菜单列表
if (this.operatemode === OperateMode.FAULT) {
this.menu = this.menuForce;
2019-11-29 12:51:58 +08:00
}
},
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();
}
2019-11-29 12:51:58 +08:00
},
// 信号关灯
signalClose() {
const step = {
start: true,
over: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.signalClose.menu.operation,
param: {
signalCode: `${this.selected.code}`
},
cmdType: CMD.Signal.CMD_SIGNAL_CLOSE_SIGNAL
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.routeControl.doShow(step, this.selected);
2019-11-29 12:51:58 +08:00
}
}).catch(() => {
this.$refs.noticeInfo.doShow(step);
});
},
// 设置故障
setStoppage() {
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
cmdType: CMD.Signal.CMD_SIGNAL_ADD_FAULT,
operation: OperationEvent.Signal.stoppage.menu.operation,
param: {
signalCode: `${this.selected.code}`
2019-11-29 12:51:58 +08:00
}
};
2019-11-29 12:51:58 +08:00
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
} else {
this.$refs.noticeInfo.doShow(step);
2019-11-29 12:51:58 +08:00
}
}).catch(() => {
this.$refs.noticeInfo.doShow(step);
});
},
// 取消故障
cancelStoppage() {
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
cmdType: CMD.Signal.CMD_SIGNAL_REMOVE_FAULT,
operation: OperationEvent.Signal.cancelStoppage.menu.operation,
param: {
signalCode: `${this.selected.code}`
2019-11-29 12:51:58 +08:00
}
};
2019-11-29 12:51:58 +08:00
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
} else {
this.$refs.noticeInfo.doShow(step);
}
}).catch(() => {
this.$refs.noticeInfo.doShow(step);
});
},
// 设置进路
arrangementRoute() {
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.arrangementRoute.menu.operation,
param: {
signalCode: `${this.selected.code}`
},
cmdType: CMD.Signal.CMD_SIGNAL_SET_ROUTE
};
2019-11-29 12:51:58 +08:00
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
2020-01-09 17:48:25 +08:00
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true});
// this.$store.dispatch('menuOperation/pushRequestList', { device: this.selected, operation: { code: OperationEvent.Signal.arrangementRoute.menu.operation, name: '始端/终端选择',cmdType:CMD.Signal.CMD_SIGNAL_SET_ROUTE}});
2019-11-29 12:51:58 +08:00
}
}).catch(() => {
this.$refs.noticeInfo.doShow(step);
});
},
// 进路引导
guide() {
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.guide.menu.operation,
param: {
signalCode: `${this.selected.code}`
},
cmdType: CMD.Signal.CMD_SIGNAL_ROUTE_GUIDE
};
this.$store.dispatch('training/nextNew', step).then(({ valid, response }) => {
if (valid) {
2020-01-09 17:48:25 +08:00
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
// this.$store.dispatch('menuOperation/pushRequestList', {device: this.selected, operation: { code: OperationEvent.Signal.guide.menu.operation, name: '引导信号',cmdType:CMD.Signal.CMD_SIGNAL_ROUTE_GUIDE}});
}
});
},
// 取消进路
cancelTrainRoute() {
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.cancelTrainRoute.menu.operation,
param: {
signalCode: `${this.selected.code}`
},
cmdType: CMD.Signal.CMD_SIGNAL_CANCEL_ROUTE
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
2020-01-09 17:48:25 +08:00
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
// this.$store.dispatch('menuOperation/pushRequestList', {device: this.selected, operation: { code: OperationEvent.Signal.cancelTrainRoute.menu.operation, name: '取消进路',cmdType:CMD.Signal.CMD_SIGNAL_CANCEL_ROUTE}});
}
});
},
2020-01-09 17:48:25 +08:00
// 信号封锁
lock() {
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
2020-01-09 17:48:25 +08:00
operation: OperationEvent.Signal.lock.menu.operation,
param: {
signalCode: `${this.selected.code}`
},
cmdType: CMD.Signal.CMD_SIGNAL_BLOCK
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
// this.$store.dispatch('menuOperation/pushRequestList', { device: this.selected, operation: { code: OperationEvent.Signal.lock.menu.operation, name: '终端信号机封锁',cmdType:CMD.Signal.CMD_SIGNAL_BLOCK}});
}
2020-01-09 17:48:25 +08:00
}).catch(() => {
this.$refs.noticeInfo.doShow(step);
});
},
// 信号解封
unlock() {
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.unlock.menu.operation,
param: {
signalCode: `${this.selected.code}`
},
cmdType: CMD.Signal.CMD_SIGNAL_UNBLOCK
};
2020-01-09 17:48:25 +08:00
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
// this.$store.dispatch('menuOperation/pushRequestList', { device: this.selected, operation: { code: OperationEvent.Signal.unlock.menu.operation, name: '终端信号机解封',cmdType:CMD.Signal.CMD_SIGNAL_UNBLOCK}});
2020-01-09 17:48:25 +08:00
}
});
},
// 进路交人工控
humanControl() {
const routes = [];
this.routeList.forEach(elem => {
if (elem.startSignalCode === this.selected.code) {
// routes.push(elem);
if (elem.atsControl == '1') {
routes.push(elem.code);
}
}
});
if (routes.length <= 0) {
this.$refs.noticeInfo.doShow({}, ['所选的进路没有一个是人工的']);
return false;
}
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.humanControl.menu.operation,
param: {
signalCode: `${this.selected.code}`,
routeCodeList:routes
},
cmdType: CMD.Signal.CMD_SIGNAL_CLOSE_AUTO_SETTING
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
2019-11-29 12:51:58 +08:00
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
// this.$store.dispatch('menuOperation/pushRequestList', { device: this.selected, operation: '关闭自动进路',cmdType:CMD.Signal.CMD_SIGNAL_CLOSE_AUTO_SETTING});
}
});
},
// 进路交自动控
atsAutoControl() {
const routes = [];
this.routeList.forEach(elem => {
if (elem.startSignalCode === this.selected.code) {
// routes.push(elem);
if (elem.atsControl == '0') {
routes.push(elem.code);
}
}
});
if (routes.length <= 0) {
this.$refs.noticeInfo.doShow({}, ['所选的进路没有一个是自动的']);
return false;
}
const step = {
start: true,
over:true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.atsAutoControl.menu.operation,
param: {
signalCode: `${this.selected.code}`,
routeCodeList:routes
},
cmdType: CMD.Signal.CMD_SIGNAL_OPEN_AUTO_SETTING
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
2019-11-29 12:51:58 +08:00
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
// this.$store.dispatch('menuOperation/pushRequestList', { device: this.selected, operation: { code: OperationEvent.Signal.atsAutoControl.menu.operation, name: '开放自动进路',cmdType:CMD.Signal.CMD_SIGNAL_OPEN_AUTO_SETTING}});
}
});
2020-01-08 09:41:55 +08:00
},
createDeviceLabel() {
2020-01-10 14:50:04 +08:00
this.doClose();
2020-01-08 09:41:55 +08:00
this.$refs.createDeviceLabel.doShow();
2019-11-29 12:51:58 +08:00
}
}
};
</script>