From 1bd6b7718286b8263ccae485fe488b344f114fd8 Mon Sep 17 00:00:00 2001 From: haifeng414 Date: Wed, 19 Feb 2020 10:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ajax=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/testPlan/AllTestPlan.vue | 28 +++++--------- .../components/testPlan/CreateTestPlan.vue | 38 +++++++++---------- .../testPlan/components/BasicConfig.vue | 36 ++++++++---------- 3 files changed, 43 insertions(+), 59 deletions(-) diff --git a/frontend/src/performance/components/testPlan/AllTestPlan.vue b/frontend/src/performance/components/testPlan/AllTestPlan.vue index 65d0e6080..b7df0d532 100644 --- a/frontend/src/performance/components/testPlan/AllTestPlan.vue +++ b/frontend/src/performance/components/testPlan/AllTestPlan.vue @@ -101,14 +101,10 @@ name: this.condition }; - this.$post(this.buildPagePath(this.queryPath), param).then(response => { - if (response.data.success) { - let data = response.data.data; - this.total = data.itemCount; - this.tableData = data.listObject; - } else { - this.$message.error(response.message); - } + this.$post(this.buildPagePath(this.queryPath), param, response => { + let data = response.data; + this.total = data.itemCount; + this.tableData = data.listObject; }) }, search() { @@ -151,16 +147,12 @@ id: testPlan.id }; - this.$post(this.deletePath, data).then(response => { - if (response.data.success) { - this.$message({ - message: '删除成功!', - type: 'success' - }); - this.initTableData(); - } else { - this.$message.error(response.message); - } + this.$post(this.deletePath, data, () => { + this.$message({ + message: '删除成功!', + type: 'success' + }); + this.initTableData(); }); }, } diff --git a/frontend/src/performance/components/testPlan/CreateTestPlan.vue b/frontend/src/performance/components/testPlan/CreateTestPlan.vue index d9fb489ec..1a2245334 100644 --- a/frontend/src/performance/components/testPlan/CreateTestPlan.vue +++ b/frontend/src/performance/components/testPlan/CreateTestPlan.vue @@ -77,8 +77,8 @@ }, methods: { listProjects() { - this.$get(this.listProjectPath).then(response => { - this.projects = response.data.data; + this.$get(this.listProjectPath, response => { + this.projects = response.data; }) }, save() { @@ -88,13 +88,11 @@ let options = this.getSaveOption(); - this.$request(options).then(response => { - if (response) { - this.$message({ - message: '保存成功!', - type: 'success' - }); - } + this.$request(options, () => { + this.$message({ + message: '保存成功!', + type: 'success' + }); }); }, saveAndRun() { @@ -104,20 +102,18 @@ let options = this.getSaveOption(); - this.$request(options).then(response => { - if (response) { + this.$request(options, () => { + this.$message({ + message: '保存成功!', + type: 'success' + }); + + this.$post(this.runPath, {id: this.testPlan.id}).then(() => { this.$message({ - message: '保存成功!', + message: '正在运行!', type: 'success' }); - - this.$post(this.runPath, {id: this.testPlan.id}).then(() => { - this.$message({ - message: '正在运行!', - type: 'success' - }); - }) - } + }) }); }, getSaveOption() { @@ -135,7 +131,7 @@ type: "application/json" })); - return { + return { method: 'POST', url: url, data: formData, diff --git a/frontend/src/performance/components/testPlan/components/BasicConfig.vue b/frontend/src/performance/components/testPlan/components/BasicConfig.vue index d6fc848c1..9312e8809 100644 --- a/frontend/src/performance/components/testPlan/components/BasicConfig.vue +++ b/frontend/src/performance/components/testPlan/components/BasicConfig.vue @@ -72,8 +72,8 @@ }, methods: { getFileMetadata(testPlan) { - this.$get(this.getFileMetadataPath + "/" + testPlan.id).then(response => { - let file = response.data.data; + this.$get(this.getFileMetadataPath + "/" + testPlan.id, response => { + let file = response.data; this.testPlan.file = file; @@ -115,25 +115,21 @@ name: file.name }; - this.$post(this.jmxDownloadPath, data).then(response => { - if (response) { - const content = response.data; - const blob = new Blob([content]); - if ("download" in document.createElement("a")) { - // 非IE下载 - // chrome/firefox - let aTag = document.createElement('a'); - aTag.download = file.name; - aTag.href = URL.createObjectURL(blob) - aTag.click(); - URL.revokeObjectURL(aTag.href) - } else { - // IE10+下载 - navigator.msSaveBlob(blob, this.filename) - } + this.$post(this.jmxDownloadPath, data, response => { + const content = response.data; + const blob = new Blob([content]); + if ("download" in document.createElement("a")) { + // 非IE下载 + // chrome/firefox + let aTag = document.createElement('a'); + aTag.download = file.name; + aTag.href = URL.createObjectURL(blob) + aTag.click(); + URL.revokeObjectURL(aTag.href) + } else { + // IE10+下载 + navigator.msSaveBlob(blob, this.filename) } - }).catch((response) => { - this.$message.error(response.message); }); }, handleDelete(file, index) { -- GitLab