From 3c004ab7a5b33a7c391fe05331a3e2db09e1ae87 Mon Sep 17 00:00:00 2001 From: joylink_cuiweidong <364937672@qq.com> Date: Thu, 3 Dec 2020 13:45:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BB=A3=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/cmdPlugin/Handler.js | 65 +++++++++++++++++++------------- 1 file changed, 38 insertions(+), 27 deletions(-) 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); - } + }); }); }