实训代码调整

This commit is contained in:
joylink_cuiweidong 2020-12-03 13:45:18 +08:00
parent 646d585ecf
commit 3c004ab7a5

View File

@ -33,17 +33,27 @@ class Handler {
}
afterValid(operation, valid) {
const basicInfo = store.getters['training/basicInfo'];
if (basicInfo.id && valid) {
const group = router.currentRoute.query.group;
sendTrainingNextStepNew({ trainingId: basicInfo.id, operation: operation }, group);
}
if (!valid) {
this.pop();
} else if (operation.cancel === true) {
this.clear();
}
return new Promise((resolve, reject) => {
const basicInfo = store.getters['training/basicInfo'];
if (basicInfo.id && valid) {
const group = router.currentRoute.query.group;
sendTrainingNextStepNew({ trainingId: basicInfo.id, operation: operation }, group).then(res=>{
if (!valid) {
this.pop();
} else if (operation.cancel === true) {
this.clear();
}
resolve();
}).catch(error => {
if (!valid) {
this.pop();
} else if (operation.cancel === true) {
this.clear();
}
reject(error);
});
}
});
}
getWholeParam() {
@ -94,24 +104,25 @@ class Handler {
this.storeOperation(operation);
const rtn = { valid: false, response: null };
const valid = ValidateHandler.vaildate(this.getTrainingMode(), operation);
this.afterValid(operation, valid);
rtn.valid = valid;
if (operation.cmdType && valid) {
const command = this.getCommand(operation);
if (command) {
CommandHandler.execute(command.id, command.get()).then(response => {
rtn.response = response;
resolve(rtn);
}).catch(error => {
reject(error);
});
this.afterValid(operation, valid).then(()=>{
rtn.valid = valid;
if (operation.cmdType && valid) {
const command = this.getCommand(operation);
if (command) {
CommandHandler.execute(command.id, command.get()).then(response => {
rtn.response = response;
resolve(rtn);
}).catch(error => {
reject(error);
});
} else {
rtn.response = '获取指令失败,暂无指令或参数传值不正确,请检查指令字典';
reject(rtn);
}
} else {
rtn.response = '获取指令失败,暂无指令或参数传值不正确,请检查指令字典';
reject(rtn);
resolve(rtn);
}
} else {
resolve(rtn);
}
});
});
}