import React from 'react';
import { Input, Modal, Form, Select, Button, InputNumber } from 'antd';
const CreateForm = (props) => {
  const { Option, OptGroup } = Select;
  return (
    <Modal
      title={props.values.id ? '编辑' : '新建'}
      width={640}
      visible={props.modalVisible}
      bodyStyle={{ padding: '32px 40px 48px' }}
      footer={null}
      onCancel={() => {
        props.onCancel();
      }}
      destroyOnClose
      maskClosable={false}
    >
      <Form
        layout="horizontal"
        labelCol={{ span: 4 }}
        preserve={false}
        initialValues={props.values}
        onFinish={props.onFinish}
      >
        <Form.Item name="id" hidden={true}>
          <Input />
        </Form.Item>
        <Form.Item name="name" label="企业名称" rules={[{ required: true, max: 30 }]}>
          <Input placeholder="请输入企业名称" />
        </Form.Item>
        <Form.Item name="code" label="企业编码" rules={[{ required: true, max: 30 }]}>
          <Input placeholder="请输入企业编码" />
        </Form.Item>
        <Form.Item name="adminName" label="管理员姓名" rules={[{ required: true, max: 20 }]}>
          <Input placeholder="请输入管理员姓名" />
        </Form.Item>
        <Form.Item name="settlementCycles" label="结算周期" rules={[{ required: true}]}>
          <InputNumber step={1} min={1} max={100}  precision={0} />
        </Form.Item>
        <Form.Item name="email" label="电子邮件" rules={[{ required: true, max: 50,message:"请输入电子邮件"},{pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
message: '邮箱格式不正确', }]}>
          <Input placeholder="电子邮件是登录账户" disabled={props.values.id?true:false} />
        </Form.Item>
        <Form.Item name="phone" label="电话" rules={[{ max: 20,pattern: /0?(13|14|15|18|17)[0-9]{9}$/,
message: '手机号格式不正确' }]}>
          <Input placeholder="请输入电话" />
        </Form.Item>
        <Form.Item name="host" label="域名" rules={[{ max: 100 }]}>
          <Input placeholder="请输入域名" />
        </Form.Item>
        <Form.Item name="wechatAppId" label="小程序id" rules={[{ max: 100 }]}>
          <Input placeholder="小程序id" />
        </Form.Item>
        <Form.Item name="remark" label="备注" rules={[{ max: 100 }]}>
          <Input placeholder="请输入备注" />
        </Form.Item>
        <Form.Item>
          <Button type="primary" htmlType="submit">
            保存
          </Button>
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default CreateForm;
