|
|
|
|
@ -7,7 +7,7 @@ import {
|
|
|
|
|
Node,
|
|
|
|
|
Edge
|
|
|
|
|
} 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 { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
|
import { convertFlowData, reverseConvertFlowData, revertFlowData } from '@/utils/convertFlowData';
|
|
|
|
|
@ -22,7 +22,7 @@ import {
|
|
|
|
|
updateEventListOld,
|
|
|
|
|
addRuntimeLog,
|
|
|
|
|
clearRuntimeLogs,
|
|
|
|
|
updateRuntimeId
|
|
|
|
|
updateRuntimeId, updateFlowData
|
|
|
|
|
} from '@/store/ideContainer';
|
|
|
|
|
import {
|
|
|
|
|
validateAllNodes,
|
|
|
|
|
@ -912,18 +912,24 @@ export const useFlowCallbacks = (
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
|
const flowMainData = flowData[currentAppData.id]?.main?.components;
|
|
|
|
|
const sameData: any = Object.values(flowMainData).filter((item: any) => {
|
|
|
|
|
if (item?.component?.compId === newNode.data.compId) return item;
|
|
|
|
|
});
|
|
|
|
|
if (sameData.length) {
|
|
|
|
|
const flowSubMap = flowData[currentAppData.id]?.subMap || {};
|
|
|
|
|
const sameData: any = flowSubMap[newNode.data.compId];
|
|
|
|
|
if (sameData) {
|
|
|
|
|
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 {
|
|
|
|
|
newNode.data.component = {
|
|
|
|
|
type: nodeType
|
|
|
|
|
type: nodeType,
|
|
|
|
|
compId: newNode.data.compId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1061,18 +1067,24 @@ export const useFlowCallbacks = (
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
|
const flowMainData = flowData[currentAppData.id]?.main?.components;
|
|
|
|
|
const sameData: any = Object.values(flowMainData).filter((item: any) => {
|
|
|
|
|
if (item?.component?.compId === newNode.data.compId) return item;
|
|
|
|
|
});
|
|
|
|
|
if (sameData.length) {
|
|
|
|
|
const flowSubMap = flowData[currentAppData.id]?.subMap || {};
|
|
|
|
|
const sameData: any = flowSubMap[newNode.data.compId];
|
|
|
|
|
if (sameData) {
|
|
|
|
|
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 {
|
|
|
|
|
newNode.data.component = {
|
|
|
|
|
type: nodeType
|
|
|
|
|
type: nodeType,
|
|
|
|
|
compId: newNode.data.compId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1174,6 +1186,19 @@ export const useFlowCallbacks = (
|
|
|
|
|
...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 {
|
|
|
|
|
Message.error(res.message);
|
|
|
|
|
@ -1200,6 +1225,19 @@ export const useFlowCallbacks = (
|
|
|
|
|
...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 {
|
|
|
|
|
Message.error(res.message);
|
|
|
|
|
|