From 0b00189ee186dca5a2d1c08b492c5fbdd8e31403 Mon Sep 17 00:00:00 2001 From: baiqi Date: Fri, 9 Aug 2024 17:47:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=84=91=E5=9B=BE):=20=E8=84=91=E5=9B=BE?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E5=9C=A8=E7=BC=96=E8=BE=91=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=86=85=E5=AE=B9=E6=97=B6=E7=A6=81=E7=94=A8&?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=84=91=E5=9B=BE=E7=94=A8=E4=BE=8B=E5=AD=90?= =?UTF-8?q?=E5=AD=99=E8=8A=82=E7=82=B9=E4=BF=AE=E6=94=B9=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms-minders/featureCaseMinder/index.vue | 42 +++++++++++++++++++ .../featureCaseMinder/useMinderBaseApi.ts | 8 ++-- .../ms-minder-editor/hooks/useShortCut.ts | 15 +++++++ .../pure/ms-minder-editor/minderEditor.vue | 1 + 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue b/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue index 057ba3c84f..306a2646ed 100644 --- a/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue +++ b/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue @@ -677,6 +677,18 @@ id: node.data?.id || '', type: 'NONE', }); + } else if (caseOffspringTags.some((e) => node.data?.resource?.includes(e))) { + // 用例下的子孙节点的移除,标记用例节点变化 + const parentCase = tempMinderParams.value.updateCaseList.find((e) => e.id !== node.data?.id); + if (!parentCase) { + if (node.parent?.data?.resource?.includes(caseTag)) { + // 第二层子节点 + node.parent.data.changed = true; + } else if (node.parent?.parent?.data?.resource?.includes(caseTag)) { + // 第三层子节点 + node.parent.parent.data.changed = true; + } + } } else if (!caseOffspringTags.some((e) => node.data?.resource?.includes(e))) { // 非用例下的子孙节点的移除,才加入删除资源队列 tempMinderParams.value.deleteResourceList.push({ @@ -859,6 +871,36 @@ ...getNodeMoveInfo(nodeIndex, parent as MinderJsonNode), }); } + } else if (node.data.resource?.includes(caseTag)) { + // 处理用例节点(直接更改用例子孙节点可能没触发用例节点变化) + let hasChangedSubNode = false; + traverseTree(node.children, (child) => { + if (child.data?.changed === true) { + hasChangedSubNode = true; + return false; + } + return true; + }); + if (hasChangedSubNode) { + const caseNodeInfo = getCaseNodeInfo(node as MinderJsonNode); + let caseBaseInfo; + if (activeCase.value.id === node.data.id) { + // 当前用例节点是打开的用例详情,获取用例详情数据 + caseBaseInfo = baseInfoRef.value?.makeParams(); + } + tempMinderParams.value.updateCaseList.push({ + id: node.data.id, + moduleId: parent?.data.id || '', + type: 'UPDATE', + templateId: templateId.value, + tags: caseBaseInfo?.tags || [], + customFields: caseBaseInfo?.customFields || [], + name: caseBaseInfo?.name || node.data.text, + ...getNodeMoveInfo(nodeIndex, parent as MinderJsonNode), + ...caseNodeInfo, + }); + } + return false; // 用例的子孙节点已经处理过,跳过 } return true; }); diff --git a/frontend/src/components/business/ms-minders/featureCaseMinder/useMinderBaseApi.ts b/frontend/src/components/business/ms-minders/featureCaseMinder/useMinderBaseApi.ts index eb5bea1600..a3c836fd0d 100644 --- a/frontend/src/components/business/ms-minders/featureCaseMinder/useMinderBaseApi.ts +++ b/frontend/src/components/business/ms-minders/featureCaseMinder/useMinderBaseApi.ts @@ -370,8 +370,8 @@ export default function useMinderBaseApi({ hasEditPermission }: { hasEditPermiss /** * 插入步骤描述 */ - function insetStepDesc() { - insertSpecifyNode('AppendChildNode', stepTag); + function insetStepDesc(type: 'AppendChildNode' | 'AppendSiblingNode') { + insertSpecifyNode(type, stepTag); nextTick(() => { insertSpecifyNode('AppendChildNode', stepExpectTag); }); @@ -420,7 +420,7 @@ export default function useMinderBaseApi({ hasEditPermission }: { hasEditPermiss insertSpecifyNode('AppendChildNode', remarkTag); } else if (!hasTextDesc) { // 没有文本描述,则默认添加一个步骤描述 - insetStepDesc(); + insetStepDesc('AppendChildNode'); } } } else if ( @@ -468,7 +468,7 @@ export default function useMinderBaseApi({ hasEditPermission }: { hasEditPermiss insertSpecifyNode('AppendSiblingNode', remarkTag); } else if (!hasTextDesc) { // 没有文本描述,则默认添加一个步骤描述 - insetStepDesc(); + insetStepDesc('AppendSiblingNode'); } } else if (node.parent?.data?.resource?.includes(moduleTag) || !node.parent?.data?.resource) { // 当前节点的父节点是模块或没有标签,则默认添加一个文本节点 diff --git a/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts b/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts index 05bc1532f0..5021a318f1 100644 --- a/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts +++ b/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts @@ -1,3 +1,4 @@ +import type { MinderJsonNode } from '../props'; import useMinderOperation, { type MinderOperationProps } from './useMinderOperation'; type ShortcutKey = 'expand' | 'enter' | 'appendSiblingNode' | 'appendChildNode' | 'undo' | 'redo' | 'delete'; @@ -10,6 +11,20 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati const { minderCopy, minderCut, minderPaste } = useMinderOperation(options); const handleKeyDown = (event: KeyboardEvent) => { + const nodes: MinderJsonNode[] = window.minder.getSelectedNodes(); + if (nodes.length === 0) { + return; + } + const { editor } = window; + const { fsm } = editor; + const state = fsm.state(); + switch (state) { + case 'input': { + // 输入状态下不响应快捷键 + return; + } + default: + } const key = event.key.toLowerCase(); const isCtrlOrCmd = event.ctrlKey || event.metaKey; diff --git a/frontend/src/components/pure/ms-minder-editor/minderEditor.vue b/frontend/src/components/pure/ms-minder-editor/minderEditor.vue index ee21c33933..38668dc09c 100644 --- a/frontend/src/components/pure/ms-minder-editor/minderEditor.vue +++ b/frontend/src/components/pure/ms-minder-editor/minderEditor.vue @@ -184,6 +184,7 @@ } }, handleContentChange: (node?: MinderJsonNode) => { + // !!!注意:这里如果是点击输入框以外的地方触发失焦,node 为 undefined,此时 node.data.changed 已标记 true emit('contentChange', node); }, handleMinderEvent: (event) => {