fix(接口测试): 场景被跨项目A的场景和测试计划引用后-该场景的中跳转链接跨项目显示不正确

--user=郭雨琦
--bug=1012858
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001012858
This commit is contained in:
guoyuqi 2022-04-28 14:43:43 +08:00 committed by 刘瑞斌
parent c7146e13c3
commit 0e76edcb66
4 changed files with 126 additions and 12 deletions

View File

@ -33,7 +33,7 @@
:checkRedirectID="checkRedirectID"
:isRedirectEdit="isRedirectEdit"
:is-read-only="isReadOnly"
@openScenario="editScenario"
@openScenario="clickResource"
@edit="editScenario"
@changeSelectDataRangeAll="changeSelectDataRangeAll"
:custom-num="customNum"
@ -56,7 +56,7 @@
:checkRedirectID="checkRedirectID"
:isRedirectEdit="isRedirectEdit"
:is-read-only="isReadOnly"
@openScenario="editScenario"
@openScenario="clickResource"
@edit="editScenario"
@changeSelectDataRangeAll="changeSelectDataRangeAll"
:custom-num="customNum"
@ -105,7 +105,7 @@
<script>
import {getCurrentProjectID, getCurrentUser, getUUID, hasPermission} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentUser, getCurrentWorkspaceId, getUUID, hasPermission} from "@/common/js/utils";
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
@ -668,6 +668,42 @@ export default {
this.$refs.apiTrashScenarioList.condition.versionId = currentVersion || null;
}
this.refreshAll();
},
clickResource(resource) {
let workspaceId = getCurrentWorkspaceId();
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.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(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: workspaceId}
});
if (isTurnSpace) {
window.open(automationData.href, '_blank');
}
},
checkPermission(resource, workspaceId, isTurnSpace) {
this.$get('/project/getOwnerProjectIds', res => {
const project = res.data.find(p => p === resource.projectId);
if (!project) {
this.$warning(this.$t('commons.no_permission'));
} else {
this.gotoTurn(resource, workspaceId, isTurnSpace)
}
})
}
}
};

View File

@ -17,9 +17,9 @@
<span>{{ $t('api_test.automation.plan_ref') }}</span>
<div class="refs">
<div v-for="(item, index) in planRefs" :key="index" class="el-button--text">
<router-link :to="'/track/plan/view/' + item.id">
<el-link @click="openTestPlan(item)">
{{ item.name }}
</router-link>
</el-link>
</div>
</div>
@ -63,6 +63,13 @@ export default {
openScenario(item) {
this.$emit('openScenario', item);
this.visible = false;
},
openTestPlan(item){
let automationData = this.$router.resolve({
path: '/track/plan/view/' + item.id,
query: { workspaceId: item.workspaceId, projectId: item.projectId, charType: 'scenario'}
});
window.open(automationData.href, '_blank');
}
}
}

View File

@ -4,18 +4,18 @@
<span>{{ $t('api_test.automation.scenario_ref') }}</span>
<div class="refs" v-loading="scenarioLoading">
<div v-for="(item, index) in scenarioRefs" :key="index" class="el-button--text">
<router-link :to="{name: 'ApiAutomation', params: { dataSelectRange: 'edit:' + item.id }}">
<el-link @click="openScenario(item)">
{{ item.name }}
</router-link>
</el-link>
</div>
</div>
<span>{{ $t('api_test.automation.plan_ref') }}</span>
<div class="refs">
<div v-for="(item, index) in planRefs" :key="index" class="el-button--text">
<router-link :to="'/track/plan/view/' + item.id">
<el-link @click="openTestPlan(item)">
{{ item.name }}
</router-link>
</el-link>
</div>
</div>
@ -31,7 +31,9 @@
<script>
export default {
import {getCurrentProjectID, getCurrentWorkspaceId, getUUID} from "@/common/js/utils";
export default {
name: "MsReferenceView",
components: {},
data() {
@ -58,6 +60,49 @@
open(row) {
this.getReferenceData(row);
this.visible = true
},
openScenario(resource) {
let workspaceId = getCurrentWorkspaceId();
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.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(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: workspaceId}
});
if (isTurnSpace) {
window.open(automationData.href, '_blank');
}
},
checkPermission(resource, workspaceId, isTurnSpace) {
this.$get('/project/getOwnerProjectIds', res => {
const project = res.data.find(p => p === resource.projectId);
if (!project) {
this.$warning(this.$t('commons.no_permission'));
} else {
this.gotoTurn(resource, workspaceId, isTurnSpace)
}
})
},
openTestPlan(item){
let automationData = this.$router.resolve({
path: '/track/plan/view/' + item.id,
query: { workspaceId: item.workspaceId, projectId: item.projectId, charType: 'api'}
});
window.open(automationData.href, '_blank');
}
}
}

View File

@ -53,6 +53,7 @@ import TestPlanLoad from "@/business/components/track/plan/view/comonents/load/T
import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
import TestPlanReportContent from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent";
import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm";
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
export default {
name: "TestPlanView",
@ -102,8 +103,29 @@ export default {
}
},
created() {
let workspaceId = this.$route.params.workspaceId;
if (workspaceId) {
sessionStorage.setItem(WORKSPACE_ID, workspaceId);
}else {
if(this.$route.query.workspaceId){
workspaceId = this.$route.query.workspaceId;
sessionStorage.setItem(WORKSPACE_ID, workspaceId);
}
}
let projectId = this.$route.params.projectId;
if (projectId) {
sessionStorage.setItem(PROJECT_ID, projectId);
this.projectId = projectId;
}else {
if (this.$route.query.projectId) {
projectId = this.$route.query.projectId;
sessionStorage.setItem(PROJECT_ID, this.$route.query.projectId);
this.projectId = projectId;
} else {
this.projectId = getCurrentProjectID();
}
}
this.$EventBus.$on('projectChange', this.handleProjectChange);
this.projectId = getCurrentProjectID();
this.checkVersionEnable();
},
destroyed () {
@ -122,7 +144,11 @@ export default {
}
},
genRedirectParam() {
this.redirectCharType = this.$route.params.charType;
if (this.$route.params.charType) {
this.redirectCharType = this.$route.params.charType;
} else {
this.redirectCharType = this.$route.query.charType;
}
this.clickType = this.$route.params.clickType;
if (this.redirectCharType != "") {
if (this.redirectCharType == 'scenario') {