实训调整

This commit is contained in:
fan 2022-08-30 15:38:26 +08:00
parent 305b9e7eb5
commit edc15a02ba
14 changed files with 122 additions and 102 deletions

View File

@ -404,7 +404,7 @@ export default {
if (!this.routeDataMap) { this.handleRouteDataMap(); } if (!this.routeDataMap) { this.handleRouteDataMap(); }
if (!this.checkHaveRoute(deviceList)) { // deviceList if (!this.checkHaveRoute(deviceList)) { // deviceList
this.$message.error('无效的进路按钮'); // this.$message.error('');
this.clearOperate(); this.clearOperate();
return; return;
} }

View File

@ -487,7 +487,7 @@ export default {
if (!this.routeDataMap) { this.handleRouteDataMap(); } if (!this.routeDataMap) { this.handleRouteDataMap(); }
if (!this.checkHaveRoute(deviceList)) { // deviceList if (!this.checkHaveRoute(deviceList)) { // deviceList
this.$message.error('无效的进路按钮'); // this.$message.error('');
this.clearOperate(); this.clearOperate();
return; return;
} }

View File

@ -478,7 +478,7 @@ export default {
const operate = { operation: this.Signal.arrangementRoute.button.operation }; const operate = { operation: this.Signal.arrangementRoute.button.operation };
if (!this.routeDataMap) { this.handleRouteDataMap(); } if (!this.routeDataMap) { this.handleRouteDataMap(); }
if (!this.checkHaveRoute(deviceList)) { // deviceList if (!this.checkHaveRoute(deviceList)) { // deviceList
this.$message.error('无效的进路按钮'); // this.$message.error('');
this.clearOperate(); this.clearOperate();
return; return;
} }

View File

@ -605,7 +605,7 @@ export default {
if (!this.checkHaveRoute(deviceList)) { if (!this.checkHaveRoute(deviceList)) {
// deviceList // deviceList
this.$message.error('无效的进路按钮') // this.$message.error('')
this.clearOperate() this.clearOperate()
return return
} }

View File

@ -474,7 +474,7 @@ export default {
const operate = { operation: this.Signal.arrangementRoute.button.operation }; const operate = { operation: this.Signal.arrangementRoute.button.operation };
if (!this.routeDataMap) { this.handleRouteDataMap(); } if (!this.routeDataMap) { this.handleRouteDataMap(); }
if (!this.checkHaveRoute(deviceList)) { // deviceList if (!this.checkHaveRoute(deviceList)) { // deviceList
this.$message.error('无效的进路按钮'); // this.$message.error('');
this.clearOperate(); this.clearOperate();
return; return;
} }

View File

@ -510,7 +510,7 @@ export default {
if (!this.checkHaveRoute(deviceList)) { if (!this.checkHaveRoute(deviceList)) {
// deviceList // deviceList
this.$message.error('无效的进路按钮'); // this.$message.error('');
this.clearOperate(); this.clearOperate();
return; return;
} }

View File

@ -474,7 +474,7 @@ export default {
const operate = { operation: this.Signal.arrangementRoute.button.operation }; const operate = { operation: this.Signal.arrangementRoute.button.operation };
if (!this.routeDataMap) { this.handleRouteDataMap(); } if (!this.routeDataMap) { this.handleRouteDataMap(); }
if (!this.checkHaveRoute(deviceList)) { // deviceList if (!this.checkHaveRoute(deviceList)) { // deviceList
this.$message.error('无效的进路按钮'); // this.$message.error('');
this.clearOperate(); this.clearOperate();
return; return;
} }

View File

@ -435,30 +435,42 @@ const training = {
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' }); commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' });
return; return;
} }
if (store.state.trainingNew.trainingDetail && !store.state.trainingNew.trainingSwitch) {
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' });
return;
}
// 处理operation // 处理operation
Handler.handle(operate).then(rtn => { Handler.handle(operate).then(rtn => {
if (state.trainingStart) { if (store.state.trainingNew.trainingSwitch) {
// 教学和联系模式需要给出过程步骤提示 store.dispatch('trainingNew/checkTrainingOperate', operate).then(res => {
if (TrainingMode.TEACH == state.mode || TrainingMode.PRACTICE == state.mode) { commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' });
if (rtn && rtn.valid) { resolve(rtn);
commit('next'); }).catch(() => {
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' }); commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red' });
commit('tipEventIncrement'); });
} else { } else {
if (!operate.repeat) { if (state.trainingStart) {
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red' }); // 教学和联系模式需要给出过程步骤提示
if (TrainingMode.TEACH == state.mode || TrainingMode.PRACTICE == state.mode) {
if (rtn && rtn.valid) {
commit('next');
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' });
commit('tipEventIncrement');
} else {
if (!operate.repeat) {
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red' });
}
} }
} else if (TrainingMode.EXAM == state.mode || TrainingMode.TEST == state.mode) {
// 测试和考试不给提示
rtn && rtn.valid && commit('next');
} }
} else if (TrainingMode.EXAM == state.mode || TrainingMode.TEST == state.mode) {
// 测试和考试不给提示
rtn && rtn.valid && commit('next');
} }
resolve(rtn);
} }
store.dispatch('trainingNew/setTrainingOperate', operate);
resolve(rtn);
}).catch(error => { }).catch(error => {
// console.error(error); console.error(error);
reject(error); reject(error);
}); });
}); });

View File

@ -6,7 +6,8 @@ const training = {
trainingSwitch: false, // 实训开始结束标志 trainingSwitch: false, // 实训开始结束标志
trainingOperate: null, trainingOperate: null,
stepOrder: 1, stepOrder: 1,
operateOrder: 0 operateOrder: 0,
stepOverCount: 0
}, },
getters: { getters: {
teachMode: (state) => { teachMode: (state) => {
@ -23,6 +24,9 @@ const training = {
}, },
stepOrder: (state) => { stepOrder: (state) => {
return state.stepOrder; return state.stepOrder;
},
stepOverCount: (state) => {
return state.stepOverCount;
} }
}, },
mutations: { mutations: {
@ -49,6 +53,12 @@ const training = {
}, },
clearOperateOrder: (state) => { clearOperateOrder: (state) => {
state.operateOrder = 0; state.operateOrder = 0;
},
stepOverCountChange: (state) => {
state.stepOverCount++;
},
clearStepOverCount: (state) => {
state.clearStepOverCount = 0;
} }
}, },
actions: { actions: {
@ -78,6 +88,44 @@ const training = {
}, },
clearOperateOrder: ({commit}) => { clearOperateOrder: ({commit}) => {
commit('clearOperateOrder'); commit('clearOperateOrder');
},
clearStepOverCount: ({commit}) => {
commit('clearStepOverCount');
},
checkTrainingOperate:({commit, state}, trainingOperate) => {
return new Promise((resolve, reject) => {
const stepList = JSON.parse(state.trainingDetail.stepJson);
const step = stepList.find(item => item.id == state.stepOrder );
const operateIndex = step.operations.findIndex(item => item.id == state.operateOrder);
const stepOperation = step.operations[operateIndex];
let flag = true;
if (trainingOperate.cmdType || stepOperation.operationType) {
const cmd = trainingOperate.cmdType ? trainingOperate.cmdType.value : '';
flag = (cmd === stepOperation.operationType) && flag;
}
if (trainingOperate.code || stepOperation.deviceCode) {
flag = (trainingOperate.code === stepOperation.deviceCode) && flag;
}
if (trainingOperate.operation || stepOperation.domId) {
flag = (trainingOperate.operation === stepOperation.domId) && flag;
}
if (trainingOperate.userOperationType || stepOperation.userOperationType) {
flag = (trainingOperate.userOperationType === stepOperation.userOperationType) && flag;
}
for (const param in stepOperation.params) {
flag = (trainingOperate.params[param] === stepOperation.params[param]) && flag;
}
if (flag && step.operations.length === (operateIndex + 1 )) {
commit('stepOverCountChange');
resolve();
} else if (flag) {
commit('operateOrderIncrease');
resolve();
} else {
console.error('校验失败;');
reject('校验失败');
}
});
} }
} }
}; };

View File

@ -53,48 +53,17 @@ export default {
} }
}, },
watch: { watch: {
'$store.state.trainingNew.trainingOperate':function(val) { '$store.state.trainingNew.stepOverCount': function(val) {
if (this.trainingSwitch && val) { this.nextStep();
const stepList = JSON.parse(this.trainingDetail.stepJson);
const step = stepList.find(item => item.id == this.$store.state.trainingNew.stepOrder );
const operateIndex = step.operations.findIndex(item => item.id == this.$store.state.trainingNew.operateOrder);
this.checkOperation(val, step.operations[operateIndex], step.operations.length === (operateIndex + 1 ));
}
} }
}, },
beforeDestroy() { beforeDestroy() {
this.$store.dispatch('socket/clearTrainingOverCount'); this.$store.dispatch('socket/clearTrainingOverCount');
this.$store.dispatch('training/clearStepOverCount');
}, },
mounted() { mounted() {
}, },
methods: { methods: {
checkOperation(now, data, stepOver) {
let flag = true;
if (now.cmdType || data.operationType) {
const cmd = now.cmdType ? now.cmdType.value : '';
flag = (cmd === data.operationType) && flag;
}
if (now.code || data.deviceCode) {
flag = (now.code === data.deviceCode) && flag;
}
if (now.operation || data.domId) {
flag = (now.operation === data.domId) && flag;
}
if (now.userOperationType || data.userOperationType) {
flag = (now.userOperationType === data.userOperationType) && flag;
}
for (const param in data.params) {
flag = (now.params[param] === data.params[param]) && flag;
}
console.log(now, data, stepOver, flag);
if (flag && stepOver) {
this.nextStep();
} else if (flag) {
this.$store.dispatch('trainingNew/operateOrderIncrease');
} else {
console.error('校验失败;');
}
},
async back() { async back() {
if (this.$route.query.group) { if (this.$route.query.group) {
await clearSimulation(this.$route.query.group); await clearSimulation(this.$route.query.group);

View File

@ -114,7 +114,7 @@ export default {
}, },
async loadScript(index, data) { async loadScript(index, data) {
if (this.trainingSwitch) { if (this.trainingSwitch) {
this.$message.success('请先结束当前实训后再加载新的实训!'); this.$message.error('请先结束当前实训后再加载新的实训!');
return; return;
} }
try { try {

View File

@ -64,48 +64,17 @@ export default {
} }
}, },
watch: { watch: {
'$store.state.trainingNew.trainingOperate':function(val) { '$store.state.trainingNew.stepOverCount': function(val) {
if (this.trainingSwitch && val) { this.nextStep();
const stepList = JSON.parse(this.trainingDetail.stepJson);
const step = stepList.find(item => item.id == this.$store.state.trainingNew.stepOrder );
const operateIndex = step.operations.findIndex(item => item.id == this.$store.state.trainingNew.operateOrder);
this.checkOperation(val, step.operations[operateIndex], step.operations.length === (operateIndex + 1 ));
}
} }
}, },
async beforeDestroy() { async beforeDestroy() {
this.$store.dispatch('socket/clearTrainingOverCount'); this.$store.dispatch('socket/clearTrainingOverCount');
this.$store.dispatch('training/clearStepOverCount');
}, },
mounted() { mounted() {
}, },
methods: { methods: {
checkOperation(now, data, stepOver) {
let flag = true;
if (now.cmdType || data.operationType) {
const cmd = now.cmdType ? now.cmdType.value : '';
flag = (cmd === data.operationType) && flag;
}
if (now.code || data.deviceCode) {
flag = (now.code === data.deviceCode) && flag;
}
if (now.operation || data.domId) {
flag = (now.operation === data.domId) && flag;
}
if (now.userOperationType || data.userOperationType) {
flag = (now.userOperationType === data.userOperationType) && flag;
}
for (const param in data.params) {
flag = (now.params[param] === data.params[param]) && flag;
}
console.log(now, data, stepOver, flag);
if (flag && stepOver) {
this.nextStep();
} else if (flag) {
this.$store.dispatch('trainingNew/operateOrderIncrease');
} else {
console.error('校验失败;');
}
},
overallTranslation(flag) { overallTranslation(flag) {
const panel = document.getElementById('leftSlider'); const panel = document.getElementById('leftSlider');
if (flag) { if (flag) {
@ -139,7 +108,7 @@ export default {
this.$store.dispatch('trainingNew/trainingEnd'); this.$store.dispatch('trainingNew/trainingEnd');
this.$store.dispatch('socket/clearTrainingStepTip'); this.$store.dispatch('socket/clearTrainingStepTip');
this.$store.dispatch('trainingNew/clearStepOrder'); this.$store.dispatch('trainingNew/clearStepOrder');
this.$store.dispatch('trainingNew/setTrainingDetail', null); // this.$store.dispatch('trainingNew/setTrainingDetail', null);
}).catch(() => { }).catch(() => {
this.$message.error('结束实训失败!'); this.$message.error('结束实训失败!');
}); });

View File

@ -19,14 +19,30 @@ export default {
}, },
watch: { watch: {
'$store.state.socket.trainingStepTip': function(val) { '$store.state.socket.trainingStepTip': function(val) {
if (this.teachMode === ScriptMode.TEACH) { if (val && this.teachMode === ScriptMode.TEACH) {
this.trainingTipMessage = val; this.trainingTipMessage = val;
} else {
this.trainingTipMessage = '';
} }
}, },
'$store.state.socket.trainingOverCount': function(val) { '$store.state.socket.trainingOverCount': function(val) {
if (this.teachMode === ScriptMode.TEACH) { if (this.teachMode === ScriptMode.TEACH) {
this.trainingTipMessage = '实训完成,请点击结束按钮。'; this.trainingTipMessage = '实训完成,请点击结束按钮。';
} }
},
'$store.state.training.operateErrMsg': function (val) {
this.tipInfo({ color: val.color, message: val.errMsg });
}
},
methods: {
tipInfo(opt) {
if (opt && opt.hasOwnProperty('color') && opt.hasOwnProperty('message')) {
const h = this.$createElement;
this.$notify({
title: this.$t('global.tips'),
message: h('i', { style: 'color:' + opt.color }, opt.message)
});
}
} }
} }
}; };

View File

@ -229,18 +229,24 @@ export default {
async previewScript(index, data) { async previewScript(index, data) {
console.log('预览', index, data); console.log('预览', index, data);
if (this.trainingSwitch) { if (this.trainingSwitch) {
this.$message.success('请先结束当前实训后再加载新的实训!'); this.$message.error('请先结束当前实训后再加载新的实训!');
return; return;
} }
try { try {
const detailResp = await getTrainingAll(data.id); const detailResp = await getTrainingAll(data.id);
this.training = detailResp.data; this.training = detailResp.data;
const mapLocation = JSON.parse(detailResp.data.mapLocationJson); if (detailResp.data.mapLocationJson) {
const playerId = JSON.parse(detailResp.data.playerIdJson)[0]; const mapLocation = JSON.parse(detailResp.data.mapLocationJson);
const member = this.$store.state.training.memberData[playerId]; this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y});
this.$store.dispatch('training/setPrdType', this.prdTypeMap[member.type]); }
this.$store.dispatch('training/setRoles', member.type); if (detailResp.data.playerIdJson) {
this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y}); const playerId = JSON.parse(detailResp.data.playerIdJson)[0];
if (playerId) {
const member = this.$store.state.training.memberData[playerId];
this.$store.dispatch('training/setPrdType', this.prdTypeMap[member.type]);
this.$store.dispatch('training/setRoles', member.type);
}
}
this.$store.dispatch('trainingNew/setTrainingDetail', detailResp.data); this.$store.dispatch('trainingNew/setTrainingDetail', detailResp.data);
await loadDraftTraining(this.group, data.id, {mode: this.teachMode}); await loadDraftTraining(this.group, data.id, {mode: this.teachMode});
this.$message.success('加载实训成功!'); this.$message.success('加载实训成功!');