king
2023-06-18 03fb8af6eb071bef24a1ab3224905c13f238241d
src/tabviews/custom/components/chart/antv-G6/index.jsx
@@ -1184,7 +1184,8 @@
      _options.push(_item)
    })
    root = this.getTree(root, _options)
    root.nodeNumber = 0
    root = this.getTree(root, _options, root)
    root.children = root.children || []
    if (plot.subtype === 'mindmap') {
@@ -1248,13 +1249,16 @@
    return root
  }
  getTree = (parent, options) => {
  getTree = (parent, options, root) => {
    parent.children = []
    // 添加菜单的子元素
    options = options.filter(option => {
      if (option.$parentId === parent.id) {
        delete option.$parentId
        parent.children.push(option)
        root.nodeNumber++
        return false
      }
      return true
@@ -1264,7 +1268,7 @@
      parent.children = null
    } else {
      parent.children = parent.children.map(item => {
        item = this.getTree(item, options)
        item = this.getTree(item, options, root)
        return item
      })
@@ -1357,7 +1361,7 @@
    graph.render()
    graph.fitView()
    if (plot.collapsed === 'true') {
    if (plot.collapsed === 'true' || data.nodeNumber < 5) {
      graph.zoomTo(1, { x: 0, y: plot.height / 2 })
    }
  }
@@ -1480,7 +1484,7 @@
    if (plot.collapsed === 'true' && plot.dirField) {
      tree.zoomTo(1, { x: width / 2, y: plot.height / 2 })
    } else if (plot.collapsed === 'true') {
    } else if (plot.collapsed === 'true' || data.nodeNumber < 5) {
      tree.zoomTo(1, { x: 0, y: plot.height / 2 })
    }
  }