rt-sim-training-client/src/jmapNew/theme/chengdu_03/menus/menuButton.vue

393 lines
17 KiB
Vue
Raw Normal View History

2019-11-29 12:51:58 +08:00
<template>
<div v-if="isShowBtn" class="menu" style="height: 45px;" :style="{left: point.x+'px', top: point.y+'px' }">
2019-12-31 14:32:04 +08:00
<button :id="Signal.arrangementRoute.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Signal.arrangementRoute.button.operation, 'Signal')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Signal.cancelTrainRoute.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Signal.cancelTrainRoute.button.operation, 'Signal')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Signal.guide.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Signal.guide.button.operation, 'Signal')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
<!-- 流程未做暂不显示 -->
<!-- <button :id="Switch.guideLock.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Switch.guideLock.button.operation)">
<span style="color: red">
<center><b></b><b></b></center>
<center><b></b><b></b></center>
</span>
</button> -->
2019-12-31 14:32:04 +08:00
<button :id="Signal.humanTrainRoute.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Signal.humanTrainRoute.button.operation, 'Signal')">
2019-11-29 12:51:58 +08:00
<span style="color: red">
<center><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Section.fault.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Section.fault.button.operation, 'Section')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Switch.locate.button.domId" class="button_box" :style="{width: width+'px',backgroundColor:buttonUpColor}" @click="buttonDown(Switch.locate.button.operation, 'Switch')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Switch.reverse.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Switch.reverse.button.operation, 'Switch')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Switch.lock.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Switch.lock.button.operation, 'Switch')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Switch.unlock.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Switch.unlock.button.operation, 'Switch')">
2019-11-29 12:51:58 +08:00
<span style="color: red">
<center><b></b><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="MixinCommand.block.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(MixinCommand.block.button.operation, 'MixinCommand')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b></center>
<center><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="MixinCommand.unblock.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(MixinCommand.unblock.button.operation, 'MixinCommand')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b></center>
<center><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="MixinCommand.functionButton.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(MixinCommand.functionButton.button.operation, 'MixinCommand')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center>
<b style="color:deepskyblue"></b>
<b style="color:burlywood"></b>
</center>
<center>
<b style="color: red"></b>
<b style="color:forestgreen"></b>
</center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Signal.atsAutoControl.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Signal.atsAutoControl.button.operation, 'Signal')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
2019-12-31 14:32:04 +08:00
<button :id="Signal.humanControl.button.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Signal.humanControl.button.operation, 'Signal')">
2019-11-29 12:51:58 +08:00
<span style="color: black">
<center><b></b></center>
<center><b></b><b></b></center>
</span>
</button>
<button :id="Command.cancel.clearMbm.domId" class="button_box" :style="{width: width+'px', backgroundColor:buttonUpColor}" @click="buttonDown(Command.cancel.clearMbm.operation)">
<span style="color: black">
<center><b></b></center>
<center><b></b></center>
</span>
</button>
<password-box ref="password" @checkOver="passWordCommit" />
</div>
</template>
<script>
2019-12-31 14:32:04 +08:00
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
import OperationHandler from '@/scripts/cmdPlugin/OperationHandler';
import Handler from '@/scripts/cmdPlugin/Handler';
// import { deepAssign } from '@/utils/index';
2019-11-29 12:51:58 +08:00
import PasswordBox from './dialog/childDialog/passwordInputBox.vue';
2019-12-31 14:32:04 +08:00
import CMD from '@/scripts/cmdPlugin/CommandEnum';
2019-11-29 12:51:58 +08:00
export default {
2019-12-31 14:32:04 +08:00
name: 'MapButtonMenu',
components: {
PasswordBox
},
data() {
return {
point: {
x: -1000,
y: -1000
},
operation: '0',
buttonName: '',
buttonDownColor: '#A8A8A8',
buttonUpColor: '#DCDCDC',
width: 58,
tempData: null,
offset: {},
commandType: '',
cmdTypeList: []
};
},
computed: {
Switch() {
return OperationEvent.Switch;
},
Section() {
return OperationEvent.Section;
},
Signal() {
return OperationEvent.Signal;
},
MixinCommand() {
return OperationEvent.MixinCommand;
},
Command() {
return OperationEvent.Command;
},
isShowBtn() {
return this.$store.state.training.prdType == '01';
},
CMD() {
return CMD;
},
cmdType() {
switch (this.operation) {
case this.Switch.lock.button.operation: // 道岔单锁
return CMD.Switch.CMD_SWITCH_SINGLE_LOCK;
case this.Switch.unlock.button.operation: // 道岔解锁
return CMD.Switch.CMD_SWITCH_SINGLE_UNLOCK;
case this.Switch.locate.button.operation || this.Switch.reverse.button.operation: // 道岔定位/反位
return CMD.Switch.CMD_SWITCH_TURN;
case this.MixinCommand.block.button.operation: // 封锁
return {};
case this.MixinCommand.unblock.button.operation: // 解封
return {};
case this.Signal.atsAutoControl.button.operation: // 自动控
return CMD.Signal.CMD_SIGNAL_OPEN_AUTO_SETTING;
case this.Signal.humanControl.button.operation: // 人工控
return CMD.Signal.CMD_SIGNAL_CLOSE_AUTO_SETTING;
case this.Section.fault.button.operation: // 区故解
return CMD.Section.CMD_SECTION_FAULT_UNLOCK;
case this.Signal.humanTrainRoute.button.operation: // 总人解 (取消引导进路)
return CMD.Section.CMD_SIGNAL_HUMAN_RELEASE_ROUTE;
case this.Signal.cancelTrainRoute.button.operation: // 总取消
return CMD.Section.CMD_SIGNAL_CANCEL_ROUTE;
case this.Signal.arrangementRoute.button.operation: // 排列进路
return CMD.Section.CMD_SIGNAL_SET_ROUTE;
case this.Signal.guide.button.operation: // 引导进路
return CMD.Section.CMD_SIGNAL_ROUTE_GUIDE;
}
return '';
}
},
watch: {
'$store.state.config.canvasOffsetCount': function (val) {
this.resetPosition();
},
'$store.state.menuOperation.buttonOperation': function (val, old) {
this.updateButtonShow(val, old);
},
'$store.state.menuOperation.selectedCount': function (val) {
this.selectedChange();
}
},
mounted() {
this.resetPosition();
},
methods: {
passWordCommit(data) {
const operate = {
type: 'mbm',
operation: data.operateNext
};
2019-11-29 12:51:58 +08:00
2019-12-31 14:32:04 +08:00
this.$store.dispatch('training/next', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
}
}).catch(() => {
this.$refs.noticeInfo.doShow(operate);
});
},
resetPosition() {
this.$nextTick(() => {
const canvasOffset = this.$store.state.config.canvasOffset;
this.point = {
x: canvasOffset.x + 20,
y: canvasOffset.y + this.$store.state.config.height - 65
};
this.$store.dispatch('training/tipReload');
});
},
updateButtonShow(val, old) {
if (old) {
// 恢复旧按钮显示
const domId = OperationHandler.getDomIdByOperation(old);
const dom = document.getElementById(domId);
if (dom) {
dom.disabled = false;
dom.style.backgroundColor = this.buttonUpColor;
}
}
if (val) {
// 新按钮按下效果
const domId = OperationHandler.getDomIdByOperation(val);
const dom = document.getElementById(domId);
if (dom) {
dom.disabled = true;
dom.style.backgroundColor = this.buttonDownColor;
}
}
},
buttonDown(operation, commandType) {
if (operation != this.Command.cancel.clearMbm.operation) {
const operate = {
type: 'mbm',
operation: operation
};
this.$store.dispatch('training/next', operate).then(({ valid }) => {
if (valid) {
this.operation = operation;
this.commandType = commandType;
if (this.commandType == 'MixinCommand') {
this.cmdTypeList = ['Switch', 'Signal'];
} else {
this.cmdTypeList = [commandType];
}
this.$store.dispatch('menuOperation/setButtonOperation', operation); // 按钮菜单是否被按下
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
if (operation == this.Signal.humanTrainRoute.button.operation) { // 总人解操作 显示密码窗
operate['operateNext'] = this.Command.close.password.operation;
this.$refs.password.doShow(operate);
} else if (operation == this.Section.fault.button.operation) { // 区故解操作 显示密码窗
operate['operateNext'] = this.Command.close.password.operation;
this.$refs.password.doShow(operate);
} else if (operation == this.Switch.unlock.button.operation) { // 道岔解锁操作 显示密码窗
operate['operateNext'] = this.Command.close.password.operation;
this.$refs.password.doShow(operate);
} else if (operation == this.MixinCommand.unblock.button.operation) { // 解封操作 显示密码窗
operate['operateNext'] = this.Command.close.password.operation;
this.$refs.password.doShow(operate);
}
this.$store.dispatch('training/emitTipFresh');
}
});
} else {
const operate = {
start: true,
type: 'mbm',
operation: operation
};
this.$store.dispatch('training/next', operate).then(({ valid }) => {
if (valid) {
this.commandType = '';
this.$store.dispatch('menuOperation/setButtonOperation', null);
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
Handler.clear(); // 清空操作组
}
});
}
},
selectedChange() {
// 按钮按下时
if (this.$store.state.menuOperation.buttonOperation) {
const model = this.$store.state.menuOperation.selected; // 选择设备
if (model._type) {
const operate = this.handelOperate(model);
if (this.cmdTypeList.indexOf(model._type) >= 0) {
this.$store.dispatch('training/next', operate).then(({ valid, response }) => {
if (valid) {
if (this.operation == this.Signal.guide.button.operation) { // 引导进路操作 显示密码窗
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
operate['operateNext'] = this.Command.close.password.operation;
this.operation = '0';
this.$refs.password.doShow(operate);
}
}
});
} else {
Handler.clear(); // 清空操作组
this.$store.dispatch('menuOperation/setButtonOperation', null);
}
} else {
Handler.clear(); // 清空操作组
this.$store.dispatch('menuOperation/setButtonOperation', null);
}
}
},
handelOperate(model) { // 设置operate
const operate = {
send: true,
operation: this.$store.state.menuOperation.buttonOperation,
cmdType: this.cmdType,
param: {}
};
switch (this.commandType) {
case 'Switch':
operate.param['Switch_Code'] = model.code;
break;
case 'Signal':
operate.param['Signal_Code'] = model.code;
break;
case 'Section':
operate.param['Section_Code'] = model.code;
break;
case 'MixinCommand':
if (model._type == 'Switch') {
if (this.operation == this.MixinCommand.block.button.operation) {
operate.cmdType = CMD.Switch.CMD_SWITCH_BLOCK;
} else if (this.operation == this.MixinCommand.unblock.button.operation) {
operate.cmdType = CMD.Switch.CMD_SWITCH_UNBLOCK;
}
operate.param['Switch_Code'] = model.code;
} else if (model._type == 'Signal') {
if (this.operation == this.MixinCommand.block.button.operation) {
operate.cmdType = CMD.Signal.CMD_SIGNAL_BLOCK;
} else if (this.operation == this.MixinCommand.unblock.button.operation) {
operate.cmdType = CMD.Signal.CMD_SIGNAL_UNBLOCK;
}
operate.param['Signal_Code'] = model.code;
}
break;
}
return operate;
}
}
2019-11-29 12:51:58 +08:00
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
$bg: #fff;
$hoverBg: #f5f7fa;
.button_box{
display: block;
float: left;
}
.menu {
background-color: $bg;
position: fixed;
border: 1px solid gray;
z-index: 10;
display: block;
.dsp-block {
display: block;
text-align: center;
border-radius: unset;
width: 100%;
}
.dsp-block:hover {
background-color: $hoverBg;
}
}
</style>