diff --git a/src/scripts/cmdPlugin/Handler.js b/src/scripts/cmdPlugin/Handler.js index 8ccb9b347..832693c12 100644 --- a/src/scripts/cmdPlugin/Handler.js +++ b/src/scripts/cmdPlugin/Handler.js @@ -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); - } + }); }); } diff --git a/src/views/designPlatform/demonList.vue b/src/views/designPlatform/demonList.vue index d6064243a..cbf1f8f18 100644 --- a/src/views/designPlatform/demonList.vue +++ b/src/views/designPlatform/demonList.vue @@ -1,19 +1,21 @@ @@ -231,45 +233,28 @@ export default { };