【Vue + Antv X6】可拖拽流程图组件

使用事项:

❗先放个组件上来,使用手册有空会补全

❗需要下载依赖

"@antv/x6": "^2.18.1",

"@antv/x6-plugin-dnd": "^2.1.1",

组件:

组件使用:

html 复制代码
  <flowChart :key="flowChartKey" ref="flowChart" left-title="可用工序" :node-list="nodeList" :graph-data="dataJson"
             :drawer-config="drawerConfig" :line-drawer-config="lineDrawerConfig"
              route-record-type="2" route-record-label="procedureName" route-record-key="procedureId"/>
javascript 复制代码
      nodeList: [],
      dataJson: {},
      drawerConfig: [
        {
          type: undefined,
          prop: 'procedureId'
        },
        {
          type: 'input',
          label: '工序名称',
          prop: 'procedureName',
          placeholder: '请输入工序名称',
          disabled: true
        },
        {
          type: 'input',
          label: '工序编号',
          prop: 'procedureCode',
          placeholder: '请输入工序编号',
          disabled: true
        },
        {
          type: 'selectDict',
          label: '工序类型',
          prop: 'procedureType',
          placeholder: '请选择工序类型',
          dictType: 'MES_GXLX',
          disabled: true
        }
      ],
      lineDrawerConfig: [
        {
          type: undefined,
          prop: 'procedureId'
        },
        {
          type: 'input',
          label: '起始工序',
          prop: 'startProcedureName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'input',
          label: '下道工序',
          prop: 'endProcedureName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'selectRoute',
          label: '记录工序',
          prop: 'recordProcedure',
          placeholder: '请选择',
          options: [],
          disabled: false
        }
      ]
javascript 复制代码
     // 获取节点数据
        const nodeList = this.form.nodeList || []
        const nodes = []
        nodeList.forEach(el => {
          const coordinate = el.coordinate.split(',') || []
          const portList = el.portList.map(item => ({
            group: item.portGroup,
            id: item.portId
          }))
          console.log('el.procedureType.toString()', el.procedureType, el.procedureType ? el.procedureType.toString() : '')
          nodes.push({
            id: el.nodeId,
            x: coordinate.length ? coordinate[0] * 1 : 0,
            y: coordinate.length ? coordinate[1] * 1 : 0,
            width: el.width,
            height: el.height,
            label: el.nodeDesc,
            nodeType: el.nodeType,
            shape: 'custom-node',
            ports: {
              items: portList
            },
            nodeData: {
              procedureCode: el.procedureCode,
              procedureId: el.procedureId,
              procedureName: el.procedureName,
              procedureType: el.procedureType != null ? (el.procedureType === 0 ? '0' : el.procedureType.toString()) : ''
            }
          })
        })
        // 获取连线数据
        const linkList = this.form.linkList || []
        const edges = []
        linkList.forEach(el => {
          edges.push({
            id: el.linkId,
            source: {
              cell: el.startId,
              port: el.startPortId
            },
            target: {
              cell: el.endId,
              port: el.endPortId
            },
            nodeData: {
              recordProcedure: el.recordProcedure,
              startProcedure: el.startProcedure,
              startProcedureName: el.startProcedureName,
              postProcedure: el.postProcedure,
              endProcedureName: el.postProcedureName
            }
          })
        })
        this.dataJson = {
          nodes,
          edges
        }
相关推荐
猿榜2 分钟前
js逆向-喜某拉雅Xm-Sign参数解密
javascript
转转技术团队3 分钟前
代码变更暗藏危机?代码影响范围分析为你保驾护航
前端·javascript·node.js
Spark2388 分钟前
关于vue3整合tiptap的slash菜单的ts支持
vue.js
Mintopia13 分钟前
Node.js高级实战:自定义流与Pipeline的高效数据处理 ——从字母生成器到文件管道的深度解析
前端·javascript·node.js
Mintopia14 分钟前
Three.js深度解析:InstancedBufferGeometry实现动态星空特效 ——高效渲染十万粒子的底层奥秘
前端·javascript·three.js
随笔记15 分钟前
Flex布局下,label标签设置宽度依旧对不齐,完美解决(flex-shrink属性)
javascript·css·vue.js
樊小肆19 分钟前
实战!从 0 到 1 搭建 H5 AI 对话页面
前端·vue.js
JiangJiang20 分钟前
揭秘Vue3源码之computed:懒计算与缓存机制全解析
前端·vue.js·面试
前端Hardy22 分钟前
HTML&CSS:超丝滑的动态导航菜单
javascript·css·html
前端Hardy29 分钟前
HTML&CSS:你绝对没见过的input输入框,确定不看看吗
javascript·css·html