mxGraph使用(vue)

mxGraph使用(vue)

  1. 安装
    npm install mxgraph --save
  2. 新建mxGraph.js
    import mx from 'mxgraph'
    const mxgraph = mx({
         
      mxImageBasePath: './src/images',
      mxBasePath: './src'
    })
    window.mxGraph = mxgraph.mxGraph
    window.mxGraphModel = mxgraph.mxGraphModel
    window.mxEditor = mxgraph.mxEditor
    window.mxGeometry = mxgraph.mxGeometry
    window.mxDefaultKeyHandler = mxgraph.mxDefaultKeyHandler
    window.mxDefaultPopupMenu = mxgraph.mxDefaultPopupMenu
    window.mxStylesheet = mxgraph.mxStylesheet
    window.mxDefaultToolbar = mxgraph.mxDefaultToolbar
    window.mxToolbar = mxgraph.mxToolbar
    window.mxCell = mxgraph.mxCell
    window.mxCodec = mxgraph.mxCodec
    window.mxEvent = mxgraph.mxEvent
    window.mxUtils = mxgraph.mxUtils
    window.mxConstants = mxgraph.mxConstants
    
    export default mxgraph
    
3. 页面引入, 定义元素,可以使用id,也可以使用ref
```html
<div id="graph_container" class="svg-container" style="width: 100%; height: 100%;padding: 10px;"></div>
  1. 根据数据渲染流程图 (数据定义)
graphData: [
        {
   
            "name": "年度审计计划",
            "state": 3,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 1
                }
            ]
        },
        {
   
            "name": "项目开始",
            "state": 3,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 2
                }
            ]
        },
        {
   
            "name": "项目审前符合性调查",
            "state": 3,
            "userName": "zbb",
            "time": null,
            "target": [
                {
   
                    "solidLine": 0,
                    "targetIndex": 3
                },
                {
   
                    "solidLine": 1,
                    "targetIndex": 4
                }
            ]
        },
        {
   
            "name": "协审招选结果",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 4
                }
            ]
        },
        {
   
            "name": "组成审计组",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 5
                }
            ]
        },
        {
   
            "name": "代拟审计通知书",
            "state": 3,
            "userName": "cqj",
            "time": "2021-11-05 17:46:13",
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 6
                }
            ]
        },
        {
   
            "name": "调查了解情况",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 0,
                    "targetIndex": 7
                },
                {
   
                    "solidLine": 1,
                    "targetIndex": 8
                }
            ],
            divider: 1
        },
        {
   
            "name": "审计工作方案",
            "state": 3,
            "userName": "zbb",
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 8
                }
            ]
        },
        {
   
            "name": "审计实施方案",
            "state": 3,
            "userName": "www",
            "time": null,
            "target": [
                {
   
                    "solidLine": 0,
                    "targetIndex": 9
                },
                {
   
                    "solidLine": 1,
                    "targetIndex": 10
                }
            ]
        },
        {
   
            "name": "审计进点会",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 10
                }
            ]
        },
        {
   
            "name": "现场审计",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 11
                }
            ]
        },
        {
   
            "name": "内控质量交叉复合",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 0,
                    "targetIndex": 12
                },
                {
   
                    "solidLine": 1,
                    "targetIndex": 13
                }
            ]
        },
        {
   
            "name": "外聘中介服务考核",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 13
                }
            ],
            divider: 2
        },
        {
   
            "name": "审计资料整理",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 14
                }
            ]
        },
        {
   
            "name": "法规处网上审查",
            "state": 0,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 15
                }
            ]
        },
        {
   
            "name": "草拟审计报告(征求意见稿)",
            "state": 1,
            "userName": null,
            "time": null,
            "target": [
                {
   
                    "solidLine": 1,
                    "targetIndex": 16
                }
            ]
     
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值