| | |
| | | uniqueChange: PropTypes.func // 修改函数 |
| | | } |
| | | |
| | | state = { |
| | | editItem: null // 编辑元素 |
| | | } |
| | | |
| | | edit = (record) => { |
| | | this.setState({ |
| | | editItem: record |
| | | }) |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | field: record.field.split(','), |
| | | errorCode: record.errorCode, |
| | | verifyType: record.verifyType || 'physical' |
| | | }) |
| | | } |
| | | |
| | | |
| | | handleConfirm = () => { |
| | | const { fields } = this.props |
| | | let change = {} |
| | | |
| | | fields.forEach(col => { |
| | | change[col.Column] = col.Text |
| | | }) |
| | | |
| | | // 表单提交时检查输入值是否正确 |
| | | 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.Column === field)[0] |
| | | let label = '' |
| | | if (item) { |
| | | label = item.Text |
| | | } |
| | | return label |
| | | return change[field] || '' |
| | | }) |
| | | |
| | | values.fieldlabel = values.fieldlabel.join(',') |
| | | values.field = values.field.join(',') |
| | | |
| | | this.setState({ |
| | | editItem: null |
| | | }, () => { |
| | | this.props.uniqueChange(values) |
| | | }) |
| | | this.props.uniqueChange(values) |
| | | this.props.form.setFieldsValue({ |
| | | field: [], |
| | | }) |
| | |
| | | return ( |
| | | <Form {...formItemLayout} className="verify-form" id="verifycard1"> |
| | | <Row gutter={24}> |
| | | <Col span={8}> |
| | | <Col span={7}> |
| | | <Form.Item label={'列名'}> |
| | | {getFieldDecorator('field', { |
| | | initialValue: [], |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={6}> |
| | | <Col span={7}> |
| | | <Form.Item label={'报错编码'}> |
| | | {getFieldDecorator('errorCode', { |
| | | initialValue: 'E', |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={6}> |
| | | <Col span={7}> |
| | | <Form.Item label={'验证类型'}> |
| | | {getFieldDecorator('verifyType', { |
| | | initialValue: 'physical', |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={4} className="add"> |
| | | <Col span={3} className="add"> |
| | | <Button onClick={this.handleConfirm} className="mk-green"> |
| | | 保存 |
| | | 添加 |
| | | </Button> |
| | | </Col> |
| | | </Row> |