| | |
| | | columnChange: PropTypes.func // 修改函数 |
| | | } |
| | | |
| | | state = { |
| | | editItem: null // 编辑元素 |
| | | } |
| | | |
| | | edit = (record) => { |
| | | this.setState({ |
| | | editItem: record |
| | | }) |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | label: record.label, |
| | | field: record.field, |
| | | datatype: record.datatype |
| | | }) |
| | | } |
| | | |
| | | state = {} |
| | | |
| | | handleConfirm = () => { |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.uuid = this.state.editItem ? this.state.editItem.uuid : '' |
| | | |
| | | this.setState({ |
| | | editItem: null |
| | | }, () => { |
| | | this.props.columnChange(values) |
| | | }) |
| | | this.props.form.setFieldsValue({ |
| | | label: '', |
| | | field: '' |
| | | this.props.columnChange(values, () => { |
| | | this.props.form.setFieldsValue({ |
| | | label: '', |
| | | field: '' |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { dict } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | return ( |
| | | <Form {...formItemLayout} className="verify-form" id="verifycard1"> |
| | | <Row gutter={24}> |
| | | <Col span={7}> |
| | | <Col span={6}> |
| | | <Form.Item label={'名称'}> |
| | | {getFieldDecorator('label', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '名称!' |
| | | message: dict['form.required.input'] + '名称!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleConfirm}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={7}> |
| | | <Col span={6}> |
| | | <Form.Item label={'字段'}> |
| | | {getFieldDecorator('field', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '字段!' |
| | | message: dict['form.required.input'] + '字段!' |
| | | }, |
| | | { |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleConfirm} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={7}> |
| | | <Col span={6}> |
| | | <Form.Item label={'数据类型'}> |
| | | {getFieldDecorator('datatype', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.select'] + '数据类型!' |
| | | message: dict['form.required.select'] + '数据类型!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select> |
| | | <Select.Option value="Nvarchar(10)"> Nvarchar(10) </Select.Option> |
| | | <Select.Option value="Nvarchar(20)"> Nvarchar(20) </Select.Option> |
| | | <Select.Option value="Nvarchar(50)"> Nvarchar(50) </Select.Option> |
| | | <Select.Option value="Nvarchar(100)"> Nvarchar(100) </Select.Option> |
| | | <Select.Option value="Nvarchar(512)"> Nvarchar(512) </Select.Option> |
| | |
| | | <Select.Option value="Decimal(18,16)"> Decimal(18,16) </Select.Option> |
| | | <Select.Option value="Decimal(18,17)"> Decimal(18,17) </Select.Option> |
| | | <Select.Option value="Decimal(18,18)"> Decimal(18,18) </Select.Option> |
| | | {/* <Select.Option value="date"> date </Select.Option> */} |
| | | <Select.Option value="date"> date </Select.Option> |
| | | <Select.Option value="datetime"> datetime </Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={3} className="add"> |
| | | <Button onClick={this.handleConfirm} type="primary" className="mk-green"> |
| | | 保存 |
| | | {dict['model.add']} |
| | | </Button> |
| | | </Col> |
| | | </Row> |