From 366a5a4826645625bfe5529f8e94121a2dfb85fc Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 30 Mar 2023 20:19:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E8=84=91=E5=9B=BE=E6=B7=BB=E4=B8=A4=E7=BA=A7=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=90=8E=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E7=BA=A7=E4=B8=BA=E6=A8=A1=E5=9D=97=EF=BC=8C=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=90=8E=E7=AC=AC=E4=BA=8C=E7=BA=A7=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024774 --user=陈建星 【测试跟踪】github#23044,功能用例-脑图模式下,添加多级临时节点,修改第一级临时节点为模块,保存后,该节点下数据丢失 https://www.tapd.cn/55049933/s/1357891 --- .../frontend/src/business/case/TestCase.vue | 2 +- .../business/common/minder/TestCaseMinder.vue | 19 +++++++++++++++++++ .../src/business/module/TestCaseNodeTree.vue | 14 ++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) 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); },