From 8dc3249347066bba648cfdde3a41fa18e70901c9 Mon Sep 17 00:00:00 2001 From: q4speed Date: Tue, 21 Apr 2020 15:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/test/ApiTestConfig.vue | 25 ++++++--- .../api/test/components/ApiAssertionRegex.vue | 6 +-- .../api/test/components/ApiAssertionText.vue | 16 +++--- .../api/test/components/ApiKeyValue.vue | 51 ++++++++++--------- .../api/test/components/ApiRequestConfig.vue | 2 +- .../api/test/components/ApiRequestForm.vue | 20 ++++---- .../api/test/components/ApiScenarioConfig.vue | 7 ++- .../api/test/components/ApiScenarioForm.vue | 2 +- 8 files changed, 70 insertions(+), 59 deletions(-) diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index a85f5edc15..50d26f98b1 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -8,13 +8,13 @@ - + 保存 - + @@ -35,9 +35,10 @@ projects: [], change: false, test: { + id: null, projectId: null, name: null, - scenario_definition: [] + scenarioDefinition: [] } } }, @@ -53,11 +54,21 @@ methods: { saveTest: function () { - this.change = false; - this.$message({ - message: this.$t('commons.save_success'), - type: 'success' + + let param = { + id: this.test.id, + projectId: this.test.projectId, + name: this.test.name, + scenarioDefinition: JSON.stringify(this.test.scenarioDefinition) + } + + this.result = this.$post("/api/save", param, response => { + this.test.id = response.data; + this.$message({ + message: this.$t('commons.save_success'), + type: 'success' + }); }); } }, diff --git a/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue b/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue index 3c53617938..bc61db655b 100644 --- a/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue +++ b/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue @@ -4,9 +4,9 @@ - - - + + + diff --git a/frontend/src/business/components/api/test/components/ApiAssertionText.vue b/frontend/src/business/components/api/test/components/ApiAssertionText.vue index 9916f71637..20bc6840c6 100644 --- a/frontend/src/business/components/api/test/components/ApiAssertionText.vue +++ b/frontend/src/business/components/api/test/components/ApiAssertionText.vue @@ -4,19 +4,19 @@ - - - + + + - - - - - + + + + + diff --git a/frontend/src/business/components/api/test/components/ApiKeyValue.vue b/frontend/src/business/components/api/test/components/ApiKeyValue.vue index ed90e30d78..12aff27318 100644 --- a/frontend/src/business/components/api/test/components/ApiKeyValue.vue +++ b/frontend/src/business/components/api/test/components/ApiKeyValue.vue @@ -12,8 +12,21 @@ - + + + + + +
+ + + + + + + + +
@@ -31,45 +44,33 @@ items: Array }, + data() { + return { + kv: new KeyValue() + } + }, + methods: { add: function () { - this.items.push(new KeyValue()); + if (this.kv.key || this.kv.value) { + this.items.push(this.kv); + this.kv = new KeyValue(); + } }, remove: function (index) { this.items.splice(index, 1); - if (this.items.length === 0) { - this.add(); - } }, check: function () { - let isNeedCreate = true; let removeIndex = -1; this.items.forEach((item, index) => { if (!item.key && !item.value) { - // 多余的空行 - if (index !== this.items.length - 1) { - removeIndex = index; - } - // 没有空行,需要创建空行 - isNeedCreate = false; + removeIndex = index; } }); - if (isNeedCreate) { - this.add(); - } if (removeIndex !== -1) { this.remove(removeIndex); } // TODO 检查key重复 - }, - isDisable: function (index) { - return this.items.length - 1 === index; - } - }, - - created() { - if (this.items.length === 0) { - this.add(); } } } diff --git a/frontend/src/business/components/api/test/components/ApiRequestConfig.vue b/frontend/src/business/components/api/test/components/ApiRequestConfig.vue index 9746e52699..7e6f87a15d 100644 --- a/frontend/src/business/components/api/test/components/ApiRequestConfig.vue +++ b/frontend/src/business/components/api/test/components/ApiRequestConfig.vue @@ -11,7 +11,7 @@
- + 复制请求 删除请求 diff --git a/frontend/src/business/components/api/test/components/ApiRequestForm.vue b/frontend/src/business/components/api/test/components/ApiRequestForm.vue index 0ddf3375e9..34b0791f57 100644 --- a/frontend/src/business/components/api/test/components/ApiRequestForm.vue +++ b/frontend/src/business/components/api/test/components/ApiRequestForm.vue @@ -1,20 +1,20 @@