| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Spin, Tooltip, message, Modal, notification, Switch } from 'antd' |
| | | import { UndoOutlined, RedoOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined, SaveOutlined, ZoomInOutlined, ZoomOutOutlined, OneToOneOutlined, QuestionCircleOutlined, ClearOutlined } from '@ant-design/icons' |
| | | import { Spin, Tooltip, message, Modal, notification, Switch, Button } from 'antd' |
| | | import { UndoOutlined, RedoOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined, ZoomInOutlined, ZoomOutOutlined, OneToOneOutlined, QuestionCircleOutlined, ClearOutlined } from '@ant-design/icons' |
| | | import { Graph, Shape } from '@antv/x6' |
| | | import { Stencil } from '@antv/x6-plugin-stencil' |
| | | import { Transform } from '@antv/x6-plugin-transform' |
| | |
| | | status: 0, |
| | | flowname: '', |
| | | flowcode: '', |
| | | orgs: [] |
| | | orgs: [], |
| | | empty: true |
| | | } |
| | | |
| | | selectNode = null |
| | |
| | | worker_id: work.worker_id || '', |
| | | workercode: work.workercode || '', |
| | | workername: work.workername || '', |
| | | job_type: job.job_type || '', |
| | | parentIds: [com.OrgCode, dep.co_pro_code, job.jobcode], |
| | | parentNames: [com.OrgName, dep.co_pro_name, job.jobname] |
| | | } |
| | |
| | | worker_id: work.worker_id || '', |
| | | workercode: work.workercode || '', |
| | | workername: work.workername || '', |
| | | job_type: job.job_type || '', |
| | | parentIds: [com.OrgCode, dep.co_pro_code, job.jobcode, group.work_group], |
| | | parentNames: [com.OrgName, dep.co_pro_name, job.jobname, group.work_group] |
| | | } |
| | |
| | | const { BID } = this.state |
| | | |
| | | if (!BID) { |
| | | this.cells = [] |
| | | if (!is(fromJS(this.data), fromJS([]))) { |
| | | this.cells = [] |
| | | this.handleData() |
| | | } |
| | | this.setState({empty: true}) |
| | |
| | | status: item.status || 0, |
| | | flowname: item.works_flow_name || '', |
| | | flowcode: item.works_flow_code || '', |
| | | loading: false |
| | | loading: false, |
| | | empty: cells.length === 0 |
| | | }) |
| | | |
| | | if (result.message) { |
| | |
| | | |
| | | graph.clearTransformWidgets() |
| | | }) |
| | | |
| | | graph.on('node:dblclick', () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mk-x6-dbclick') |
| | | }, 100) |
| | | }) |
| | | graph.on('edge:dblclick', () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mk-x6-dbclick') |
| | | }, 100) |
| | | }) |
| | | |
| | | graph.on('blank:click', () => { |
| | | this.selectNode = null |
| | | |
| | |
| | | if (!isNew) return |
| | | |
| | | let target = edge.getTargetCell() |
| | | let source = edge.getSourceCell() |
| | | |
| | | if (!target) return |
| | | if (!target || !source) return |
| | | |
| | | if (source.prop('mknode') === 'end') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '结束节点不可添加分支!', |
| | | duration: 2 |
| | | }) |
| | | graph.removeCells([edge]) |
| | | return |
| | | } |
| | | |
| | | let mkdata = target.prop('mkdata') |
| | | |
| | |
| | | edge.prop('mknode', 'endEdge') |
| | | } else if (target.prop('mknode') === 'start') { |
| | | edge.prop('mknode', 'startEdge') |
| | | } else if (source.prop('mknode') === 'start') { |
| | | edge.prop('mknode', 'firstEdge') |
| | | } |
| | | if (mkdata) { |
| | | edge.prop('mkdata', {status: mkdata.status, statusName: mkdata.statusName}) |
| | |
| | | this.mkGraph.zoomTo(1) |
| | | } |
| | | |
| | | close = () => { |
| | | const { config } = this.state |
| | | |
| | | let nodes = this.mkGraph.toJSON() |
| | | |
| | | if (!is(fromJS(nodes.cells), fromJS(this.cells))) { |
| | | confirm({ |
| | | title: '流程图已修改,确定关闭吗?', |
| | | okText: '确定', |
| | | cancelText: '取消', |
| | | onOk() { |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | } |
| | | } |
| | | |
| | | save = () => { |
| | | const { BID, plot, status, flowname, flowcode } = this.state |
| | | |
| | |
| | | } |
| | | }) |
| | | |
| | | if (start_num !== 1 || end_num !== 1 || unvalid) { |
| | | if (start_num !== 1 || end_num === 0 || unvalid) { |
| | | _status = 0 |
| | | } |
| | | } |
| | |
| | | loading: false, |
| | | status: _status |
| | | }) |
| | | this.cells = nodes.cells |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | |
| | | loading: false, |
| | | status: _status |
| | | }) |
| | | this.cells = nodes.cells |
| | | } |
| | | } else { |
| | | notification.error({ |
| | |
| | | message: '请添加结束节点!', |
| | | duration: 2 |
| | | }) |
| | | } else if (end_num > 1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '结束节点不可添加多个!', |
| | | duration: 2 |
| | | }) |
| | | // } else if (end_num > 1) { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: '结束节点不可添加多个!', |
| | | // duration: 2 |
| | | // }) |
| | | } else if (emptyNode) { |
| | | let errmsg = '部分节点未设置基本信息。' |
| | | if (emptyNode.attrs && emptyNode.attrs.text && emptyNode.attrs.text.text) { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loading, config, node, orgs, status, flowname } = this.state |
| | | const { loading, config, node, orgs, status, flowname, empty } = this.state |
| | | |
| | | let style = {...config.style} |
| | | |
| | | if (config.plot.function === 'show') { |
| | | if (config.plot.empty === 'hidden' && this.cells.length === 0) { |
| | | if (config.plot.empty === 'hidden' && empty) { |
| | | style.position = 'absolute' |
| | | style.width = '100%' |
| | | style.zIndex = -1 |
| | |
| | | <Tooltip title="清空"> |
| | | <ClearOutlined onClick={this.clearNode}/> |
| | | </Tooltip> |
| | | <Tooltip overlayStyle={{maxWidth: 260}} title="快捷键:复制(ctrl+c)、剪切(ctrl+x)、粘贴(ctrl+v)、后退(ctrl+z)、前进(ctrl+shift+z)、删除(backspace 或 delete)"> |
| | | <Tooltip overlayStyle={{maxWidth: 310}} title="快捷键:复制(ctrl+c)、剪切(ctrl+x)、粘贴(ctrl+v)、后退(ctrl+z)、前进(ctrl+shift+z)、删除(backspace 或 delete);双击节点或连线可编辑自定义信息。"> |
| | | <QuestionCircleOutlined /> |
| | | </Tooltip> |
| | | </div> |
| | | <div className="flow-name">{flowname}</div> |
| | | <div className="right-tool"> |
| | | <Tooltip title="启用/停用"> |
| | | <Switch size="small" style={{marginRight: '10px'}} checked={status === 10} onChange={this.changeStatus} /> |
| | | </Tooltip> |
| | | <Tooltip title="保存"> |
| | | <SaveOutlined style={{marginRight: '10px'}} onClick={this.save}/> |
| | | </Tooltip> |
| | | <Switch size="large" checked={status === 10} checkedChildren="启" unCheckedChildren="停" onChange={this.changeStatus} /> |
| | | <Button className="save" onClick={this.save}>保存</Button> |
| | | <Button className="close" onClick={this.close}>关闭</Button> |
| | | </div> |
| | | </div> |
| | | <div className="canvas" style={{width: '100%', minHeight: config.plot.height, height: config.plot.height}} id={config.uuid + 'canvas'}> |