实训调整
This commit is contained in:
parent
305b9e7eb5
commit
edc15a02ba
@ -404,7 +404,7 @@ export default {
|
||||
if (!this.routeDataMap) { this.handleRouteDataMap(); }
|
||||
|
||||
if (!this.checkHaveRoute(deviceList)) { // 无效的进路按钮选择 清除deviceList
|
||||
this.$message.error('无效的进路按钮');
|
||||
// this.$message.error('无效的进路按钮');
|
||||
this.clearOperate();
|
||||
return;
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ export default {
|
||||
if (!this.routeDataMap) { this.handleRouteDataMap(); }
|
||||
|
||||
if (!this.checkHaveRoute(deviceList)) { // 无效的进路按钮选择 清除deviceList
|
||||
this.$message.error('无效的进路按钮');
|
||||
// this.$message.error('无效的进路按钮');
|
||||
this.clearOperate();
|
||||
return;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ export default {
|
||||
const operate = { operation: this.Signal.arrangementRoute.button.operation };
|
||||
if (!this.routeDataMap) { this.handleRouteDataMap(); }
|
||||
if (!this.checkHaveRoute(deviceList)) { // 无效的进路按钮选择 清除deviceList
|
||||
this.$message.error('无效的进路按钮');
|
||||
// this.$message.error('无效的进路按钮');
|
||||
this.clearOperate();
|
||||
return;
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ export default {
|
||||
|
||||
if (!this.checkHaveRoute(deviceList)) {
|
||||
// 无效的进路按钮选择 清除deviceList
|
||||
this.$message.error('无效的进路按钮')
|
||||
// this.$message.error('无效的进路按钮')
|
||||
this.clearOperate()
|
||||
return
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ export default {
|
||||
const operate = { operation: this.Signal.arrangementRoute.button.operation };
|
||||
if (!this.routeDataMap) { this.handleRouteDataMap(); }
|
||||
if (!this.checkHaveRoute(deviceList)) { // 无效的进路按钮选择 清除deviceList
|
||||
this.$message.error('无效的进路按钮');
|
||||
// this.$message.error('无效的进路按钮');
|
||||
this.clearOperate();
|
||||
return;
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ export default {
|
||||
|
||||
if (!this.checkHaveRoute(deviceList)) {
|
||||
// 无效的进路按钮选择 清除deviceList
|
||||
this.$message.error('无效的进路按钮');
|
||||
// this.$message.error('无效的进路按钮');
|
||||
this.clearOperate();
|
||||
return;
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ export default {
|
||||
const operate = { operation: this.Signal.arrangementRoute.button.operation };
|
||||
if (!this.routeDataMap) { this.handleRouteDataMap(); }
|
||||
if (!this.checkHaveRoute(deviceList)) { // 无效的进路按钮选择 清除deviceList
|
||||
this.$message.error('无效的进路按钮');
|
||||
// this.$message.error('无效的进路按钮');
|
||||
this.clearOperate();
|
||||
return;
|
||||
}
|
||||
|
@ -435,9 +435,21 @@ const training = {
|
||||
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' });
|
||||
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
|
||||
Handler.handle(operate).then(rtn => {
|
||||
if (store.state.trainingNew.trainingSwitch) {
|
||||
store.dispatch('trainingNew/checkTrainingOperate', operate).then(res => {
|
||||
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' });
|
||||
resolve(rtn);
|
||||
}).catch(() => {
|
||||
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red' });
|
||||
});
|
||||
} else {
|
||||
if (state.trainingStart) {
|
||||
// 教学和联系模式需要给出过程步骤提示
|
||||
if (TrainingMode.TEACH == state.mode || TrainingMode.PRACTICE == state.mode) {
|
||||
@ -455,10 +467,10 @@ const training = {
|
||||
rtn && rtn.valid && commit('next');
|
||||
}
|
||||
}
|
||||
store.dispatch('trainingNew/setTrainingOperate', operate);
|
||||
resolve(rtn);
|
||||
}
|
||||
}).catch(error => {
|
||||
// console.error(error);
|
||||
console.error(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,8 @@ const training = {
|
||||
trainingSwitch: false, // 实训开始结束标志
|
||||
trainingOperate: null,
|
||||
stepOrder: 1,
|
||||
operateOrder: 0
|
||||
operateOrder: 0,
|
||||
stepOverCount: 0
|
||||
},
|
||||
getters: {
|
||||
teachMode: (state) => {
|
||||
@ -23,6 +24,9 @@ const training = {
|
||||
},
|
||||
stepOrder: (state) => {
|
||||
return state.stepOrder;
|
||||
},
|
||||
stepOverCount: (state) => {
|
||||
return state.stepOverCount;
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
@ -49,6 +53,12 @@ const training = {
|
||||
},
|
||||
clearOperateOrder: (state) => {
|
||||
state.operateOrder = 0;
|
||||
},
|
||||
stepOverCountChange: (state) => {
|
||||
state.stepOverCount++;
|
||||
},
|
||||
clearStepOverCount: (state) => {
|
||||
state.clearStepOverCount = 0;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -78,6 +88,44 @@ const training = {
|
||||
},
|
||||
clearOperateOrder: ({commit}) => {
|
||||
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('校验失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -53,48 +53,17 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$store.state.trainingNew.trainingOperate':function(val) {
|
||||
if (this.trainingSwitch && val) {
|
||||
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 ));
|
||||
}
|
||||
'$store.state.trainingNew.stepOverCount': function(val) {
|
||||
this.nextStep();
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$store.dispatch('socket/clearTrainingOverCount');
|
||||
this.$store.dispatch('training/clearStepOverCount');
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
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() {
|
||||
if (this.$route.query.group) {
|
||||
await clearSimulation(this.$route.query.group);
|
||||
|
@ -114,7 +114,7 @@ export default {
|
||||
},
|
||||
async loadScript(index, data) {
|
||||
if (this.trainingSwitch) {
|
||||
this.$message.success('请先结束当前实训后再加载新的实训!');
|
||||
this.$message.error('请先结束当前实训后再加载新的实训!');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -64,48 +64,17 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$store.state.trainingNew.trainingOperate':function(val) {
|
||||
if (this.trainingSwitch && val) {
|
||||
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 ));
|
||||
}
|
||||
'$store.state.trainingNew.stepOverCount': function(val) {
|
||||
this.nextStep();
|
||||
}
|
||||
},
|
||||
async beforeDestroy() {
|
||||
this.$store.dispatch('socket/clearTrainingOverCount');
|
||||
this.$store.dispatch('training/clearStepOverCount');
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
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) {
|
||||
const panel = document.getElementById('leftSlider');
|
||||
if (flag) {
|
||||
@ -139,7 +108,7 @@ export default {
|
||||
this.$store.dispatch('trainingNew/trainingEnd');
|
||||
this.$store.dispatch('socket/clearTrainingStepTip');
|
||||
this.$store.dispatch('trainingNew/clearStepOrder');
|
||||
this.$store.dispatch('trainingNew/setTrainingDetail', null);
|
||||
// this.$store.dispatch('trainingNew/setTrainingDetail', null);
|
||||
}).catch(() => {
|
||||
this.$message.error('结束实训失败!');
|
||||
});
|
||||
|
@ -19,14 +19,30 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
'$store.state.socket.trainingStepTip': function(val) {
|
||||
if (this.teachMode === ScriptMode.TEACH) {
|
||||
if (val && this.teachMode === ScriptMode.TEACH) {
|
||||
this.trainingTipMessage = val;
|
||||
} else {
|
||||
this.trainingTipMessage = '';
|
||||
}
|
||||
},
|
||||
'$store.state.socket.trainingOverCount': function(val) {
|
||||
if (this.teachMode === ScriptMode.TEACH) {
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -229,18 +229,24 @@ export default {
|
||||
async previewScript(index, data) {
|
||||
console.log('预览', index, data);
|
||||
if (this.trainingSwitch) {
|
||||
this.$message.success('请先结束当前实训后再加载新的实训!');
|
||||
this.$message.error('请先结束当前实训后再加载新的实训!');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const detailResp = await getTrainingAll(data.id);
|
||||
this.training = detailResp.data;
|
||||
if (detailResp.data.mapLocationJson) {
|
||||
const mapLocation = JSON.parse(detailResp.data.mapLocationJson);
|
||||
this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y});
|
||||
}
|
||||
if (detailResp.data.playerIdJson) {
|
||||
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.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y});
|
||||
}
|
||||
}
|
||||
this.$store.dispatch('trainingNew/setTrainingDetail', detailResp.data);
|
||||
await loadDraftTraining(this.group, data.id, {mode: this.teachMode});
|
||||
this.$message.success('加载实训成功!');
|
||||
|
Loading…
Reference in New Issue
Block a user