From 50d4d03380e95fd2d45907f27765c507a854c1c0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 11 Mar 2021 17:54:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=9B=A0=E5=8D=A1=E9=A1=BF=20?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=8F=90=E4=BA=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/EditApiScenario.vue | 77 ++++++++++--------- frontend/src/business/main.js | 15 ++++ 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index d06a8b0e95..cfebd0feb7 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -5,7 +5,7 @@
- + {{ $t('commons.save') }}
@@ -119,7 +119,7 @@ :project-list="projectList" ref="envPopover"/> - {{$t('api_test.request.debug')}} + {{$t('api_test.request.debug')}} @@ -707,29 +707,29 @@ }, runDebug() { /*触发执行操作*/ - // if (!this.currentEnvironmentId) { - // this.$error(this.$t('api_test.environment.select_environment')); - // return; - // } let sign = this.$refs.envPopover.checkEnv(); if (!sign) { return; } this.$refs['currentScenario'].validate((valid) => { if (valid) { - this.editScenario(); - this.debugData = { - id: this.currentScenario.id, - name: this.currentScenario.name, - type: "scenario", - variables: this.currentScenario.variables, - referenced: 'Created', - enableCookieShare: this.enableCookieShare, - headers: this.currentScenario.headers, - environmentMap: this.projectEnvMap, - hashTree: this.scenarioDefinition - }; - this.reportId = getUUID().substring(0, 8); + Promise.all([ + this.editScenario()]).then(val => { + if (val) { + this.debugData = { + id: this.currentScenario.id, + name: this.currentScenario.name, + type: "scenario", + variables: this.currentScenario.variables, + referenced: 'Created', + enableCookieShare: this.enableCookieShare, + headers: this.currentScenario.headers, + environmentMap: this.projectEnvMap, + hashTree: this.scenarioDefinition + }; + this.reportId = getUUID().substring(0, 8); + } + }); } }) }, @@ -884,24 +884,27 @@ return bodyUploadFiles; }, editScenario() { - document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败 - this.$refs['currentScenario'].validate((valid) => { - if (valid) { - this.setParameter(); - let bodyFiles = this.getBodyUploadFiles(this.currentScenario); - this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, response => { - this.$success(this.$t('commons.save_success')); - this.path = "/api/automation/update"; - if (response.data) { - this.currentScenario.id = response.data.id; - } - if (this.currentScenario.tags instanceof String) { - this.currentScenario.tags = JSON.parse(this.currentScenario.tags); - } - this.$emit('refresh', this.currentScenario); - }) - } - }) + return new Promise((resolve, reject) => { + document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败 + this.$refs['currentScenario'].validate((valid) => { + if (valid) { + this.setParameter(); + let bodyFiles = this.getBodyUploadFiles(this.currentScenario); + this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, response => { + this.$success(this.$t('commons.save_success')); + this.path = "/api/automation/update"; + if (response.data) { + this.currentScenario.id = response.data.id; + } + if (this.currentScenario.tags instanceof String) { + this.currentScenario.tags = JSON.parse(this.currentScenario.tags); + } + this.$emit('refresh', this.currentScenario); + resolve(); + }) + } + }) + }); }, getApiScenario() { if (this.currentScenario.tags != undefined && !(this.currentScenario.tags instanceof Array)) { diff --git a/frontend/src/business/main.js b/frontend/src/business/main.js index 1b2c601312..3afcf3d9ca 100644 --- a/frontend/src/business/main.js +++ b/frontend/src/business/main.js @@ -22,8 +22,10 @@ import {left2RightDrag, bottom2TopDrag, right2LeftDrag} from "../common/js/direc import JsonSchemaEditor from './components/common/json-schema/schema/index'; import JSONPathPicker from 'vue-jsonpath-picker'; import VueClipboard from 'vue-clipboard2' + Vue.use(JsonSchemaEditor); import VuePapaParse from 'vue-papa-parse' + Vue.use(VuePapaParse) Vue.config.productionTip = false; @@ -56,6 +58,19 @@ Vue.directive('tester', tester); Vue.directive('left-to-right-drag', left2RightDrag); Vue.directive('right-to-left-drag', right2LeftDrag); Vue.directive('bottom-to-top-drag', bottom2TopDrag); +// 防止重复点击 +Vue.directive('preventReClick', { + inserted(el, binding) { + el.addEventListener('click', () => { + if (!el.disabled) { + el.disabled = true + setTimeout(() => { + el.disabled = false + }, binding.value || 2000) + } + }) + } +}) new Vue({ el: '#app',