From b15806dca72641139ebbb61d4cfcb58932050cb6 Mon Sep 17 00:00:00 2001 From: fan Date: Thu, 1 Dec 2022 15:38:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BF=E7=9C=9F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/simulation.js | 8 +++ .../fuzhou_01/menus/menuDeplotButton.vue | 2 +- .../theme/fuzhou_01/menus/menuSection.vue | 48 +++++++++++-- .../theme/fuzhou_01/menus/menuSignal.vue | 70 ++++++++++++++++--- src/scripts/cmdPlugin/newHandler.js | 1 + src/store/modules/training.js | 5 +- src/views/newMap/display/index.vue | 9 +-- .../display/simulationMenu/simulationMenu.vue | 10 +-- 8 files changed, 124 insertions(+), 29 deletions(-) diff --git a/src/api/simulation.js b/src/api/simulation.js index 182cd0daa..c8e80dcfc 100644 --- a/src/api/simulation.js +++ b/src/api/simulation.js @@ -559,3 +559,11 @@ export function destroySimulationByAdmin(group) { method: 'post' }); } + +/** 非仿真创建者退出仿真 */ +export function exitSimulation(group) { + return request({ + url: `/simulation/${group}/exit`, + method: 'put' + }); +} diff --git a/src/jmapNew/theme/fuzhou_01/menus/menuDeplotButton.vue b/src/jmapNew/theme/fuzhou_01/menus/menuDeplotButton.vue index 716754214..5289f7742 100644 --- a/src/jmapNew/theme/fuzhou_01/menus/menuDeplotButton.vue +++ b/src/jmapNew/theme/fuzhou_01/menus/menuDeplotButton.vue @@ -193,7 +193,7 @@ export default { return OperationEvent.Station; }, isShowBtn() { - return this.$store.state.training.prdType == '09'; + return this.$store.state.training.roles === 'DEPOT_DISPATCHER' || this.$store.state.training.roles === 'SIGNAL_BUILDING'; } }, watch: { diff --git a/src/jmapNew/theme/fuzhou_01/menus/menuSection.vue b/src/jmapNew/theme/fuzhou_01/menus/menuSection.vue index b811cdaeb..7b7cdc9f2 100644 --- a/src/jmapNew/theme/fuzhou_01/menus/menuSection.vue +++ b/src/jmapNew/theme/fuzhou_01/menus/menuSection.vue @@ -61,7 +61,13 @@ export default { label: '故障解锁', handler: this.fault, cmdType: CMD.Section.CMD_SECTION_FAULT_UNLOCK, - isDisabled: (section, work) => { if (work === 'localWork') { return this.$store.state.training.roleDeviceCode === section.stationCode; } else { return false; } }, + isDisabled: (section, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === section.stationCode; + } else { + return false; + } + }, isShow: (section, work) => ['01', '02', '03'].includes(section.type) }, { @@ -94,34 +100,66 @@ export default { label: '计轴预复位', handler: this.axlePreReset, cmdType: CMD.Section.CMD_SECTION_AXIS_PRE_RESET, + isDisabled: (section, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === section.stationCode; + } else { + return false; + } + }, isShow: (section, work) => ['01', '02', '03'].includes(section.type) }, { label: this.$t('menu.menuSection.sectionBlockade'), handler: this.lock, cmdType: CMD.Section.CMD_SECTION_BLOCK, - isDisabled: section => section.blockade === 1, + // isDisabled: section => section.blockade === 1, + isDisabled: (section, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === section.stationCode && section.blockade === 1; + } else { + return section.blockade === 1; + } + }, isShow: (section, work) => ['01', '02', '03'].includes(section.type) }, { label: this.$t('menu.menuSection.sectionUnblock'), handler: this.unlock, cmdType: CMD.Section.CMD_SECTION_UNBLOCK, - isDisabled: section => section.blockade !== 1, + isDisabled: (section, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === section.stationCode && section.blockade !== 1; + } else { + return section.blockade !== 1; + } + }, isShow: (section, work) => ['01', '02', '03'].includes(section.type) }, { label: '设置限速', handler: this.setSpeed, cmdType: CMD.Section.CMD_SECTION_SET_LIMIT_SPEED, - isDisabled: section => section.speedUpLimit !== -1, + isDisabled: (section, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === section.stationCode && section.speedUpLimit !== -1; + } else { + return section.speedUpLimit !== -1; + } + }, isShow: (section, work) => section.type === '02' }, { label: '取消限速', handler: this.cancelSpeed, cmdType: CMD.Section.CMD_SECTION_CANCEL_LIMIT_SPEED, - isDisabled: section => section.speedUpLimit === -1, + isDisabled: (section, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === section.stationCode && section.speedUpLimit === -1; + } else { + return section.speedUpLimit === -1; + } + }, isShow: (section, work) => section.type === '02' } ], diff --git a/src/jmapNew/theme/fuzhou_01/menus/menuSignal.vue b/src/jmapNew/theme/fuzhou_01/menus/menuSignal.vue index 05c33158f..da1cbcdd0 100644 --- a/src/jmapNew/theme/fuzhou_01/menus/menuSignal.vue +++ b/src/jmapNew/theme/fuzhou_01/menus/menuSignal.vue @@ -64,39 +64,80 @@ export default { { label: this.$t('menu.menuSignal.routeSelect'), handler: this.arrangementRoute, - cmdType: CMD.Signal.CMD_SIGNAL_SET_ROUTE + cmdType: CMD.Signal.CMD_SIGNAL_SET_ROUTE, + isDisabled: (signal, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === signal.stationCode; + } else { + return false; + } + } }, { label: this.$t('menu.menuSignal.routeCancel'), handler: this.cancelTrainRoute, - cmdType: CMD.Signal.CMD_SIGNAL_CANCEL_ROUTE + cmdType: CMD.Signal.CMD_SIGNAL_CANCEL_ROUTE, + isDisabled: (signal, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === signal.stationCode; + } else { + return false; + } + } }, { label: this.$t('menu.menuSignal.signalBlock'), handler: this.lock, cmdType: CMD.Signal.CMD_SIGNAL_BLOCK, - isDisabled: signal => signal.blockade === 1 + isDisabled: (signal, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === signal.stationCode && signal.blockade === 1; + } else { + return signal.blockade === 1; + } + } }, { label: this.$t('menu.menuSignal.signalDeblock'), handler: this.unlock, cmdType: CMD.Signal.CMD_SIGNAL_UNBLOCK, - isDisabled: signal => signal.blockade !== 1 + isDisabled: (signal, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === signal.stationCode && signal.blockade !== 1; + } else { + return signal.blockade !== 1; + } + } }, { label: this.$t('menu.menuSignal.signalReopen'), handler: this.reopenSignal, - cmdType: CMD.Signal.CMD_SIGNAL_REOPEN_SIGNAL + cmdType: CMD.Signal.CMD_SIGNAL_REOPEN_SIGNAL, + isDisabled: (signal, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === signal.stationCode; + } else { + return false; + } + } }, { label: this.$t('menu.menuSignal.signalOff'), handler: this.signalClose, - cmdType: CMD.Signal.CMD_SIGNAL_CLOSE_SIGNAL + cmdType: CMD.Signal.CMD_SIGNAL_CLOSE_SIGNAL, + isDisabled: (signal, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === signal.stationCode; + } else { + return false; + } + } }, { label: '进路引导', handler: this.guide, cmdType: CMD.Signal.CMD_SIGNAL_ROUTE_GUIDE, + isDisabled: (signal, work) => this.$store.state.training.roleDeviceCode === signal.stationCode, isShow: (signal, work) => work === 'localWork' }, { @@ -109,28 +150,28 @@ export default { label: this.$t('menu.menuSignal.setInterlockAutoRoute'), handler: this.setAutoInterlock, cmdType: CMD.Signal.CMD_SIGNAL_SET_CI_AUTO, - isDisabled: signal => signal.fleetMode === 1, + isDisabled: (signal, work) => this.$store.state.training.roleDeviceCode === signal.stationCode && signal.fleetMode === 1, isShow: (signal, work) => work === 'localWork' }, { label: this.$t('menu.menuSignal.cancelInterlockAutoRoute'), handler: this.cancelAutoInterlock, cmdType: CMD.Signal.CMD_SIGNAL_CANCEL_CI_AUTO, - isDisabled: signal => signal.fleetMode === 0, + isDisabled: (signal, work) => this.$store.state.training.roleDeviceCode === signal.stationCode && signal.fleetMode === 0, isShow: (signal, work) => work === 'localWork' }, { label: this.$t('menu.menuSignal.setInterlockAutoTrigger'), handler: this.setAutoTrigger, cmdType: CMD.Signal.CMD_SIGNAL_SET_CI_AUTO_TRIGGER, - isDisabled: signal => signal.ciControl === 1, + isDisabled: (signal, work) => this.$store.state.training.roleDeviceCode === signal.stationCode && signal.ciControl === 1, isShow: (signal, work) => work === 'localWork' }, { label: this.$t('menu.menuSignal.cancelInterlockAutoTrigger'), handler: this.cancelAutoTrigger, cmdType: CMD.Signal.CMD_SIGNAL_CANCEL_CI_AUTO_TRIGGER, - isDisabled: signal => signal.ciControl !== 1, + isDisabled: (signal, work) => this.$store.state.training.roleDeviceCode === signal.stationCode && signal.ciControl !== 1, isShow: (signal, work) => work === 'localWork' }, { @@ -148,6 +189,13 @@ export default { { label: '查询进路控制模式', handler: this.detail, + isDisabled: (signal, work) => { + if (work === 'localWork') { + return this.$store.state.training.roleDeviceCode === signal.stationCode; + } else { + return false; + } + }, cmdType: CMD.Signal.CMD_SIGNAL_DETAIL } ], @@ -261,7 +309,7 @@ export default { initMenu() { this.menu = []; this.menuNormal.forEach(menuItem => { - menuItem.disabled = menuItem.isDisabled ? menuItem.isDisabled(this.selected) : false; + menuItem.disabled = menuItem.isDisabled ? menuItem.isDisabled(this.selected, this.work) : false; menuItem.show = menuItem.isShow ? menuItem.isShow(this.selected, this.work) : true; this.menu.push(menuItem); }); diff --git a/src/scripts/cmdPlugin/newHandler.js b/src/scripts/cmdPlugin/newHandler.js index be8bd308c..545216ebf 100644 --- a/src/scripts/cmdPlugin/newHandler.js +++ b/src/scripts/cmdPlugin/newHandler.js @@ -62,6 +62,7 @@ class Handler { this.clear(); resolve({ valid, response }); }).catch(error => { + this.clear(); reject(error); }); } diff --git a/src/store/modules/training.js b/src/store/modules/training.js index 82aa9da4c..84abb4c9c 100644 --- a/src/store/modules/training.js +++ b/src/store/modules/training.js @@ -49,7 +49,8 @@ const training = { notifySelected: null, // 场景弹窗内容 runPathList:[], // 运行线 (宁波三号线) domConfig: {}, // 线路功能前端配置项 - simulationUserType: '' // 仿真用户角色 + simulationUserType: '', // 仿真用户角色 + simulationCreator: false }, getters: { @@ -214,9 +215,11 @@ const training = { }, setSimulationUserList: (state, simulationUserList) => { state.simulationUserType = ''; + state.simulationCreator = false; simulationUserList.forEach(item => { if (item.userId == store.state.user.id ) { state.simulationUserType = item.userType; + state.simulationCreator = item.creator; } }); state.simulationUserList = simulationUserList; diff --git a/src/views/newMap/display/index.vue b/src/views/newMap/display/index.vue index 4fbe82c5d..94396d5d1 100644 --- a/src/views/newMap/display/index.vue +++ b/src/views/newMap/display/index.vue @@ -18,7 +18,7 @@ import { getSessionStorage } from '@/utils/auth'; import { mapGetters } from 'vuex'; import TerminalsPicture from './terminals/index'; import SimulationMenu from './simulationMenu/simulationMenu'; -import { clearSimulation, getSimulationInfoNew} from '@/api/simulation'; +import { getSimulationInfoNew, destroySimulationByAdmin, exitSimulation } from '@/api/simulation'; import { loadMapDataById, loadRunPlanData } from '@/utils/loaddata'; import { getByGroupStationList } from '@/api/jmap/map'; import { EventBus } from '@/scripts/event-bus'; @@ -29,7 +29,6 @@ import TrainingMenu from './trainingList/trainingMenu'; import TrainingDesign from './trainingDesign/designPane.vue'; import VoiceChatBox from './voiceChatBox'; import DesignTrainingMenu from './trainingList/designTrainingMenu'; -import { SimulationUserType } from '@/scripts/ConstDic'; export default { name: 'DisplayDraft', components: { @@ -100,8 +99,10 @@ export default { this.$store.dispatch('trainingNew/clearStepOverCount'); this.$store.dispatch('trainingNew/trainingEnd'); this.$store.dispatch('trainingNew/changeTeachMode', ''); - if (this.$store.state.training.simulationUserType === SimulationUserType.TEACHER) { - clearSimulation(this.group); + if (this.$store.state.training.simulationCreator) { + destroySimulationByAdmin(this.group); + } else { + exitSimulation(this.group); } }, methods:{ diff --git a/src/views/newMap/display/simulationMenu/simulationMenu.vue b/src/views/newMap/display/simulationMenu/simulationMenu.vue index 56ab0dc54..73d366dff 100644 --- a/src/views/newMap/display/simulationMenu/simulationMenu.vue +++ b/src/views/newMap/display/simulationMenu/simulationMenu.vue @@ -20,7 +20,6 @@