Skip to content

FlowEditor

流程编辑器组件,基于 Vue Flow 实现,用于可视化流程设计。

基本用法

json
{
  "com": "FlowEditor",
  "model": "flowData"
}

Props

属性类型默认值说明
value / v-modelobject-流程数据
readonlybooleanfalse是否只读
heightstring'500px'编辑器高度

数据结构

typescript
interface FlowData {
  nodes: Node[]
  edges: Edge[]
}

interface Node {
  id: string
  type: string
  position: { x: number, y: number }
  data: { label: string, [key: string]: any }
}

interface Edge {
  id: string
  source: string
  target: string
  type?: string
}

示例

基本使用

json
{
  "data": {
    "flowData": {
      "nodes": [
        { "id": "1", "type": "input", "position": { "x": 250, "y": 0 }, "data": { "label": "开始" } },
        { "id": "2", "type": "default", "position": { "x": 250, "y": 100 }, "data": { "label": "处理" } },
        { "id": "3", "type": "output", "position": { "x": 250, "y": 200 }, "data": { "label": "结束" } }
      ],
      "edges": [
        { "id": "e1-2", "source": "1", "target": "2" },
        { "id": "e2-3", "source": "2", "target": "3" }
      ]
    }
  },
  "com": "FlowEditor",
  "model": "flowData",
  "props": { "height": "600px" }
}

只读模式

json
{
  "com": "FlowEditor",
  "props": {
    "value": "{{ flowData }}",
    "readonly": true
  }
}

在卡片中使用

json
{
  "com": "NCard",
  "props": { "title": "流程设计" },
  "children": [
    {
      "com": "FlowEditor",
      "model": "flowData",
      "props": { "height": "500px" }
    }
  ]
}

功能特性

  • 拖拽添加节点
  • 连接节点
  • 缩放和平移
  • 小地图
  • 控制面板
  • 自定义节点类型

基于 MIT 许可发布