1
This commit is contained in:
parent
091ea4fe7b
commit
e76af9b8f5
@ -184,7 +184,6 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
const history = new History({
|
const history = new History({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
beforeAddCommand(event: any, args: any) {
|
beforeAddCommand(event: any, args: any) {
|
||||||
console.log('History command added:', event, args);
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
afterExecuteCommand: () => {
|
afterExecuteCommand: () => {
|
||||||
@ -216,9 +215,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
showAnchorSelectionBox: false,
|
showAnchorSelectionBox: false,
|
||||||
pointerEvents: 'auto'
|
pointerEvents: 'auto'
|
||||||
});
|
});
|
||||||
console.log('Initializing Selection plugin:', selection);
|
|
||||||
graph.use(selection);
|
graph.use(selection);
|
||||||
|
|
||||||
graph.use(new MiniMap({
|
graph.use(new MiniMap({
|
||||||
container: minimapContainerRef.current!,
|
container: minimapContainerRef.current!,
|
||||||
width: minimapWidth,
|
width: minimapWidth,
|
||||||
@ -238,12 +235,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
async: true,
|
async: true,
|
||||||
frozen: true,
|
frozen: true,
|
||||||
interacting: false,
|
interacting: false,
|
||||||
grid: false,
|
grid: false
|
||||||
getCellView(cell) {
|
|
||||||
if (cell.isNode()) {
|
|
||||||
return SimpleNodeView;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
viewport: {
|
viewport: {
|
||||||
padding: 0,
|
padding: 0,
|
||||||
@ -271,12 +263,6 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
graph.on('cell:added', ({cell}) => {
|
graph.on('cell:added', ({cell}) => {
|
||||||
const canUndo = history.canUndo();
|
const canUndo = history.canUndo();
|
||||||
const canRedo = history.canRedo();
|
const canRedo = history.canRedo();
|
||||||
console.log('Cell added:', {
|
|
||||||
cell,
|
|
||||||
canUndo,
|
|
||||||
canRedo,
|
|
||||||
stackSize: history.stackSize,
|
|
||||||
});
|
|
||||||
// 强制更新组件状态
|
// 强制更新组件状态
|
||||||
setForceUpdate(prev => !prev);
|
setForceUpdate(prev => !prev);
|
||||||
});
|
});
|
||||||
@ -297,13 +283,6 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
graph.on('cell:changed', ({cell, options}) => {
|
graph.on('cell:changed', ({cell, options}) => {
|
||||||
const canUndo = history.canUndo();
|
const canUndo = history.canUndo();
|
||||||
const canRedo = history.canRedo();
|
const canRedo = history.canRedo();
|
||||||
console.log('Cell changed:', {
|
|
||||||
cell,
|
|
||||||
options,
|
|
||||||
canUndo,
|
|
||||||
canRedo,
|
|
||||||
stackSize: history.stackSize,
|
|
||||||
});
|
|
||||||
// 强制更新组件状态
|
// 强制更新组件状态
|
||||||
setForceUpdate(prev => !prev);
|
setForceUpdate(prev => !prev);
|
||||||
});
|
});
|
||||||
@ -944,7 +923,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
response.graph?.nodes?.forEach((workflowDefinitionNode: any) => {
|
response.graph?.nodes?.forEach((workflowDefinitionNode: any) => {
|
||||||
const node = addNodeToGraph(false, graphInstance, workflowDefinitionNode, nodeDefinitions);
|
const node = addNodeToGraph(false, graphInstance, workflowDefinitionNode, nodeDefinitions);
|
||||||
// 保存节点配置
|
// 保存节点配置
|
||||||
node.setProp('config', workflowDefinitionNode.config);
|
node.setProp('workflowDefinitionNode', workflowDefinitionNode);
|
||||||
nodeMap.set(workflowDefinitionNode.id, node);
|
nodeMap.set(workflowDefinitionNode.id, node);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1060,6 +1039,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
const handleNodeConfigUpdate = (values: any) => {
|
const handleNodeConfigUpdate = (values: any) => {
|
||||||
if (!selectedNode) return;
|
if (!selectedNode) return;
|
||||||
// 更新节点配置
|
// 更新节点配置
|
||||||
|
console.log("// 更新节点配置", values);
|
||||||
selectedNode.setProp('config', values);
|
selectedNode.setProp('config', values);
|
||||||
// 更新节点显示名称
|
// 更新节点显示名称
|
||||||
if (values.name) {
|
if (values.name) {
|
||||||
@ -1094,17 +1074,18 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
type: nodeType,
|
type: nodeType,
|
||||||
name: node.attr('label/text'),
|
name: node.attr('label/text'),
|
||||||
graph: {
|
graph: {
|
||||||
shape: nodeDefinition?.graphConfig.uiSchema.shape,
|
// shape: nodeDefinition?.graphConfig.uiSchema.shape,
|
||||||
size: {
|
// size: {
|
||||||
width: node.size().width,
|
// width: node.size().width,
|
||||||
height: node.size().height
|
// height: node.size().height
|
||||||
},
|
// },
|
||||||
style: nodeDefinition?.graphConfig.uiSchema.style,
|
// style: nodeDefinition?.graphConfig.uiSchema.style,
|
||||||
ports: nodeDefinition?.graphConfig.uiSchema.ports,
|
// ports: nodeDefinition?.graphConfig.uiSchema.ports,
|
||||||
position: {
|
// position: {
|
||||||
x: position.x,
|
// x: position.x,
|
||||||
y: position.y
|
// y: position.y
|
||||||
}
|
// }
|
||||||
|
uiVariables: nodeDefinition.uiVariables
|
||||||
},
|
},
|
||||||
config: node.getProp('config') || {}
|
config: node.getProp('config') || {}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -108,6 +108,7 @@ const validateAllNodesConfig = (graph: Graph): ValidationResult => {
|
|||||||
|
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
const nodeDefinition = node.getProp('nodeDefinition');
|
const nodeDefinition = node.getProp('nodeDefinition');
|
||||||
|
console.log(nodeDefinition)
|
||||||
const result = validateNodeConfig(node, nodeDefinition);
|
const result = validateNodeConfig(node, nodeDefinition);
|
||||||
if (!result.valid) {
|
if (!result.valid) {
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export interface WorkflowDefinition extends BaseResponse {
|
|||||||
category: string;
|
category: string;
|
||||||
triggers: string[];
|
triggers: string[];
|
||||||
graph: {
|
graph: {
|
||||||
nodes: any[];
|
nodes: WorkflowDefinitionNode[];
|
||||||
edges: any[];
|
edges: any[];
|
||||||
};
|
};
|
||||||
formConfig: {
|
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 {
|
export interface WorkflowDefinitionQuery extends BaseQuery {
|
||||||
name?: string;
|
name?: string;
|
||||||
key?: string;
|
key?: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user