可正常保存流程
This commit is contained in:
parent
1d222da2dc
commit
42ad69abb5
@ -65,6 +65,7 @@ const FlowDesigner: React.FC<FlowDesignerProps> = ({
|
||||
color: '#000000',
|
||||
},
|
||||
edgeText: {
|
||||
textWidth: 100,
|
||||
fontSize: 12,
|
||||
color: '#000000',
|
||||
background: {
|
||||
@ -110,7 +111,14 @@ const FlowDesigner: React.FC<FlowDesignerProps> = ({
|
||||
// 注册事件
|
||||
logicflow.on('node:click', ({ data }) => {
|
||||
console.log('Node clicked:', data);
|
||||
setSelectedNode(data);
|
||||
const nodeModel = logicflow.getNodeModelById(data.id);
|
||||
const nodeData = {
|
||||
id: data.id,
|
||||
type: data.type,
|
||||
text: data.text,
|
||||
properties: nodeModel.getProperties()
|
||||
};
|
||||
setSelectedNode(nodeData);
|
||||
});
|
||||
|
||||
logicflow.on('blank:click', () => {
|
||||
@ -161,7 +169,9 @@ const FlowDesigner: React.FC<FlowDesignerProps> = ({
|
||||
// 处理节点配置更新
|
||||
const handleNodeConfigSave = (config: any) => {
|
||||
if (lf && selectedNode) {
|
||||
lf.setProperties(selectedNode.id, config);
|
||||
const nodeModel = lf.getNodeModelById(selectedNode.id);
|
||||
nodeModel.updateText(config.text.value);
|
||||
nodeModel.setProperties(config);
|
||||
setSelectedNode(null);
|
||||
|
||||
// 触发 onChange
|
||||
|
||||
@ -5,7 +5,12 @@ import type { BaseNodeModel } from '@logicflow/core';
|
||||
type NodeType = 'start' | 'end' | 'task' | 'gateway';
|
||||
|
||||
interface NodeConfigProps {
|
||||
node: BaseNodeModel & { type: NodeType };
|
||||
node: {
|
||||
id: string;
|
||||
type: NodeType;
|
||||
text?: { value: string; x: number; y: number };
|
||||
properties?: Record<string, any>;
|
||||
};
|
||||
onSave: (config: any) => void;
|
||||
onCancel: () => void;
|
||||
}
|
||||
@ -31,7 +36,7 @@ const NodeConfig: React.FC<NodeConfigProps> = ({
|
||||
layout="vertical"
|
||||
initialValues={{
|
||||
text: node.text?.value,
|
||||
...node.getProperties()
|
||||
...node.properties
|
||||
}}
|
||||
onFinish={handleFinish}
|
||||
>
|
||||
|
||||
@ -5,7 +5,7 @@ import { useNavigate, useParams } from 'react-router-dom';
|
||||
import FlowDesigner from './components/FlowDesigner';
|
||||
import FormDesigner from './components/FormDesigner';
|
||||
import { getDefinition, createDefinition, updateDefinition } from '../../service';
|
||||
import type { WorkflowDefinitionRequest } from '../../types';
|
||||
import type { WorkflowDefinitionRequest, WorkflowStatus } from '../../types';
|
||||
|
||||
const Edit: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
@ -43,7 +43,9 @@ const Edit: React.FC = () => {
|
||||
formDefinition: formData,
|
||||
nodeConfig: '{}',
|
||||
transitionConfig: '{}',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
version: 1,
|
||||
status: 'DRAFT' as WorkflowStatus
|
||||
};
|
||||
|
||||
if (id) {
|
||||
@ -56,6 +58,7 @@ const Edit: React.FC = () => {
|
||||
navigate('/workflow/definition');
|
||||
} catch (error) {
|
||||
console.error('Save failed:', error);
|
||||
message.error('保存失败');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -56,16 +56,16 @@ export interface WorkflowDefinition {
|
||||
formDefinition: string;
|
||||
graphDefinition: string;
|
||||
enabled: boolean;
|
||||
version: number;
|
||||
status: WorkflowStatus;
|
||||
remark?: string;
|
||||
status?: WorkflowStatus;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
// 工作流定义响应数据
|
||||
export interface WorkflowDefinitionResponse extends BaseResponse, Omit<WorkflowDefinition, 'id' | 'status' | 'createTime' | 'updateTime'> {
|
||||
export interface WorkflowDefinitionResponse extends BaseResponse, WorkflowDefinition {
|
||||
id: number;
|
||||
status: WorkflowStatus;
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
}
|
||||
@ -78,16 +78,8 @@ export interface WorkflowDefinitionQuery extends BaseQuery {
|
||||
}
|
||||
|
||||
// 工作流定义请求数据
|
||||
export interface WorkflowDefinitionRequest {
|
||||
code: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
nodeConfig: string;
|
||||
transitionConfig: string;
|
||||
formDefinition: string;
|
||||
graphDefinition: string;
|
||||
enabled: boolean;
|
||||
remark?: string;
|
||||
export interface WorkflowDefinitionRequest extends Omit<WorkflowDefinition, 'id' | 'createTime' | 'updateTime'> {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
// 节点定义响应数据
|
||||
|
||||
Loading…
Reference in New Issue
Block a user