feat(功能用例): 脑图保存调整&快捷键屏蔽
This commit is contained in:
parent
0e306a8ac2
commit
adb9af742e
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div class="h-full pl-[16px]">
|
||||
<div class="baseInfo-form" :class="props.activeCase.isNew ? 'baseInfo-form--no-bottom' : ''">
|
||||
<div class="baseInfo-form">
|
||||
<a-skeleton v-if="baseInfoLoading || props.loading" :loading="baseInfoLoading || props.loading" :animation="true">
|
||||
<a-space direction="vertical" class="w-full" size="large">
|
||||
<a-skeleton-line :rows="10" :line-height="30" :line-spacing="30" />
|
||||
|
@ -27,7 +27,7 @@
|
|||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
<div v-if="!props.activeCase.isNew" class="flex items-center gap-[12px] bg-white py-[16px]">
|
||||
<div class="flex items-center gap-[12px] bg-white py-[16px]">
|
||||
<a-button
|
||||
v-permission="['FUNCTIONAL_CASE:READ+UPDATE']"
|
||||
type="primary"
|
||||
|
@ -49,7 +49,11 @@
|
|||
import { MinderJsonNode } from '@/components/pure/ms-minder-editor/props';
|
||||
import MsTagsInput from '@/components/pure/ms-tags-input/index.vue';
|
||||
|
||||
import { getCaseDefaultFields, updateCaseRequest } from '@/api/modules/case-management/featureCase';
|
||||
import {
|
||||
createCaseRequest,
|
||||
getCaseDefaultFields,
|
||||
updateCaseRequest,
|
||||
} from '@/api/modules/case-management/featureCase';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import useAppStore from '@/store/modules/app';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
|
@ -74,7 +78,7 @@
|
|||
const baseInfoFormRef = ref<FormInstance>();
|
||||
const baseInfoForm = ref({
|
||||
name: '',
|
||||
tags: [],
|
||||
tags: [] as string[],
|
||||
templateId: '',
|
||||
moduleId: 'root',
|
||||
});
|
||||
|
@ -137,7 +141,7 @@
|
|||
...baseInfoForm.value,
|
||||
id: props.activeCase.id,
|
||||
projectId: appStore.currentProjectId,
|
||||
caseEditType: props.activeCase.caseEditType,
|
||||
caseEditType: props.activeCase.caseEditType || 'STEP',
|
||||
customFields: formItem.value.map((item: any) => {
|
||||
return {
|
||||
fieldId: item.field,
|
||||
|
@ -154,10 +158,21 @@
|
|||
if (valid === true) {
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await updateCaseRequest({
|
||||
request: makeParams(),
|
||||
fileList: [],
|
||||
});
|
||||
if (props.activeCase.isNew !== false) {
|
||||
const res = await createCaseRequest({
|
||||
request: makeParams(),
|
||||
fileList: [],
|
||||
});
|
||||
const selectedNode: MinderJsonNode = window.minder.getSelectedNode();
|
||||
if (selectedNode?.data) {
|
||||
selectedNode.data.id = res.id;
|
||||
}
|
||||
} else {
|
||||
await updateCaseRequest({
|
||||
request: makeParams(),
|
||||
fileList: [],
|
||||
});
|
||||
}
|
||||
const selectedNode: MinderJsonNode = window.minder.getSelectedNode();
|
||||
if (selectedNode?.data) {
|
||||
selectedNode.data.text = baseInfoForm.value.name;
|
||||
|
@ -200,7 +215,4 @@
|
|||
overflow-y: auto;
|
||||
height: calc(100% - 64px);
|
||||
}
|
||||
.baseInfo-form--no-bottom {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
FeatureCaseMinderStepItem,
|
||||
FeatureCaseMinderUpdateParams,
|
||||
} from '@/models/caseManagement/featureCase';
|
||||
import { TableQueryParams } from '@/models/common';
|
||||
import { MoveMode, TableQueryParams } from '@/models/common';
|
||||
import { MinderEventName } from '@/enums/minderEnum';
|
||||
|
||||
import { convertToFile, initFormCreate } from '@/views/case-management/caseManagementFeature/components/utils';
|
||||
|
@ -239,6 +239,23 @@
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点的移动信息
|
||||
* @param node 节点
|
||||
* @param parent 父节点
|
||||
*/
|
||||
function getNodeMoveInfo(node: MinderJsonNode, parent?: MinderJsonNode): { moveMode: MoveMode; targetId?: string } {
|
||||
const nodeIndex = parent?.children?.findIndex((e) => e.data.id === node.data.id);
|
||||
const moveMode = nodeIndex === 0 ? 'BEFORE' : 'AFTER';
|
||||
return {
|
||||
moveMode,
|
||||
targetId:
|
||||
moveMode === 'BEFORE'
|
||||
? parent?.children?.[1]?.data.id
|
||||
: parent?.children?.[(nodeIndex || parent.children.length - 1) - 1]?.data.id,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成脑图保存的入参
|
||||
*/
|
||||
|
@ -252,21 +269,20 @@
|
|||
name: node.data.text,
|
||||
parentId: parent?.data.id || 'NONE',
|
||||
type: node.data.isNew !== false ? 'ADD' : 'UPDATE',
|
||||
moveMode: node.data.moveMode,
|
||||
targetId: node.data.targetId,
|
||||
...getNodeMoveInfo(node as MinderJsonNode, parent as MinderJsonNode),
|
||||
});
|
||||
} else if (node.data.resource?.includes(caseTag)) {
|
||||
const caseNodeInfo = getCaseNodeInfo(node as MinderJsonNode);
|
||||
const caseBaseInfo = baseInfoRef.value?.makeParams();
|
||||
tempMinderParams.value.updateCaseList.push({
|
||||
id: node.data.id,
|
||||
name: node.data.text,
|
||||
moduleId: parent?.data.id || '',
|
||||
type: node.data.isNew !== false ? 'ADD' : 'UPDATE',
|
||||
templateId: templateId.value,
|
||||
tags: node.data.resource || [],
|
||||
customFields: baseInfoRef.value?.makeParams().customFields || [],
|
||||
moveMode: node.data.moveMode,
|
||||
targetId: node.data.targetId,
|
||||
tags: caseBaseInfo?.tags || [],
|
||||
customFields: caseBaseInfo?.customFields || [],
|
||||
name: caseBaseInfo?.name || node.data.text,
|
||||
...getNodeMoveInfo(node as MinderJsonNode, parent as MinderJsonNode),
|
||||
...caseNodeInfo,
|
||||
});
|
||||
return false; // 用例的子孙节点已经处理过,跳过
|
||||
|
@ -362,18 +378,6 @@
|
|||
nextTick(() => {
|
||||
const newNode: MinderJsonNode = window.minder.getSelectedNode();
|
||||
newNode.data.isNew = true; // 新建的节点标记为新建
|
||||
switch (command) {
|
||||
case 'AppendChildNode':
|
||||
newNode.data.moveMode = 'APPEND'; // 新建的节点标记为插入模式
|
||||
newNode.data.targetId = newNode.parent?.data.id || '';
|
||||
break;
|
||||
case 'AppendSiblingNode':
|
||||
newNode.data.moveMode = 'AFTER'; // 新建的节点标记为插入模式
|
||||
newNode.data.targetId = newNode.data.id || '';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,7 +189,8 @@ export default function ClipboardRuntime(this: any) {
|
|||
* @Editor: Naixor
|
||||
* @Date: 2015.9.24
|
||||
*/
|
||||
document.addEventListener('copy', (e) => beforeCopy(e));
|
||||
document.addEventListener('cut', (e) => beforeCut(e));
|
||||
document.addEventListener('paste', (e) => beforePaste(e));
|
||||
// TODO: 未来需要支持自定义快捷键处理逻辑
|
||||
// document.addEventListener('copy', (e) => beforeCopy(e));
|
||||
// document.addEventListener('cut', (e) => beforeCut(e));
|
||||
// document.addEventListener('paste', (e) => beforePaste(e));
|
||||
}
|
||||
|
|
|
@ -35,36 +35,37 @@ function HotboxRuntime(this: any) {
|
|||
handleHotBoxShow();
|
||||
});
|
||||
|
||||
function handleShortcut(e: any) {
|
||||
// 检查是否按下Ctrl键(Windows和Linux)或Command键(Mac)
|
||||
const isCtrlKey = e.ctrlKey || e.metaKey;
|
||||
// 检查是否按下Enter键
|
||||
const isEnterKey = e.key === 'Enter';
|
||||
// 检查是否同时按下Ctrl(或Command)和Enter键
|
||||
if (isCtrlKey && isEnterKey) {
|
||||
// 处理Ctrl+Enter组合键事件
|
||||
e.preventDefault(); // 阻止默认行为
|
||||
// 执行进入模块方法
|
||||
const node = minder.getSelectedNode();
|
||||
let position: MinderNodePosition | undefined;
|
||||
if (node) {
|
||||
const box = node.getRenderBox();
|
||||
position = {
|
||||
x: box.cx,
|
||||
y: box.cy,
|
||||
};
|
||||
minderStore.dispatchEvent(MinderEventName.ENTER_NODE, position, node.rc.node, node.data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
minder.dispatchKeyEvent(e);
|
||||
}
|
||||
// TODO: 未来需要支持自定义快捷键处理逻辑
|
||||
// function handleShortcut(e: any) {
|
||||
// // 检查是否按下Ctrl键(Windows和Linux)或Command键(Mac)
|
||||
// const isCtrlKey = e.ctrlKey || e.metaKey;
|
||||
// // 检查是否按下Enter键
|
||||
// const isEnterKey = e.key === 'Enter';
|
||||
// // 检查是否同时按下Ctrl(或Command)和Enter键
|
||||
// if (isCtrlKey && isEnterKey) {
|
||||
// // 处理Ctrl+Enter组合键事件
|
||||
// e.preventDefault(); // 阻止默认行为
|
||||
// // 执行进入模块方法
|
||||
// const node = minder.getSelectedNode();
|
||||
// let position: MinderNodePosition | undefined;
|
||||
// if (node) {
|
||||
// const box = node.getRenderBox();
|
||||
// position = {
|
||||
// x: box.cx,
|
||||
// y: box.cy,
|
||||
// };
|
||||
// minderStore.dispatchEvent(MinderEventName.ENTER_NODE, position, node.rc.node, node.data);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// minder.dispatchKeyEvent(e);
|
||||
// }
|
||||
|
||||
fsm.when('normal -> normal', (exit: any, enter: any, reason: any, e: any) => {
|
||||
if (reason === 'shortcut-handle') {
|
||||
handleShortcut(e);
|
||||
}
|
||||
});
|
||||
// fsm.when('normal -> normal', (exit: any, enter: any, reason: any, e: any) => {
|
||||
// if (reason === 'shortcut-handle') {
|
||||
// handleShortcut(e);
|
||||
// }
|
||||
// });
|
||||
|
||||
fsm.when('modal -> normal', (exit: any, enter: any, reason: any) => {
|
||||
if (reason === 'import-text-finish') {
|
||||
|
|
|
@ -94,7 +94,7 @@ function JumpingRuntime(this: IJumpingRuntime): void {
|
|||
receiverElement.innerHTML = '';
|
||||
}
|
||||
// normal -> normal shortcut
|
||||
fsm.jump('normal', 'shortcut-handle', e);
|
||||
// fsm.jump('normal', 'shortcut-handle', e); TODO: 未来需要支持自定义快捷键处理逻辑
|
||||
break;
|
||||
}
|
||||
case 'keyup': {
|
||||
|
|
Loading…
Reference in New Issue