diff --git a/framework/sdk-parent/frontend/src/api/project.js b/framework/sdk-parent/frontend/src/api/project.js index 49806d0062..8cd485f395 100644 --- a/framework/sdk-parent/frontend/src/api/project.js +++ b/framework/sdk-parent/frontend/src/api/project.js @@ -1,4 +1,5 @@ import {get, post} from '../plugins/request' + const BASE_URL = '/project/'; export function getOwnerProjects() { @@ -9,6 +10,10 @@ export function getProjectListAll() { return get(BASE_URL + 'list/all') } +export function getProject(projectId) { + return get(BASE_URL + 'get/' + projectId); +} + export function getUserProjectList(data) { return post(BASE_URL + 'list/related', data) } diff --git a/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue b/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue index cff2764ed1..0cd7f9e12d 100644 --- a/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue +++ b/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue @@ -238,7 +238,7 @@ import MsContainer from "metersphere-frontend/src/components/MsContainer"; import MsBottomContainer from "metersphere-frontend/src/components/MsBottomContainer"; import BatchEdit from "@/business/case/components/BatchEdit"; import {API_METHOD_COLOUR, CASE_PRIORITY, RESULT_MAP,} from "metersphere-frontend/src/model/JsonData"; -import {getCurrentProjectID, getCurrentWorkspaceId,} from "metersphere-frontend/src/utils/token"; +import {getCurrentProjectID,} from "metersphere-frontend/src/utils/token"; import {hasLicense, hasPermission,} from "metersphere-frontend/src/utils/permission"; import {getUUID, strMapToObj} from "metersphere-frontend/src/utils"; import PriorityTableItem from "../../../../common/tableItems/planview/PriorityTableItem"; @@ -273,6 +273,7 @@ import MsTestPlanApiStatus from "@/business/plan/view/comonents/api/TestPlanApiS import {getProjectVersions} from "@/business/utils/sdk-utils"; import {TEST_PLAN_API_CASE_CONFIGS} from "metersphere-frontend/src/components/search/search-components"; import MsTestPlanRunModeWithEnv from "@/business/plan/common/TestPlanRunModeWithEnv"; +import {getProject} from "@/api/project"; export default { name: "TestPlanApiCaseList", @@ -726,19 +727,25 @@ export default { } }, openApiById(item) { - let definitionData = this.$router.resolve( - "/api/definition/default/" + - getUUID() + - "/apiTestCase/single:" + - item.caseId + - "/" + - getCurrentProjectID() + - "/" + - item.protocol + - "/" + - getCurrentWorkspaceId() - ); - window.open(definitionData.href, "_blank"); + let projectId = item.projectId; + getProject(projectId).then((rsp) => { + if (rsp.data) { + let workspaceId = rsp.data.workspaceId; + let definitionData = this.$router.resolve( + "/api/definition/default/" + + getUUID() + + "/apiTestCase/single:" + + item.caseId + + "/" + + projectId + + "/" + + item.protocol + + "/" + + workspaceId + ); + window.open(definitionData.href, "_blank"); + } + }); }, getTagToolTips(tags) { try { diff --git a/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiScenarioList.vue b/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiScenarioList.vue index 4bdea17e2c..9471cba57f 100644 --- a/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiScenarioList.vue +++ b/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiScenarioList.vue @@ -286,7 +286,7 @@ import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader"; import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination"; import MsTag from "metersphere-frontend/src/components/MsTag"; -import {getCurrentProjectID, getCurrentWorkspaceId,} from "metersphere-frontend/src/utils/token"; +import {getCurrentProjectID,} from "metersphere-frontend/src/utils/token"; import {getUUID, strMapToObj} from "metersphere-frontend/src/utils"; import {hasLicense, hasPermission,} from "metersphere-frontend/src/utils/permission"; import MsTableMoreBtn from "metersphere-frontend/src/components/table/TableMoreBtn"; @@ -323,6 +323,7 @@ import MsTestPlanApiStatus from "@/business/plan/view/comonents/api/TestPlanApiS import {getVersionFilters} from "@/business/utils/sdk-utils"; import {TEST_PLAN_API_SCENARIO_CONFIGS} from "metersphere-frontend/src/components/search/search-components"; import MsTestPlanRunModeWithEnv from "@/business/plan/common/TestPlanRunModeWithEnv"; +import {getProject} from "@/api/project"; export default { name: "MsTestPlanApiScenarioList", @@ -676,17 +677,23 @@ export default { } }, openById(item) { - let automationData = this.$router.resolve( - "/api/automation/default/" + - getUUID() + - "/scenario/edit:" + - item.caseId + - "/" + - item.projectId + - "/" + - getCurrentWorkspaceId() - ); - window.open(automationData.href, "_blank"); + let projectId = item.projectId; + getProject(projectId).then((rsp) => { + if (rsp.data) { + let workspaceId = rsp.data.workspaceId; + let automationData = this.$router.resolve( + "/api/automation/default/" + + getUUID() + + "/scenario/edit:" + + item.caseId + + "/" + + projectId + + "/" + + workspaceId + ); + window.open(automationData.href, "_blank"); + } + }); }, getTagToolTips(tags) { try {