| | |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Spin, Tooltip, message, Modal, notification } from 'antd' |
| | | import { UndoOutlined, RedoOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined, SaveOutlined, ZoomInOutlined, ZoomOutOutlined, OneToOneOutlined } from '@ant-design/icons' |
| | | import { UndoOutlined, RedoOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined, SaveOutlined, ZoomInOutlined, ZoomOutOutlined, OneToOneOutlined, QuestionCircleOutlined } from '@ant-design/icons' |
| | | import { Graph, Shape } from '@antv/x6' |
| | | import { Stencil } from '@antv/x6-plugin-stencil' |
| | | import { Transform } from '@antv/x6-plugin-transform' |
| | |
| | | Graph.registerNode( |
| | | 'mk-text', |
| | | { |
| | | inherit: 'rect', |
| | | inherit: 'text-block', |
| | | width: 66, |
| | | height: 36, |
| | | text: '文本域', |
| | | attrs: { |
| | | body: { |
| | | strokeWidth: 0, |
| | | fill: 'transparent' |
| | | }, |
| | | text: { |
| | | fontSize: 12, |
| | | fill: '#262626' |
| | | fill: '#ffffff', |
| | | stroke: '#000000', |
| | | strokeWidth: 1, |
| | | rx: 0, |
| | | ry: 0 |
| | | } |
| | | } |
| | | }, |
| | | // { |
| | | // inherit: 'rect', |
| | | // width: 66, |
| | | // height: 36, |
| | | // attrs: { |
| | | // body: { |
| | | // strokeWidth: 0, |
| | | // fill: 'transparent' |
| | | // }, |
| | | // text: { |
| | | // fontSize: 12, |
| | | // fill: '#262626' |
| | | // } |
| | | // } |
| | | // }, |
| | | true |
| | | ) |
| | | |
| | |
| | | config: null, |
| | | editing: false, |
| | | node: null, |
| | | loading: false |
| | | loading: false, |
| | | rolelist: [] |
| | | } |
| | | |
| | | selectNode = null |
| | |
| | | plot: _config.plot |
| | | }, () => { |
| | | this.loadData() |
| | | |
| | | if (_config.plot.function === 'edit') { |
| | | this.getrolelist() |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getrolelist = () => { |
| | | Api.getSystemConfig({func: 's_get_rolelist', OrderCol: 'RoleID desc', PageIndex: 1, PageSize: 1000}).then(res => { |
| | | if (!res.status) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({rolelist: res.data || []}) |
| | | }) |
| | | } |
| | | |
| | | async loadData () { |
| | |
| | | } |
| | | }) |
| | | |
| | | // #region 使用插件 |
| | | graph |
| | | .use(new Transform({ |
| | | resizing: true, |
| | |
| | | .use(new History()) |
| | | .use(new Export()) |
| | | |
| | | // #region 初始化 stencil |
| | | const stencil = new Stencil({ |
| | | title: '流程图', |
| | | target: graph, |
| | |
| | | |
| | | document.getElementById(config.uuid + 'stencil').appendChild(stencil.container) |
| | | |
| | | // #region 快捷键与事件 |
| | | graph.bindKey(['meta+c', 'ctrl+c'], () => { |
| | | const cells = graph.getSelectedCells() |
| | | if (cells.length) { |
| | |
| | | return false |
| | | }) |
| | | |
| | | // undo redo |
| | | graph.bindKey(['meta+z', 'ctrl+z'], () => { |
| | | if (graph.canUndo()) { |
| | | graph.undo() |
| | |
| | | return false |
| | | }) |
| | | |
| | | // 删除元素 |
| | | graph.bindKey(['backspace', 'delete'], () => { |
| | | const cells = graph.getSelectedCells() |
| | | if (cells.length) { |
| | |
| | | .use(new History()) |
| | | .use(new Export()) |
| | | |
| | | // #region 初始化 stencil |
| | | const stencil = new Stencil({ |
| | | title: '流程图', |
| | | target: graph, |
| | |
| | | |
| | | document.getElementById(config.uuid + 'stencil').appendChild(stencil.container) |
| | | |
| | | // #region 快捷键与事件 |
| | | graph.bindKey(['meta+c', 'ctrl+c'], () => { |
| | | const cells = graph.getSelectedCells() |
| | | if (cells.length) { |
| | |
| | | return false |
| | | }) |
| | | |
| | | // 删除元素 |
| | | graph.bindKey(['backspace', 'delete'], () => { |
| | | const cells = graph.getSelectedCells() |
| | | if (cells.length) { |
| | |
| | | } |
| | | }) |
| | | |
| | | // 控制连接桩显示/隐藏 |
| | | const showPorts = (ports, show) => { |
| | | for (let i = 0, len = ports.length; i < len; i += 1) { |
| | | ports[i].style.visibility = show ? 'visible' : 'hidden' |
| | |
| | | return |
| | | } |
| | | |
| | | // let cells = this.mkGraph.getCells() |
| | | this.selectNode.toBack() |
| | | } |
| | | |
| | | // zoom() 可获取或者设置缩放比例 |
| | | setback = () => { |
| | | if (this.mkGraph.canUndo()) { |
| | | this.mkGraph.undo() |
| | |
| | | |
| | | this.mkGraph.stopBatch('width-change') |
| | | } |
| | | } else if (node.shape === 'mk-text') { |
| | | if (key === 'title') { |
| | | this.selectNode.attr('label/text', value) |
| | | } else if (key === 'fill') { |
| | | this.selectNode.attr('body/fill', value) |
| | | } else if (key === 'stroke') { |
| | | this.selectNode.attr('body/stroke', value) |
| | | } else if (key === 'fontSize') { |
| | | this.selectNode.attr('label/style/fontSize', value) |
| | | } else if (key === 'fontFill') { |
| | | this.selectNode.attr('label/style/color', value) |
| | | } |
| | | } else { |
| | | if (key === 'title') { |
| | | this.selectNode.attr('text/text', value) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loading, config, node } = this.state |
| | | const { loading, config, node, rolelist } = this.state |
| | | |
| | | let style = {...config.style} |
| | | |
| | |
| | | <Tooltip title="前进"> |
| | | <RedoOutlined onClick={this.setprev}/> |
| | | </Tooltip> |
| | | <Tooltip overlayStyle={{maxWidth: 260}} title="快捷键:复制(ctrl+c)、剪切(ctrl+x)、粘贴(ctrl+v)、后退(ctrl+z)、前进(ctrl+shift+z)、删除(backspace 或 delete)"> |
| | | <QuestionCircleOutlined /> |
| | | </Tooltip> |
| | | </div> |
| | | <div className="right-tool"> |
| | | <Tooltip title="保存"> |
| | |
| | | <div id={config.uuid + 'container'} className="mk-container"></div> |
| | | <div className="mk-node-edit"> |
| | | <div className="header">设置</div> |
| | | {!node ? <div className="empty">未选中</div> : <NodeUpdate node={node} onChange={this.changeProps}/>} |
| | | {!node ? <div className="empty">未选中</div> : <NodeUpdate node={node} rolelist={rolelist} onChange={this.changeProps}/>} |
| | | </div> |
| | | </div> |
| | | </div> |