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:
parent
ae4494879d
commit
798f094628
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue