| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Spin, Tooltip, message, Modal, notification } from 'antd' |
| | | 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 { Graph, Shape } from '@antv/x6' |
| | | import { Stencil } from '@antv/x6-plugin-stencil' |
| | |
| | | { |
| | | inherit: 'rect', |
| | | width: 66, |
| | | height: 36, |
| | | height: 40, |
| | | attrs: { |
| | | body: { |
| | | strokeWidth: 1, |
| | |
| | | { |
| | | inherit: 'polygon', |
| | | width: 66, |
| | | height: 36, |
| | | height: 40, |
| | | attrs: { |
| | | body: { |
| | | strokeWidth: 1, |
| | |
| | | { |
| | | inherit: 'polygon', |
| | | width: 66, |
| | | height: 36, |
| | | height: 40, |
| | | attrs: { |
| | | body: { |
| | | strokeWidth: 1, |
| | |
| | | 'mk-circle', |
| | | { |
| | | inherit: 'circle', |
| | | width: 36, |
| | | height: 36, |
| | | width: 40, |
| | | height: 40, |
| | | attrs: { |
| | | body: { |
| | | strokeWidth: 1, |
| | |
| | | { |
| | | inherit: 'ellipse', |
| | | width: 66, |
| | | height: 36, |
| | | height: 40, |
| | | attrs: { |
| | | body: { |
| | | strokeWidth: 1, |
| | |
| | | 'mk-star', |
| | | { |
| | | inherit: 'polygon', |
| | | width: 36, |
| | | height: 36, |
| | | width: 40, |
| | | height: 40, |
| | | points: '100,10 40,198 190,78 10,78 160,198', |
| | | attrs: { |
| | | body: { |
| | |
| | | { |
| | | inherit: 'text-block', |
| | | width: 66, |
| | | height: 36, |
| | | height: 40, |
| | | text: '文本域', |
| | | attrs: { |
| | | body: { |
| | |
| | | editing: false, |
| | | node: null, |
| | | loading: false, |
| | | rolelist: [] |
| | | status: 0, |
| | | orgs: [] |
| | | } |
| | | |
| | | selectNode = null |
| | |
| | | this.loadData() |
| | | |
| | | if (_config.plot.function === 'edit') { |
| | | this.getrolelist() |
| | | this.getorganizations() |
| | | } |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | getrolelist = () => { |
| | | Api.getSystemConfig({func: 's_get_rolelist', OrderCol: 'RoleID desc', PageIndex: 1, PageSize: 1000}).then(res => { |
| | | getorganizations = () => { |
| | | Api.genericInterface({func: 's_get_organizations_v1'}).then(res => { |
| | | if (!res.status) { |
| | | notification.error({ |
| | | top: 92, |
| | |
| | | return |
| | | } |
| | | |
| | | this.setState({rolelist: res.data || []}) |
| | | let orgs = [] |
| | | res.organizations && res.organizations.forEach(com => { |
| | | let _com = { |
| | | key: com.OrgCode, |
| | | title: com.OrgName, |
| | | shortName: com.ShortName, |
| | | checkable: false, |
| | | disabled: true, |
| | | children: [] |
| | | } |
| | | |
| | | com.departments.forEach(dep => { |
| | | let _dep = { |
| | | key: dep.co_pro_code, |
| | | title: dep.co_pro_name, |
| | | checkable: false, |
| | | disabled: true, |
| | | children: [] |
| | | } |
| | | |
| | | dep.jobs.forEach(job => { |
| | | let _job = { |
| | | key: job.jobcode, |
| | | title: job.jobname, |
| | | checkable: false, |
| | | disabled: true, |
| | | children: [] |
| | | } |
| | | |
| | | job.work_group.forEach(group => { |
| | | if (group.work_group === 'normal') { |
| | | group.workers.forEach(work => { |
| | | let _work = { |
| | | key: work.worker_id, |
| | | title: work.workername, |
| | | email: work.email || '', |
| | | images: work.images || '', |
| | | mob: work.mob || '', |
| | | sex: work.sex || '', |
| | | work_grade: work.work_grade || '', |
| | | worker_id: work.worker_id || '', |
| | | workercode: work.workercode || '', |
| | | workername: work.workername || '', |
| | | } |
| | | |
| | | _job.children.push(_work) |
| | | }) |
| | | } else { |
| | | let _group = { |
| | | key: group.work_group, |
| | | title: group.work_group, |
| | | checkable: false, |
| | | disabled: true, |
| | | children: [] |
| | | } |
| | | |
| | | group.workers.forEach(work => { |
| | | let _work = { |
| | | key: work.worker_id, |
| | | title: work.workername, |
| | | email: work.email || '', |
| | | images: work.images || '', |
| | | mob: work.mob || '', |
| | | sex: work.sex || '', |
| | | work_grade: work.work_grade || '', |
| | | worker_id: work.worker_id || '', |
| | | workercode: work.workercode || '', |
| | | workername: work.workername || '', |
| | | } |
| | | |
| | | _group.children.push(_work) |
| | | }) |
| | | |
| | | if (_group.children.length > 0) { |
| | | _job.children.push(_group) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | if (_job.children.length > 0) { |
| | | _dep.children.push(_job) |
| | | } |
| | | }) |
| | | |
| | | if (_dep.children.length > 0) { |
| | | _com.children.push(_dep) |
| | | } |
| | | }) |
| | | |
| | | if (_com.children.length > 0) { |
| | | orgs.push(_com) |
| | | } |
| | | }) |
| | | |
| | | this.setState({orgs: orgs}) |
| | | }) |
| | | } |
| | | |
| | |
| | | this.handleData() |
| | | |
| | | this.setState({ |
| | | status: item.status || 0, |
| | | loading: false |
| | | }) |
| | | |
| | |
| | | groups: [ |
| | | { |
| | | title: '通用节点', |
| | | name: 'group1' |
| | | name: 'group1', |
| | | graphHeight: 240 |
| | | }, |
| | | { |
| | | title: '自定义', |
| | |
| | | |
| | | const r1 = graph.createNode({ |
| | | shape: 'mk-rect', |
| | | label: '开始', |
| | | mknode: 'start', |
| | | mkdata: {status: 0, statusName: '开始'}, |
| | | attrs: { |
| | | body: { |
| | | rx: 20, |
| | | ry: 26 |
| | | ry: 26, |
| | | fill: '#52c41a', |
| | | stroke: '#52c41a' |
| | | }, |
| | | text: { |
| | | fill: '#ffffff', |
| | | text: '开始' |
| | | } |
| | | } |
| | | }) |
| | | const r2 = graph.createNode({ |
| | | shape: 'mk-rect', |
| | | label: '过程' |
| | | attrs: { |
| | | body: { |
| | | rx: 20, |
| | | ry: 26, |
| | | fill: '#e6f4ff', |
| | | stroke: '#1890ff' |
| | | }, |
| | | text: { |
| | | text: '过程' |
| | | } |
| | | } |
| | | }) |
| | | const r3 = graph.createNode({ |
| | | shape: 'mk-rect', |
| | | attrs: { |
| | | body: { |
| | | rx: 6, |
| | | ry: 6 |
| | | ry: 6, |
| | | fill: '#fff7e6', |
| | | stroke: '#fa8c16' |
| | | }, |
| | | text: { |
| | | text: '可选过程' |
| | | } |
| | | }, |
| | | label: '可选过程' |
| | | } |
| | | }) |
| | | const r4 = graph.createNode({ |
| | | shape: 'mk-rect', |
| | | attrs: { |
| | | body: { |
| | | rx: 0, |
| | | ry: 0, |
| | | fill: '#fff7e6', |
| | | stroke: '#fa8c16' |
| | | }, |
| | | text: { |
| | | text: '节点' |
| | | } |
| | | } |
| | | }) |
| | | const r5 = graph.createNode({ |
| | | shape: 'mk-polygon', |
| | | attrs: { |
| | | body: { |
| | | refPoints: '0,10 10,0 20,10 10,20' |
| | | refPoints: '0,10 10,0 20,10 10,20', |
| | | fill: '#f9f0ff', |
| | | stroke: '#722ed1' |
| | | }, |
| | | text: { |
| | | text: '决策' |
| | | } |
| | | }, |
| | | label: '决策' |
| | | } |
| | | }) |
| | | const r5 = graph.createNode({ |
| | | const r6 = graph.createNode({ |
| | | shape: 'mk-paral', |
| | | attrs: { |
| | | body: { |
| | | refPoints: '10,0 40,0 30,20 0,20' |
| | | refPoints: '10,0 40,0 30,20 0,20', |
| | | fill: '#e6fffb', |
| | | stroke: '#13c2c2' |
| | | }, |
| | | text: { |
| | | text: '数据' |
| | | } |
| | | }, |
| | | label: '数据' |
| | | } |
| | | }) |
| | | const r6 = graph.createNode({ |
| | | const r7 = graph.createNode({ |
| | | shape: 'mk-circle', |
| | | label: '连接' |
| | | attrs: { |
| | | body: { |
| | | fill: '#e6f4ff', |
| | | stroke: '#1890ff' |
| | | }, |
| | | text: { |
| | | text: '连接' |
| | | } |
| | | } |
| | | }) |
| | | |
| | | const r8 = graph.createNode({ |
| | | shape: 'mk-rect', |
| | | mknode: 'end', |
| | | mkdata: {status: '', statusName: '结束'}, |
| | | attrs: { |
| | | body: { |
| | | rx: 20, |
| | | ry: 26, |
| | | fill: '#fa8c16', |
| | | stroke: '#fa8c16' |
| | | }, |
| | | text: { |
| | | fill: '#ffffff', |
| | | text: '结束' |
| | | } |
| | | } |
| | | }) |
| | | |
| | | stencil.load([r1, r2, r3, r4, r5, r6], 'group1') |
| | | stencil.load([r1, r2, r3, r4, r5, r6, r7, r8], 'group1') |
| | | |
| | | const p1 = graph.createNode({ |
| | | shape: 'mk-ellipse', |
| | |
| | | } |
| | | |
| | | save = () => { |
| | | const { BID } = this.state |
| | | const { BID, plot, status } = this.state |
| | | |
| | | if (!BID) { |
| | | Modal.error({ |
| | |
| | | return |
| | | } |
| | | |
| | | let nodes = this.mkGraph.toJSON() |
| | | let _status = status |
| | | |
| | | if (plot.subtype === 'xflow' && status === 10) { |
| | | let start_num = nodes.cells.filter(cell => cell.mknode === 'start').length |
| | | let end_num = nodes.cells.filter(cell => cell.mknode === 'end').length |
| | | |
| | | if (start_num !== 1 || end_num !== 1) { |
| | | _status = 0 |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let nodes = this.mkGraph.toJSON() |
| | | this.mkGraph.toPNG((dataUri) => { |
| | | let param = { |
| | | func: 's_works_flow_param_upt_v6', |
| | | long_param: window.btoa(window.encodeURIComponent(JSON.stringify(nodes))), |
| | | flow_image: dataUri, |
| | | status: status, |
| | | ID: BID, |
| | | BID: '' |
| | | } |
| | |
| | | message: '保存成功!', |
| | | duration: 2 |
| | | }) |
| | | this.setState({ |
| | | loading: false, |
| | | status: _status |
| | | }) |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | }, {padding: 20}) |
| | | } |
| | |
| | | } else { |
| | | this.selectNode.attr('line/strokeDasharray', 0) |
| | | } |
| | | } else if (key === 'mkdata') { |
| | | this.selectNode.prop('mkdata', value) |
| | | } |
| | | } else if (node.shape === 'lane') { |
| | | if (key === 'title') { |
| | |
| | | this.selectNode.attr('text/fontSize', value) |
| | | } else if (key === 'fontFill') { |
| | | this.selectNode.attr('text/fill', value) |
| | | } else if (key === 'mksign') { |
| | | this.selectNode.prop('mksign', value) |
| | | } else if (key === 'mkdata') { |
| | | this.selectNode.prop('mkdata', value) |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | changeStatus = () => { |
| | | const { plot, status } = this.state |
| | | |
| | | let _status = status === 10 ? 0 : 10 |
| | | |
| | | if (plot.subtype === 'xflow' && _status === 10) { |
| | | let nodes = this.mkGraph.toJSON() |
| | | let start_num = nodes.cells.filter(cell => cell.mknode === 'start').length |
| | | let end_num = nodes.cells.filter(cell => cell.mknode === 'end').length |
| | | |
| | | if (start_num === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请添加开始节点!', |
| | | duration: 2 |
| | | }) |
| | | } else if (start_num > 1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '开始节点不可添加多个!', |
| | | duration: 2 |
| | | }) |
| | | } else if (end_num === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请添加结束节点!', |
| | | duration: 2 |
| | | }) |
| | | } else if (end_num > 1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '结束节点不可添加多个!', |
| | | duration: 2 |
| | | }) |
| | | } else { |
| | | this.setState({status: _status}) |
| | | } |
| | | } else { |
| | | this.setState({status: _status}) |
| | | } |
| | | } |
| | | |
| | | resetlane = (id, x, offset) => { |
| | | let nodes = this.mkGraph.getNodes() |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loading, config, node, rolelist } = this.state |
| | | const { loading, config, node, orgs, status } = this.state |
| | | |
| | | let style = {...config.style} |
| | | |
| | |
| | | </Tooltip> |
| | | </div> |
| | | <div className="right-tool"> |
| | | <Tooltip title="启用/停用"> |
| | | <Switch size="small" style={{marginRight: '10px'}} checked={status === 10} onChange={this.changeStatus} /> |
| | | </Tooltip> |
| | | <Tooltip title="保存"> |
| | | <SaveOutlined onClick={this.save}/> |
| | | <SaveOutlined style={{marginRight: '10px'}} onClick={this.save}/> |
| | | </Tooltip> |
| | | </div> |
| | | </div> |
| | |
| | | <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} rolelist={rolelist} onChange={this.changeProps}/>} |
| | | {!node ? <div className="empty">未选中</div> : <NodeUpdate node={node} orgs={orgs} onChange={this.changeProps}/>} |
| | | </div> |
| | | </div> |
| | | </div> |