This commit is contained in:
dengqichen 2024-12-20 14:04:55 +08:00
parent 091ea4fe7b
commit e76af9b8f5
3 changed files with 122 additions and 129 deletions

View File

@ -184,7 +184,6 @@ const WorkflowDesign: React.FC = () => {
const history = new History({
enabled: true,
beforeAddCommand(event: any, args: any) {
console.log('History command added:', event, args);
return true;
},
afterExecuteCommand: () => {
@ -216,9 +215,7 @@ const WorkflowDesign: React.FC = () => {
showAnchorSelectionBox: false,
pointerEvents: 'auto'
});
console.log('Initializing Selection plugin:', selection);
graph.use(selection);
graph.use(new MiniMap({
container: minimapContainerRef.current!,
width: minimapWidth,
@ -238,12 +235,7 @@ const WorkflowDesign: React.FC = () => {
async: true,
frozen: true,
interacting: false,
grid: false,
getCellView(cell) {
if (cell.isNode()) {
return SimpleNodeView;
}
},
grid: false
},
viewport: {
padding: 0,
@ -271,12 +263,6 @@ const WorkflowDesign: React.FC = () => {
graph.on('cell:added', ({cell}) => {
const canUndo = history.canUndo();
const canRedo = history.canRedo();
console.log('Cell added:', {
cell,
canUndo,
canRedo,
stackSize: history.stackSize,
});
// 强制更新组件状态
setForceUpdate(prev => !prev);
});
@ -297,13 +283,6 @@ const WorkflowDesign: React.FC = () => {
graph.on('cell:changed', ({cell, options}) => {
const canUndo = history.canUndo();
const canRedo = history.canRedo();
console.log('Cell changed:', {
cell,
options,
canUndo,
canRedo,
stackSize: history.stackSize,
});
// 强制更新组件状态
setForceUpdate(prev => !prev);
});
@ -944,7 +923,7 @@ const WorkflowDesign: React.FC = () => {
response.graph?.nodes?.forEach((workflowDefinitionNode: any) => {
const node = addNodeToGraph(false, graphInstance, workflowDefinitionNode, nodeDefinitions);
// 保存节点配置
node.setProp('config', workflowDefinitionNode.config);
node.setProp('workflowDefinitionNode', workflowDefinitionNode);
nodeMap.set(workflowDefinitionNode.id, node);
});
@ -1060,6 +1039,7 @@ const WorkflowDesign: React.FC = () => {
const handleNodeConfigUpdate = (values: any) => {
if (!selectedNode) return;
// 更新节点配置
console.log("// 更新节点配置", values);
selectedNode.setProp('config', values);
// 更新节点显示名称
if (values.name) {
@ -1094,17 +1074,18 @@ const WorkflowDesign: React.FC = () => {
type: nodeType,
name: node.attr('label/text'),
graph: {
shape: nodeDefinition?.graphConfig.uiSchema.shape,
size: {
width: node.size().width,
height: node.size().height
},
style: nodeDefinition?.graphConfig.uiSchema.style,
ports: nodeDefinition?.graphConfig.uiSchema.ports,
position: {
x: position.x,
y: position.y
}
// shape: nodeDefinition?.graphConfig.uiSchema.shape,
// size: {
// width: node.size().width,
// height: node.size().height
// },
// style: nodeDefinition?.graphConfig.uiSchema.style,
// ports: nodeDefinition?.graphConfig.uiSchema.ports,
// position: {
// x: position.x,
// y: position.y
// }
uiVariables: nodeDefinition.uiVariables
},
config: node.getProp('config') || {}
};

View File

@ -108,6 +108,7 @@ const validateAllNodesConfig = (graph: Graph): ValidationResult => {
for (const node of nodes) {
const nodeDefinition = node.getProp('nodeDefinition');
console.log(nodeDefinition)
const result = validateNodeConfig(node, nodeDefinition);
if (!result.valid) {
return result;

View File

@ -10,7 +10,7 @@ export interface WorkflowDefinition extends BaseResponse {
category: string;
triggers: string[];
graph: {
nodes: any[];
nodes: WorkflowDefinitionNode[];
edges: any[];
};
formConfig: {
@ -18,6 +18,17 @@ export interface WorkflowDefinition extends BaseResponse {
};
}
export interface WorkflowDefinitionNode {
id: number;
code: string;
type: string;
name: string;
uiVariables: JSON;
panelVariables: JSON;
localVariables: JSON;
formVariables: JSON;
}
export interface WorkflowDefinitionQuery extends BaseQuery {
name?: string;
key?: string;