fix(接口定义): 修复点击报告跳转没有跳转到对应项目的缺陷

--bug=1021249 --user=王孝刚 【测试跟踪】github#20887,报告链接点击跳转后,没有跳转到对应的项目
https://www.tapd.cn/55049933/s/1319759
This commit is contained in:
wxg0103 2022-12-27 18:05:32 +08:00 committed by 刘瑞斌
parent 58495f0175
commit 6a59f4c1bc
4 changed files with 55 additions and 6 deletions

View File

@ -89,4 +89,10 @@ public class WorkspaceController {
public WorkspaceResource listResource(@PathVariable String groupId, @PathVariable String type) {
return workspaceService.listResource(groupId, type);
}
@GetMapping("/get/{workspaceId}")
public Workspace getWorkspaceById(@PathVariable String workspaceId) {
return workspaceService.getWorkspaceById(workspaceId);
}
}

View File

@ -342,4 +342,7 @@ public class WorkspaceService {
return list;
}
public Workspace getWorkspaceById(String workspaceId) {
return workspaceMapper.selectByPrimaryKey(workspaceId);
}
}

View File

@ -9,7 +9,7 @@
<el-link v-if="isSingleScenario"
type="primary"
class="report-name"
@click="redirect">
@click="clickResource">
{{ report.name }}
</el-link>
<span v-else>
@ -134,15 +134,45 @@ export default {
handleSaveKeyUp($event) {
$event.target.blur();
},
redirect() {
clickResource() {
let workspaceId = getCurrentWorkspaceId();
if (this.report.projectId !== getCurrentProjectID()) {
this.$get("/project/get/" + this.report.projectId, response => {
if (response.data) {
workspaceId = response.data.workspaceId;
this.checkPermission(workspaceId, this.report.projectId, response.data.name);
}
});
} else {
this.checkPermission(workspaceId, this.report.projectId, null);
}
},
checkPermission(workspaceId, projectId, projectName) {
this.$get("/workspace/get/" + workspaceId, response => {
if (response.data) {
let workspaceName = response.data.name;
this.$get('/project/getOwnerProjectIds', res => {
const project = res.data.find(p => p === projectId);
if (!project) {
this.$warning(this.$t('commons.no_permission'));
} else {
this.redirect(workspaceId, projectId, projectName, workspaceName);
}
})
}
});
},
redirect(workspaceId, projectId, projectName, workspaceName) {
let data = this.$router.resolve({
name: this.isUi ? 'uiAutomation' : 'ApiAutomation',
query: {
redirectID: getUUID(),
dataType: "scenario",
projectId: getCurrentProjectID(),
workspaceId: getCurrentWorkspaceId(),
resourceId: this.scenarioId
projectId: projectId,
workspaceId: workspaceId,
resourceId: this.scenarioId,
projectName: projectName,
workspaceName: workspaceName,
}
});
window.open(data.href, '_blank');

View File

@ -32,7 +32,7 @@ import MsRecentList from "../../common/head/RecentList";
import MsShowAll from "../../common/head/ShowAll";
import MsCreateButton from "../../common/head/CreateButton";
import ProjectChange from "@/business/components/common/head/ProjectSwitch";
import {mapGetters} from "vuex";
import {PROJECT_ID, PROJECT_NAME, WORKSPACE, WORKSPACE_ID} from "@/common/js/constants";
export default {
name: "MsApiHeaderMenus",
@ -49,6 +49,16 @@ export default {
'$route': {
immediate: true,
handler(to) {
if (to.name==='ApiAutomation') {
if (to.query.projectName && to.query.projectId) {
sessionStorage.setItem(PROJECT_NAME, to.query.projectName);
sessionStorage.setItem(PROJECT_ID, to.query.projectId);
}
if (to.query.workspaceName && to.query.workspaceId) {
sessionStorage.setItem(WORKSPACE, to.query.workspaceName);
sessionStorage.setItem(WORKSPACE_ID, to.query.workspaceId);
}
}
let path = to.path.split("/", 4);
this.currentPath = '/' + path[1] + '/' + path[2];
if (path[3] === "report") {