| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Select, Button } from 'antd' |
| | | import { Form, Row, Col, Select, Button } from 'antd' |
| | | import './index.scss' |
| | | |
| | | |
| | | class UniqueForm extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | fields: PropTypes.array, // 表单 |
| | | uniqueChange: PropTypes.func // 表单 |
| | | dict: PropTypes.object, // 字典项 |
| | | fields: PropTypes.array, // 表单字段 |
| | | uniqueChange: PropTypes.func // 修改函数 |
| | | } |
| | | |
| | | state = { |
| | | editItem: null |
| | | editItem: null // 编辑元素 |
| | | } |
| | | |
| | | edit = (record) => { |
| | | this.setState({ |
| | | editItem: record |
| | | }) |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | field: record.field.split(','), |
| | | errmsg: record.errmsg, |
| | | errorCode: record.errorCode |
| | | }) |
| | | } |
| | | |
| | | |
| | | handleConfirm = () => { |
| | | const { fields } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.uuid = this.state.editItem ? this.state.editItem.uuid : '' |
| | | values.fieldlabel = values.field.map(field => { |
| | | let item = fields.filter(cell => cell.field === field)[0] |
| | | let label = '' |
| | | if (item) { |
| | | label = item.label |
| | | } |
| | | return label |
| | | }) |
| | | |
| | | values.fieldlabel = values.fieldlabel.join(',') |
| | | values.field = values.field.join(',') |
| | | |
| | | this.props.uniqueChange(values) |
| | |
| | | }) |
| | | this.props.form.setFieldsValue({ |
| | | field: [], |
| | | errmsg: '' |
| | | }) |
| | | } |
| | | }) |
| | |
| | | sm: { span: 16 } |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="verify-form" id="verifycard1"> |
| | | <Row gutter={24}> |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={6}> |
| | | <Form.Item label={'提示信息'}> |
| | | {getFieldDecorator('errmsg', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '提示信息!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={6}> |
| | | <Form.Item label={'报错编码'}> |
| | | {getFieldDecorator('errorCode', { |
| | | initialValue: 'E', |
| | |
| | | <Select.Option value="N"> N </Select.Option> |
| | | <Select.Option value="F"> F </Select.Option> |
| | | <Select.Option value="NM"> NM </Select.Option> |
| | | <Select.Option value="S"> S </Select.Option> |
| | | <Select.Option value="-1"> -1 </Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |