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

319 lines
11 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" />
<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 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,
NoticeInfo
},
props: {
selected: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
menu: [],
menuNormal: {
Local: [
2020-03-24 18:01:10 +08:00
// {
// 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.setSpeed,
// 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);
}
});
},
// 设置临时限速
// 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);
// }
// });
// },
undeveloped() {
this.doClose();
this.$alert('实现中......', '提示', {
confirmButtonText: '确定',
callback: action => {
}
});
}
}
};
</script>