| | |
| | | { |
| | | 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: { |
| | |
| | | const r1 = graph.createNode({ |
| | | shape: 'mk-rect', |
| | | mknode: 'start', |
| | | mkdata: {status: 0}, |
| | | attrs: { |
| | | body: { |
| | | rx: 20, |
| | |
| | | } |
| | | }) |
| | | 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: { |
| | |
| | | } |
| | | } |
| | | }) |
| | | const r5 = graph.createNode({ |
| | | const r6 = graph.createNode({ |
| | | shape: 'mk-paral', |
| | | attrs: { |
| | | body: { |
| | |
| | | } |
| | | } |
| | | }) |
| | | const r6 = graph.createNode({ |
| | | const r7 = graph.createNode({ |
| | | shape: 'mk-circle', |
| | | attrs: { |
| | | body: { |
| | |
| | | } |
| | | }) |
| | | |
| | | const r7 = graph.createNode({ |
| | | const r8 = graph.createNode({ |
| | | shape: 'mk-rect', |
| | | mknode: 'end', |
| | | attrs: { |
| | |
| | | } |
| | | }) |
| | | |
| | | stencil.load([r1, r2, r3, r4, r5, r6, r7], 'group1') |
| | | stencil.load([r1, r2, r3, r4, r5, r6, r7, r8], 'group1') |
| | | |
| | | const p1 = graph.createNode({ |
| | | shape: 'mk-ellipse', |
| | |
| | | } else { |
| | | this.selectNode.attr('line/strokeDasharray', 0) |
| | | } |
| | | } else if (key === 'mkdata') { |
| | | this.selectNode.prop('mkdata', value) |
| | | } |
| | | } else if (node.shape === 'lane') { |
| | | if (key === 'title') { |
| | |
| | | const { plot, status } = this.state |
| | | |
| | | let _status = status === 10 ? 0 : 10 |
| | | let nodes = this.mkGraph.toJSON() |
| | | |
| | | 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, |
| | |
| | | import { FormOutlined } from '@ant-design/icons' |
| | | |
| | | import ColorSketch from '@/mob/colorsketch' |
| | | import NodeForm from './nodeform' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | |
| | | |
| | | state = { |
| | | formlist: null, |
| | | mknode: null |
| | | mknode: null, |
| | | mkdata: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | this.setState({ |
| | | mknode: null, |
| | | mknode: this.props.node, |
| | | mkdata: this.props.node.mkdata || '', |
| | | formlist: this.getFormList(this.props.node) |
| | | }) |
| | | } |
| | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (!is(fromJS(this.props.node), fromJS(nextProps.node))) { |
| | | this.setState({ |
| | | mknode: null, |
| | | formlist: null |
| | | }, () => { |
| | | this.setState({ |
| | | mknode: nextProps.node, |
| | | mkdata: nextProps.node.mkdata || '', |
| | | formlist: this.getFormList(nextProps.node) |
| | | }) |
| | | }) |
| | |
| | | }, |
| | | { |
| | | type: 'other', |
| | | label: '自定义信息', |
| | | initval: node |
| | | label: '自定义信息' |
| | | } |
| | | ] |
| | | } else if (node.shape === 'lane') { |
| | |
| | | }, |
| | | { |
| | | type: 'other', |
| | | label: '自定义信息', |
| | | initval: node |
| | | label: '自定义信息' |
| | | } |
| | | ] |
| | | } |
| | |
| | | } |
| | | |
| | | confirm = () => { |
| | | this.setState({visible: false}) |
| | | this.nodeRef.handleConfirm().then(res => { |
| | | this.setState({visible: false, mkdata: res}) |
| | | this.props.onChange(res, 'mkdata') |
| | | }) |
| | | } |
| | | |
| | | getFields() { |
| | | const { formlist } = this.state |
| | | const { formlist, mkdata, mknode } = this.state |
| | | const fields = [] |
| | | |
| | | if (!formlist) return |
| | |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <span className="split-line">{item.label}:<FormOutlined onClick={() => {this.setState({visible: true})}}/></span> |
| | | {mkdata ? <div className="mk-data"> |
| | | <div>状态:{mkdata.status}<span style={{float: 'right'}}>{mkdata.statusName}</span></div> |
| | | {mknode.shape !== 'edge' ? <div>标记:{mkdata.sign || ''}</div> : null} |
| | | {mkdata.roleId ? <div>角色:{mkdata.roleName || ''}</div> : null} |
| | | {mkdata.depId ? <div>部门:{mkdata.depName || ''}</div> : null} |
| | | <div>备注:{mkdata.remark || ''}</div> |
| | | </div> : null} |
| | | </Col> |
| | | ) |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { visible } = this.state |
| | | const { visible, mkdata, mknode } = this.state |
| | | |
| | | return ( |
| | | <div className="node-edit-form-wrap"> |
| | |
| | | onCancel={() => this.setState({visible: false})} |
| | | destroyOnClose |
| | | > |
| | | |
| | | <NodeForm node={mknode} data={mkdata} rolelist={this.props.rolelist} handleSubmit={() => this.confirm()} wrappedComponentRef={(inst) => this.nodeRef = inst}/> |
| | | </Modal> |
| | | </div> |
| | | ) |
| | |
| | | padding-bottom: 2px; |
| | | font-size: 13px; |
| | | } |
| | | .mk-data { |
| | | font-size: 13px; |
| | | padding: 0 12px; |
| | | >div { |
| | | padding-bottom: 2px; |
| | | } |
| | | } |
| | | textarea.ant-input { |
| | | padding: 0px 4px; |
| | | border-radius: 0px; |
| | |
| | | border-radius: 3px; |
| | | border: 1px solid rgba(0, 0, 0, 0.07); |
| | | background: rgba(0, 0, 0, 0); |
| | | } |
| | | |
| | | .normal-node-form { |
| | | >.ant-row >.ant-col-24 { |
| | | .ant-form-item-label { |
| | | width: 16%; |
| | | } |
| | | .ant-form-item-control-wrapper { |
| | | width: 84%; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Select, Input, Radio, Tooltip, InputNumber } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | class NodeForm extends Component { |
| | | static propTpyes = { |
| | | node: PropTypes.any, |
| | | data: PropTypes.any, |
| | | rolelist: PropTypes.array |
| | | } |
| | | |
| | | state = { |
| | | ctrlType: this.props.data.ctrlType || 'role' |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { rolelist } = this.props |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | if (values.roleId) { |
| | | values.roleName = '' |
| | | rolelist.forEach(item => { |
| | | if (item.RoleID === values.roleId) { |
| | | values.roleName = item.RoleName |
| | | } |
| | | }) |
| | | } |
| | | if (values.depId) { |
| | | values.depName = '' |
| | | rolelist.forEach(item => { |
| | | if (item.RoleID === values.depId) { |
| | | values.depName = item.RoleName |
| | | } |
| | | }) |
| | | } |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { node, rolelist } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { ctrlType } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 8 } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 16 } |
| | | } |
| | | } |
| | | let data = this.props.data || {} |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="normal-node-form"> |
| | | <Row gutter={24}> |
| | | <Col span={12}> |
| | | <Form.Item label="状态值"> |
| | | {getFieldDecorator('status', { |
| | | initialValue: data.status || 0, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入状态值!' |
| | | } |
| | | ] |
| | | })( |
| | | <InputNumber precision={0}/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="状态名"> |
| | | {getFieldDecorator('statusName', { |
| | | initialValue: data.statusName || '' |
| | | })( |
| | | <Input placeholder="" autoComplete="off"/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {node.shape !== 'edge' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="标记将作为节点ID"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 标记 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('sign', { |
| | | initialValue: data.sign || '' |
| | | })( |
| | | <Input placeholder="" autoComplete="off"/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={12}> |
| | | <Form.Item label="类型"> |
| | | {getFieldDecorator('ctrlType', { |
| | | initialValue: data.ctrlType || 'role' |
| | | })( |
| | | <Radio.Group onChange={(e) => this.setState({ctrlType: e.target.value})}> |
| | | <Radio value="role">角色</Radio> |
| | | <Radio value="department">部门</Radio> |
| | | <Radio value="none">无</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {ctrlType === 'role' ? <Col span={12}> |
| | | <Form.Item label="角色"> |
| | | {getFieldDecorator('roleId', { |
| | | initialValue: data.roleId || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择角色!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}> |
| | | {rolelist.map(item => (<Select.Option key={item.RoleID} value={item.RoleID}>{item.RoleName}</Select.Option>))} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {ctrlType === 'department' ? <Col span={12}> |
| | | <Form.Item label="部门"> |
| | | {getFieldDecorator('depId', { |
| | | initialValue: data.depId || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择部门!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}> |
| | | {rolelist.map(item => (<Select.Option key={item.RoleID} value={item.RoleID}>{item.RoleName}</Select.Option>))} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={24}> |
| | | <Form.Item label="备注"> |
| | | {getFieldDecorator('remark', { |
| | | initialValue: data.remark || '' |
| | | })( |
| | | <TextArea rows={2}/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(NodeForm) |