diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index b7dcc1670d..a90f11ae8b 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -226,7 +226,6 @@ export default { environmentMap: this.envMap, isShowNum: false, response: {}, - dataWorkspaceId: '', } }, created() { @@ -683,36 +682,20 @@ export default { }, clickResource(resource) { - if (resource.refType && resource.refType === 'API') { - if (resource.protocol === 'dubbo://') { - resource.protocol = 'DUBBO' - } - let definitionData = this.$router.resolve({ - name: 'ApiDefinition', - params: { - redirectID: getUUID(), - dataType: "api", - dataSelectRange: 'edit:' + resource.id, - projectId: resource.projectId, - type: resource.protocol, - workspaceId: this.dataWorkspaceId, - } - }); - window.open(definitionData.href, '_blank'); - } else if (resource.refType && resource.refType === 'CASE') { - this.$get("/api/testcase/findById/" + resource.id, response => { + let workspaceId; + let isTurnSpace = true + if(resource.projectId!==getCurrentProjectID()){ + isTurnSpace = false; + this.$get("/project/get/" + resource.projectId, response => { if (response.data) { - response.data.sourceId = resource.resourceId; - response.data.type = resource.type; - response.data.refType = resource.refType; - response.data.workspaceId = this.dataWorkspaceId; - this.clickCase(response.data) - } else { - this.$error("接口用例场景场景已经被删除"); + workspaceId = response.data.workspaceId; + isTurnSpace = true; + this.gotoTurn(resource,workspaceId,isTurnSpace); } }); + }else{ + this.gotoTurn(resource,workspaceId,isTurnSpace); } - }, clickCase(resource) { let uri = getUrl(resource); @@ -739,16 +722,44 @@ export default { let element = document.getElementById(id); element.parentNode.removeChild(element); }, - getWorkspaceId(projectId) { - this.$get("/project/get/" + projectId, response => { - if (response.data) { - this.dataWorkspaceId = response.data.workspaceId - } - }); - }, editScenarioAdvance(data) { this.$emit('editScenarioAdvance', data); }, + gotoTurn(resource, workspaceId, isTurnSpace) { + if (resource.refType && resource.refType === 'API') { + if (resource.protocol === 'dubbo://') { + resource.protocol = 'DUBBO' + } + let definitionData = this.$router.resolve({ + name: 'ApiDefinition', + params: { + redirectID: getUUID(), + dataType: "api", + dataSelectRange: 'edit:' + resource.id, + projectId: resource.projectId, + type: resource.protocol, + workspaceId: workspaceId, + } + }); + if(isTurnSpace){ + window.open(definitionData.href, '_blank'); + } + } else if (resource.refType && resource.refType === 'CASE') { + this.$get("/api/testcase/findById/" + resource.id, response => { + if (response.data) { + response.data.sourceId = resource.resourceId; + response.data.type = resource.type; + response.data.refType = resource.refType; + response.data.workspaceId = workspaceId; + if(isTurnSpace){ + this.clickCase(response.data) + } + } else { + this.$error("接口用例场景场景已经被删除"); + } + }); + } + } } } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue index a828e0c013..68b02e815a 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -119,7 +119,6 @@ export default { created() { if (this.scenario.num) { this.isShowNum = true; - this.getWorkspaceId(this.scenario.projectId); } else { this.isShowNum = false; } @@ -134,7 +133,6 @@ export default { isShowInput: false, isShowNum: false, stepFilter: new STEP, - dataWorkspaceId: '', } }, computed: { @@ -142,9 +140,6 @@ export default { return this.scenario.referenced !== undefined && this.scenario.referenced === 'Deleted' || this.scenario.referenced === 'REF'; }, - /*projectId() { - return getCurrentProjectID(); - },*/ }, methods: { run() { @@ -261,19 +256,32 @@ export default { }, clickResource(resource) { + let workspaceId; + let isTurnSpace = true + if(resource.projectId!==getCurrentProjectID()){ + isTurnSpace = false; + this.$get("/project/get/" + resource.projectId, response => { + if (response.data) { + workspaceId = response.data.workspaceId; + isTurnSpace = true; + this.gotoTurn(resource,workspaceId,isTurnSpace); + } + }); + }else { + this.gotoTurn(resource,workspaceId,isTurnSpace); + } + + }, + gotoTurn(resource,workspaceId,isTurnSpace){ let automationData = this.$router.resolve({ name: 'ApiAutomation', - params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: this.dataWorkspaceId} - }); - window.open(automationData.href, '_blank'); - }, - getWorkspaceId(projectId) { - this.$get("/project/get/" + projectId, response => { - if (response.data) { - this.dataWorkspaceId = response.data.workspaceId; - } + params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: workspaceId} }); + if(isTurnSpace){ + window.open(automationData.href, '_blank'); + } } + } }