From 735f5d0f8336e02faa6fced45eb43d8f1d4b51b4 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 29 Jul 2022 19:02:32 +0800 Subject: [PATCH] =?UTF-8?q?style(=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=E6=B5=8B=E8=AF=95=E9=A6=96?= =?UTF-8?q?=E9=A1=B5swagger=E8=B7=B3=E8=BD=AC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015399 --user=宋天阳 【接口测试】首页-运行中的定时任务,swagger定时任务跳转后没有显示定时任务tab https://www.tapd.cn/55049933/s/1215835 --- .../api/automation/ApiAutomation.vue | 48 +- .../api/definition/ApiDefinition.vue | 101 +++-- .../components/module/ApiModule.vue | 422 ++++++++++-------- 3 files changed, 309 insertions(+), 262 deletions(-) diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index e48d936f7b..54095f6859 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -220,30 +220,32 @@ export default { if (!params) { return; } - let paramArr = params.split("edit:"); - if (paramArr.length !== 2) { - return; - } - let scenarioId = paramArr[1]; - //查找单条数据,跳转修改页面 - this.$post("/api/automation/list/1/1", {id: scenarioId}, response => { - let data = response.data; - if (data && data.listObject && data.listObject.length > 0) { - let row = data.listObject[0]; - let checks = ["array", "object"]; - if (row && row.tags && (checks.indexOf(Object.prototype.toString.call(row.tags) - .match(/\[object (\w+)\]/)[1].toLowerCase()) !== -1)) { - row.tags = JSON.parse(row.tags); - } - //如果树未加载 - if (this.moduleOptions && this.moduleOptions.length === 0) { - let projectId = data.projectId ? data.projectId : this.projectId; - this.initModules(row, projectId); - } else { - this.editScenario(row); - } + if (params instanceof String) { + let paramArr = params.split("edit:"); + if (paramArr.length !== 2) { + return; } - }); + let scenarioId = paramArr[1]; + //查找单条数据,跳转修改页面 + this.$post("/api/automation/list/1/1", {id: scenarioId}, response => { + let data = response.data; + if (data && data.listObject && data.listObject.length > 0) { + let row = data.listObject[0]; + let checks = ["array", "object"]; + if (row && row.tags && (checks.indexOf(Object.prototype.toString.call(row.tags) + .match(/\[object (\w+)\]/)[1].toLowerCase()) !== -1)) { + row.tags = JSON.parse(row.tags); + } + //如果树未加载 + if (this.moduleOptions && this.moduleOptions.length === 0) { + let projectId = data.projectId ? data.projectId : this.projectId; + this.initModules(row, projectId); + } else { + this.editScenario(row); + } + } + }); + } }, initModules(row, projectId) { this.$get("/api/automation/module/list/" + projectId, response => { diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index d5eba137b7..d8336e7a2f 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -354,51 +354,52 @@ export default { }; }, activated() { - this.selectNodeIds = []; - let routeParamObj = this.$route.params.paramObj; - if (routeParamObj) { - let dataRange = routeParamObj.dataSelectRange; - if (dataRange && dataRange.length > 0) { - this.activeDom = 'middle'; - } - let dataType = routeParamObj.dataType; - if (dataType) { - if (dataType === "api") { - this.activeDom = 'left'; - } else { + this.$nextTick(() => { + let routeParamObj = this.$route.params.paramObj; + if (routeParamObj) { + let dataRange = routeParamObj.dataSelectRange; + if (dataRange && dataRange.length > 0) { this.activeDom = 'middle'; } - } - if (routeParamObj.dataSelectRange) { - let item = JSON.parse(JSON.stringify(routeParamObj.dataSelectRange)).param; - if (item !== undefined) { - let type = item.taskGroup.toString(); - if (type === "SWAGGER_IMPORT") { - this.handleTabsEdit(this.$t('api_test.api_import.timing_synchronization'), 'SCHEDULE'); - this.param = item; + let dataType = routeParamObj.dataType; + if (dataType) { + if (dataType === "api") { + this.activeDom = 'left'; + } else { + this.activeDom = 'middle'; + } + } + if (routeParamObj.dataSelectRange) { + let item = JSON.parse(JSON.stringify(routeParamObj.dataSelectRange)).param; + if (item !== undefined) { + let type = item.taskGroup.toString(); + if (type === "SWAGGER_IMPORT") { + this.openSwaggerScheduleTab(); + this.param = item; + } + } + } + } else { + let dataType = this.$route.params.dataType; + if (dataType) { + if (dataType === "api") { + this.activeDom = 'left'; + } else { + this.activeDom = 'middle'; + } + } + if (this.$route.params.dataSelectRange) { + let item = JSON.parse(JSON.stringify(this.$route.params.dataSelectRange)).param; + if (item !== undefined) { + let type = item.taskGroup.toString(); + if (type === "SWAGGER_IMPORT") { + this.openSwaggerScheduleTab(); + this.param = item; + } } } } - } else { - let dataType = this.$route.params.dataType; - if (dataType) { - if (dataType === "api") { - this.activeDom = 'left'; - } else { - this.activeDom = 'middle'; - } - } - if (this.$route.params.dataSelectRange) { - let item = JSON.parse(JSON.stringify(this.$route.params.dataSelectRange)).param; - if (item !== undefined) { - let type = item.taskGroup.toString(); - if (type === "SWAGGER_IMPORT") { - this.handleTabsEdit(this.$t('api_test.api_import.timing_synchronization'), 'SCHEDULE'); - this.param = item; - } - } - } - } + }); }, watch: { currentProtocol() { @@ -463,6 +464,22 @@ export default { } }, methods: { + openSwaggerScheduleTab() { + //检查是否有开启的定时任务配置页,如果有的话直接跳转,不用再开启 + let scheduleTabName = ""; + if (this.apiTabs) { + this.apiTabs.forEach(tab => { + if (tab.type === 'SCHEDULE') { + scheduleTabName = tab.name; + } + }); + } + if (scheduleTabName === "") { + this.handleTabsEdit(this.$t('api_test.api_import.timing_synchronization'), 'SCHEDULE'); + } else { + this.apiDefaultTab = scheduleTabName; + } + }, setEnvironment(data) { if (data) { this.useEnvironment = data.id; @@ -733,7 +750,7 @@ export default { if (routeParamObj) { let dataRange = routeParamObj.dataSelectRange; let dataType = routeParamObj.dataType; - if (dataRange) { + if (dataRange && dataRange instanceof String) { let selectParamArr = dataRange.split("edit:"); if (selectParamArr.length === 2) { let scenarioId = selectParamArr[1]; @@ -747,7 +764,7 @@ export default { } else { let dataRange = this.$route.params.dataSelectRange; let dataType = this.$route.params.dataType; - if (dataRange) { + if (dataRange && dataRange instanceof String) { let selectParamArr = dataRange.split("edit:"); if (selectParamArr.length === 2) { let scenarioId = selectParamArr[1]; diff --git a/frontend/src/business/components/api/definition/components/module/ApiModule.vue b/frontend/src/business/components/api/definition/components/module/ApiModule.vue index 4173b1ae43..b65d78261f 100644 --- a/frontend/src/business/components/api/definition/components/module/ApiModule.vue +++ b/frontend/src/business/components/api/definition/components/module/ApiModule.vue @@ -4,23 +4,23 @@