|
|
|
@ -7,7 +7,7 @@ import {
|
|
|
|
Node,
|
|
|
|
Node,
|
|
|
|
Edge
|
|
|
|
Edge
|
|
|
|
} from '@xyflow/react';
|
|
|
|
} from '@xyflow/react';
|
|
|
|
import { refPublish, setMainFlow, setMainFlowNew, setSubFlowNew } from '@/api/appRes';
|
|
|
|
import { getAppInfoNew, setMainFlowNew, setSubFlowNew } from '@/api/appRes';
|
|
|
|
import { Message } from '@arco-design/web-react';
|
|
|
|
import { Message } from '@arco-design/web-react';
|
|
|
|
import { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
import { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
import { convertFlowData, reverseConvertFlowData, revertFlowData } from '@/utils/convertFlowData';
|
|
|
|
import { convertFlowData, reverseConvertFlowData, revertFlowData } from '@/utils/convertFlowData';
|
|
|
|
@ -22,7 +22,7 @@ import {
|
|
|
|
updateEventListOld,
|
|
|
|
updateEventListOld,
|
|
|
|
addRuntimeLog,
|
|
|
|
addRuntimeLog,
|
|
|
|
clearRuntimeLogs,
|
|
|
|
clearRuntimeLogs,
|
|
|
|
updateRuntimeId
|
|
|
|
updateRuntimeId, updateFlowData
|
|
|
|
} from '@/store/ideContainer';
|
|
|
|
} from '@/store/ideContainer';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
validateAllNodes,
|
|
|
|
validateAllNodes,
|
|
|
|
@ -36,13 +36,14 @@ import {
|
|
|
|
} from '@/utils/flowCommon';
|
|
|
|
} from '@/utils/flowCommon';
|
|
|
|
import { projectFlowHandle } from '@/pages/flowEditor/utils/projectFlowHandle';
|
|
|
|
import { projectFlowHandle } from '@/pages/flowEditor/utils/projectFlowHandle';
|
|
|
|
import { appFLowHandle } from '@/pages/flowEditor/utils/appFlowhandle';
|
|
|
|
import { appFLowHandle } from '@/pages/flowEditor/utils/appFlowhandle';
|
|
|
|
|
|
|
|
import { handelEventNodeList, updateEvent, upDatePublish } from '@/pages/flowEditor/utils/common';
|
|
|
|
|
|
|
|
|
|
|
|
import { Dispatch } from 'redux';
|
|
|
|
import { Dispatch } from 'redux';
|
|
|
|
import { runMainFlow, stopApp } from '@/api/apps';
|
|
|
|
import { runMainFlow, stopApp } from '@/api/apps';
|
|
|
|
import store from '@/store';
|
|
|
|
import store from '@/store';
|
|
|
|
import { updateAppEvent, updateAppEventChannel, updateAppFlowData } from '@/api/appEvent';
|
|
|
|
import { updateAppEvent, updateAppEventChannel, updateAppFlowData } from '@/api/appEvent';
|
|
|
|
import { sleep } from '@/utils/common';
|
|
|
|
import { sleep } from '@/utils/common';
|
|
|
|
import { queryEventItemBySceneIdOld } from '@/api/event';
|
|
|
|
import { queryEventItemBySceneIdOld, deleteEventSub, deleteEventPub } from '@/api/event';
|
|
|
|
|
|
|
|
|
|
|
|
export const useFlowCallbacks = (
|
|
|
|
export const useFlowCallbacks = (
|
|
|
|
nodes: Node[],
|
|
|
|
nodes: Node[],
|
|
|
|
@ -810,7 +811,11 @@ export const useFlowCallbacks = (
|
|
|
|
target: loopStartNode.id,
|
|
|
|
target: loopStartNode.id,
|
|
|
|
sourceHandle: edgeForNodeAdd.sourceHandle,
|
|
|
|
sourceHandle: edgeForNodeAdd.sourceHandle,
|
|
|
|
targetHandle: 'start', // 循环开始节点的输入句柄
|
|
|
|
targetHandle: 'start', // 循环开始节点的输入句柄
|
|
|
|
type: 'custom'
|
|
|
|
type: 'custom',
|
|
|
|
|
|
|
|
lineType: 'api',
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
lineType: 'api'
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
id: `e${loopEndNode.id}-${edgeForNodeAdd.target}`,
|
|
|
|
id: `e${loopEndNode.id}-${edgeForNodeAdd.target}`,
|
|
|
|
@ -818,7 +823,11 @@ export const useFlowCallbacks = (
|
|
|
|
target: edgeForNodeAdd.target,
|
|
|
|
target: edgeForNodeAdd.target,
|
|
|
|
sourceHandle: 'break', // 循环结束节点的输出句柄
|
|
|
|
sourceHandle: 'break', // 循环结束节点的输出句柄
|
|
|
|
targetHandle: edgeForNodeAdd.targetHandle,
|
|
|
|
targetHandle: edgeForNodeAdd.targetHandle,
|
|
|
|
type: 'custom'
|
|
|
|
type: 'custom',
|
|
|
|
|
|
|
|
lineType: 'api',
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
lineType: 'api'
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
@ -903,18 +912,24 @@ export const useFlowCallbacks = (
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
const flowMainData = flowData[currentAppData.id]?.main?.components;
|
|
|
|
const flowSubMap = flowData[currentAppData.id]?.subMap || {};
|
|
|
|
const sameData: any = Object.values(flowMainData).filter((item: any) => {
|
|
|
|
const sameData: any = flowSubMap[newNode.data.compId];
|
|
|
|
if (item?.component?.compId === newNode.data.compId) return item;
|
|
|
|
if (sameData) {
|
|
|
|
});
|
|
|
|
|
|
|
|
if (sameData.length) {
|
|
|
|
|
|
|
|
newNode.data.component = {
|
|
|
|
newNode.data.component = {
|
|
|
|
...sameData[0].component
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId,
|
|
|
|
|
|
|
|
customDef: JSON.stringify({
|
|
|
|
|
|
|
|
dataIns: newNode.data.parameters.dataIns,
|
|
|
|
|
|
|
|
dataOuts: newNode.data.parameters.dataOuts,
|
|
|
|
|
|
|
|
subflowId: sameData,
|
|
|
|
|
|
|
|
name: newNode.data.title
|
|
|
|
|
|
|
|
})
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
newNode.data.component = {
|
|
|
|
newNode.data.component = {
|
|
|
|
type: nodeType
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -977,7 +992,11 @@ export const useFlowCallbacks = (
|
|
|
|
target: newNode.id,
|
|
|
|
target: newNode.id,
|
|
|
|
sourceHandle: edgeForNodeAdd.sourceHandle,
|
|
|
|
sourceHandle: edgeForNodeAdd.sourceHandle,
|
|
|
|
targetHandle: newNodeTargetHandle,
|
|
|
|
targetHandle: newNodeTargetHandle,
|
|
|
|
type: 'custom'
|
|
|
|
type: 'custom',
|
|
|
|
|
|
|
|
lineType: 'api',
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
lineType: 'api'
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
id: `e${newNode.id}-${edgeForNodeAdd.target}`,
|
|
|
|
id: `e${newNode.id}-${edgeForNodeAdd.target}`,
|
|
|
|
@ -985,7 +1004,11 @@ export const useFlowCallbacks = (
|
|
|
|
target: edgeForNodeAdd.target,
|
|
|
|
target: edgeForNodeAdd.target,
|
|
|
|
sourceHandle: newNodeSourceHandle,
|
|
|
|
sourceHandle: newNodeSourceHandle,
|
|
|
|
targetHandle: edgeForNodeAdd.targetHandle,
|
|
|
|
targetHandle: edgeForNodeAdd.targetHandle,
|
|
|
|
type: 'custom'
|
|
|
|
type: 'custom',
|
|
|
|
|
|
|
|
lineType: 'api',
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
lineType: 'api'
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
@ -1044,18 +1067,24 @@ export const useFlowCallbacks = (
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
const flowMainData = flowData[currentAppData.id]?.main?.components;
|
|
|
|
const flowSubMap = flowData[currentAppData.id]?.subMap || {};
|
|
|
|
const sameData: any = Object.values(flowMainData).filter((item: any) => {
|
|
|
|
const sameData: any = flowSubMap[newNode.data.compId];
|
|
|
|
if (item?.component?.compId === newNode.data.compId) return item;
|
|
|
|
if (sameData) {
|
|
|
|
});
|
|
|
|
|
|
|
|
if (sameData.length) {
|
|
|
|
|
|
|
|
newNode.data.component = {
|
|
|
|
newNode.data.component = {
|
|
|
|
...sameData[0].component
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId,
|
|
|
|
|
|
|
|
customDef: JSON.stringify({
|
|
|
|
|
|
|
|
dataIns: newNode.data.parameters.dataIns,
|
|
|
|
|
|
|
|
dataOuts: newNode.data.parameters.dataOuts,
|
|
|
|
|
|
|
|
subflowId: sameData,
|
|
|
|
|
|
|
|
name: newNode.data.title
|
|
|
|
|
|
|
|
})
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
newNode.data.component = {
|
|
|
|
newNode.data.component = {
|
|
|
|
type: nodeType
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1111,168 +1140,7 @@ export const useFlowCallbacks = (
|
|
|
|
}, [edgeForNodeAdd, positionForNodeAdd, addNodeOnEdge, addNodeOnPane]);
|
|
|
|
}, [edgeForNodeAdd, positionForNodeAdd, addNodeOnEdge, addNodeOnPane]);
|
|
|
|
// endregion
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
|
|
// 保存所有节点和边数据到服务器,更新事件相关数据
|
|
|
|
|
|
|
|
const updateEvent = (revertedData, appid) => {
|
|
|
|
|
|
|
|
// 初始化参数对象
|
|
|
|
|
|
|
|
const params: any = {
|
|
|
|
|
|
|
|
eventListenes: [],
|
|
|
|
|
|
|
|
eventSends: []
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历所有节点,查找事件相关节点
|
|
|
|
|
|
|
|
Object.entries(revertedData).forEach(([nodeId, nodeConfig]: [string, any]) => {
|
|
|
|
|
|
|
|
// 检查节点是否有component属性和type定义
|
|
|
|
|
|
|
|
if (nodeConfig.component?.type) {
|
|
|
|
|
|
|
|
const nodeType = nodeConfig.component.type;
|
|
|
|
|
|
|
|
const customDef = nodeConfig.component.customDef;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 解析customDef,可能是字符串也可能是对象
|
|
|
|
|
|
|
|
let eventConfig;
|
|
|
|
|
|
|
|
if (typeof customDef === 'string') {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
eventConfig = JSON.parse(customDef);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.error('Failed to parse customDef:', e);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
eventConfig = customDef;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据节点类型处理事件节点
|
|
|
|
|
|
|
|
if (nodeType === 'EVENTLISTENE') {
|
|
|
|
|
|
|
|
// 事件接收节点
|
|
|
|
|
|
|
|
params.eventListenes.push({
|
|
|
|
|
|
|
|
nodeName: nodeConfig.nodeName || '',
|
|
|
|
|
|
|
|
eventId: eventConfig?.eventId || null,
|
|
|
|
|
|
|
|
topic: eventConfig?.topic || '',
|
|
|
|
|
|
|
|
eventName: eventConfig?.name || '',
|
|
|
|
|
|
|
|
dataOuts: nodeConfig.dataOuts || [],
|
|
|
|
|
|
|
|
nodeId: nodeConfig.nodeId
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeType === 'EVENTSEND') {
|
|
|
|
|
|
|
|
// 事件发送节点
|
|
|
|
|
|
|
|
params.eventSends.push({
|
|
|
|
|
|
|
|
nodeName: nodeConfig.nodeName || '',
|
|
|
|
|
|
|
|
eventId: eventConfig?.eventId || null,
|
|
|
|
|
|
|
|
topic: eventConfig?.topic || '',
|
|
|
|
|
|
|
|
eventName: eventConfig?.name || '',
|
|
|
|
|
|
|
|
dataIns: nodeConfig.dataIns || [],
|
|
|
|
|
|
|
|
nodeId: nodeConfig.nodeId
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 调用更新事件的API
|
|
|
|
|
|
|
|
if (params.eventListenes.length > 0 || params.eventSends.length > 0) {
|
|
|
|
|
|
|
|
return params;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else return null;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const upDatePublish = async (revertedData) => {
|
|
|
|
|
|
|
|
const { currentAppData } = store.getState().ideContainer;
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
|
|
appId: currentAppData.id,
|
|
|
|
|
|
|
|
publishAppId: []
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
revertedData.forEach(item => {
|
|
|
|
|
|
|
|
if (item?.component && item.component.type === 'SUB' && !item.component.customDef) params.publishAppId.push(item.component.compId); // 复合组件的这个compId实际上就是flowHousVO里面的id
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (params.publishAppId.length > 0) {
|
|
|
|
|
|
|
|
const res: any = await refPublish(params);
|
|
|
|
|
|
|
|
if (res.code === 200) return res.data;
|
|
|
|
|
|
|
|
else return {};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else return {};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const handelEventNodeList = (newRevertedData) => {
|
|
|
|
|
|
|
|
const { appRuntimeData, currentAppData } = store.getState().ideContainer;
|
|
|
|
|
|
|
|
const current = appRuntimeData[currentAppData.id];
|
|
|
|
|
|
|
|
const deleteEventSendNodeList = [];
|
|
|
|
|
|
|
|
const deleteEventlisteneList = [];
|
|
|
|
|
|
|
|
// 处理流程接口后的数据
|
|
|
|
|
|
|
|
const currentEventSendNodeList = current.eventSendNodeList;
|
|
|
|
|
|
|
|
const currentEventlisteneList = current.eventlisteneList;
|
|
|
|
|
|
|
|
// 画布数据
|
|
|
|
|
|
|
|
const nodeEntries: [string, any][] = Object.entries(newRevertedData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 分类事件节点
|
|
|
|
|
|
|
|
const eventSendNodes = [];
|
|
|
|
|
|
|
|
const eventListenerNodes = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从nodeEntries中提取事件节点
|
|
|
|
|
|
|
|
nodeEntries.forEach(([nodeId, nodeConfig]) => {
|
|
|
|
|
|
|
|
if (nodeConfig.component?.type === 'EVENTSEND') {
|
|
|
|
|
|
|
|
eventSendNodes.push({ nodeId, ...nodeConfig });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeConfig.component?.type === 'EVENTLISTENE') {
|
|
|
|
|
|
|
|
eventListenerNodes.push({ nodeId, ...nodeConfig });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理EVENTSEND节点
|
|
|
|
|
|
|
|
// 如果currentEventSendNodeList中有而nodeEntries中没有,则加入删除列表
|
|
|
|
|
|
|
|
currentEventSendNodeList.forEach((eventNode) => {
|
|
|
|
|
|
|
|
const nodeId = eventNode;
|
|
|
|
|
|
|
|
const nodeInCanvas = eventSendNodes.find(node => node.nodeId === nodeId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!nodeInCanvas) {
|
|
|
|
|
|
|
|
// 画布数据中没有该节点,加入删除列表
|
|
|
|
|
|
|
|
deleteEventSendNodeList.push(eventNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
// 节点存在于画布中,比较时间戳
|
|
|
|
|
|
|
|
// nodeId格式为"节点类型-时间戳"
|
|
|
|
|
|
|
|
const canvasNode = nodeInCanvas.nodeId.split('-');
|
|
|
|
|
|
|
|
const canvasTimestamp = canvasNode[canvasNode.length - 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const interfaceNode = nodeId.split('-');
|
|
|
|
|
|
|
|
const interfaceTimestamp = interfaceNode[interfaceNode.length - 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果画布数据的时间戳是最新的,那就是新增的事件节点,不需要添加到deleteList中
|
|
|
|
|
|
|
|
// 反之需要进一步判断
|
|
|
|
|
|
|
|
if (canvasTimestamp < interfaceTimestamp) {
|
|
|
|
|
|
|
|
// 画布节点时间戳较旧,需要进一步判断
|
|
|
|
|
|
|
|
// 这里留空,等待后续实现
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理EVENTLISTENE节点
|
|
|
|
|
|
|
|
// 如果currentEventlisteneList中有而nodeEntries中没有,则加入删除列表
|
|
|
|
|
|
|
|
currentEventlisteneList.forEach((eventNode) => {
|
|
|
|
|
|
|
|
const nodeId = eventNode;
|
|
|
|
|
|
|
|
const nodeInCanvas = eventListenerNodes.find(node => node.nodeId === nodeId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!nodeInCanvas) {
|
|
|
|
|
|
|
|
// 画布数据中没有该节点,加入删除列表
|
|
|
|
|
|
|
|
deleteEventlisteneList.push(eventNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
// 节点存在于画布中,比较时间戳
|
|
|
|
|
|
|
|
// nodeId格式为"节点类型-时间戳"
|
|
|
|
|
|
|
|
const canvasNode = nodeInCanvas.nodeId.split('-');
|
|
|
|
|
|
|
|
const canvasTimestamp = canvasNode[canvasNode.length - 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const interfaceNode = nodeId.split('-');
|
|
|
|
|
|
|
|
const interfaceTimestamp = interfaceNode[interfaceNode.length - 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果画布数据的时间戳是最新的,那就是新增的事件节点,不需要添加到deleteList中
|
|
|
|
|
|
|
|
// 反之需要进一步判断
|
|
|
|
|
|
|
|
if (canvasTimestamp < interfaceTimestamp) {
|
|
|
|
|
|
|
|
// 画布节点时间戳较旧,需要进一步判断
|
|
|
|
|
|
|
|
// 这里留空,等待后续实现
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
deleteEventSendNodeList,
|
|
|
|
|
|
|
|
deleteEventlisteneList
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const saveFlowDataToServer = useCallback(async () => {
|
|
|
|
const saveFlowDataToServer = useCallback(async () => {
|
|
|
|
if (useDefault) {
|
|
|
|
if (useDefault) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -1295,8 +1163,7 @@ export const useFlowCallbacks = (
|
|
|
|
const newRevertedData = reverseConvertFlowData(nodes, edges, upDatePublishCB);
|
|
|
|
const newRevertedData = reverseConvertFlowData(nodes, edges, upDatePublishCB);
|
|
|
|
const { flowData, currentAppData, info } = store.getState().ideContainer;
|
|
|
|
const { flowData, currentAppData, info } = store.getState().ideContainer;
|
|
|
|
const { deleteEventSendNodeList, deleteEventlisteneList } = handelEventNodeList(newRevertedData);
|
|
|
|
const { deleteEventSendNodeList, deleteEventlisteneList } = handelEventNodeList(newRevertedData);
|
|
|
|
// console.log(deleteEventSendNodeList, deleteEventlisteneList);
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
let params = {};
|
|
|
|
let params = {};
|
|
|
|
// 更新复合组件/子流程
|
|
|
|
// 更新复合组件/子流程
|
|
|
|
if (currentAppData.key.includes('sub')) {
|
|
|
|
if (currentAppData.key.includes('sub')) {
|
|
|
|
@ -1313,6 +1180,25 @@ export const useFlowCallbacks = (
|
|
|
|
// 更新事件枚举表
|
|
|
|
// 更新事件枚举表
|
|
|
|
const res1: any = await queryEventItemBySceneIdOld(info.id);
|
|
|
|
const res1: any = await queryEventItemBySceneIdOld(info.id);
|
|
|
|
if (res1.code === 200) dispatch(updateEventListOld(res1.data));
|
|
|
|
if (res1.code === 200) dispatch(updateEventListOld(res1.data));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新缓存数据 - 与主流程保持一致
|
|
|
|
|
|
|
|
dispatch(updateCanvasDataMap({
|
|
|
|
|
|
|
|
...canvasDataMap,
|
|
|
|
|
|
|
|
[currentAppData.id]: { nodes, edges }
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
const appRes: any = await getAppInfoNew(currentAppData.id);
|
|
|
|
|
|
|
|
// 更新 flowData 中的数据
|
|
|
|
|
|
|
|
dispatch(updateFlowData({ [currentAppData.id]: appRes.data }));
|
|
|
|
|
|
|
|
// 同步更新到 canvasDataMap
|
|
|
|
|
|
|
|
if (appRes.data.main?.components) {
|
|
|
|
|
|
|
|
const { nodes, edges } = convertFlowData(appRes.data.main.components, true);
|
|
|
|
|
|
|
|
setNodes(nodes);
|
|
|
|
|
|
|
|
setEdges(edges);
|
|
|
|
|
|
|
|
dispatch(updateCanvasDataMap({
|
|
|
|
|
|
|
|
...canvasDataMap,
|
|
|
|
|
|
|
|
[currentAppData.id]: { nodes, edges }
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
Message.error(res.message);
|
|
|
|
Message.error(res.message);
|
|
|
|
@ -1339,23 +1225,45 @@ export const useFlowCallbacks = (
|
|
|
|
...canvasDataMap,
|
|
|
|
...canvasDataMap,
|
|
|
|
[currentAppData.id]: { nodes, edges }
|
|
|
|
[currentAppData.id]: { nodes, edges }
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
const appRes: any = await getAppInfoNew(currentAppData.id);
|
|
|
|
|
|
|
|
// 更新 flowData 中的数据
|
|
|
|
|
|
|
|
dispatch(updateFlowData({ [currentAppData.id]: appRes.data }));
|
|
|
|
|
|
|
|
// 同步更新到 canvasDataMap
|
|
|
|
|
|
|
|
if (appRes.data.main?.components) {
|
|
|
|
|
|
|
|
const { nodes, edges } = convertFlowData(appRes.data.main.components, true);
|
|
|
|
|
|
|
|
setNodes(nodes);
|
|
|
|
|
|
|
|
setEdges(edges);
|
|
|
|
|
|
|
|
dispatch(updateCanvasDataMap({
|
|
|
|
|
|
|
|
...canvasDataMap,
|
|
|
|
|
|
|
|
[currentAppData.id]: { nodes, edges }
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
Message.error(res.message);
|
|
|
|
Message.error(res.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 事件节点变动数据有长度就通知后端,主流程和子流程(复合节点)通用
|
|
|
|
|
|
|
|
if (deleteEventSendNodeList.length > 0 || deleteEventlisteneList.length > 0) {
|
|
|
|
|
|
|
|
deleteEventSendNodeList.length > 0 && deleteEventPub({
|
|
|
|
|
|
|
|
appId: currentAppData.id,
|
|
|
|
|
|
|
|
topics: deleteEventSendNodeList
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
deleteEventlisteneList.length > 0 && deleteEventSub({
|
|
|
|
|
|
|
|
appId: currentAppData.id,
|
|
|
|
|
|
|
|
topics: deleteEventlisteneList
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error('Error saving flow data:', error);
|
|
|
|
console.error('Error saving flow data:', error);
|
|
|
|
Message.error('保存失败');
|
|
|
|
Message.error('保存失败');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
const params = {
|
|
|
|
|
|
|
|
nodes,
|
|
|
|
|
|
|
|
edges
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const appFlowParams = {
|
|
|
|
const appFlowParams = {
|
|
|
|
appEventList: {}
|
|
|
|
appEventList: {},
|
|
|
|
|
|
|
|
eventEdges: []
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
nodes.forEach(node => {
|
|
|
|
nodes.forEach(node => {
|
|
|
|
@ -1367,6 +1275,20 @@ export const useFlowCallbacks = (
|
|
|
|
|
|
|
|
|
|
|
|
const eventMap = new Map();
|
|
|
|
const eventMap = new Map();
|
|
|
|
edges.forEach((edge: any) => {
|
|
|
|
edges.forEach((edge: any) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理事件连线
|
|
|
|
|
|
|
|
appFlowParams.eventEdges.push({
|
|
|
|
|
|
|
|
id: edge.id,
|
|
|
|
|
|
|
|
source: edge.source,
|
|
|
|
|
|
|
|
target: edge.target,
|
|
|
|
|
|
|
|
lineType: 'data',
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
displayData: {
|
|
|
|
|
|
|
|
...edge.data.displayData
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 应用组件的桩点id就是事件id
|
|
|
|
// 应用组件的桩点id就是事件id
|
|
|
|
const sourceId = edge.sourceHandle;
|
|
|
|
const sourceId = edge.sourceHandle;
|
|
|
|
const targetId = edge.targetHandle;
|
|
|
|
const targetId = edge.targetHandle;
|
|
|
|
|