import React, { PureComponent as Component } from 'react' import PropTypes from 'prop-types' import { Form, Input, Select, Button } from 'antd'; import constants from '../../../../constants/variable.js' import { handleApiPath, nameLengthLimit } from '../../../../common.js' const HTTP_METHOD = constants.HTTP_METHOD; const HTTP_METHOD_KEYS = Object.keys(HTTP_METHOD); const FormItem = Form.Item; const Option = Select.Option; function hasErrors(fieldsError) { return Object.keys(fieldsError).some(field => fieldsError[field]); } class AddInterfaceForm extends Component { static propTypes = { form: PropTypes.object, onSubmit: PropTypes.func, onCancel: PropTypes.func, catid: PropTypes.number, catdata: PropTypes.array } handleSubmit = (e) => { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.props.onSubmit(values, () => { this.props.form.resetFields(); }); } }); } handlePath = (e) => { let val = e.target.value this.props.form.setFieldsValue({ path: handleApiPath(val) }) } render() { const { getFieldDecorator, getFieldsError } = this.props.form; const prefixSelector = getFieldDecorator('method', { initialValue: 'GET' })( ); const formItemLayout = { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 14 } } }; return (
); } } export default Form.create()(AddInterfaceForm);