实训场景调整

This commit is contained in:
fan 2022-09-13 17:06:36 +08:00
parent e42537a8e4
commit af06707a16
10 changed files with 109 additions and 37 deletions

View File

@ -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);
});
}
}
});
}

View File

@ -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' });
}
}
};

View File

@ -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);

View File

@ -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'; // 张赛

View File

@ -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;

View File

@ -4,7 +4,7 @@
<training-jlmap refs="trainingJlmap" />
<training-tip ref="trainingTip" />
<training-position-tip ref="trainingPositionTip" />
<!-- <training-menu ref="trainingMenu" :offset-bottom="offsetBottom" />-->
<!-- <training-menu ref="trainingMenu" :offset-bottom="offsetBottom" />-->
<div class="trainBack">
<el-button-group>
<el-button v-if="!trainingSwitch && trainingDetail" type="success" @click="handlerStart">开始</el-button>
@ -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: {

View File

@ -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 = '';

View File

@ -119,7 +119,6 @@ export default {
});
},
openEditOperate(data) {
console.log(data, '***');
this.$refs.editOperate.doShow(data);
},
backStepList(data) {

View File

@ -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() {

View File

@ -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;
},