From 3315114522d002579c20cd3038e85e88a11818c2 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Mon, 20 Oct 2025 21:58:31 +0800 Subject: [PATCH] 1 --- .../Design/components/NodeConfigModal.tsx | 315 ++++++++---------- .../Workflow2/Design/components/NodePanel.tsx | 110 ++---- .../Design/components/PropertyPanel.tsx | 238 ------------- frontend/src/pages/Workflow2/Design/index.tsx | 88 ++--- .../Design/nodes/definitions/DeployNode.ts | 189 +++++++++++ .../Design/nodes/definitions/EndEventNode.ts | 56 ++++ .../nodes/definitions/ServiceTaskNode.ts | 180 ++++++++++ .../nodes/definitions/StartEventNode.ts | 56 ++++ .../Design/nodes/definitions/UserTaskNode.ts | 155 +++++++++ .../Design/nodes/definitions/index.ts | 29 ++ .../src/pages/Workflow2/Design/nodes/types.ts | 99 ++++++ frontend/src/pages/Workflow2/Design/types.ts | 15 +- 12 files changed, 968 insertions(+), 562 deletions(-) delete mode 100644 frontend/src/pages/Workflow2/Design/components/PropertyPanel.tsx create mode 100644 frontend/src/pages/Workflow2/Design/nodes/definitions/DeployNode.ts create mode 100644 frontend/src/pages/Workflow2/Design/nodes/definitions/EndEventNode.ts create mode 100644 frontend/src/pages/Workflow2/Design/nodes/definitions/ServiceTaskNode.ts create mode 100644 frontend/src/pages/Workflow2/Design/nodes/definitions/StartEventNode.ts create mode 100644 frontend/src/pages/Workflow2/Design/nodes/definitions/UserTaskNode.ts create mode 100644 frontend/src/pages/Workflow2/Design/nodes/definitions/index.ts create mode 100644 frontend/src/pages/Workflow2/Design/nodes/types.ts diff --git a/frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx b/frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx index 4bfc14f4..9fe0b22c 100644 --- a/frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx +++ b/frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx @@ -1,7 +1,11 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Form, Input, Tabs, Card, Button, Space, message } from 'antd'; +import { Modal, Tabs, Button, Space, message } from 'antd'; import { SaveOutlined, ReloadOutlined } from '@ant-design/icons'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { convertJsonSchemaToColumns } from '@/utils/jsonSchemaUtils'; import type { FlowNode, FlowNodeData } from '../types'; +import type { WorkflowNodeDefinition } from '../nodes/types'; +import { isConfigurableNode } from '../nodes/types'; interface NodeConfigModalProps { visible: boolean; @@ -10,7 +14,11 @@ interface NodeConfigModalProps { onOk: (nodeId: string, updatedData: Partial) => void; } -const { TextArea } = Input; +interface FormData { + configs?: Record; + inputMapping?: Record; + outputMapping?: Record; +} const NodeConfigModal: React.FC = ({ visible, @@ -18,187 +26,176 @@ const NodeConfigModal: React.FC = ({ onCancel, onOk }) => { - const [form] = Form.useForm(); const [loading, setLoading] = useState(false); - const [activeTab, setActiveTab] = useState('basic'); + const [activeTab, setActiveTab] = useState('config'); + const [formData, setFormData] = useState({}); + + // 获取节点定义 + const nodeDefinition: WorkflowNodeDefinition | null = node?.data?.nodeDefinition || null; - // 重置表单数据 useEffect(() => { - if (visible && node) { - form.setFieldsValue({ - label: node.data.label, - description: node.data.nodeDefinition?.description || '', - // 基础配置 - timeout: node.data.configs?.timeout || 3600, - retryCount: node.data.configs?.retryCount || 0, - priority: node.data.configs?.priority || 'normal', - // 输入映射 - inputMapping: JSON.stringify(node.data.inputMapping || {}, null, 2), - // 输出映射 - outputMapping: JSON.stringify(node.data.outputMapping || {}, null, 2), + if (visible && node && nodeDefinition) { + // 从节点数据中获取现有配置 + const nodeData = node.data || {}; + + // 准备默认的基本信息配置 + const defaultConfig = { + nodeName: nodeDefinition.nodeName, // 默认节点名称 + nodeCode: nodeDefinition.nodeCode, // 默认节点编码 + description: nodeDefinition.description // 默认节点描述 + }; + + // 合并默认值和已保存的配置 + setFormData({ + configs: { ...defaultConfig, ...(nodeData.configs || {}) }, + inputMapping: nodeData.inputMapping || {}, + outputMapping: nodeData.outputMapping || {}, }); } else { - form.resetFields(); + setFormData({}); } - }, [visible, node, form]); + }, [visible, node, nodeDefinition]); - const handleSubmit = async () => { + const handleSubmit = () => { if (!node) return; - + try { - const values = await form.validateFields(); setLoading(true); - // 解析JSON字符串 - let inputMapping = {}; - let outputMapping = {}; - - try { - inputMapping = values.inputMapping ? JSON.parse(values.inputMapping) : {}; - } catch (error) { - message.error('输入映射JSON格式错误'); - return; - } - - try { - outputMapping = values.outputMapping ? JSON.parse(values.outputMapping) : {}; - } catch (error) { - message.error('输出映射JSON格式错误'); - return; - } - const updatedData: Partial = { - label: values.label, - configs: { - ...node.data.configs, - timeout: values.timeout, - retryCount: values.retryCount, - priority: values.priority, - }, - inputMapping, - outputMapping, + // 更新节点标签为配置中的节点名称 + label: formData.configs?.nodeName || node.data.label, + configs: formData.configs, + inputMapping: formData.inputMapping, + outputMapping: formData.outputMapping, }; onOk(node.id, updatedData); message.success('节点配置保存成功'); onCancel(); } catch (error) { - console.error('保存节点配置失败:', error); + if (error instanceof Error) { + message.error(error.message); + } } finally { setLoading(false); } }; const handleReset = () => { - form.resetFields(); - if (node) { - form.setFieldsValue({ - label: node.data.label, - description: node.data.nodeDefinition?.description || '', - timeout: 3600, - retryCount: 0, - priority: 'normal', - inputMapping: '{}', - outputMapping: '{}', + if (nodeDefinition) { + const defaultConfig = { + nodeName: nodeDefinition.nodeName, + nodeCode: nodeDefinition.nodeCode, + description: nodeDefinition.description + }; + + setFormData({ + configs: defaultConfig, + inputMapping: {}, + outputMapping: {}, }); } }; - const renderBasicConfig = () => ( - - - - + const handleConfigChange = (values: Record) => { + setFormData(prev => ({ + ...prev, + configs: values + })); + }; - -