From bb8c95a962c9056dc6b0c839f81a0973747d405a Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 27 Oct 2021 17:56:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=A4=8D=E5=88=B6=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20=20--bug=3D1007334=20--user=3D=E8=B5=B5=E5=8B=87=20?= =?UTF-8?q?=E3=80=90github#6815=20=E3=80=91=20=E5=A4=8D=E5=88=B6=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=9C=A8=E6=9C=AA=E4=BF=9D=E5=AD=98=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E7=BC=96=E8=BE=91=E5=8E=9F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E8=B7=B3=E8=BD=AC=E7=9A=84=E6=98=AF=E5=8F=A6?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=A4=8D=E5=88=B6=E6=8E=A5=E5=8F=A3=20https:?= =?UTF-8?q?//www.tapd.cn/55049933/s/1060079?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/definition/ApiDefinition.vue | 47 ++++++++++--------- .../definition/components/list/ApiList.vue | 9 ++-- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index bf2bcac6cf..6a2a870049 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -371,7 +371,7 @@ export default { }, watch: { currentProtocol() { - if(this.activeDom === 'right'){ + if (this.activeDom === 'right') { this.activeDom = 'left'; } this.handleCommand("CLOSE_ALL"); @@ -407,7 +407,7 @@ export default { // }); } }, - mounted(){ + mounted() { this.init(); }, methods: { @@ -422,8 +422,8 @@ export default { this.$post('/api/definition/env/create', {userId: getCurrentUserId(), envId: envId}, response => { }); }, - getTrashApi(){ - this.$get("/api/module/trashCount/"+this.projectId +"/"+this.currentProtocol, response => { + getTrashApi() { + this.$get("/api/module/trashCount/" + this.projectId + "/" + this.currentProtocol, response => { this.total = response.data; }); }, @@ -594,32 +594,37 @@ export default { debug(id) { this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id); }, - init(){ + init() { let routeTestCase = this.$route.params.apiDefinition; - if(routeTestCase){ + if (routeTestCase) { this.editApi(routeTestCase) } }, editApi(row) { - let name = ""; - if (row.isCopy) { - name = "copy" + "-" + row.name; - row.name = "copy" + "-" + row.name; - } else { - if (row.name) { - name = this.$t('api_test.definition.request.edit_api') + "-" + row.name; + const index = this.apiTabs.find(p => p.api && p.api.id === row.id); + if (!index) { + let name = ""; + if (row.isCopy) { + name = "copy" + "-" + row.name; + row.name = "copy" + "-" + row.name; } else { - name = this.$t('api_test.definition.request.title'); + if (row.name) { + name = this.$t('api_test.definition.request.edit_api') + "-" + row.name; + } else { + name = this.$t('api_test.definition.request.title'); + } } - } - this.activeTab = "api"; - if (row != null && row.tags != 'null' && row.tags != '' && row.tags != undefined) { - if (Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object' - && Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'array') { - row.tags = JSON.parse(row.tags); + this.activeTab = "api"; + if (row != null && row.tags != 'null' && row.tags != '' && row.tags != undefined) { + if (Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object' + && Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'array') { + row.tags = JSON.parse(row.tags); + } } + this.handleTabsEdit(name, "ADD", row); + } else { + this.apiDefaultTab = index.name; } - this.handleTabsEdit(name, "ADD", row); }, handleCase(api) { this.currentApi = api; diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index f1aeece5df..e2b3a7f5c5 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -203,7 +203,7 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable import MsBottomContainer from "../BottomContainer"; import MsBatchEdit from "../basis/BatchEdit"; import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; -import {downloadFile, getCurrentProjectID} from "@/common/js/utils"; +import {downloadFile, getCurrentProjectID, getUUID} from "@/common/js/utils"; import {API_LIST} from '@/common/js/constants'; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; @@ -605,11 +605,12 @@ export default { this.$emit('editApi', row); }, handleCopy(row) { - row.isCopy = true; - this.$emit('editApi', JSON.parse(JSON.stringify(row))); + let obj = JSON.parse(JSON.stringify(row)); + obj.isCopy = true; + obj.id =getUUID(); + this.$emit('editApi', obj); }, runApi(row) { - let request = row ? JSON.parse(row.request) : {}; if (row.tags instanceof Array) { row.tags = JSON.stringify(row.tags);