From fc8c8d714687a22f711d642d192bd4149f3b7e88 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 22 四月 2024 11:15:14 +0800 Subject: [PATCH] 2024-04-22 --- src/tabviews/zshare/tablenodes/index.jsx | 117 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 88 insertions(+), 29 deletions(-) diff --git a/src/tabviews/zshare/tablenodes/index.jsx b/src/tabviews/zshare/tablenodes/index.jsx index 8a728df..4a258bc 100644 --- a/src/tabviews/zshare/tablenodes/index.jsx +++ b/src/tabviews/zshare/tablenodes/index.jsx @@ -1,12 +1,11 @@ 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, Tooltip } from 'antd' import Api from '@/api' import G6 from "@antv/g6" import Utils from '@/utils/utils.js' -import options from '@/store/options.js' import './index.scss' const { Search } = Input @@ -155,11 +154,8 @@ let { tbs, ptbs } = this.getTbs(config) ptbs = Array.from(new Set(ptbs)) + ptbs = ptbs.filter(tb => tb.length > 1 && tb !== 'dbo') ptbs.sort() - if (ptbs.length && sessionStorage.getItem('mk_tb_names')) { - let names = sessionStorage.getItem('mk_tb_names') - ptbs = ptbs.filter(tb => names.indexOf(',' + tb.toLowerCase() + ',') > -1) - } if (ptbs.length) { ptbs.forEach((item, i) => { @@ -169,6 +165,7 @@ id: 'par' + i, direction: 'left', color: '#5AD8A6', + node: 'table', children: [] } @@ -184,6 +181,7 @@ if (result.tb_list) { result.tb_list.sort((a, b) => a.tbname > b.tbname ? 1 : -1) + let length = result.tb_list.length result.tb_list.forEach((item, i) => { let cell = { label: item.tbname, @@ -191,6 +189,8 @@ id: 'table' + i, direction: 'right', color: '#1890ff', + collapsed: false, + collable: true, children: [] } @@ -209,10 +209,17 @@ id: item.tbname + 'menu' + i, direction: 'right', color: '#1890ff', + type: 'dice-mind-map-leaf', param: _param }) } }) + } + + if (cell.children.length > 5 && length > 1) { + cell.collapsed = true + } else if (cell.children.length === 0) { + cell.collable = false } data.children.push(cell) @@ -261,12 +268,12 @@ const stroke = cfg.style.stroke || '#096dd9'; return ` - <group> - <rect draggable="true" style={{width: ${width}, height: 30, stroke: ${stroke}, radius: 4}} keyshape> - <text style={{ fontSize: 14, marginLeft: 6, marginTop: 6 }}>${cfg.label}</text> - </rect> - </group> - `; + <group> + <rect draggable="true" style={{width: ${width}, height: 30, stroke: ${stroke}, radius: 4}} keyshape> + <text style={{ fontSize: 14, marginLeft: 6, marginTop: 6 }}>${cfg.label}</text> + </rect> + </group> + `; }, getAnchorPoints() { return [ @@ -285,13 +292,13 @@ const color = cfg.color; return ` - <group> - <rect draggable="true" style={{width: ${width}, height: 26, fill: 'transparent' }}> - <text style={{ fontSize: 12, fill: ${cfg.fontcolor ? cfg.fontcolor : 'black'}, marginLeft: 12, marginTop: 6 }}>${cfg.label}</text> - </rect> - <rect style={{ fill: ${color}, width: ${width}, height: 2, x: 0, y: 32 }} /> - </group> - `; + <group> + <rect draggable="true" style={{width: ${width}, cursor: ${cfg.collable ? 'pointer' : 'default'}, height: 26, fill: 'transparent' }}> + <text style={{ fontSize: 12, fill: ${cfg.fontcolor ? cfg.fontcolor : 'black'}, cursor: ${cfg.collable ? 'pointer' : 'default'}, marginLeft: 12, marginTop: 6 }}>${cfg.label} ${cfg.collable ? '+' : ''}</text> + </rect> + <rect style={{ fill: ${color}, width: ${width}, cursor: ${cfg.collable ? 'pointer' : 'default'}, height: 2, x: 0, y: 32 }} /> + </group> + `; }, getAnchorPoints() { return [ @@ -302,6 +309,7 @@ }, 'single-node', ); + G6.registerBehavior('scroll-canvas', { getEvents: function getEvents() { return { @@ -337,6 +345,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) => { @@ -358,9 +404,10 @@ data.color = color; } - if (d.children) { + if (d.children && !d.collapsed) { data.children = d.children.map((child) => changeData(child, level + 1, data.color)); } + return data; }; return changeData(data); @@ -399,9 +446,21 @@ lineWidth: 2, }, }, - minZoom: 0.5, + minZoom: 0.3, modes: { - default: ['drag-canvas', 'zoom-canvas'], + default: [ + { + type: 'collapse-expand', + trigger: 'click', + shouldBegin: (e, self) => { + if (e.item && e.item.getModel().collable) return true; + return false; + }, + }, + 'drag-canvas', + 'zoom-canvas', + 'dice-mindmap' + ], }, }); @@ -414,14 +473,13 @@ const { config } = this.props const { visible, loading, empty, debug } = this.state + if (window.GLOB.mkHS || window.GLOB.systemType === 'production' || !debug || window.GLOB.sysType === 'cloud') return null + return ( - <div className={'page-message-wrap ' + (debug && options.sysType !== 'cloud' ? 'exist' : '')}> - {debug && options.sysType !== 'cloud' ? <Button - icon="fork" - shape="circle" - className="page-message" - onClick={this.trigger} - /> : null} + <div className="tool-wrap"> + <Tooltip placement="left" title="琛ㄥ叧绯诲浘"> + <Button icon="fork" shape="circle" onClick={this.trigger}/> + </Tooltip> <Modal title="" wrapClassName="view-table-modal" @@ -441,6 +499,7 @@ </div> <div className="footer"> <Button key="cancel" onClick={() => { this.setState({ visible: false })}}>鍏抽棴</Button> + <span className="tip">娉細鐐瑰嚮琛ㄥ悕鍙睍寮�/鏀惰捣鑿滃崟</span> </div> </Modal> </div> -- Gitblit v1.8.0