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

491 lines
17 KiB
Vue
Raw Normal View History

2019-11-29 12:51:58 +08:00
<template>
<div>
<pop-menu ref="popMenu" :menu="menu" />
<route-selection ref="routeSelection" />
<route-control ref="routeControl" />
<route-detail ref="routeDetail" />
<route-guide ref="routeGuide" />
<route-hand-control ref="routeHandControl" />
<notice-info ref="noticeInfo" />
</div>
2019-11-29 12:51:58 +08:00
</template>
<script>
import PopMenu from '@/components/PopMenu';
import RouteControl from './dialog/routeControl';
import RouteSelection from './dialog/routeSelection';
import RouteDetail from './dialog/routeDetail';
import RouteHandControl from './dialog/routeHandControl';
import RouteGuide from './dialog/routeGuide';
import NoticeInfo from './dialog/childDialog/childDialog/noticeInfo';
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';
import { querySignalStatus } from '@/api/simulation';
2019-11-29 12:51:58 +08:00
export default {
name: 'SignalMenu',
components: {
PopMenu,
RouteControl,
RouteSelection,
RouteHandControl,
RouteDetail,
RouteGuide,
NoticeInfo
},
props: {
selected: {
type: Object,
default: () => {
return null;
2019-11-29 12:51:58 +08:00
}
}
},
data() {
return {
menu: [],
menuNormal: {
Local: [
{
label: '始端/终端选择',
handler: '',
cmdType: ''
},
{
label: '取消进路',
handler: this.cancelTrainRoute,
cmdType: ''
},
{
label: '开放自动进路',
handler: '',
cmdType: ''
},
{
label: '关闭自动进路',
handler: '',
cmdType: ''
},
{
label: '终端信号封锁',
handler: this.lock,
cmdType: ''
},
{
label: '终端信号解封',
handler: this.unlock,
cmdType: ''
},
{
label: '引导信号',
handler: '',
cmdType: ''
},
{
label: '设备标签',
handler: '',
cmdType: ''
},
{
label: '模拟',
handler: '',
cmdType: ''
},
{
label: '选择设备',
handler: '',
cmdType: ''
},
{
label: '帮助',
handler: '',
cmdType: ''
}
],
Center: [
{
label: '始端/终端选择',
handler: '',
cmdType: ''
},
{
label: '取消进路',
handler: this.cancelTrainRoute,
cmdType: ''
},
{
label: '开放自动进路',
handler: '',
cmdType: ''
},
{
label: '关闭自动进路',
handler: '',
cmdType: ''
},
{
label: '终端信号封锁',
handler: this.lock,
cmdType: ''
},
{
label: '终端信号解封',
handler: this.unlock,
cmdType: ''
},
{
label: '引导信号',
handler: '',
cmdType: ''
},
{
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
},
{
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'
]),
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,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.signalClose.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
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 });
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,
code: `${this.selected.code}`,
cmdType: CMD.Signal.CMD_SIGNAL_ADD_FAULT,
operation: OperationEvent.Signal.stoppage.menu.operation,
param: {
Signal_Code: `${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,
code: `${this.selected.code}`,
cmdType: CMD.Signal.CMD_SIGNAL_REMOVE_FAULT,
operation: OperationEvent.Signal.cancelStoppage.menu.operation,
param: {
Signal_Code: `${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,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.arrangementRoute.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
2019-11-29 12:51:58 +08:00
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
if (valid) {
querySignalStatus(this.group, {signalCode: `${this.selected.code}`}).then(resp => {
const tempData = resp.data;
this.$refs.routeSelection.doShow(step.operation, this.selected, tempData);
});
2019-11-29 12:51:58 +08:00
}
}).catch(() => {
this.$refs.noticeInfo.doShow(step);
});
},
// 进路引导
guide() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.guide.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
this.$store.dispatch('training/nextNew', step).then(({ valid, response }) => {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
if (valid) {
querySignalStatus(this.group, {signalCode: `${this.selected.code}`}).then(resp => {
const tempData = resp.data;
this.$refs.routeGuide.doShow(step.operation, this.selected, tempData);
});
}
});
},
// 取消进路
cancelTrainRoute() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.cancelTrainRoute.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
if (valid) {
this.$refs.routeControl.doShow(step, this.selected);
}
});
},
// 总人解
humanTrainRoute() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.humanTrainRoute.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
if (valid) {
this.$refs.routeControl.doShow(step, this.selected);
}
});
},
// 信号重开
reopenSignal() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.reopenSignal.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.routeControl.doShow(step, this.selected);
}
});
},
// 信号封锁
lock() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.lock.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
2019-11-29 12:51:58 +08:00
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.$refs.routeControl.doShow(step, this.selected);
}
}).catch(() => {
this.$refs.noticeInfo.doShow(step);
});
},
// 信号解封
unlock() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.unlock.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
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.$refs.routeControl.doShow(step, this.selected);
}
});
},
// 进路交人工控
humanControl() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.humanControl.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
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 });
querySignalStatus(this.group, {signalCode: `${this.selected.code}`}).then(resp => {
const tempData = resp.data;
this.$refs.routeHandControl.doShow(step, this.selected, tempData);
});
}
});
},
// 进路交自动控
atsAutoControl() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.atsAutoControl.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
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 });
querySignalStatus(this.group, {signalCode: `${this.selected.code}`}).then(resp => {
const tempData = resp.data;
this.$refs.routeHandControl.doShow(step, this.selected, tempData);
});
}
});
},
// 查询进路状态
detail() {
const step = {
start: true,
code: `${this.selected.code}`,
operation: OperationEvent.Signal.detail.menu.operation,
param: {
Signal_Code: `${this.selected.code}`
}
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
querySignalStatus(this.group, {signalCode: `${this.selected.code}`}).then(resp => {
const tempData = resp.data;
this.$refs.routeDetail.doShow(step, this.selected, tempData);
});
}
});
2019-11-29 12:51:58 +08:00
}
}
};
</script>