add.js 2.2 KB
Newer Older
vipcxj's avatar
vipcxj committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
import React from 'react';
import { Button, Input, Form } from 'antd';
import styles from './add.less';
import { thisPush } from '../../../../services/route';

const FormItem = Form.Item;
class Add extends React.Component {
  componentDidMount() {
  }
  onCancel = () => {
    thisPush(this, { pathname: '../list' });
  };
  handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        this.props.dispatch({ type: 'appInfo/addAppInfo', payload: { values } });
      }
    });
  };
  render() {
    // console.log(this.props.appInfo);
    const { getFieldDecorator } = this.props.form;
    return (
      <div className={styles.wrapper}>
        <div className={styles.container}>
          <Form onSubmit={this.handleSubmit}>
            <FormItem
              label="名称"
              labelCol={{ span: 4 }}
              wrapperCol={{ span: 8 }}
            >
              {getFieldDecorator('name', {
                rules: [{ required: true, message: 'Please input your name!' }],
              })(
                <Input />,
              )}
            </FormItem>
            <FormItem
              label="包名"
              labelCol={{ span: 4 }}
              wrapperCol={{ span: 8 }}
            >
              {getFieldDecorator('packageName', {
                rules: [{ required: true, message: 'Please input your packageName!' }],
              })(
                <Input />,
              )}
            </FormItem>
            <FormItem
              label="描述"
              labelCol={{ span: 4 }}
              wrapperCol={{ span: 8 }}
            >
              {getFieldDecorator('description', {
              })(
                <Input />,
              )}
            </FormItem>
            <FormItem
              wrapperCol={{ span: 8, offset: 4 }}
            >
              <Button type="primary" htmlType="submit">
                提交
              </Button>
              <Button style={{ marginLeft: 60 }} onClick={this.onCancel}>
                返回
              </Button>
            </FormItem>
          </Form>
        </div>
      </div>
    );
  }
}
export default Form.create()(Add);