From c93847b4822e0005afddbc75c1a99a82e4de27a3 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Thu, 12 Dec 2024 15:09:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A5=E5=85=B7=E6=A0=8F?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/NodeConfig/validate.ts | 4 +- .../Designer/components/NodePanel/types.ts | 88 ++++++------------- .../Definition/Designer/utils/graphUtils.ts | 7 +- 3 files changed, 29 insertions(+), 70 deletions(-) diff --git a/frontend/src/pages/Workflow/Definition/Designer/components/NodeConfig/validate.ts b/frontend/src/pages/Workflow/Definition/Designer/components/NodeConfig/validate.ts index 9ed7d298..23cf2ce4 100644 --- a/frontend/src/pages/Workflow/Definition/Designer/components/NodeConfig/validate.ts +++ b/frontend/src/pages/Workflow/Definition/Designer/components/NodeConfig/validate.ts @@ -1,6 +1,6 @@ import Ajv from 'ajv'; import addFormats from 'ajv-formats'; -import { NodeType } from '../../../../types'; +import {NodeTypeEnum} from "@/pages/Workflow/Definition/Designer/components/NodePanel/types"; const ajv = new Ajv({ allErrors: true, @@ -17,7 +17,7 @@ export interface ValidationResult { } export const validateNodeConfig = ( - nodeType: NodeType, + nodeType: NodeTypeEnum, formData: any ): ValidationResult => { console.log('Validating node config:', { nodeType, formData }); diff --git a/frontend/src/pages/Workflow/Definition/Designer/components/NodePanel/types.ts b/frontend/src/pages/Workflow/Definition/Designer/components/NodePanel/types.ts index b0dc0296..7e3e94d7 100644 --- a/frontend/src/pages/Workflow/Definition/Designer/components/NodePanel/types.ts +++ b/frontend/src/pages/Workflow/Definition/Designer/components/NodePanel/types.ts @@ -1,5 +1,4 @@ import { BaseResponse } from '@/types/base/response'; -import { NodeGraph } from '../../../types'; /** * 节点样式 @@ -16,83 +15,48 @@ export interface NodeStyle { * 节点类别 */ export enum NodeCategory { - EVENT = 'EVENT', // 事件节点 - TASK = 'TASK', // 任务节点 - GATEWAY = 'GATEWAY', // 网关节点 - CONTAINER = 'CONTAINER' // 容器节点 + EVENT = 'EVENT', // 事件节点 + TASK = 'TASK', // 任务节点 + GATEWAY = 'GATEWAY', // 网关节点 + CONTAINER = 'CONTAINER' // 容器节点 } /** * 节点类型 */ export enum NodeTypeEnum { - START_EVENT = 'START_EVENT', // 开始节点 - END_EVENT = 'END_EVENT', // 结束节点 - USER_TASK = 'USER_TASK', // 用户任务 - SERVICE_TASK = 'SERVICE_TASK', // 服务任务 - SCRIPT_TASK = 'SCRIPT_TASK', // 脚本任务 - EXCLUSIVE_GATEWAY = 'EXCLUSIVE_GATEWAY', // 排他网关 - PARALLEL_GATEWAY = 'PARALLEL_GATEWAY', // 并行网关 - SUB_PROCESS = 'SUB_PROCESS', // 子流程 - CALL_ACTIVITY = 'CALL_ACTIVITY' // 调用活动 -} - -/** - * 节点详情 - */ -export interface NodeDetails { - description: string; // 详细描述 - features: string[]; // 功能特性 - scenarios: string[]; // 使用场景 -} - -/** - * JSON Schema属性 - */ -export interface JsonSchemaProperty { - type: string; - title: string; - description: string; - format?: string; - default?: any; - enum?: string[]; - enumNames?: string[]; -} - -/** - * 节点配置Schema - */ -export interface NodeConfigSchema { - type: string; - properties: Record; - required: string[]; + START_EVENT = 'START_EVENT', // 开始节点 + END_EVENT = 'END_EVENT', // 结束节点 + USER_TASK = 'USER_TASK', // 用户任务 + SERVICE_TASK = 'SERVICE_TASK', // 服务任务 + SCRIPT_TASK = 'SCRIPT_TASK', // 脚本任务 + EXCLUSIVE_GATEWAY = 'EXCLUSIVE_GATEWAY', // 排他网关 + PARALLEL_GATEWAY = 'PARALLEL_GATEWAY', // 并行网关 + SUB_PROCESS = 'SUB_PROCESS', // 子流程 + CALL_ACTIVITY = 'CALL_ACTIVITY' // 调用活动 } /** * 节点图形配置 */ export interface NodeGraphConfig { - code: string; // 节点代码 - name: string; // 节点名称 - description: string; // 节点描述 - details: NodeDetails; // 节点详情 - configSchema: NodeConfigSchema; // 配置模式 - uiSchema: NodeGraph; // UI渲染模式 + style: NodeStyle; // 节点样式 + ports?: any[]; // 连接点配置 + shape?: string; // 节点形状 } /** * 节点类型定义 */ export interface NodeType extends BaseResponse { - type: NodeTypeEnum; // 节点类型 - name: string; // 节点名称 - description: string; // 节点描述 - category: NodeCategory; // 节点分类 - flowableConfig: any; // 工作流引擎配置 - graphConfig: NodeGraphConfig; // 图形配置 - style: NodeStyle; // 节点样式 - orderNum: number; // 排序号 - enabled: boolean; // 是否启用 - deleted: boolean; // 是否删除 - extraData: any; // 扩展数据 + type: NodeTypeEnum; // 节点类型 + name: string; // 节点名称 + description: string; // 节点描述 + category: NodeCategory; // 节点分类 + graphConfig: NodeGraphConfig; // 图形配置 + style?: NodeStyle; // 兼容旧版本的样式配置 + orderNum: number; // 排序号 + enabled: boolean; // 是否启用 + deleted: boolean; // 是否删除 + extraData: any; // 扩展数据 } diff --git a/frontend/src/pages/Workflow/Definition/Designer/utils/graphUtils.ts b/frontend/src/pages/Workflow/Definition/Designer/utils/graphUtils.ts index 07de3e8c..ac0fb661 100644 --- a/frontend/src/pages/Workflow/Definition/Designer/utils/graphUtils.ts +++ b/frontend/src/pages/Workflow/Definition/Designer/utils/graphUtils.ts @@ -8,13 +8,8 @@ import { Snapline } from '@antv/x6-plugin-snapline'; import { MiniMap } from '@antv/x6-plugin-minimap'; import { NodeData, - EdgeData, - WorkflowDefinition, - GraphData, - EdgeStyle, - NodeType } from '../types'; -import { generateNodeStyle, generatePorts } from './nodeUtils'; +import {WorkflowDefinition} from "@/pages/Workflow/Definition/types"; // Initialize graph with enhanced configuration export const initGraph = ({