feat(功能用例): 用例评审脑图查看-评审状态标签&不能修改脑图

This commit is contained in:
teukkk 2024-07-04 19:04:03 +08:00 committed by 刘瑞斌
parent 2802612800
commit 4c39528cf0
3 changed files with 69 additions and 38 deletions

View File

@ -13,8 +13,8 @@
:can-show-more-menu-node-operation="false" :can-show-more-menu-node-operation="false"
:more-menu-other-operation-list="canShowEnterNode ? [] : moreMenuOtherOperationList" :more-menu-other-operation-list="canShowEnterNode ? [] : moreMenuOtherOperationList"
disabled disabled
single-tag
@node-select="handleNodeSelect" @node-select="handleNodeSelect"
@before-exec-command="handleBeforeExecCommand"
> >
<template #extractMenu> <template #extractMenu>
<template v-if="showCaseMenu"> <template v-if="showCaseMenu">
@ -77,6 +77,7 @@
import MsDescription, { Description } from '@/components/pure/ms-description/index.vue'; import MsDescription, { Description } from '@/components/pure/ms-description/index.vue';
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 { MinderEvent } from '@/components/pure/ms-minder-editor/props';
import { setPriorityView } from '@/components/pure/ms-minder-editor/script/tool/utils'; import { setPriorityView } from '@/components/pure/ms-minder-editor/script/tool/utils';
import { MsFileItem } from '@/components/pure/ms-upload/types'; import { MsFileItem } from '@/components/pure/ms-upload/types';
import Attachment from '@/components/business/ms-minders/featureCaseMinder/attachment.vue'; import Attachment from '@/components/business/ms-minders/featureCaseMinder/attachment.vue';
@ -111,6 +112,12 @@
const { t } = useI18n(); const { t } = useI18n();
const minderStore = useMinderStore(); const minderStore = useMinderStore();
const statusTagMap: Record<string, string> = {
PASS: t('common.pass'),
UN_PASS: t('common.unPass'),
UNDER_REVIEWED: t('caseManagement.caseReview.reviewing'),
RE_REVIEWED: t('caseManagement.caseReview.reReview'),
};
const caseTag = t('common.case'); const caseTag = t('common.case');
const moduleTag = t('common.module'); const moduleTag = t('common.module');
const importJson = ref<MinderJson>({ const importJson = ref<MinderJson>({
@ -133,6 +140,7 @@
resource: props.modulesCount[e.id] !== undefined ? [moduleTag] : e.data?.resource, resource: props.modulesCount[e.id] !== undefined ? [moduleTag] : e.data?.resource,
expandState: e.level === 0 ? 'expand' : 'collapse', expandState: e.level === 0 ? 'expand' : 'collapse',
count: props.modulesCount[e.id], count: props.modulesCount[e.id],
disabled: true,
}, },
children: children:
props.modulesCount[e.id] > 0 && !e.children?.length props.modulesCount[e.id] > 0 && !e.children?.length
@ -175,14 +183,18 @@
onMounted(() => { onMounted(() => {
initCaseTree(); initCaseTree();
//
window.minder._resourceColorMapping = {
[statusTagMap.UNDER_REVIEWED]: 8,
[statusTagMap.PASS]: 4,
[statusTagMap.UN_PASS]: 5,
[statusTagMap.RE_REVIEWED]: 6,
};
}); });
watch( watch([() => props.moduleId, () => props.viewStatusFlag], () => {
() => props.moduleId, initCaseTree();
() => { });
initCaseTree();
}
);
/** /**
* 移除占位的虚拟节点 * 移除占位的虚拟节点
@ -202,11 +214,10 @@
* @param renderNode 需要渲染的子节点 * @param renderNode 需要渲染的子节点
*/ */
function handleRenderNode(node: MinderJsonNode, renderNode: MinderJsonNode) { function handleRenderNode(node: MinderJsonNode, renderNode: MinderJsonNode) {
const { data } = node; if (!node.data) return;
if (!data) return;
window.minder.renderNodeBatch(renderNode); window.minder.renderNodeBatch(renderNode);
node.layout(); node.layout();
data.isLoaded = true; node.data.isLoaded = true;
} }
/** /**
@ -219,6 +230,7 @@
{ {
...data, ...data,
expandState: 'collapse', expandState: 'collapse',
disabled: true,
}, },
parentNode parentNode
); );
@ -242,25 +254,23 @@
/** /**
* 加载模块节点下的用例节点 * 加载模块节点下的用例节点
* @param selectedNode 选中节点 * @param node 选中节点
* @param loadMoreCurrent 加载模块下更多用例时的当前页码 * @param loadMoreCurrent 加载模块下更多用例时的当前页码
*/ */
async function initNodeCases(selectedNode?: MinderJsonNode, loadMoreCurrent?: number) { async function initNodeCases(node: MinderJsonNode, loadMoreCurrent?: number) {
try { try {
loading.value = true; loading.value = true;
const node = selectedNode || window.minder.getSelectedNode(); if (!node?.data) return;
const { data } = node;
if (!data) return;
const { list, total } = await getCaseReviewMinder({ const { list, total } = await getCaseReviewMinder({
current: loadMoreCurrent ? loadMoreCurrent + 1 : 1, current: (loadMoreCurrent ?? 0) + 1,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleId: data.id, moduleId: node.data?.id,
reviewId: route.query.id as string, reviewId: route.query.id as string,
viewFlag: props.viewFlag, viewFlag: props.viewFlag,
viewStatusFlag: props.viewStatusFlag, viewStatusFlag: props.viewStatusFlag,
}); });
// //
removeFakeNode(node, loadMoreCurrent ? `tmp-${data.id}` : 'fakeNode'); removeFakeNode(node, loadMoreCurrent ? `tmp-${node.data?.id}` : 'fakeNode');
// //
if ((!list || list.length === 0) && node.children?.length && !loadMoreCurrent) { if ((!list || list.length === 0) && node.children?.length && !loadMoreCurrent) {
node.expand(); node.expand();
@ -270,9 +280,18 @@
// //
let waitingRenderNodes: MinderJsonNode[] = []; let waitingRenderNodes: MinderJsonNode[] = [];
list.forEach((e) => { list.forEach((e: MinderJsonNode) => {
// //
const child = createNode(e.data, node); const child = createNode(
{
...(e.data as MinderJsonNodeData),
resource: [
...(statusTagMap[e.data?.status] ? [statusTagMap[e.data?.status]] : []),
...(e.data?.resource ?? []),
],
},
node
);
waitingRenderNodes.push(child); waitingRenderNodes.push(child);
// /// // ///
const grandChildren = renderSubNodes(child, e.children); const grandChildren = renderSubNodes(child, e.children);
@ -284,14 +303,15 @@
waitingRenderNodes = waitingRenderNodes.concat(node.children); waitingRenderNodes = waitingRenderNodes.concat(node.children);
} }
// //
if (total > list.length * (loadMoreCurrent || 1)) { if (total > 100 * ((loadMoreCurrent ?? 0) + 1)) {
const moreNode = window.minder.createNode( const moreNode = window.minder.createNode(
{ {
id: `tmp-${data.id}`, id: `tmp-${node.data?.id}`,
text: '...', text: '...',
type: 'tmp', type: 'tmp',
expandState: 'collapse', expandState: 'collapse',
current: loadMoreCurrent ? loadMoreCurrent + 1 : 1, current: (loadMoreCurrent ?? 0) + 1,
disabled: true,
}, },
node node
); );
@ -308,13 +328,6 @@
} }
} }
watch(
() => props.viewStatusFlag,
() => {
initNodeCases();
}
);
const extraVisible = ref<boolean>(false); const extraVisible = ref<boolean>(false);
const activeExtraKey = ref<'baseInfo' | 'attachment' | 'history'>('baseInfo'); const activeExtraKey = ref<'baseInfo' | 'attachment' | 'history'>('baseInfo');
const baseInfoLoading = ref(false); const baseInfoLoading = ref(false);
@ -471,18 +484,18 @@
setPriorityView(true, 'P'); setPriorityView(true, 'P');
return; return;
} }
// : // :
if ( if (
node?.data?.resource?.includes(caseTag) || node?.data?.resource?.includes(caseTag) ||
(node?.data?.resource?.includes(moduleTag) && node.type !== 'root') (node?.data?.resource?.includes(moduleTag) && node.type !== 'root' && (node.children || []).length > 0)
) { ) {
canShowFloatMenu.value = true; canShowFloatMenu.value = true;
} else { } else {
canShowFloatMenu.value = false; canShowFloatMenu.value = false;
} }
// : // :
if (data?.resource?.includes(moduleTag) && (node.children || []).length > 0) { if (data?.resource?.includes(moduleTag)) {
canShowEnterNode.value = true; canShowEnterNode.value = true;
} else { } else {
canShowEnterNode.value = false; canShowEnterNode.value = false;
@ -507,7 +520,23 @@
setPriorityView(true, 'P'); setPriorityView(true, 'P');
} }
/**
* 脑图命令执行前拦截
* @param event 命令执行事件
*/
function handleBeforeExecCommand(event: MinderEvent) {
if (['movetoparent', 'arrange'].includes(event.commandName)) {
event.stopPropagation();
}
}
defineExpose({ defineExpose({
initNodeCases, initCaseTree,
}); });
</script> </script>
<style lang="less" scoped>
:deep(.comment-list-item-name) {
max-width: 200px;
}
</style>

View File

@ -6,7 +6,9 @@
<div class="flex-1"> <div class="flex-1">
<div class="flex items-center gap-[8px]"> <div class="flex items-center gap-[8px]">
<a-tooltip :content="item.userName" :mouse-enter-delay="300"> <a-tooltip :content="item.userName" :mouse-enter-delay="300">
<div class="one-line-text max-w-[300px] font-medium text-[var(--color-text-1)]">{{ item.userName }}</div> <div class="comment-list-item-name one-line-text max-w-[300px] font-medium text-[var(--color-text-1)]">
{{ item.userName }}
</div>
</a-tooltip> </a-tooltip>
<div v-if="item.status === 'PASS'" class="flex items-center"> <div v-if="item.status === 'PASS'" class="flex items-center">
<MsIcon type="icon-icon_succeed_filled" class="mr-[4px] text-[rgb(var(--success-6))]" /> <MsIcon type="icon-icon_succeed_filled" class="mr-[4px] text-[rgb(var(--success-6))]" />
@ -17,7 +19,7 @@
{{ t('caseManagement.caseReview.fail') }} {{ t('caseManagement.caseReview.fail') }}
</div> </div>
<div v-else-if="item.status === 'UNDER_REVIEWED'" class="flex items-center"> <div v-else-if="item.status === 'UNDER_REVIEWED'" class="flex items-center">
<MsIcon type="icon-icon_warning_filled" class="mr-[4px] text-[rgb(var(--link-6))]" /> <MsIcon type="icon-icon_warning_filled" class="mr-[4px] text-[rgb(var(--warning-6))]" />
{{ t('caseManagement.caseReview.suggestion') }} {{ t('caseManagement.caseReview.suggestion') }}
</div> </div>
<div v-else-if="item.status === 'RE_REVIEWED'" class="flex items-center"> <div v-else-if="item.status === 'RE_REVIEWED'" class="flex items-center">

View File

@ -540,7 +540,7 @@
if (showType.value === 'list') { if (showType.value === 'list') {
searchCase(); searchCase();
} else { } else {
msCaseReviewMinderRef.value?.initNodeCases(); msCaseReviewMinderRef.value?.initCaseTree();
emit('init', { moduleIds: [props.activeFolder], projectId: appStore.currentProjectId, pageSize: 10, current: 1 }); emit('init', { moduleIds: [props.activeFolder], projectId: appStore.currentProjectId, pageSize: 10, current: 1 });
} }
} }