0.1.22 • Published 9 months ago

model-logic-dag v0.1.22

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

model-logic-DAG

这是一个可用于模型、服务链式调用配置的DAG工具

Install

npm i model-logic-dag --save

Usage

在页面中使用

.vue file:

<ModelDAG
  ref="modelDAG"
  :stencils="stencils"
  :links="links"
></ModelDAG>
import ModelDAG from 'model-logic-dag'
export default {
  components: { ModelDAG }
}

Attributes

参数说明类型可选值默认值
preview预览模式Booleantrue | falsefalse
stencils工具栏元素数据Arraystencil-[]
links元素连接线限制关系Arraylink-[]
linksLimit是否开启元素连线关系限制,默认开启,需要传入links,存在links中的关系才允许被连线,为falselinks参数无效Boolean-true
background画布背景Object-{}
grid画布网格Object-{}

stencils示例

// item[].type 有以下类型
//   start |   end   |   model  |   rhombus  | logic
// 开始节点 | 结束节点 | 原子能力 | 菱形逻辑节点 | 逻辑节点
[
  {
    groupName: '原子能力',
    id: '1',
    items: [
      {
        label: '人头检测',
        type: 'model' //元素类型 默认为model
      },
      {
        label: '现金检测',
        type: 'model'
      },
      {
        label: '火焰检测',
        type: 'model'
      }
    ]
  },
  {
    groupName: '通用组件',
    id: '2',
    items: [
      {
        label: '逻辑判断',
        type: 'rhombus'
      }
    ]
  }
]

links示例

[
  {
    target: '2',
    source: '1'
  }
]

一组link包含一个source和一个target,当关系存在于links中时,连线关系才可以被建立,否则无法连接元素

Events

事件名说明回调参数
link-click点击关系线时触发({link, sourceNode, targetNode})
node-click点击节点时触发({node, inputNodes, outputNodes})
node-add节点被添加到画布时触发(node)
linked边连接时出发({edge, sourceNode, targetNode})
cell-remove节点、边被删除时触发({ cell, index, options })

Methods

clear()

清空画布

layout(...)

名称类型是否必填可选值默认值描述
cellsDataObject--需要被展示的元素数据
cellsData.nodesArray--需要被展示的元素节点数据
cellsData.edgesArray--需要被展示的元素边数据
nodes.idString--元素节点的ID
nodes.labelString--节点标签文字
nodes.typeString'model' | 'begin' | 'rhombus'-节点的类型
edge.sourceString--边的起始节点ID
edge.targetString--边的目标节点ID
edge.sourcePositionString'left' | 'top'right边的起始点位于元素的位置
edge.targetPositionString'right' | 'bottom'left边的目标点位于元素的位置
{
  nodes: [
    {
      id: '原子能力1',
      label: '原子能力1',
      type: 'model' // model为方形元素,通常用于原子能力
    },
    {
      id: '原子能力2',
      label: '原子能力2',
      type: 'model'
    },
    {
      id: '逻辑组件1',
      label: '逻辑组件',
      type: 'rhombus',  // rhombus为菱形元素,通常用于逻辑判断
    }
  ],
  edges: [
    {
      source: 'begin-node',
      target: '原子能力1',
      sourcePosition: 'right',
      targetPosition: 'left'
    },
    {
      source: 'begin-node',
      target: '原子能力2'
    },
    {
      source: '原子能力1',
      target: '逻辑组件1'
    },
    {
      source: '原子能力2',
      target: '逻辑组件1'
    }
  ]
}

setEdgeStatus()

设置边的状态

名称类型是否必填可选值默认值描述
edgeObject--需要被修改的边
statusStringsuccess | fail-状态,也可以直接传入颜色来设置

toGraphJSON()

获取画布数据,用于还原画布

fromGraphJSON(...)

导入画布数据,还原画布

名称类型是否必填可选值默认值描述
cellsArray--导入画布数据,还原画布,数据来源一般为toGraphJSON中获取的数据

getData()

获取业务数据

getCellById()

根据cell.id获取cell数据

0.1.20

9 months ago

0.1.21

9 months ago

0.1.22

9 months ago

0.1.10

10 months ago

0.1.11

10 months ago

0.1.12

10 months ago

0.1.13

10 months ago

0.1.14

10 months ago

0.1.15

10 months ago

0.1.16

9 months ago

0.1.8

10 months ago

0.1.17

9 months ago

0.1.7

12 months ago

0.1.18

9 months ago

0.1.19

9 months ago

0.1.9

10 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago