From 2aa5ab63b4bbce5c36dbb3511b205b3b5f6af9bd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 07 五月 2024 11:34:20 +0800 Subject: [PATCH] 2024-05-07 --- src/tabviews/custom/components/chart/antv-X6/nodeupdate/nodeform.jsx | 235 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 173 insertions(+), 62 deletions(-) diff --git a/src/tabviews/custom/components/chart/antv-X6/nodeupdate/nodeform.jsx b/src/tabviews/custom/components/chart/antv-X6/nodeupdate/nodeform.jsx index 83ef825..92efe95 100644 --- a/src/tabviews/custom/components/chart/antv-X6/nodeupdate/nodeform.jsx +++ b/src/tabviews/custom/components/chart/antv-X6/nodeupdate/nodeform.jsx @@ -1,42 +1,79 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Select, Input, Radio, Tooltip, InputNumber } from 'antd' +import { Form, Row, Col, Input, Radio, Tooltip, InputNumber, Switch, notification } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' +import MemberForm from './memberform' const { TextArea } = Input class NodeForm extends Component { static propTpyes = { node: PropTypes.any, data: PropTypes.any, - rolelist: PropTypes.array + orgs: PropTypes.array, + handleSubmit: PropTypes.func } state = { - ctrlType: this.props.data.ctrlType || 'role' + flowType: 'approval', + execCondition: false, + approvalMethod: 'orsign', + readOnly: false, + options: [] + } + + UNSAFE_componentWillMount() { + const { node, data } = this.props + + let options = [] + let readOnly = false + + if (node.mknode === 'start') { + readOnly = true + } else if (node.mknode === 'end') { + + } else if (node.mknode === 'endEdge') { + options = ['approvalMethod', 'execCondition'] + } else if (node.mknode === 'startEdge') { + readOnly = true + } else if (node.mknode === 'firstEdge') { + options = ['approver', 'members', 'copys'] + } else if (node.shape !== 'edge') { // node + options = ['sign'] + } else { + options = ['flowType', 'approvalMethod', 'approver', 'members', 'copys', 'execCondition'] + } + + this.setState({ + flowType: data.flowType || 'approval', + execCondition: options.includes('execCondition') && data.execCondition === 'open', + approvalMethod: data.approvalMethod || 'orsign', + options, + readOnly + }) } 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.approvalMethod === 'countersign' && values.members.length > 5) { + notification.warning({ + top: 92, + message: '浼氱鏃跺鎵逛汉涓嶅彲瓒呰繃5浜猴紒', + duration: 10 }) + return } - if (values.depId) { - values.depName = '' - rolelist.forEach(item => { - if (item.RoleID === values.depId) { - values.depName = item.RoleName - } - }) + + if (values.execCondition === true) { + values.execCondition = 'open' + } else if (values.execCondition === false) { + values.execCondition = 'close' + } + + if (values.matchVal) { + values.matchVal = values.matchVal.replace(/\t+|\v+|\s+/g, '') } resolve(values) } else { @@ -47,9 +84,9 @@ } render() { - const { node, rolelist } = this.props + const { orgs } = this.props const { getFieldDecorator } = this.props.form - const { ctrlType } = this.state + const { flowType, execCondition, approvalMethod, readOnly, options } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -65,18 +102,18 @@ return ( <Form {...formItemLayout} className="normal-node-form"> <Row gutter={24}> + {options.includes('approver') || options.includes('execCondition') ? <Col span={24}> + <p className="mk-split">鎸夐挳鎵ц鍛戒护</p> + </Col> : null} <Col span={12}> <Form.Item label="鐘舵�佸��"> {getFieldDecorator('status', { - initialValue: data.status || 0, + initialValue: data.status, rules: [ - { - required: true, - message: '璇疯緭鍏ョ姸鎬佸��!' - } + { required: true, message: '璇疯緭鍏ョ姸鎬佸��!' } ] })( - <InputNumber precision={0}/> + <InputNumber readOnly={readOnly} precision={0} onPressEnter={() => this.props.handleSubmit()}/> )} </Form.Item> </Col> @@ -85,11 +122,11 @@ {getFieldDecorator('statusName', { initialValue: data.statusName || '' })( - <Input placeholder="" autoComplete="off"/> + <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/> )} </Form.Item> </Col> - {node.shape !== 'edge' ? <Col span={12}> + {options.includes('sign') ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title="鏍囪灏嗕綔涓鸿妭鐐笽D"> <QuestionCircleOutlined className="mk-form-tip" /> @@ -99,54 +136,48 @@ {getFieldDecorator('sign', { initialValue: data.sign || '' })( - <Input placeholder="" autoComplete="off"/> + <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/> )} </Form.Item> </Col> : null} - <Col span={12}> - <Form.Item label="绫诲瀷"> - {getFieldDecorator('ctrlType', { - initialValue: data.ctrlType || 'role' + {options.includes('flowType') ? <Col span={12}> + <Form.Item label="鎿嶄綔绫诲瀷"> + {getFieldDecorator('flowType', { + initialValue: flowType })( - <Radio.Group onChange={(e) => this.setState({ctrlType: e.target.value})}> - <Radio value="role">瑙掕壊</Radio> - <Radio value="department">閮ㄩ棬</Radio> - <Radio value="none">鏃�</Radio> + <Radio.Group onChange={(e) => this.setState({flowType: e.target.value})}> + <Radio value="approval">瀹℃壒</Radio> + <Radio value="reject">椹冲洖</Radio> </Radio.Group> )} </Form.Item> - </Col> - {ctrlType === 'role' ? <Col span={12}> - <Form.Item label="瑙掕壊"> - {getFieldDecorator('roleId', { - initialValue: data.roleId || '', - rules: [ - { - required: true, - message: '璇烽�夋嫨瑙掕壊!' - } - ] + </Col> : null} + {options.includes('approvalMethod') && flowType !== 'reject' ? <Col span={12}> + <Form.Item label="瀹℃壒鏂瑰紡"> + {getFieldDecorator('approvalMethod', { + initialValue: approvalMethod })( - <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> + <Radio.Group onChange={(e) => this.setState({approvalMethod: e.target.value})}> + <Radio value="orsign">鎴栫</Radio> + <Radio value="countersign">浼氱</Radio> + </Radio.Group> )} </Form.Item> </Col> : null} - {ctrlType === 'department' ? <Col span={12}> - <Form.Item label="閮ㄩ棬"> - {getFieldDecorator('depId', { - initialValue: data.depId || '', + {options.includes('approvalMethod') && flowType !== 'reject' && approvalMethod === 'countersign' ? <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title="绀轰緥锛氣�滆储鍔$粡鐞嗗紶鎬诲凡瀹℃牳鈥濓紝鍏朵腑鈥滃凡瀹℃牳鈥濅负浼氱鏍囪銆�"> + <QuestionCircleOutlined className="mk-form-tip" /> + 浼氱鏍囪 + </Tooltip> + }> + {getFieldDecorator('mark', { + initialValue: data.mark || '宸插鏍�', rules: [ - { - required: true, - message: '璇烽�夋嫨閮ㄩ棬!' - } + { 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> + <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/> )} </Form.Item> </Col> : null} @@ -159,6 +190,86 @@ )} </Form.Item> </Col> + {options.includes('approver') ? <Col span={24}> + <p className="mk-split">涓嬩竴姝ュ鎵规潈闄�</p> + </Col> : null} + {options.includes('approver') ? <Col span={12}> + <Form.Item label="璁剧疆瀹℃壒浜�"> + {getFieldDecorator('approver', { + initialValue: data.approver || 'member' + })( + <Radio.Group> + <Radio value="member">鎸囧畾鎴愬憳</Radio> + <Radio value="departmentManager">閮ㄩ棬涓荤</Radio> + <Radio value="directManager">鐩村睘涓荤</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {options.includes('members') ? <Col span={12}> + <Form.Item label="瀹℃壒浜�"> + {getFieldDecorator('members', { + initialValue: data.members || [], + rules: [ + { required: true, message: '璇锋坊鍔犲鎵逛汉!' } + ] + })( + <MemberForm orgs={orgs} title="瀹℃壒浜�"/> + )} + </Form.Item> + </Col> : null} + {options.includes('copys') ? <Col span={12}> + <Form.Item label="鎶勯�佷汉"> + {getFieldDecorator('copys', { + initialValue: data.copys || [] + })( + <MemberForm orgs={orgs} title="鎶勯�佷汉"/> + )} + </Form.Item> + </Col> : null} + {options.includes('execCondition') && flowType !== 'reject' ? <Col span={24}> + <p className="mk-split">鍒嗘敮鎵ц鏉′欢</p> + </Col> : null} + {options.includes('execCondition') && flowType !== 'reject' ? <Col span={12}> + <Form.Item label="鎵ц鏉′欢"> + {getFieldDecorator('execCondition', { + valuePropName: 'checked', + initialValue: execCondition + })( + <Switch checkedChildren="寮�鍚�" unCheckedChildren="鍏抽棴" onChange={(val) => this.setState({execCondition: val})} /> + )} + </Form.Item> + </Col> : null} + {flowType !== 'reject' && execCondition ? <Col span={12}> + <Form.Item label="瀵规瘮鏂瑰紡"> + {getFieldDecorator('match', { + initialValue: data.match || '=' + })( + <Radio.Group> + <Radio value="=">=</Radio> + <Radio value="<"><</Radio> + <Radio value=">">></Radio> + <Radio value="<="><=</Radio> + <Radio value=">=">>=</Radio> + <Radio value="!=">!=</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {flowType !== 'reject' && execCondition ? <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title="瀵规瘮鍊间腑涓嶅彲鍖呭惈鍒惰〃绗︺�佺┖鏍笺�佹崲琛岀绛夈��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 瀵规瘮鍊� + </Tooltip> + }> + {getFieldDecorator('matchVal', { + initialValue: data.matchVal || '' + })( + <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/> + )} + </Form.Item> + </Col> : null} </Row> </Form> ) -- Gitblit v1.8.0