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

View File

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

View File

@ -1,7 +1,11 @@
import type { MinderJsonNode, MinderJsonNodeData } from '@/components/pure/ms-minder-editor/props'; 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 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) { export function isDisableNode(minder: any) {
let node: MinderJsonNode; let node: MinderJsonNode;
@ -243,3 +247,58 @@ export function clearSelectedNodes() {
window.minder.toggleSelect(currentSelectedNodes); 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);
}