From af06707a16c5f17b412807b7a76934d15455ccd7 Mon Sep 17 00:00:00 2001 From: fan Date: Tue, 13 Sep 2022 17:06:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=9C=BA=E6=99=AF=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/cmdPlugin/CommandHandler.js | 62 ++++++++++++++----- src/store/modules/training.js | 5 +- src/store/modules/trainingNew.js | 10 +++ src/utils/baseUrl.js | 4 +- .../designPlatform/trainingPositionTip.vue | 15 +++-- src/views/designPlatform/trainingPreview.vue | 8 +-- src/views/designPlatform/trainingTip.vue | 22 ++++--- src/views/trainingManage/demonMenu.vue | 1 - src/views/trainingManage/editDetails.vue | 2 +- src/views/trainingManage/editOperate.vue | 17 ++++- 10 files changed, 109 insertions(+), 37 deletions(-) diff --git a/src/scripts/cmdPlugin/CommandHandler.js b/src/scripts/cmdPlugin/CommandHandler.js index e8961c27d..9ba06b287 100644 --- a/src/scripts/cmdPlugin/CommandHandler.js +++ b/src/scripts/cmdPlugin/CommandHandler.js @@ -164,21 +164,55 @@ class CommandHandle { return new Promise((resolve, reject) => { const group = router.currentRoute.query.group; const newApi = router.currentRoute.query.newApi + ''; - if (newApi === 'true') { - const userInfo = store.state.training.simulationUserList.find(el => el.id == store.state.user.id); - sendSimulationCommand(group, userInfo.memberId, id, command).then((response) => { - resolve(response); - }).catch(error => { - reject(error); - }); - } else { - sendCommandNew(group, id, command).then((response) => { - resolve(response); - }).catch(error => { - reject(error); - }); + if (router.currentRoute.path.includes('trainingDesign')) { + store.dispatch('trainingNew/setSceneOperate', {id, command}); + } + if (store.state.trainingNew.trainingSwitch) { + const stepList = JSON.parse(store.state.trainingNew.trainingDetail.stepJson); + const step = stepList.find(item => item.id == store.state.trainingNew.stepOrder ); + const operateIndex = step.operations.findIndex(item => item.id == store.state.trainingNew.operateOrder); + const stepOperation = step.operations[operateIndex]; + let flag = true; + if (stepOperation.operationType !== id) { + flag = false; + } + for (const item in stepOperation.params) { + flag = command[item] === stepOperation.params[item] && flag; + } + if (flag) { + if (newApi === 'true') { + const userInfo = store.state.training.simulationUserList.find(el => el.id == store.state.user.id); + sendSimulationCommand(group, userInfo.memberId, id, command).then((response) => { + resolve(response); + }).catch(error => { + reject(error); + }); + } else { + sendCommandNew(group, id, command).then((response) => { + resolve(response); + }).catch(error => { + reject(error); + }); + } + } else { + store.dispatch('setOperateErrMsg'); + } + } else { + if (newApi === 'true') { + const userInfo = store.state.training.simulationUserList.find(el => el.id == store.state.user.id); + sendSimulationCommand(group, userInfo.memberId, id, command).then((response) => { + resolve(response); + }).catch(error => { + reject(error); + }); + } else { + sendCommandNew(group, id, command).then((response) => { + resolve(response); + }).catch(error => { + reject(error); + }); + } } - }); } diff --git a/src/store/modules/training.js b/src/store/modules/training.js index a88f80426..a1c7a2ec7 100644 --- a/src/store/modules/training.js +++ b/src/store/modules/training.js @@ -442,7 +442,7 @@ const training = { // 处理operation Handler.handle(operate).then(rtn => { - if (store.state.trainingNew.trainingSwitch) { + if (store.state.trainingNew.trainingSwitch && store.state.trainingNew.trainingDetail.type === 'SINGLE') { store.dispatch('trainingNew/checkTrainingOperate', operate).then(res => { commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' }); resolve(rtn); @@ -677,6 +677,9 @@ const training = { }, setUserRole: ({ commit }, userRole) => { commit('setUserRole', userRole); + }, + setOperateErrMsg: ({ commit }) => { + commit('setOperateErrMsg', { errMsg: '操作错误!', color: 'red' }); } } }; diff --git a/src/store/modules/trainingNew.js b/src/store/modules/trainingNew.js index eb137e555..c4c70b3f6 100644 --- a/src/store/modules/trainingNew.js +++ b/src/store/modules/trainingNew.js @@ -6,6 +6,7 @@ const training = { trainingSwitch: false, // 实训开始结束标志 trainingOperate: null, simulationPause: false, // 实训 暂停判断 + sceneOperate: null, stepOrder: 0, operateOrder: 0, stepOverCount: 0, @@ -32,6 +33,9 @@ const training = { }, trainingScore: (state) => { return state.trainingScore; + }, + sceneOperate: (state) => { + return state.sceneOperate; } }, mutations: { @@ -70,6 +74,9 @@ const training = { }, setTrainingScore: (state, score) => { state.trainingScore = score; + }, + setSceneOperate: (state, sceneOperate) => { + state.sceneOperate = sceneOperate; } }, actions: { @@ -109,6 +116,9 @@ const training = { setTrainingScore: ({commit}, score) => { commit('setTrainingScore', score); }, + setSceneOperate: ({commit}, sceneOperate) => { + commit('setSceneOperate', sceneOperate); + }, checkTrainingOperate:({commit, state}, trainingOperate) => { return new Promise((resolve, reject) => { const stepList = JSON.parse(state.trainingDetail.stepJson); diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 8eced22fe..a1a9e525a 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -25,13 +25,13 @@ export function handlerUrl(data) { // const data = null; // BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud'; - BASE_API = 'http://192.168.3.233/rtss-server'; + // BASE_API = 'http://192.168.3.233/rtss-server'; // BASE_API = 'http://114.116.51.125/jlcloud'; // BASE_API = 'http://192.168.8.152:9000'; // 袁琪 // BASE_API = 'http://192.168.3.94: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://192.168.3.37:9000'; // 卫志宏 // BASE_API = 'http://b29z135112.zicp.vip'; // BASE_API = 'http://2925963m2a.zicp.vip'; // 杜康 // BASE_API = 'http://2i38984j47.qicp.vip'; // 张赛 diff --git a/src/views/designPlatform/trainingPositionTip.vue b/src/views/designPlatform/trainingPositionTip.vue index 1ffd7bf4e..714cbae83 100644 --- a/src/views/designPlatform/trainingPositionTip.vue +++ b/src/views/designPlatform/trainingPositionTip.vue @@ -29,15 +29,21 @@ export default { ...mapGetters([ 'canvasWidth', 'canvasHeight' - ]) + ]), + trainingDetail() { + return this.$store.state.trainingNew.trainingDetail; + } }, watch: { '$store.state.socket.trainingStepTip': function(val) { - if (val) { + if (val && this.trainingDetail.type === 'SINGLE') { + const member = this.$store.state.training.memberData[val.memberId]; this.$nextTick(function() { this.$store.dispatch('trainingNew/clearOperateOrder'); this.$store.dispatch('trainingNew/stepOrderIncrease'); - this.tipInit(); + if (member.userId == this.$store.state.user.id) { + this.tipInit(); + } }); } }, @@ -65,7 +71,7 @@ export default { if (steps && steps.length) { const step = steps[stepOrder - 1]; const distance = 5; - this.tip = this.$store.state.socket.trainingStepTip; + this.tip = this.$store.state.socket.trainingStepTip.content; if (step && step.tipPosition && step.tipPosition.deviceCode) { const position = this.getShapeTipPoint(step.tipPosition); if (position) { @@ -77,7 +83,6 @@ export default { } } else if (step && step.tipPosition && step.tipPosition.domId) { const position = this.getOtherTipPoint(step.tipPosition); - console.log(position, '**********', step); if (position) { this.position = position; this.position.y -= distance; diff --git a/src/views/designPlatform/trainingPreview.vue b/src/views/designPlatform/trainingPreview.vue index b6a6a29fb..0d251ef63 100644 --- a/src/views/designPlatform/trainingPreview.vue +++ b/src/views/designPlatform/trainingPreview.vue @@ -4,7 +4,7 @@ - +
开始 @@ -21,15 +21,15 @@ import MenuDemon from './demonMenu.vue'; import TrainingTip from './trainingTip'; import TrainingPositionTip from './trainingPositionTip'; import TrainingJlmap from './trainingJlmap'; -import TrainingMenu from './trainingMenu'; +// import TrainingMenu from './trainingMenu'; export default { name: 'TrainingDesign', components: { MenuDemon, TrainingTip, TrainingJlmap, - TrainingPositionTip, - TrainingMenu + TrainingPositionTip + // TrainingMenu }, props: { widthLeft: { diff --git a/src/views/designPlatform/trainingTip.vue b/src/views/designPlatform/trainingTip.vue index 16ea0d37b..36ee68dc7 100644 --- a/src/views/designPlatform/trainingTip.vue +++ b/src/views/designPlatform/trainingTip.vue @@ -15,16 +15,24 @@ export default { computed: { teachMode() { return this.$store.state.trainingNew.teachMode; + }, + trainingDetail() { + return this.$store.state.trainingNew.trainingDetail; } }, watch: { - // '$store.state.socket.trainingStepTip': function(val) { - // if (val && this.teachMode === ScriptMode.TEACH) { - // this.trainingTipMessage = val; - // } else { - // this.trainingTipMessage = ''; - // } - // }, + '$store.state.socket.trainingStepTip': function(val) { + if (val && this.trainingDetail.type === 'SCENE') { + const member = this.$store.state.training.memberData[val.memberId]; + this.$nextTick(function() { + this.$store.dispatch('trainingNew/clearOperateOrder'); + this.$store.dispatch('trainingNew/stepOrderIncrease'); + if (member.userId == this.$store.state.user.id) { + this.trainingTipMessage = val.content; + } + }); + } + }, '$store.state.trainingNew.trainingSwitch': function(val) { if (!val) { this.trainingTipMessage = ''; diff --git a/src/views/trainingManage/demonMenu.vue b/src/views/trainingManage/demonMenu.vue index 3f8aa49db..058c433fb 100644 --- a/src/views/trainingManage/demonMenu.vue +++ b/src/views/trainingManage/demonMenu.vue @@ -119,7 +119,6 @@ export default { }); }, openEditOperate(data) { - console.log(data, '***'); this.$refs.editOperate.doShow(data); }, backStepList(data) { diff --git a/src/views/trainingManage/editDetails.vue b/src/views/trainingManage/editDetails.vue index 8cce125cd..7bbfc0559 100644 --- a/src/views/trainingManage/editDetails.vue +++ b/src/views/trainingManage/editDetails.vue @@ -273,7 +273,7 @@ export default { assignUsersPlayRoles([{ userId: this.$store.state.user.id, memberId: member.id}], this.$route.query.group).then(resp => { }).catch(() => { this.$message.error('调整角色失败!'); }); } - this.$emit('openEditOperate', { index: index, data: row }); + this.$emit('openEditOperate', { index: index, data: row, type: this.editData.type }); this.doClose(); }, minisize() { diff --git a/src/views/trainingManage/editOperate.vue b/src/views/trainingManage/editOperate.vue index 154103f55..d67d09da8 100644 --- a/src/views/trainingManage/editOperate.vue +++ b/src/views/trainingManage/editOperate.vue @@ -42,6 +42,7 @@ export default { dialogWidth: 500, dataIndex: 0, tagIndex: 0, + trainingType: '', stepDetail: { id: '', description: '', @@ -51,7 +52,7 @@ export default { }, watch: { '$store.state.trainingNew.trainingOperate': function (val) { - if (val && this.dialogVisible) { + if (val && this.dialogVisible && this.trainingType === 'SINGLE') { const data = { deviceCode: val.code || '', userOperationType: val.userOperationType || '', @@ -62,6 +63,16 @@ export default { }; this.stepDetail.operations.push(data); } + }, + '$store.state.trainingNew.sceneOperate': function (val) { + if (val && this.dialogVisible && this.trainingType === 'SCENE') { + const data = { + operationType: val.id, + params: val.command, + t: 'S' + }; + this.stepDetail.operations.push(data); + } } }, methods: { @@ -71,6 +82,7 @@ export default { this.stepDetail.description = data.data.description; this.stepDetail.operations = data.data.operations || []; this.dataIndex = data.index; + this.trainingType = data.type; this.dialogVisible = true; } }, @@ -88,7 +100,7 @@ export default { }, backStepList() { const tipPosition = {}; - if (this.stepDetail.operations[this.tagIndex]) { + if (this.stepDetail.operations[this.tagIndex] && this.trainingType === 'SINGLE') { tipPosition.domId = this.stepDetail.operations[this.tagIndex].domId; tipPosition.deviceCode = this.stepDetail.operations[this.tagIndex].deviceCode; tipPosition.operateIndex = this.tagIndex; @@ -100,6 +112,7 @@ export default { description: '', operations: [] }; + this.trainingType = ''; this.dataIndex = 0; this.tagIndex = 0; },