|
|
|
@ -7,7 +7,7 @@ import {
|
|
|
|
Node,
|
|
|
|
Node,
|
|
|
|
Edge
|
|
|
|
Edge
|
|
|
|
} from '@xyflow/react';
|
|
|
|
} from '@xyflow/react';
|
|
|
|
import { refPublish, setMainFlow, setMainFlowNew } from '@/api/appRes';
|
|
|
|
import { refPublish, setMainFlow, 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';
|
|
|
|
@ -1003,7 +1003,7 @@ export const useFlowCallbacks = (
|
|
|
|
const emptyEvent = eventList.find(item => item.topic.includes('**empty**'));
|
|
|
|
const emptyEvent = eventList.find(item => item.topic.includes('**empty**'));
|
|
|
|
newNode.data.component = {
|
|
|
|
newNode.data.component = {
|
|
|
|
type: nodeType,
|
|
|
|
type: nodeType,
|
|
|
|
customDef: { eventId: emptyEvent.id, name: emptyEvent.name, topic: emptyEvent.topic }
|
|
|
|
customDef: { eventId: emptyEvent.eventId, name: emptyEvent.name, topic: emptyEvent.topic }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 将未定义的节点动态追加进nodeTypes
|
|
|
|
// 将未定义的节点动态追加进nodeTypes
|
|
|
|
@ -1046,7 +1046,7 @@ export const useFlowCallbacks = (
|
|
|
|
// endregion
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
|
|
// 保存所有节点和边数据到服务器,更新事件相关数据
|
|
|
|
// 保存所有节点和边数据到服务器,更新事件相关数据
|
|
|
|
const updateEvent = (revertedData) => {
|
|
|
|
const updateEvent = (revertedData, appid) => {
|
|
|
|
// 初始化参数对象
|
|
|
|
// 初始化参数对象
|
|
|
|
const params: any = {
|
|
|
|
const params: any = {
|
|
|
|
eventListenes: [],
|
|
|
|
eventListenes: [],
|
|
|
|
@ -1098,8 +1098,8 @@ export const useFlowCallbacks = (
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// 调用更新事件的API
|
|
|
|
// 调用更新事件的API
|
|
|
|
if (params.eventListenes.lengrh > 0 || params.eventSends.length > 0) {
|
|
|
|
if (params.eventListenes.length > 0 || params.eventSends.length > 0) {
|
|
|
|
updateAppEvent(initialData.appId, params);
|
|
|
|
updateAppEvent(appid, params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const upDatePublish = async (revertedData) => {
|
|
|
|
const upDatePublish = async (revertedData) => {
|
|
|
|
@ -1141,21 +1141,36 @@ export const useFlowCallbacks = (
|
|
|
|
const { flowData, currentAppData } = store.getState().ideContainer;
|
|
|
|
const { flowData, currentAppData } = store.getState().ideContainer;
|
|
|
|
// console.log('revertedData:', revertedData);
|
|
|
|
// console.log('revertedData:', revertedData);
|
|
|
|
// console.log('newRevertedData:', newRevertedData);
|
|
|
|
// console.log('newRevertedData:', newRevertedData);
|
|
|
|
const params = {
|
|
|
|
let params = {};
|
|
|
|
...flowData[currentAppData.id]?.main || {},
|
|
|
|
// 更新复合组件/子流程
|
|
|
|
components: newRevertedData
|
|
|
|
if (currentAppData.key.includes('sub')) {
|
|
|
|
};
|
|
|
|
params = {
|
|
|
|
// return;
|
|
|
|
...currentAppData?.compData || {},
|
|
|
|
updateEvent(revertedData.nodeConfigs);
|
|
|
|
components: newRevertedData
|
|
|
|
// 旧版数据结构
|
|
|
|
};
|
|
|
|
// const res: any = await setMainFlow(revertedData, initialData.appId);
|
|
|
|
updateEvent(revertedData.nodeConfigs, currentAppData.parentAppId);
|
|
|
|
// 新版数据结构
|
|
|
|
const res: any = await setSubFlowNew(params, currentAppData.parentAppId);
|
|
|
|
const res: any = await setMainFlowNew(params, initialData.appId);
|
|
|
|
if (res.code === 200) {
|
|
|
|
if (res.code === 200) {
|
|
|
|
Message.success('保存成功');
|
|
|
|
Message.success('保存成功');
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
Message.error(res.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 更新主流程
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
Message.error(res.message);
|
|
|
|
params = {
|
|
|
|
|
|
|
|
...flowData[currentAppData.id]?.main || {},
|
|
|
|
|
|
|
|
components: newRevertedData
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
updateEvent(revertedData.nodeConfigs, initialData.appId);
|
|
|
|
|
|
|
|
const res: any = await setMainFlowNew(params, initialData.appId);
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
Message.success('保存成功');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
Message.error(res.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error('Error saving flow data:', error);
|
|
|
|
console.error('Error saving flow data:', error);
|
|
|
|
@ -1167,7 +1182,6 @@ export const useFlowCallbacks = (
|
|
|
|
nodes,
|
|
|
|
nodes,
|
|
|
|
edges
|
|
|
|
edges
|
|
|
|
};
|
|
|
|
};
|
|
|
|
console.log('params:', params);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [nodes, edges, initialData?.appId]);
|
|
|
|
}, [nodes, edges, initialData?.appId]);
|
|
|
|
// 运行处理函数
|
|
|
|
// 运行处理函数
|
|
|
|
|