From 3b121a4e25bc57693d231a805133fe14defd18f5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 30 六月 2023 00:23:05 +0800 Subject: [PATCH] 2023-06-30 --- src/tabviews/custom/components/chart/antv-X6/index.jsx | 221 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 141 insertions(+), 80 deletions(-) diff --git a/src/tabviews/custom/components/chart/antv-X6/index.jsx b/src/tabviews/custom/components/chart/antv-X6/index.jsx index 4bb634b..6a8f37a 100644 --- a/src/tabviews/custom/components/chart/antv-X6/index.jsx +++ b/src/tabviews/custom/components/chart/antv-X6/index.jsx @@ -333,6 +333,47 @@ true ) +const styles = { + blue: '#1890ff', + red: '#f5222d', + orange_red: '#fa541c', + orange: '#fa8c16', + orange_yellow: '#faad14', + yellow: '#fadb14', + yellow_green: '#a0d911', + green: '#52c41a', + cyan: '#13c2c2', + blue_purple: '#2f54eb', + purple: '#722ed1', + magenta: '#eb2f96', + grass_green: '#aeb303', + deep_red: '#c32539', + deep_blue: '#1d3661', + blue1: '#e6f7ff', + red1: '#fff1f0', + orange_red1: '#fff2e8', + orange1: '#fff7e6', + orange_yellow1: '#fffbe6', + yellow1: '#feffe6', + yellow_green1: '#fcffe6', + green1: '#f6ffed', + cyan1: '#e6fffb', + blue_purple1: '#f0f5ff', + purple1: '#f9f0ff', + magenta1: '#fff0f6', + grass_green1: '#f2efda', + deep_red1: '#fff0f0', + deep_blue1: '#eff1f4' +} + +let sysColor = '#1890ff' +let lightColor = '#e6f7ff' +if (window.GLOB.style) { + let type = window.GLOB.style.replace(/bg_black_style_|bg_white_style_/, '') + sysColor = styles[type] || '#1890ff' + lightColor = styles[type + '1'] || '#e6f7ff' +} + class antvX6Chart extends Component { static propTpyes = { config: PropTypes.object @@ -563,6 +604,7 @@ max: 2 }, autoResize: true, + interacting: false, panning: true, background: { color: config.plot.backgroundColor || 'transparent' @@ -585,36 +627,6 @@ allowBlank: false, snap: { radius: 20 - }, - createEdge() { - return new Shape.Edge({ - attrs: { - line: { - stroke: '#000000', - strokeWidth: 1, - targetMarker: { - name: 'block', - width: 12, - height: 8 - } - } - }, - zIndex: 0 - }) - }, - validateConnection({ targetMagnet }) { - return !!targetMagnet - } - }, - highlighting: { - magnetAdsorbed: { - name: 'stroke', - args: { - attrs: { - fill: '#5F95FF', - stroke: '#5F95FF' - } - } } } }) @@ -631,6 +643,16 @@ graph.resetCells(cells) graph.positionContent('center') } + + if (config.plot.click) { + graph.on('cell:click', ({ node }) => { + this.checkNode(graph, node) + }) + + graph.on('blank:click', () => { + this.checkNode(graph) + }) + } } laneSrender = () => { @@ -642,6 +664,7 @@ min: 0.5, max: 2 }, + interacting: false, autoResize: true, panning: true, background: { color: '#ffffff' }, @@ -663,55 +686,6 @@ allowBlank: false, snap: { radius: 20 - }, - createEdge() { - return new Shape.Edge({ - attrs: { - line: { - stroke: '#000000', - strokeWidth: 1, - targetMarker: { - name: 'block', - width: 12, - height: 8 - } - } - }, - zIndex: 2 - }) - }, - validateConnection({ targetMagnet }) { - return !!targetMagnet - } - }, - highlighting: { - magnetAdsorbed: { - name: 'stroke', - args: { - attrs: { - fill: '#5F95FF', - stroke: '#5F95FF' - } - } - } - }, - translating: { - restrict(cellView) { - const cell = cellView.cell - const parentId = cell.prop('parent') - - if (parentId) { - const parentNode = graph.getCellById(parentId) - if (parentNode) { - return parentNode.getBBox().moveAndExpand({ - x: 0, - y: 36, - width: 0, - height: -36, - }) - } - } - return cell.getBBox() } } }) @@ -727,6 +701,16 @@ }) graph.resetCells(cells) graph.positionContent('top') + } + + if (config.plot.click) { + graph.on('cell:click', ({ node }) => { + this.checkNode(graph, node) + }) + + graph.on('blank:click', () => { + this.checkNode(graph) + }) } } @@ -1594,6 +1578,83 @@ } } + checkNode = (graph, node) => { + const { plot, config } = this.state + + let nodes = graph.getNodes() + + nodes.forEach(item => { + if (item.prop('shape') === 'lane') return + + if (item.prop('oristyle')) { + let style = item.prop('oristyle') + + item.prop('attrs/body/fill', style.fill) + item.prop('attrs/body/stroke', style.stroke) + item.prop('attrs/text/fill', style.text) + } + }) + + if (!node || ['lane', 'mk-text', 'edge'].includes(node.prop('shape'))) { + MKEmitter.emit('resetSelectLine', config.uuid, '', '') + return + } + + if (!node.prop('oristyle')) { + node.prop('oristyle', { + fill: node.prop('attrs/body/fill'), + stroke: node.prop('attrs/body/stroke'), + text: node.prop('attrs/text/fill') + }) + } + + node.prop('attrs/body/fill', lightColor) + node.prop('attrs/body/stroke', sysColor) + node.prop('attrs/text/fill', sysColor) + + let sign = node.prop('mksign') || '' + + if (plot.click === 'menus') { + let menu = null + + if (plot.menus && plot.menus.length > 0) { + plot.menus.forEach(m => { + if (sign !== m.sign) return + menu = m + }) + } + if (!menu || !menu.MenuID) return + + let newtab = { + MenuID: menu.MenuID, + MenuName: menu.MenuName, + MenuNo: menu.MenuNo || '', + type: menu.tabType, + param: {$BID: sign} + } + + MKEmitter.emit('modifyTabs', newtab, true) + } else if (plot.click === 'menu') { + let menuId = plot.menu.slice(-1)[0] + let newtab = window.GLOB.mkThdMenus.filter(m => m.MenuID === menuId)[0] + + if (!newtab && plot.MenuID) { + newtab = { + MenuID: plot.MenuID, + MenuName: plot.MenuName, + MenuNo: plot.MenuNo, + type: plot.tabType + } + } else if (!newtab) { + return + } + + MKEmitter.emit('modifyTabs', {...newtab, param: {$BID: sign}}, true) + } else { + MKEmitter.emit('resetSelectLine', config.uuid, sign, {}) + } + } + resetlane = (id, x, offset) => { let nodes = this.mkGraph.getNodes() @@ -1627,7 +1688,7 @@ </div> : null } <NormalHeader config={config} /> - <div className="canvas" style={{width: '100%', minHeight: config.plot.height, height: config.plot.height}} id={config.uuid + 'canvas'}> + <div className={'canvas only-show' + (config.plot.click ? ' switchable' : '')} style={{width: '100%', minHeight: config.plot.height, height: config.plot.height}} id={config.uuid + 'canvas'}> <div id={config.uuid + 'container'} className="mk-container"></div> </div> </div> -- Gitblit v1.8.0