rt-sim-training-client/src/jmapNew/theme/foshan_01/menus/menuSwitch.vue

411 lines
14 KiB
Vue
Raw Normal View History

<template>
<div>
<pop-menu ref="popMenu" :menu="menu" />
<switch-control ref="switchControl" />
<switch-un-lock ref="switchUnLock" />
<speed-limit-control ref="speedLimitControl" />
<alxe-effective ref="alxeEffective" />
<notice-info ref="noticeInfo" />
</div>
</template>
<script>
import PopMenu from '@/components/PopMenu';
import SwitchControl from './dialog/switchControl';
import SwitchUnLock from './dialog/switchUnLock';
import SpeedLimitControl from './dialog/speedLimitControl';
import AlxeEffective from './dialog/alxeEffective';
import NoticeInfo from './dialog/childDialog/childDialog/noticeInfo';
import { mapGetters } from 'vuex';
import CMD from '@/scripts/cmdPlugin/CommandEnum';
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
import { DeviceMenu, OperateMode } from '@/scripts/ConstDic';
import MenuContextHandler from '@/scripts/cmdPlugin/MenuContextHandler';
export default {
name: 'SwitchMenu',
components: {
PopMenu,
SwitchControl,
SwitchUnLock,
SpeedLimitControl,
AlxeEffective,
NoticeInfo
},
props: {
selected: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
menu: [],
menuNormal: {
Local: [
{
label: '定操',
handler: this.locate,
cmdType: CMD.Switch.CMD_SWITCH_TURN_NP_CHAIN
},
{
label: '反操',
handler: this.reverse,
cmdType: CMD.Switch.CMD_SWITCH_TURN_RP_CHAIN
},
{
label: '道岔单锁',
handler: this.lock,
cmdType: CMD.Switch.CMD_SWITCH_SINGLE_LOCK
},
{
label: '道岔单解',
handler: this.unlock,
cmdType: CMD.Switch.CMD_SWITCH_SINGLE_UNLOCK
},
{
label: '道岔封锁',
handler: this.block,
cmdType: CMD.Switch.CMD_SWITCH_BLOCK
},
{
label: '道岔解封',
handler: this.unblock,
cmdType: CMD.Switch.CMD_SWITCH_UNBLOCK
}
],
Center: [
{
label: '定操',
handler: this.locate,
cmdType: CMD.Switch.CMD_SWITCH_TURN_NP_CHAIN
},
{
label: '反操',
handler: this.reverse,
cmdType: CMD.Switch.CMD_SWITCH_TURN_RP_CHAIN
},
{
type: 'separator'
},
{
label: '区段激活',
handler: this.active,
cmdType: CMD.Switch.CMD_SWITCH_ACTIVE
},
{
label: '区段切除',
handler: this.split,
cmdType: CMD.Switch.CMD_SWITCH_CUT_OFF
},
{
type: 'separator'
},
{
label: '确认计轴有效',
handler: this.alxeEffective,
cmdType: CMD.Switch.CMD_SWITCH_COMFIRMATION_AXLE
},
{
label: '设置临时限速',
handler: this.setSpeed,
cmdType: CMD.Section.CMD_SECTION_SET_LIMIT_SPEED
},
{
type: 'separator'
},
{
label: '查看公里标',
handler: this.undeveloped,
cmdType: CMD.Section.CMD_SECTION_SET_LIMIT_SPEED
}
]
},
menuForce: [
{
label: '设置故障',
handler: this.setStoppage,
cmdType: CMD.Switch.CMD_SWITCH_ADD_FAULT
},
{
label: '取消故障',
handler: this.cancelStoppage,
cmdType: CMD.Switch.CMD_SWITCH_REMOVE_FAULT
}
]
};
},
computed: {
...mapGetters('training', [
'mode',
'operatemode'
]),
...mapGetters('menuOperation', [
'buttonOperation'
])
},
watch: {
'$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Switch) && !this.buttonOperation) {
this.doShow(this.$store.state.menuOperation.menuPosition);
} else {
this.doClose();
}
}
},
methods: {
clickEvent() {
const self = this;
window.onclick = function (e) {
self.doClose();
};
},
initMenu() {
// 编辑模式菜单列表
this.menu = MenuContextHandler.covert(this.menuNormal);
// 故障模式菜单列表
if (this.operatemode === OperateMode.FAULT) {
this.menu = this.menuForce;
}
},
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();
}
},
// 设置故障
setStoppage() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.stoppage.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.mouseCancelState(this.selected);
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
} else {
this.$refs.noticeInfo.doShow(operate);
}
}).catch(() => {
this.$refs.noticeInfo.doShow(operate);
});
},
// 取消故障
cancelStoppage() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.cancelStoppage.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.mouseCancelState(this.selected);
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
} else {
this.$refs.noticeInfo.doShow(operate);
}
}).catch(() => {
this.$refs.noticeInfo.doShow(operate);
});
},
// 单操到定位
locate() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.locate.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchControl.doShow(operate, this.selected);
}
});
},
// 单操到反位
reverse() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.reverse.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchControl.doShow(operate, this.selected);
}
});
},
// 道岔单锁
lock() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.lock.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchControl.doShow(operate, this.selected);
}
});
},
// 道岔解锁
unlock() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.unlock.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchUnLock.doShow(operate, this.selected);
}
});
},
// 道岔封锁
block() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.block.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchControl.doShow(operate, this.selected);
}
});
},
// 道岔解封
unblock() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.unblock.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchUnLock.doShow(operate, this.selected);
}
});
},
// 区段切除
split() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.split.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchControl.doShow(operate, this.selected);
}
});
},
// 区段激活
active() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.active.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.switchControl.doShow(operate, this.selected);
}
});
},
// 设置临时限速
setSpeed() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.setSpeed.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.speedLimitControl.doShow(operate, this.selected);
}
});
},
// 确认计轴有效
alxeEffective() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Switch.alxeEffective.menu.operation,
param: {
switchCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.alxeEffective.doShow(operate, this.selected);
}
});
},
undeveloped() {
this.doClose();
this.$alert('实现中......', '提示', {
confirmButtonText: '确定',
callback: action => {
}
});
}
}
};
</script>