diff --git a/test-track/frontend/src/business/case/TestCase.vue b/test-track/frontend/src/business/case/TestCase.vue index e24a529eb0..2fa84c3df9 100644 --- a/test-track/frontend/src/business/case/TestCase.vue +++ b/test-track/frontend/src/business/case/TestCase.vue @@ -482,7 +482,7 @@ export default { if (this.$refs.testCaseList) { this.$refs.testCaseList.initTableData(); } - this.$refs.nodeTree.list(); + this.$refs.nodeTree.list({ isForceSetCurrentKey: true }); }, toggleMinderFullScreen(isFullScreen) { this.enableAsideHidden = isFullScreen; diff --git a/test-track/frontend/src/business/common/minder/TestCaseMinder.vue b/test-track/frontend/src/business/common/minder/TestCaseMinder.vue index 35aad8417f..4d1f27cf0d 100644 --- a/test-track/frontend/src/business/common/minder/TestCaseMinder.vue +++ b/test-track/frontend/src/business/common/minder/TestCaseMinder.vue @@ -102,6 +102,7 @@ export default { needRefresh: false, noRefresh: false, noRefreshMinder: false, + noRefreshMinderForSelectNode: false, saveCases: [], saveModules: [], saveModuleNodeMap: new Map(), @@ -143,6 +144,11 @@ export default { }, watch: { selectNode() { + if (this.noRefreshMinderForSelectNode) { + // 如果是保存触发的刷新模块,则不刷新脑图 + this.noRefreshMinderForSelectNode = false; + return; + } if (this.$refs.minder) { this.caseNum = this.selectNode.data.caseNum; this.$refs.minder.handleNodeSelect(this.selectNode); @@ -340,6 +346,10 @@ export default { // 保存会刷新模块,刷新完模块,脑图也会自动刷新 // 如果是保存触发的刷新模块,则不刷新脑图 this.noRefreshMinder = true; + if (this.selectNode && this.selectNode.data) { + // 如果有选中的模块, 则不刷新 watch -> selectNode + this.noRefreshMinderForSelectNode = true; + } } // 由于模块修改刷新的脑图,不刷新模块 this.noRefresh = false; @@ -418,6 +428,15 @@ export default { this.pushDeleteNode(data); module.id = null; this.extraNodeChanged.push(data); + if (node.children) { + // 原本是临时节点,改成模块后,该节点的子节点需要生成新的临时节点 + node.children.forEach((child) => { + if (child.data.isExtraNode) { + child.data.changed = true; + child.data.id = null; + } + }); + } } if (data.type === 'case') { diff --git a/test-track/frontend/src/business/module/TestCaseNodeTree.vue b/test-track/frontend/src/business/module/TestCaseNodeTree.vue index 85ad5c5e84..9d0e12ad89 100644 --- a/test-track/frontend/src/business/module/TestCaseNodeTree.vue +++ b/test-track/frontend/src/business/module/TestCaseNodeTree.vue @@ -166,7 +166,7 @@ export default { this.$emit('enablePublic', this.condition.publicEnable); this.$emit('toPublic', 'public'); }, - list() { + list({ isForceSetCurrentKey } = {}) { if (this.projectId) { this.caseCondition.casePublic = false; this.loading = true; @@ -193,7 +193,11 @@ export default { }); } } else { - this.setCurrentKey(); + if (isForceSetCurrentKey) { + this.forceSetCurrentKey(); + } else { + this.setCurrentKey(); + } } }); } @@ -223,6 +227,12 @@ export default { this.$refs.nodeTree.setCurrentKey(this.currentNode); } }, + // 重新获取 currentNode ,因为脑图更新完之后可能存在 currentNode 过时的情况 + forceSetCurrentKey() { + if (this.$refs.nodeTree && this.currentNode) { + this.$refs.nodeTree.setCurrentKeyById(this.currentNode.data.id); + } + }, increase(id) { this.$refs.nodeTree.increase(id); },