rt-sim-training-client/src/jmapNew/theme/chengdu_01/menus/menuTrain.vue
2020-02-13 16:47:10 +08:00

421 lines
15 KiB
Vue

<template>
<div>
<pop-menu ref="popMenu" :menu="menu" />
<train-init-plan ref="trainInitPlan"/>
<notice-info ref="noticeInfo" />
</div>
</template>
<script>
import PopMenu from '@/components/PopMenu';
import TrainInitPlan from './dialog/trainInitPlan';
import NoticeInfo from './dialog/childDialog/childDialog/noticeInfo';
import { MenuDisabledState } from './utils/menuItemStatus';
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 CancelMouseState from '@/mixin/CancelMouseState';
export default {
name: 'MenuTrain',
components: {
PopMenu,
NoticeInfo,
TrainInitPlan
},
mixins: [
CancelMouseState
],
props: {
selected: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
menu: [],
menuNormal: {
Local: [],
Center: [
// {
// label: '追踪号',
// handler: '',
// children: [
// {
// label: '目的地ID',
// handler: '',
// cmdType: ''
// },
// {
// label: '删除ID',
// handler: '',
// cmdType: ''
// },
// {
// label: '更改追踪号',
// handler: '',
// cmdType: ''
// },
// {
// label: '交换追踪号',
// handler: '',
// cmdType: ''
// },
// {
// label: '运行等级',
// handler: '',
// cmdType: ''
// },
// {
// label: '列车模式',
// handler: '',
// cmdType: ''
// },
// {
// label: '惰性模式',
// handler: '',
// cmdType: ''
// },
// {
// label: '旁路模式',
// handler: '',
// cmdType: ''
// },
// {
// label: '开门禁止',
// handler: '',
// cmdType: ''
// }
// ]
// },
// {
// label: '列车明细',
// handler: '',
// cmdType: ''
// },
// {
// label: '无线',
// handler: '',
// cmdType: ''
// },
// {
// label: 'TWC',
// handler: '',
// cmdType: ''
// },
// {
// label: '设备标签',
// handler: '',
// cmdType: ''
// },
// {
// label: '模拟',
// handler: '',
// cmdType: ''
// },
// {
// label: '帮助',
// handler: '',
// cmdType: ''
// }
{
label: '新建计划列车',
handler: this.createPlanTrain,
cmdType: CMD.TrainWindow.CMD_Train_Init_Plan
}
]
},
menuForce: [
{
label: '设置通信故障',
handler: this.setStoppage,
disabledCallback: MenuDisabledState.Train.setStoppage
},
{
label: '取消通信故障',
handler: this.cancelStoppage,
disabledCallback: MenuDisabledState.Train.cancelStoppage
}
],
menuSpeed: [
{
label: '确认运行至前方站',
handler: this.limitSpeed,
disabledCallback: MenuDisabledState.Train.limitSpeed
}
]
};
},
computed: {
...mapGetters('training', [
'mode',
'operatemode'
]),
...mapGetters('menuOperation', [
'buttonOperation'
])
},
watch: {
'$store.state.menuOperation.menuCount': function () {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Train) && !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 = trainMenuFiltration(this.menuNormal);
this.menu = MenuContextHandler.covert(this.menuNormal);
// 故障模式菜单列表
if (this.operatemode === OperateMode.FAULT) {
this.menu = [...this.menuForce, ...this.menuSpeed];
}
// this.menu = menuConvert(this.menu);
},
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,
send: true,
code: this.selected.code,
operation: OperationEvent.Train.stoppage.menu.operation
};
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,
send: true,
code: this.selected.code,
operation: OperationEvent.Train.cancelStoppage.menu.operation
};
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);
});
},
// 限速行驶
limitSpeed() {
const operate = {
start: true,
send: true,
code: this.selected.code,
operation: OperationEvent.Train.limitSpeed.menu.operation
};
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);
});
},
// 设计划车
setPlanTrainId() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.setPlanTrainId.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainControl.doShow(operate, this.selected);
} else {
this.$refs.noticeInfo.doShow(operate);
}
});
},
// 设目的地车
destinationTrainId() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.destinationTrainId.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainControl.doShow(operate, this.selected);
} else {
this.$refs.noticeInfo.doShow(operate);
}
});
},
// 设人工车
artificialTrainId() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.artificialTrainId.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainControl.doShow(operate, this.selected);
} else {
this.$refs.noticeInfo.doShow(operate);
}
});
},
// 详细列车信息
detailTrainInfo() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.detailTrainInfo.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainDetailInfo.doShow(operate, this.selected);
} else {
this.$refs.noticeInfo.doShow(operate);
}
});
},
// 创建车组号
createTrainNo() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.createTrainNo.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainCreateNumber.doShow(operate, this.selected);
}
});
},
// 删除车组号
deleteTrainNo() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.deleteTrainNo.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainDeleteNumber.doShow(operate, this.selected);
}
});
},
// 修改车组号
editTrainNo() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.editTrainNo.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainEditNumber.doShow(operate, this.selected);
}
});
},
// 移动车组号
moveTrainNo() {
const operate = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.moveTrainNo.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainMoveNumber.doShow(operate, this.selected);
}
});
},
createPlanTrain() {
const step = {
start: true,
code: this.selected.code,
operation: OperationEvent.Train.createPlanTrain.menu.operation,
param: {
trainWindowCode: this.selected.code
}
};
this.$store.dispatch('training/nextNew', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$refs.trainInitPlan.doShow(step, this.selected);
}
});
},
undeveloped() {
this.doClose();
this.$alert('实现中......', '提示', {
confirmButtonText: '确定',
callback: action => {
}
});
}
}
};
</script>