Flow 流程

常用的流程组件

<!-- 导入需要的包 (一定要放到index.html中的head标签里-->
<script src="https://cdn.staticfile.org/jsPlumb/2.11.1/js/jsplumb.min.js"></script>


自定义头部
自定义流程A-节点A
自定义头部
自定义流程A-节点B
自定义头部
自定义流程A-节点C
自定义头部
自定义节点D

点击线条即可删除线条

<template>
  <el-button type="primary"
             @click="$refs.flow.addNode('测试节点')">添加节点</el-button>
  <el-button type="primary"
             @click="handleNext">下一个节点</el-button>
  <br /><br />
  <avue-flow :height="600"
             :width="1200"
             ref="flow"
             :option="option"
             v-model="form">
    <template #header="{node}">
      <i class="el-icon-delete"
         @click="$refs.flow.deleteNode(node.id)"></i>
      自定义头部
    </template>
    <template #="{node}">
      <span>自定义{{(node || {}).name}}</span>
    </template>
  </avue-flow>
</template>
<script>

export default {
  data () {
    return {
      count: 0,
      form: '',
      option: {
        "name": "流程A",
        "nodeList": [
          {
            "id": "nodeA",
            "name": "流程A-节点A",
            "left": 39,
            "top": 110,
          },
          {
            "id": "nodeB",
            "name": "流程A-节点B",
            "left": 340,
            "top": 161,
          },
          {
            "id": "nodeC",
            "name": "流程A-节点C",
            "left": 739,
            "top": 161,
          },
          {
            "id": "nodeD",
            "name": "节点D",
            "left": 739,
            "top": 20,
          }
        ],
        "lineList": [
          {
            "from": "nodeA",
            "to": "nodeB"
          },
          {
            "from": "nodeB",
            "to": "nodeC"
          },
          {
            "from": "nodeC",
            "to": "nodeD"
          }
        ]
      }
    }
  },
  computed: {
    nodeList () {
      return this.option.nodeList
    }
  },
  mounted () {
    this.form = this.nodeList[this.count].id;
  },
  methods: {
    handleClick (node) {
      this.$message.success(JSON.stringify(node))
    },
    handleNext () {
      this.count++
      if (this.count >= this.nodeList.length) {
        this.count = 0;
      }
      this.form = this.nodeList[this.count].id;
    }
  }


}
</script>
显示代码

Variables

参数说明类型可选值默认值
width画布宽度Number--
height画布高度Number--
option属性配置Object--

Events

事件名说明参数
click节点点击事件node

Methods

方法名说明参数
nodeAdd节点新增name
deleteNode节点删除id
Last Updated:
Contributors: smallwei
您正在浏览基于Avue 3.x文档; 点击这里 查看Avue 2.x 的文档