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