2020-03-23 14:27:57 +08:00
|
|
|
<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';
|
2020-03-25 13:20:31 +08:00
|
|
|
import {menuOperate, commitOperate} from './utils/menuOperate';
|
2020-03-23 14:27:57 +08:00
|
|
|
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: [
|
|
|
|
],
|
|
|
|
Center: [
|
2020-03-23 17:25:18 +08:00
|
|
|
// {
|
|
|
|
// label: '设置临时限速',
|
|
|
|
// handler: this.setSpeed,
|
|
|
|
// cmdType: CMD.Section.CMD_SECTION_SET_LIMIT_SPEED
|
|
|
|
// },
|
2020-03-23 14:27:57 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
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();
|
|
|
|
}
|
2020-03-25 13:20:31 +08:00
|
|
|
},
|
|
|
|
'$store.state.menuOperation.selectedCount': function(val) {
|
|
|
|
if (this.buttonOperation && this.$store.state.menuOperation.selected._type == 'Switch') {
|
|
|
|
this.operationHandler(this.buttonOperation, this.$store.state.menuOperation.selected);
|
|
|
|
}
|
2020-03-23 14:27:57 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
},
|
2020-03-25 13:20:31 +08:00
|
|
|
operationHandler(buttonOperation, selectType) {
|
|
|
|
switch (buttonOperation) {
|
|
|
|
case OperationEvent.Switch.locate.button.operation: {
|
|
|
|
// 道岔总定
|
|
|
|
if (!selectType.normalPosition && selectType.reversePosition) {
|
|
|
|
this.locate(selectType);
|
2020-03-23 14:27:57 +08:00
|
|
|
}
|
2020-03-25 13:20:31 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OperationEvent.Switch.reverse.button.operation: {
|
|
|
|
// 道岔总反
|
|
|
|
if (selectType.normalPosition && !selectType.reversePosition) {
|
|
|
|
this.reverse(selectType);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OperationEvent.Switch.lock.button.operation: {
|
|
|
|
// 道岔单锁
|
|
|
|
if (!selectType.singleLock) {
|
|
|
|
this.lock(selectType);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OperationEvent.Switch.unlock.button.operation: {
|
|
|
|
// 道岔解锁
|
|
|
|
if (selectType.singleLock) {
|
|
|
|
this.unlock(selectType);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OperationEvent.Switch.block.button.operation: {
|
|
|
|
// 道岔封锁
|
|
|
|
if (!selectType.blockade) {
|
|
|
|
this.block(selectType);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OperationEvent.Switch.unblock.button.operation: {
|
|
|
|
// 道岔解封
|
|
|
|
if (selectType.blockade) {
|
|
|
|
this.unblock(selectType);
|
2020-03-23 14:27:57 +08:00
|
|
|
}
|
2020-03-25 13:20:31 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OperationEvent.Switch.turnoutForce.button.operation: {
|
|
|
|
// 道岔强扳
|
|
|
|
this.switchTurnoutForce(selectType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 单操到定位
|
|
|
|
locate(selectType) {
|
2020-03-30 11:27:34 +08:00
|
|
|
commitOperate(menuOperate.Switch.locate, {switchCode:selectType.code}, 3).then(({valid, operate})=>{
|
2020-03-25 13:20:31 +08:00
|
|
|
// this.$refs.switchControl.doShow(data.operate, this.selected);
|
|
|
|
}).catch(error=>{
|
|
|
|
this.$refs.noticeInfo.doShow({}, error.message);
|
2020-03-23 14:27:57 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
// 单操到反位
|
2020-03-25 13:20:31 +08:00
|
|
|
reverse(selectType) {
|
2020-03-30 11:27:34 +08:00
|
|
|
commitOperate(menuOperate.Switch.reverse, {switchCode:selectType.code}, 3).then(({valid, operate})=>{
|
2020-03-25 13:20:31 +08:00
|
|
|
// this.$refs.switchControl.doShow(data.operate, this.selected);
|
|
|
|
}).catch(error=>{
|
|
|
|
this.$refs.noticeInfo.doShow({}, error.message);
|
2020-03-23 14:27:57 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
// 道岔单锁
|
2020-03-25 13:20:31 +08:00
|
|
|
lock(selectType) {
|
2020-03-30 11:27:34 +08:00
|
|
|
commitOperate(menuOperate.Switch.lock, {switchCode:selectType.code}, 3).then(({valid, operate})=>{
|
2020-03-25 13:20:31 +08:00
|
|
|
// this.$refs.switchControl.doShow(data.operate, this.selected);
|
|
|
|
}).catch(error=>{
|
|
|
|
this.$refs.noticeInfo.doShow({}, error.message);
|
2020-03-23 14:27:57 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
// 道岔解锁
|
2020-03-25 13:20:31 +08:00
|
|
|
unlock(selectType) {
|
2020-03-30 11:27:34 +08:00
|
|
|
commitOperate(menuOperate.Switch.unlock, {switchCode:selectType.code}, 3).then(({valid, operate})=>{
|
2020-03-25 13:20:31 +08:00
|
|
|
// this.$refs.switchUnLock.doShow(data.operate, this.selected);
|
|
|
|
}).catch(error=>{
|
|
|
|
this.$refs.noticeInfo.doShow({}, error.message);
|
2020-03-23 14:27:57 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
// 道岔封锁
|
2020-03-25 13:20:31 +08:00
|
|
|
block(selectType) {
|
2020-03-30 11:27:34 +08:00
|
|
|
commitOperate(menuOperate.Switch.block, {switchCode:selectType.code}, 3).then(({valid, operate})=>{
|
2020-03-25 13:20:31 +08:00
|
|
|
// this.$refs.switchControl.doShow(data.operate, this.selected);
|
|
|
|
}).catch(error=>{
|
|
|
|
this.$refs.noticeInfo.doShow({}, error.message);
|
2020-03-23 14:27:57 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
// 道岔解封
|
2020-03-25 13:20:31 +08:00
|
|
|
unblock(selectType) {
|
2020-03-30 11:27:34 +08:00
|
|
|
commitOperate(menuOperate.Switch.unblock, {switchCode:selectType.code}, 3).then(({valid, operate})=>{
|
2020-03-25 13:20:31 +08:00
|
|
|
// this.$refs.switchUnLock.doShow(data.operate, this.selected);
|
|
|
|
}).catch(error=>{
|
|
|
|
this.$refs.noticeInfo.doShow({}, error.message);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 道岔强扳
|
|
|
|
switchTurnoutForce(selectType) {
|
2020-03-30 11:27:34 +08:00
|
|
|
commitOperate(menuOperate.Switch.turnoutForce, {switchCode:selectType.code}, 3).then(({valid, operate})=>{
|
2020-03-25 13:20:31 +08:00
|
|
|
}).catch(error=>{
|
|
|
|
this.$refs.noticeInfo.doShow({}, error.message);
|
2020-03-23 14:27:57 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
// 设置临时限速
|
2020-03-23 17:25:18 +08:00
|
|
|
// 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);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
2020-03-23 14:27:57 +08:00
|
|
|
undeveloped() {
|
|
|
|
this.doClose();
|
|
|
|
this.$alert('实现中......', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
callback: action => {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|