fix(测试用例): 评审脑图&执行脑图-评审模块或执行模块后重新渲染子模块

--bug=1047742 --user=吕梦园
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001047742
--bug=1047158 --user=吕梦园
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001047158
This commit is contained in:
teukkk 2024-10-23 10:50:26 +08:00 committed by 刘瑞斌
parent ae4494879d
commit 798f094628
3 changed files with 82 additions and 11 deletions

View File

@ -116,11 +116,13 @@
import MsMinderEditor from '@/components/pure/ms-minder-editor/minderEditor.vue';
import type { MinderJson, MinderJsonNode, MinderJsonNodeData } from '@/components/pure/ms-minder-editor/props';
import {
clearNodeChildren,
clearSelectedNodes,
createNode,
expendNodeAndChildren,
handleRenderNode,
removeFakeNode,
renderSubModules,
renderSubNodes,
setPriorityView,
} from '@/components/pure/ms-minder-editor/script/tool/utils';
@ -516,13 +518,17 @@
// status
if (isCaseTag(node.data)) {
window.minder.execCommand('resource', [statusTagMap[status]]);
} else if (node.data.id === 'NONE') {
//
initCaseTree();
} else if (status !== StartReviewStatus.UNDER_REVIEWED && node.data?.resource?.includes(moduleTag)) {
//
for (let i = node.children.length - 1; i >= 0; i--) {
window.minder.removeNode(node.children[i]);
//
clearNodeChildren(node);
renderSubModules(node, importJson.value.root, modulesCount.value);
//
if (node.data.id !== 'NONE') {
initNodeCases(node);
}
//
initNodeCases(node);
}
emit('handleReviewDone');
}

View File

@ -218,11 +218,13 @@
import MsMinderEditor from '@/components/pure/ms-minder-editor/minderEditor.vue';
import type { MinderJson, MinderJsonNode, MinderJsonNodeData } from '@/components/pure/ms-minder-editor/props';
import {
clearNodeChildren,
clearSelectedNodes,
createNode,
expendNodeAndChildren,
handleRenderNode,
removeFakeNode,
renderSubModules,
renderSubNodes,
setPriorityView,
} from '@/components/pure/ms-minder-editor/script/tool/utils';
@ -675,13 +677,17 @@
initExecuteHistory(node.data);
}
window.minder.refresh();
} else if (node.data.id === 'NONE') {
//
initCaseTree();
} else if (isModuleOrCollection(node.data)) {
//
for (let i = node.children.length - 1; i >= 0; i--) {
window.minder.removeNode(node.children[i]);
}
//
clearNodeChildren(node);
renderSubModules(node, importJson.value.root, modulesCount.value);
//
initNodeCases(node);
if (node.data.id !== 'NONE') {
initNodeCases(node);
}
}
emit('refreshPlan');
}

View File

@ -1,7 +1,11 @@
import type { MinderJsonNode, MinderJsonNodeData } from '@/components/pure/ms-minder-editor/props';
import { useI18n } from '@/hooks/useI18n';
import type { MinderNodePosition } from '@/store/modules/components/minder-editor/types';
import { getGenerateId, mapTree } from '@/utils';
import { findNodeByKey, getGenerateId, mapTree } from '@/utils';
const { t } = useI18n();
const moduleTag = t('common.module');
export function isDisableNode(minder: any) {
let node: MinderJsonNode;
@ -243,3 +247,58 @@ export function clearSelectedNodes() {
window.minder.toggleSelect(currentSelectedNodes);
}
}
// 清空子节点,从后向前遍历时,删除节点不会影响到尚未遍历的节点
export function clearNodeChildren(node: MinderJsonNode) {
if (!node.children?.length) return;
for (let i = node.children.length - 1; i >= 0; i--) {
window.minder.removeNode(node.children[i]);
}
}
// 重新递归渲染子模块
export function renderSubModules(
node: MinderJsonNode,
importJsonRoot: MinderJsonNode,
modulesCount: Record<string, any>
) {
const waitingRenderNodes: MinderJsonNode[] = [];
const createSubModules = (id: string) => {
const curNode: MinderJsonNode | null = findNodeByKey(importJsonRoot.children as MinderJsonNode[], id, 'id', 'data');
const minderNode = window.minder.getNodeById(id);
if (curNode?.children) {
const moduleNode = curNode.children.filter(
(child) => child.data?.resource?.includes(moduleTag) || child.data?.type === 'tmpModule'
);
if (!moduleNode.length) {
const newNode = createNode(
{
id: 'fakeNode',
text: t('ms.minders.moreCase'),
resource: [''],
},
minderNode
);
waitingRenderNodes.push(newNode);
} else {
moduleNode.forEach((childNode) => {
if (!childNode.data) return;
const newNode = createNode(
{
...childNode.data,
id: childNode.id || childNode.data?.id || '',
text: childNode.name || childNode.data?.text.replace(/<\/?p\b[^>]*>/gi, '') || '',
count: modulesCount[childNode.data.id],
isLoaded: false,
},
minderNode
);
waitingRenderNodes.push(newNode);
createSubModules(childNode.data.id);
});
}
}
};
createSubModules(node.data?.id as string);
handleRenderNode(node, waitingRenderNodes);
}