From 32ea838b58005ff0e5f1d70464c33b5ce2cff91b Mon Sep 17 00:00:00 2001 From: fan Date: Thu, 3 Nov 2022 16:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/cmdPlugin/newHandler.js | 71 +++++++++++-------- src/store/modules/trainingNew.js | 36 ++++------ src/utils/baseUrl.js | 4 +- .../newMap/display/terminals/dispatchWork.vue | 29 +++++++- .../newMap/display/terminals/terminalMenu.vue | 1 - 5 files changed, 83 insertions(+), 58 deletions(-) diff --git a/src/scripts/cmdPlugin/newHandler.js b/src/scripts/cmdPlugin/newHandler.js index 6fc31b839..a28390e02 100644 --- a/src/scripts/cmdPlugin/newHandler.js +++ b/src/scripts/cmdPlugin/newHandler.js @@ -2,6 +2,7 @@ import ValidateHandler from './newValidateHandler'; import store from '@/store/index'; import { getLocalStorage } from '@/utils/auth'; import { sendCommandNew } from '@/api/jmap/training'; +import router from '@/router/index'; class Handler { constructor() { @@ -35,40 +36,50 @@ class Handler { } handle(operation) { - return new Promise((resolve, reject) => { - this.storeOperation(operation); - const rtn = { valid: false, response: null }; - rtn.valid = ValidateHandler.validate(this.getTrainingMode(), operation); - if (!rtn.valid ) { - this.pop(); - reject(); - } else { - if (operation.cancel === true) { - this.clear(); - } else { - if (operation.cmdType.value) { - rtn.cmdType = operation.cmdType.value; - rtn.params = this.getWholeParam(); - } - } - resolve(rtn); - } - }); - } - execute(cmdType, wholeParam) { // return new Promise((resolve, reject) => { - // const command = CommandHandler.getCommand(cmdType, wholeParam); - // if (command.isError) { - // reject(command); + // this.storeOperation(operation); + // const rtn = { valid: false, response: null }; + // rtn.valid = ValidateHandler.validate(this.getTrainingMode(), operation); + // if (!rtn.valid ) { + // this.pop(); + // reject(); // } else { - // CommandHandler.execute(command.id, command.get()).then(response => { - // resolve(response); - // }).catch(error => { - // reject(error); - // }); + // if (operation.cancel === true) { + // this.clear(); + // } else { + // if (operation.cmdType.value) { + // rtn.cmdType = operation.cmdType.value; + // rtn.params = this.getWholeParam(); + // } + // } + // resolve(rtn); // } // }); - // return sendCommandNew() + this.storeOperation(operation); + const result = { valid: false }; + result.valid = ValidateHandler.validate(this.getTrainingMode(), operation); + if (!result.valid) { + this.pop(); + } else { + if (operation.cancel === true) { + this.clear(); + } else if (operation.cmdType.value) { + result.cmdType = operation.cmdType.value; + result.params = this.getWholeParam(); + } + } + return result; + } + execute(cmdType, wholeParam) { + const group = router.currentRoute.query.group; + return new Promise((resolve, reject) => { + sendCommandNew(group, cmdType, wholeParam).then(response => { + resolve(response); + }).catch(error => { + reject(error); + }); + + }); } getTrainingMode () { diff --git a/src/store/modules/trainingNew.js b/src/store/modules/trainingNew.js index 6d00a779f..3301571c3 100644 --- a/src/store/modules/trainingNew.js +++ b/src/store/modules/trainingNew.js @@ -1,5 +1,4 @@ import { setLocalStorage } from '@/utils/auth'; -import { addTrainingNew } from '../../api/jmap/training'; import NewHandler from '@/scripts/cmdPlugin/newHandler'; import { ScriptMode } from '@/scripts/ConstDic'; import store from '@/store/index'; @@ -148,30 +147,19 @@ const training = { }, next: ({ commit, state }, operate) => { setLocalStorage('nextNew', JSON.stringify(operate)); - return new Promise((resolve, reject) => { - store.dispatch('training/setOperate', operate); - if (state.trainingDetail && !state.trainingSwitch) { - commit('setOperateErrMsg', { errMsg: LangStorage.getLang() === 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' }); - return; + store.dispatch('training/setOperate', operate); + if (state.trainingDetail && !state.trainingSwitch) { + commit('setOperateErrMsg', { errMsg: LangStorage.getLang() === 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' }); + } else { + const result = NewHandler.handle(operate); + if (state.trainingSwitch && state.trainingDetail.type === 'SINGLE' && (state.teachMode === ScriptMode.TEACH || state.teachMode === ScriptMode.PRACTICE)) { + const msg = result && result.valid ? {errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green'} : {errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red'}; + commit('setOperateErrMsg', msg); + } else { + commit('setTrainingOperate', operate); } - NewHandler.handle(operate).then(rtn => { - if (state.trainingSwitch && state.trainingDetail.type === 'SINGLE') { - if (state.teachMode === ScriptMode.TEACH || state.teachMode === ScriptMode.PRACTICE) { - if (rtn && rtn.valid) { - commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' }); - } else { - commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red' }); - } - } - } else { - commit('setTrainingOperate', operate); - } - resolve(rtn); - }).catch(error => { - console.error(error); - reject(error); - }); - }); + return result; + } } } }; diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 9de79fd8a..f84210e59 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -23,13 +23,13 @@ export function handlerUrl() { let OSS_URL; if (process.env.NODE_ENV === 'development') { // 开发分支 - // BASE_API = 'http://192.168.3.233/rtss-server'; + BASE_API = 'http://192.168.3.233/rtss-server'; // BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'http://114.116.51.125/jlcloud'; // BASE_API = 'http://192.168.3.90:9000'; // 周寅 // BASE_API = 'http://192.168.3.94:9000'; // 旭强 - BASE_API = 'http://192.168.3.15:9000'; // 张赛 + // BASE_API = 'http://192.168.3.15:9000'; // 张赛 // BASE_API = 'http://192.168.3.5:9000'; // 夏增彬 // BASE_API = 'http://192.168.3.37:9000'; // 卫志宏 // BASE_API = 'http://b29z135112.zicp.vip'; diff --git a/src/views/newMap/display/terminals/dispatchWork.vue b/src/views/newMap/display/terminals/dispatchWork.vue index 99def063d..0a62f2c84 100644 --- a/src/views/newMap/display/terminals/dispatchWork.vue +++ b/src/views/newMap/display/terminals/dispatchWork.vue @@ -55,12 +55,39 @@ export default { const logicData = {routeData:this.$store.state.map.routeData, autoReentryData: this.$store.state.map.autoReentryData}; const repaint = this.$store.state.map.initJlmapLoadedCount === 1; this.$jlmap.setMap(this.mapData, this.mapDevice, logicData, repaint); - this.$jlmap.amendDevice([...this.sectionList, ...this.signalList, ...this.trainWindowList]); + if (this.mapData && this.mapData.pictureList) { + const picture = this.mapData.pictureList.find(picture => picture.type === 'dispatchWork'); + if (picture) { + this.handlerPictureShow(picture); + } else { + this.$jlmap.amendDevice([...this.sectionList, ...this.signalList, ...this.trainWindowList]); + const list = []; + for (const key in this.mapDevice) { + list.push(this.mapDevice[key]); + } + this.$jlmap.updateShowStation(list); + } + } else { + this.$jlmap.amendDevice([...this.sectionList, ...this.signalList, ...this.trainWindowList]); + const list = []; + for (const key in this.mapDevice) { + list.push(this.mapDevice[key]); + } + this.$jlmap.updateShowStation(list); + } + }, + // 新的画面显示逻辑 + handlerPictureShow(picture) { const list = []; + const deviceList = []; for (const key in this.mapDevice) { list.push(this.mapDevice[key]); + deviceList.push(key); } this.$jlmap.updateShowStation(list); + this.$store.dispatch('map/setPictureDeviceMap', picture.deviceMap); + this.$jlmap.updatePicture(deviceList); + this.$jlmap.updateTransform(picture.scaling, picture.origin); } } }; diff --git a/src/views/newMap/display/terminals/terminalMenu.vue b/src/views/newMap/display/terminals/terminalMenu.vue index ac7fc2bf3..7830ec429 100644 --- a/src/views/newMap/display/terminals/terminalMenu.vue +++ b/src/views/newMap/display/terminals/terminalMenu.vue @@ -186,7 +186,6 @@ export default { } this.terminalList = []; [...this.commonTerminal, ...this.terminalMap[currentType]].forEach(item => { - console.log(this.itemMap, item); if (item.roleList.includes(this.roles) && (!item.functionItem || this.itemMap[item.functionItem])) { this.terminalList.push(item); }