feat(flowEditor): 添加流程节点单步执行功能

master
钟良源 1 month ago
parent c1c11d0d0d
commit c9a61f762a

@ -1,5 +1,14 @@
import axios from 'axios'; import axios from 'axios';
import { apiResData, queryParams, applicationModel, publishApi, paramsT } from '@/api/interface/index'; import {
apiResData,
queryParams,
applicationModel,
publishApi,
paramsT,
StepRunEventParams,
ExecuteCurrentEventParams,
ReconnectRunParams
} from '@/api/interface/index';
// 公共路径 // 公共路径
const urlPrefix = '/api/v1/bpms-workbench'; const urlPrefix = '/api/v1/bpms-workbench';
@ -109,3 +118,18 @@ export function refreshToken(data: publishApi) {
export function getProjectEnv(id) { export function getProjectEnv(id) {
return axios.get<paramsT>(`${urlPrefix}/apps/env/${id}`); return axios.get<paramsT>(`${urlPrefix}/apps/env/${id}`);
} }
// 事件运行时-单步执行事件
export function stepRunEvent(params: StepRunEventParams) {
return axios.post(`${runPrefix}/apps/run/event`, params);
}
// 事件运行时-从当前节点执行
export function executeCurrentEvent(params: ExecuteCurrentEventParams) {
return axios.post(`${runPrefix}/apps/breakpoint`, params);
}
// 流程运行时-重连运行
export function reconnectRun(params: ReconnectRunParams) {
return axios.post(`${runPrefix}/apps/reconnect`, params);
}

@ -1,7 +1,8 @@
import React, { useEffect } from 'react'; import React from 'react';
import { Menu, Message } from '@arco-design/web-react'; import { Menu, Message } from '@arco-design/web-react';
import { Node } from '@xyflow/react'; import { Node } from '@xyflow/react';
import { isJSON } from '@/utils/common'; import { isJSON } from '@/utils/common';
import { stepRunEvent } from '@/api/apps';
interface NodeContextMenuProps { interface NodeContextMenuProps {
node: Node; node: Node;
@ -53,6 +54,34 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
onCloseMenu(null); onCloseMenu(null);
}; };
// 单步执行事件
const handleStepRun = async () => {
try {
// 从节点的 component.customDef 中获取事件ID
let eventId = '';
const customDef = (node as any).data?.component?.customDef;
if (customDef) {
if (typeof customDef === 'string') {
const parsed = isJSON(customDef) ? JSON.parse(customDef) : {};
eventId = parsed.eventId || '';
} else {
eventId = customDef.eventId || '';
}
}
if (!eventId) {
Message.warning('该节点未配置事件,请先选择事件');
onCloseMenu(null);
return;
}
await stepRunEvent({ eventId });
Message.success('单步执行已触发');
} catch (error: any) {
Message.error(error?.message || '单步执行失败');
}
onCloseMenu(null);
};
// 根据节点类型和其他条件动态生成菜单项 // 根据节点类型和其他条件动态生成菜单项
const renderMenuItems = () => { const renderMenuItems = () => {
@ -79,6 +108,15 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
</Menu.Item> </Menu.Item>
); );
// 单步执行 - 仅对事件接收节点显示
if (node.data.type === 'EVENTLISTENE') {
menuItems.push(
<Menu.Item key="step-run" onClick={handleStepRun}>
</Menu.Item>
);
}
} }
// 可以根据节点类型添加特定的操作 // 可以根据节点类型添加特定的操作

Loading…
Cancel
Save