king
2023-01-18 9cacf4bf8339ebdfbf2fec7604b501a8dc32f9a4
src/tabviews/zshare/tablenodes/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Modal, Button, notification, Spin, Input, Typography } from 'antd'
import { Modal, Button, notification, Spin, Input, Typography, message } from 'antd'
import Api from '@/api'
import G6 from "@antv/g6"
@@ -166,6 +166,7 @@
              id: 'par' + i,
              direction: 'left',
              color: '#5AD8A6',
              node: 'table',
              children: []
            }
@@ -345,6 +346,44 @@
        ev.preventDefault();
      },
    });
    G6.registerBehavior('dice-mindmap', {
      getEvents() {
        return {
          'node:dblclick': 'editNode',
        };
      },
      editNode(evt) {
        const item = evt.item;
        const model = item.get('model');
        // 选中节点
        this.graph.getNodes().forEach(node => {
          let _model = node.get('model')
          if (_model.fontcolor === '#1890ff') {
            _model.fontcolor = ''
            this.graph.updateItem(node, _model, false)
          }
        })
        if (model.direction === 'left') {
          if (model.node === 'table') {
            model.fontcolor = '#1890ff'
            this.graph.updateItem(item, model, false)
            let oInput = document.createElement('input')
            oInput.value = model.label
            document.body.appendChild(oInput)
            oInput.select()
            document.execCommand('Copy')
            document.body.removeChild(oInput)
            message.success('表名复制成功。')
          }
          return
        }
      }
    });
    
    const dataTransform = (data) => {
      const changeData = (d, level = 0, color) => {
@@ -420,7 +459,8 @@
            },
          },
          'drag-canvas',
          'zoom-canvas'
          'zoom-canvas',
          'dice-mindmap'
        ],
      },
    });