From 4be30fd5eec04cd276631c25301a94c002a34387 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 13 Mar 2023 16:32:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?URL=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AEID=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024038 --user=陈建星 功能测试用例列表查询URL优化 https://www.tapd.cn/55049933/s/1348234 --- .../src/components/head/ProjectSearchList.vue | 16 ++++++ .../src/components/new-ui/MsNodeTree.vue | 6 +++ .../business/case/components/TestCaseList.vue | 29 ++++++++-- .../src/business/head/TrackHeaderMenus.vue | 53 +++++-------------- .../src/business/module/TestCaseNodeTree.vue | 9 +++- 5 files changed, 65 insertions(+), 48 deletions(-) diff --git a/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue b/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue index 21b4634b3d..a7ca9a0df0 100644 --- a/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue +++ b/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue @@ -136,8 +136,24 @@ export default { this.$router.push("/"); } } + + this.rewriteProjectRouteParam(); this.reload(); }, + rewriteProjectRouteParam() { + if (this.$route.query.projectId && merge) { + let query = {}; + Object.assign(query, this.$route.query); + + // 切换项目的时候如果有项目 ID 参数,修改为切换后的项目 ID,模块参数置空 + query.projectId = getCurrentProjectID(); + delete query.moduleId; + + this.$router.push({ + query: Object.assign(query) + }); + } + }, change(projectId) { let currentProjectId = getCurrentProjectID(); if (projectId === currentProjectId) { diff --git a/framework/sdk-parent/frontend/src/components/new-ui/MsNodeTree.vue b/framework/sdk-parent/frontend/src/components/new-ui/MsNodeTree.vue index 8ab290a9c3..4880d993e2 100644 --- a/framework/sdk-parent/frontend/src/components/new-ui/MsNodeTree.vue +++ b/framework/sdk-parent/frontend/src/components/new-ui/MsNodeTree.vue @@ -305,6 +305,9 @@ export default { let pNodes = []; this.getChildNodeId(node.data, nodeIds); this.getParentNodes(node, pNodes); + pNodes.forEach(item => { + this.nodeExpand(item); + }); this.$emit("nodeSelectEvent", node, nodeIds, pNodes); }, filterNode(value, data) { @@ -344,6 +347,9 @@ export default { } }); }, + getNode(key) { + return this.$refs.tree.getNode(key); + }, // 改变节点的状态 changeTreeNodeStatus(parentData) { for (let i = 0; i < parentData.children.length; i++) { diff --git a/test-track/frontend/src/business/case/components/TestCaseList.vue b/test-track/frontend/src/business/case/components/TestCaseList.vue index a0c865038e..e019e472a2 100644 --- a/test-track/frontend/src/business/case/components/TestCaseList.vue +++ b/test-track/frontend/src/business/case/components/TestCaseList.vue @@ -271,8 +271,8 @@ import { initCondition, parseCustomFilesForList, } from "metersphere-frontend/src/utils/tableUtils"; import PlanStatusTableItem from "@/business/common/tableItems/plan/PlanStatusTableItem"; -import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token"; -import {getUUID, operationConfirm, parseTag} from "metersphere-frontend/src/utils" +import {getCurrentProjectID, getCurrentWorkspaceId, setCurrentProjectID} from "metersphere-frontend/src/utils/token"; +import {parseTag} from "metersphere-frontend/src/utils" import {hasLicense} from "metersphere-frontend/src/utils/permission" import {getTestTemplate} from "@/api/custom-field-template"; import {getProjectMember, getProjectMemberUserFilter} from "@/api/user"; @@ -482,7 +482,8 @@ export default { advanceSearchShow: false, selectCounts: 0, refreshBySearch: false, - enableVersionColumn: false + enableVersionColumn: false, + projectId: '' }; }, props: { @@ -499,8 +500,8 @@ export default { } }, computed: { - projectId() { - return getCurrentProjectID(); + routeProjectId() { + return this.$route.query.projectId; }, systemFiledMap() { return SYSTEM_FIELD_NAME_MAP; @@ -516,6 +517,8 @@ export default { }) }, created: function () { + this.checkCurrentProject(); + getProjectMemberUserFilter((data) => { this.userFilter = data; }); @@ -631,6 +634,22 @@ export default { }); }); }, + checkCurrentProject() { + // 带了 routeProjectId 校验是否是当前项目 + if (this.routeProjectId) { + if (getCurrentProjectID() !== this.routeProjectId) { + setCurrentProjectID(this.routeProjectId); + location.reload(); + return; + } else { + // 切换项目,url会重写为新的项目ID,也走这里 + this.projectId = this.routeProjectId; + } + } else { + // 没带 routeProjectId 则使用当前项目 + this.projectId = getCurrentProjectID(); + } + }, getTagToolTips(tags) { return getTagToolTips(tags); }, diff --git a/test-track/frontend/src/business/head/TrackHeaderMenus.vue b/test-track/frontend/src/business/head/TrackHeaderMenus.vue index df01382b8b..a07365a2c6 100644 --- a/test-track/frontend/src/business/head/TrackHeaderMenus.vue +++ b/test-track/frontend/src/business/head/TrackHeaderMenus.vue @@ -9,7 +9,7 @@ {{ $t("i18n.home") }} - + {{ $t("test_track.case.test_case") }} @@ -57,33 +57,6 @@ export default { testCaseProjectPath: '', isProjectActivation: true, currentProject: sessionStorage.getItem(PROJECT_NAME), - caseRecent: { - title: this.$t('test_track.recent_case'), - url: "/test/case/recent/5", - index: function (item) { - return '/track/case/edit/' + item.id; - }, - router: function (item) { - } - }, - reviewRecent: { - title: this.$t('test_track.recent_review'), - url: "/test/case/review/recent/5", - index: function (item) { - return '/track/review/view/' + item.id; - }, - router: function (item) { - } - }, - planRecent: { - title: this.$t('test_track.recent_plan'), - url: getCurrentProjectID() === '' ? "/test/plan/recent/5/" + undefined : "/test/plan/recent/5/" + getCurrentProjectID(), - index: function (item) { - return '/track/plan/view/' + item.id; - }, - router: function (item) { - } - }, pathName: '', }; }, @@ -91,12 +64,12 @@ export default { '$route': { immediate: true, handler(to, from) { - if (to.params && to.params.reviewId) { + if (to.path.indexOf("/track/review") >= 0) { this.pathName = '/track/review/all'; - } else if (to.params && to.params.planId) { + } else if (to.path.indexOf("/track/plan") >= 0) { this.pathName = '/track/plan/all'; } if (to.path.indexOf("/track/case") >= 0) { - this.pathName = '/track/case/all'; + this.pathName = this.caseListPath; } else { this.pathName = to.path; } @@ -107,6 +80,11 @@ export default { mounted() { this.init(); }, + computed: { + caseListPath() { + return '/track/case/all?projectId=' + this.getProjectId(); + } + }, methods: { reload() { this.isRouterAlive = false; @@ -129,9 +107,9 @@ export default { this.reload(); } }, - - }, - beforeDestroy() { + getProjectId() { + return getCurrentProjectID(); + } } }; @@ -159,13 +137,6 @@ export default { border-bottom: white !important; } -/*.project-change {*/ -/* height: 40px;*/ -/* line-height: 40px;*/ -/* color: inherit;*/ -/* margin-left: 20px;*/ -/*}*/ - .el-menu-item { padding: 0 10px; } diff --git a/test-track/frontend/src/business/module/TestCaseNodeTree.vue b/test-track/frontend/src/business/module/TestCaseNodeTree.vue index 1298b9dbb2..16a3c6cd9b 100644 --- a/test-track/frontend/src/business/module/TestCaseNodeTree.vue +++ b/test-track/frontend/src/business/module/TestCaseNodeTree.vue @@ -146,7 +146,7 @@ export default { mounted() { let store = useStore(); store.testCaseSelectNode = {}; - store.setTestCaseSelectNodeIds = []; + store.testCaseSelectNodeIds = []; this.list(); }, computed: { @@ -215,7 +215,12 @@ export default { let isCurrentNodeEqualsRouteModule = this.currentNode && this.currentNode.data && this.currentNode.data.id === this.routeModuleId; if (this.routeModuleId && !isCurrentNodeEqualsRouteModule) { if (this.$refs.nodeTree) { - this.$refs.nodeTree.setCurrentKeyById(this.routeModuleId); + this.$nextTick(() => { + if (this.$refs.nodeTree.getNode(this.routeModuleId)) { + // 如果项目有此模块,则设置 moduleId + this.$refs.nodeTree.setCurrentKeyById(this.routeModuleId); + } + }); } } else { this.setCurrentKey();