From 46773828b8c46e450a67eb1fc5e6124d87d97ab6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 23 九月 2023 19:51:11 +0800 Subject: [PATCH] 2023-09-23 --- src/tabviews/custom/components/chart/antv-X6/index.jsx | 870 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 685 insertions(+), 185 deletions(-) diff --git a/src/tabviews/custom/components/chart/antv-X6/index.jsx b/src/tabviews/custom/components/chart/antv-X6/index.jsx index 66b6b4c..97525bc 100644 --- a/src/tabviews/custom/components/chart/antv-X6/index.jsx +++ b/src/tabviews/custom/components/chart/antv-X6/index.jsx @@ -1,8 +1,8 @@ import React, {Component} from 'react' 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, QuestionCircleOutlined } from '@ant-design/icons' +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' import { Transform } from '@antv/x6-plugin-transform' @@ -17,10 +17,11 @@ import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' import NormalHeader from '@/tabviews/custom/components/share/normalheader' -import lanes from '@/menu/components/chart/antv-X6/lane.json' -import xflows from '@/menu/components/chart/antv-X6/xflow.json' +// import lanes from '@/menu/components/chart/antv-X6/lane.json' +// import xflows from '@/menu/components/chart/antv-X6/xflow.json' import './index.scss' +const { confirm } = Modal const NodeUpdate = asyncComponent(() => import('./nodeupdate')) const groups = { @@ -138,7 +139,7 @@ { inherit: 'rect', width: 66, - height: 36, + height: 40, attrs: { body: { strokeWidth: 1, @@ -168,7 +169,7 @@ { inherit: 'polygon', width: 66, - height: 36, + height: 40, attrs: { body: { strokeWidth: 1, @@ -198,7 +199,7 @@ { inherit: 'polygon', width: 66, - height: 36, + height: 40, attrs: { body: { strokeWidth: 1, @@ -225,8 +226,8 @@ 'mk-circle', { inherit: 'circle', - width: 36, - height: 36, + width: 40, + height: 40, attrs: { body: { strokeWidth: 1, @@ -256,7 +257,7 @@ { inherit: 'ellipse', width: 66, - height: 36, + height: 40, attrs: { body: { strokeWidth: 1, @@ -285,8 +286,8 @@ '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: { @@ -318,7 +319,7 @@ { inherit: 'text-block', width: 66, - height: 36, + height: 40, text: '鏂囨湰鍩�', attrs: { body: { @@ -330,23 +331,49 @@ } } }, - // { - // inherit: 'rect', - // width: 66, - // height: 36, - // attrs: { - // body: { - // strokeWidth: 0, - // fill: 'transparent' - // }, - // text: { - // fontSize: 12, - // fill: '#262626' - // } - // } - // }, 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 = { @@ -358,7 +385,10 @@ editing: false, node: null, loading: false, - rolelist: [] + status: 0, + flowname: '', + flowcode: '', + orgs: [] } selectNode = null @@ -386,7 +416,7 @@ if (BData) { BID = BData.$BID || '' } - + this.setState({ config: _config, BID: BID || '', @@ -396,7 +426,7 @@ this.loadData() if (_config.plot.function === 'edit') { - this.getrolelist() + this.getorganizations() } }) } @@ -441,8 +471,8 @@ } } - 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, @@ -452,18 +482,119 @@ 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, + selectable: false, + children: [] + } + let _works = [] + + com.departments.forEach(dep => { + let _dep = { + key: dep.co_pro_code, + title: dep.co_pro_name, + checkable: false, + selectable: false, + children: [] + } + + dep.jobs.forEach(job => { + let _job = { + key: job.jobcode, + title: job.jobname, + checkable: false, + selectable: false, + 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 || '', + parentIds: [com.OrgCode, dep.co_pro_code, job.jobcode], + parentNames: [com.OrgName, dep.co_pro_name, job.jobname] + } + + _job.children.push(_work) + }) + } else { + let _group = { + key: group.work_group, + title: group.work_group, + checkable: false, + selectable: false, + 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 || '', + parentIds: [com.OrgCode, dep.co_pro_code, job.jobcode, group.work_group], + parentNames: [com.OrgName, dep.co_pro_name, job.jobname, group.work_group] + } + + _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) { + _com.works = _works + orgs.push(_com) + } + }) + + this.setState({orgs: orgs}) }) } async loadData () { - const { config, BID } = this.state + const { BID } = this.state - if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� + if (!BID) { if (!is(fromJS(this.data), fromJS([]))) { this.cells = [] this.handleData() } + this.setState({empty: true}) return } @@ -471,35 +602,30 @@ loading: true }) - if (config) { - if (config.plot.subtype === 'xflow') { - this.cells = xflows - } else { - this.cells = lanes - } - this.handleData() - - setTimeout(() => { - this.setState({ - loading: false - }) - }, 2000) - return - } - let param = { - func: '', - BID: BID + func: 's_get_works_flow_local_param_v6', + ID: BID } let result = await Api.genericInterface(param) if (result.status) { + let item = result.data && result.data[0] ? result.data[0] : null + let cells = [] + + if (item && item.long_param) { + let long_param = JSON.parse(window.decodeURIComponent(window.atob(item.long_param))) + cells = long_param.cells || [] + } + + this.cells = cells + this.handleData() + this.setState({ + status: item.status || 0, + flowname: item.works_flow_name || '', + flowcode: item.works_flow_code || '', loading: false }) - - this.cells = result.data || [] - this.handleData() if (result.message) { if (result.ErrCode === 'Y') { @@ -578,6 +704,7 @@ max: 2 }, autoResize: true, + interacting: false, panning: true, background: { color: config.plot.backgroundColor || 'transparent' @@ -600,36 +727,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' - } - } } } }) @@ -646,6 +743,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 = () => { @@ -657,6 +764,7 @@ min: 0.5, max: 2 }, + interacting: false, autoResize: true, panning: true, background: { color: '#ffffff' }, @@ -678,55 +786,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() } } }) @@ -742,6 +801,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) + }) } } @@ -832,7 +901,8 @@ groups: [ { title: '閫氱敤鑺傜偣', - name: 'group1' + name: 'group1', + graphHeight: 240 }, { title: '鑷畾涔�', @@ -912,72 +982,159 @@ showPorts(ports, false) }) - graph.on('node:click', ({ e, x, y, node, view }) => { + graph.on('node:click', ({ node }) => { this.selectNode = node this.setState({node: node.store.data}) }) - graph.on('edge:click', ({ e, x, y, edge, view }) => { + graph.on('edge:click', ({ edge }) => { this.selectNode = edge this.setState({node: edge.store.data}) graph.clearTransformWidgets() }) - graph.on('blank:click', ({ e, x, y }) => { + graph.on('blank:click', () => { this.selectNode = null this.setState({node: null}) }) + graph.on('edge:connected', ({ isNew, edge }) => { + if (!isNew) return + + let target = edge.getTargetCell() + + if (!target) return + + let mkdata = target.prop('mkdata') + + if (target.prop('mknode') === 'end') { + edge.prop('mknode', 'endEdge') + } else if (target.prop('mknode') === 'start') { + edge.prop('mknode', 'startEdge') + } + if (mkdata) { + edge.prop('mkdata', {status: mkdata.status, statusName: mkdata.statusName}) + } + }) 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: 888, 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', @@ -989,8 +1146,7 @@ }) const p3 = graph.createNode({ - shape: 'mk-text', - label: '鏂囨湰' + shape: 'mk-text' }) stencil.load([p1, p2, p3], 'group2') @@ -1095,8 +1251,15 @@ }) graph + .use(new Transform({ + resizing: true, + rotating: true + })) .use(new Selection()) - .use(new Snapline()) + .use(new Snapline({ + enabled: true, + filter: (Graph) => Graph.prop('shape') !== 'lane' + })) .use(new Keyboard()) .use(new Clipboard()) .use(new History()) @@ -1141,14 +1304,18 @@ graph.bindKey(['meta+c', 'ctrl+c'], () => { const cells = graph.getSelectedCells() if (cells.length) { - graph.copy(cells) + if (cells[0].prop('shape') !== 'lane' && cells[0].prop('shape') !== 'edge') { + graph.copy(cells) + } } return false }) graph.bindKey(['meta+x', 'ctrl+x'], () => { const cells = graph.getSelectedCells() if (cells.length) { - graph.cut(cells) + if (cells[0].prop('shape') !== 'lane' && cells[0].prop('shape') !== 'edge') { + graph.cut(cells) + } } return false }) @@ -1175,9 +1342,19 @@ graph.bindKey(['backspace', 'delete'], () => { const cells = graph.getSelectedCells() if (cells.length) { - graph.removeCells(cells) this.selectNode = null this.setState({node: null}) + + if (cells[0].prop('shape') === 'lane') { + graph.startBatch('delete-lane') + + graph.removeCells(cells) + this.deleteLane(cells[0], graph) + + graph.stopBatch('delete-lane') + } else { + graph.removeCells(cells) + } } }) @@ -1199,8 +1376,10 @@ showPorts(ports, false) }) - graph.on('node:added', ({ cell, index, options }) => { + graph.on('node:added', ({ cell }) => { if (cell.prop('shape') === 'lane') { + if (cell.prop('zIndex') === 0) return + graph.startBatch('add-lane') this.addLane(cell, graph) @@ -1212,22 +1391,26 @@ if (num <= 1) { message.warning('璇锋坊鍔犳吵閬擄紒') graph.removeCells([cell]) - } else { + } else if (!cell.prop('parent')) { this.addNode(cell, graph) } } }) - graph.on('node:click', ({ e, x, y, node, view }) => { + graph.on('node:click', ({ node }) => { this.selectNode = node this.setState({node: node.store.data}) + + if (node.prop('shape') === 'lane') { + graph.clearTransformWidgets() + } }) - graph.on('edge:click', ({ e, x, y, edge, view }) => { + graph.on('edge:click', ({ edge }) => { this.selectNode = edge this.setState({node: edge.store.data}) graph.clearTransformWidgets() }) - graph.on('blank:click', ({ e, x, y }) => { + graph.on('blank:click', () => { this.selectNode = null this.setState({node: null}) @@ -1292,8 +1475,7 @@ }) const p3 = graph.createNode({ - shape: 'mk-text', - label: '鏂囨湰' + shape: 'mk-text' }) stencil.load([p1, p2, p3], 'group2') @@ -1363,13 +1545,149 @@ } save = () => { - // let nodes = this.mkGraph.toJSON() - // this.mkGraph.toPNG((dataUri) => { - // Api.fileuploadbase64({ - // Base64Img: dataUri - // }).then(res => { - // }) - // }, {padding: 20}) + const { BID, plot, status, flowname, flowcode } = this.state + + if (!BID) { + Modal.error({ + title: '鏈幏鍙栧埌娴佺▼ID锛屼笉鍙繚瀛橈紒', + }) + return + } + + let nodes = this.mkGraph.toJSON() + let _status = status + + if (plot.subtype === 'xflow' && status === 10) { + let start_num = 0 + let end_num = 0 + let unvalid = false + + nodes.cells.forEach(item => { + if (item.mknode === 'start') { + start_num++ + } else if (item.mknode === 'end') { + end_num++ + } else if (item.shape === 'edge' && item.mknode !== 'endEdge' && item.mknode !== 'startEdge') { + if (!item.mkdata.members || item.mkdata.members.length === 0) { + unvalid = true + } + } + + }) + if (start_num !== 1 || end_num !== 1 || unvalid) { + _status = 0 + } + } + + this.setState({ + loading: true + }) + + 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: '' + } + + let ssoParam = { + func: 's_works_flow_param_sso_upt_v6', + status: status, + ID: BID, + works_flow_code: flowcode, + works_flow_name: flowname, + long_param: window.btoa(window.encodeURIComponent(JSON.stringify(nodes))) + } + + Api.genericInterface(param).then(res => { + if (res.status) { + if (plot.subtype === 'xflow') { + Api.getSystemConfig(ssoParam).then(result => { + if (result.status) { + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛锛�', + duration: 2 + }) + this.setState({ + loading: false, + status: _status + }) + } else { + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + this.setState({ + loading: false + }) + } + }) + } else { + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛锛�', + duration: 2 + }) + this.setState({ + loading: false, + status: _status + }) + } + } else { + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + this.setState({ + loading: false + }) + } + }) + }, {padding: 20}) + } + + clearNode = () => { + let cells = this.mkGraph.getCells() + const that = this + + if (cells.length === 0) return + + confirm({ + title: '纭畾娓呯┖鍏冪礌鍚�?', + content: '娓呯┖鍚庝笉鍙仮澶嶃��', + okText: '纭畾', + cancelText: '鍙栨秷', + onOk() { + that.mkGraph.removeCells(cells) + that.mkGraph.cleanHistory() + }, + onCancel() {} + }) + } + + deleteLane = (cell, graph) => { + let id = cell.id + + let nodes = graph.getNodes() + let cells = [] + + nodes.forEach(item => { + if (item.prop('shape') === 'lane') return + + if (item.prop('parent') === id) { + cells.push(item) + } + }) + + graph.removeCells(cells) + + this.resetlane(cell.id, cell.prop('position/x'), -cell.prop('size/width')) } addLane = (cell, graph) => { @@ -1406,6 +1724,7 @@ } let height = 400 + if (typeof(config.plot.height) === 'number' || /px/.test(config.plot.height)) { height = parseInt(config.plot.height) } @@ -1498,18 +1817,37 @@ const { node } = this.state if (node.shape === 'edge') { + let labels = this.selectNode.prop('labels') + if (!labels || labels.length === 0) { + labels = [{ + attrs: {label: { text: '' }} + }] + } + if (key === 'title') { - this.selectNode.setLabels(value) + labels = JSON.parse(JSON.stringify(labels)) + labels[0].attrs.label.text = value + this.selectNode.setLabels(labels) } else if (key === 'stroke') { this.selectNode.attr('line/stroke', value) } else if (key === 'strokeWidth') { this.selectNode.attr('line/strokeWidth', value) + } else if (key === 'fontSize') { + labels = JSON.parse(JSON.stringify(labels)) + labels[0].attrs.label.fontSize = value + this.selectNode.setLabels(labels) + } else if (key === 'fontFill') { + labels = JSON.parse(JSON.stringify(labels)) + labels[0].attrs.label.fill = value + this.selectNode.setLabels(labels) } else if (key === 'lineType') { if (value === 'dash') { this.selectNode.attr('line/strokeDasharray', 5) } else { this.selectNode.attr('line/strokeDasharray', 0) } + } else if (key === 'mkdata') { + this.selectNode.prop('mkdata', value) } } else if (node.shape === 'lane') { if (key === 'title') { @@ -1558,9 +1896,162 @@ 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) } + } + } + + 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 menu = null + + if (window.GLOB.mkThdMenus.has(menuId)) { + menu = {...window.GLOB.mkThdMenus.get(menuId)} + } else if (plot.MenuID) { + menu = { + MenuID: plot.MenuID, + MenuName: plot.MenuName, + type: plot.tabType + } + } + + if (!menu) return + + menu.param = {$BID: sign} + + MKEmitter.emit('modifyTabs', menu, true) + } else { + MKEmitter.emit('resetSelectLine', config.uuid, sign, {}) + } + } + + 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 = 0 + let end_num = 0 + let unvalidId = '' + + nodes.cells.forEach(item => { + if (item.mknode === 'start') { + start_num++ + } else if (item.mknode === 'end') { + end_num++ + } else if (item.shape === 'edge' && item.mknode !== 'endEdge' && item.mknode !== 'startEdge') { + if (!item.mkdata.members || item.mkdata.members.length === 0) { + unvalidId = item.id + } + } + }) + + 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 if (unvalidId) { + let edge = this.mkGraph.getCellById(unvalidId) + + let node = edge.getTargetCell() + + let title = '' + if (node.attrs && node.attrs.text) { + title = node.attrs.text.text + '' + } else if (node.mkdata) { + title = '鐘舵�侊細' + node.mkdata.status + ' - ' + node.mkdata.statusName + } + + notification.warning({ + top: 92, + message: '杩炴帴锛�' + title + '锛夌殑绾挎湭璁剧疆瀹℃壒浜猴紒', + duration: 2 + }) + } else { + this.setState({status: _status}) + } + } else { + this.setState({status: _status}) } } @@ -1579,17 +2070,19 @@ } render() { - const { loading, config, node, rolelist } = this.state + const { loading, config, node, orgs, status, flowname } = this.state let style = {...config.style} if (config.plot.function === 'show') { if (config.plot.empty === 'hidden' && this.cells.length === 0) { - style.display = 'none' + style.position = 'absolute' + style.width = '100%' + style.zIndex = -1 } return ( - <div className="custom-x6-plot-box" id={'anchor' + config.uuid} style={config.style}> + <div className="custom-x6-plot-box" id={'anchor' + config.uuid} style={style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> @@ -1597,7 +2090,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> @@ -1636,13 +2129,20 @@ <Tooltip title="鍓嶈繘"> <RedoOutlined onClick={this.setprev}/> </Tooltip> + <Tooltip title="娓呯┖"> + <ClearOutlined onClick={this.clearNode}/> + </Tooltip> <Tooltip overlayStyle={{maxWidth: 260}} title="蹇嵎閿細澶嶅埗锛坈trl+c锛夈�佸壀鍒囷紙ctrl+x锛夈�佺矘璐达紙ctrl+v锛夈�佸悗閫�锛坈trl+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 onClick={this.save}/> + <SaveOutlined style={{marginRight: '10px'}} onClick={this.save}/> </Tooltip> </div> </div> @@ -1651,7 +2151,7 @@ <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> -- Gitblit v1.8.0