From e7e0df284041a71629554a77654b1f931142bc57 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Nov 2021 11:21:52 +0800 Subject: [PATCH] =?UTF-8?q?fix=20(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=89=A7=E8=A1=8C=E7=BB=93=E6=9E=9C=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/automation/api-automation.js | 4 ++-- .../api/automation/scenario/EditApiScenario.vue | 5 ++++- .../scenario/component/ApiResponseComponent.vue | 13 ++++++++----- .../components/list/ApiCaseSimpleList.vue | 14 +++++++++----- .../src/business/components/task/TaskCenter.vue | 10 +++++++--- frontend/src/common/js/ajax.js | 6 ++++-- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/frontend/src/business/components/api/automation/api-automation.js b/frontend/src/business/components/api/automation/api-automation.js index 36a33ee048..b729b5e0ba 100644 --- a/frontend/src/business/components/api/automation/api-automation.js +++ b/frontend/src/business/components/api/automation/api-automation.js @@ -99,8 +99,8 @@ export function saveScenario(url, scenario, scenarioDefinition, _this, success) success(response); } }, error => { - _this.$emit('errorRefresh', {}); - }); + _this.$emit('errorRefresh', error); + },true); } export function editApiScenarioCaseOrder(request, callback) { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 7bc0484a17..3f83d27b68 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -1501,7 +1501,10 @@ export default { this.initMessageSocket(); } }, - errorRefresh() { + errorRefresh(error) { + if (error && (error + "").indexOf("code 400") !== -1) { + this.$warning("步骤内容解析失败,检查是否有已经移除的插件步骤。") + } this.debug = false; this.isTop = false; this.debugLoading = false; diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue index 42493fd495..9369b646b5 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue @@ -36,7 +36,6 @@ export default { this.getExecResult(); } else { this.response = this.result; - // this.isActive = true; } if(this.apiActive){ this.isActive = false @@ -62,10 +61,14 @@ export default { let url = "/api/definition/report/getReport/" + this.apiItem.id; this.$get(url, response => { if (response.data) { - let data = JSON.parse(response.data.content); - this.response = data; - this.$set(this.apiItem, 'responseData', data); - this.isActive = true; + try { + let data = JSON.parse(response.data.content); + this.response = data; + this.$set(this.apiItem, 'responseData', data); + this.isActive = true; + }catch (error){ + this.isActive = true; + } } }); } diff --git a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue index 0a27aa4e33..6d05542d39 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue @@ -502,9 +502,13 @@ export default { let url = "/api/definition/report/get/" + apiCase.lastResultId; this.$get(url, response => { if (response.data) { - let data = JSON.parse(response.data.content); - this.response = data; - this.resVisible = true; + try { + let data = JSON.parse(response.data.content); + this.response = data; + this.resVisible = true; + } catch (error) { + this.resVisible = true; + } } }); } @@ -653,9 +657,9 @@ export default { } else if (this.selectDataRange != null) { let selectParamArr = this.selectDataRange.split(":"); if (selectParamArr.length === 2) { - if(selectParamArr[0] === "single") { + if (selectParamArr[0] === "single") { this.condition.id = selectParamArr[1]; - }else { + } else { this.condition.apiDefinitionId = selectParamArr[1]; } } diff --git a/frontend/src/business/components/task/TaskCenter.vue b/frontend/src/business/components/task/TaskCenter.vue index 5692e6dbf0..1db7e06d85 100644 --- a/frontend/src/business/components/task/TaskCenter.vue +++ b/frontend/src/business/components/task/TaskCenter.vue @@ -360,9 +360,13 @@ export default { let url = "/api/definition/report/get/" + reportId; this.$get(url, response => { if (response.data) { - let data = JSON.parse(response.data.content); - this.response = data; - this.visible = true; + try { + let data = JSON.parse(response.data.content); + this.response = data; + this.visible = true; + } catch (error) { + this.visible = true; + } } }); } diff --git a/frontend/src/common/js/ajax.js b/frontend/src/common/js/ajax.js index 837b015905..05a39f8abe 100644 --- a/frontend/src/common/js/ajax.js +++ b/frontend/src/common/js/ajax.js @@ -107,7 +107,7 @@ export function post(url, data, success, failure) { } } -export function request(axiosRequestConfig, success, failure) { +export function request(axiosRequestConfig, success, failure, hideError) { let result = {loading: true}; if (!success) { return axios.request(axiosRequestConfig); @@ -115,7 +115,9 @@ export function request(axiosRequestConfig, success, failure) { axios.request(axiosRequestConfig).then(response => { then(success, response, result); }).catch(error => { - exception(error, result); + if (!hideError) { + exception(error, result); + } if (failure) { then(failure, error, result); }