import React, { useEffect } from 'react'
import { Form, Select, Button, Modal } from 'antd'

const formItemLayout = {
  labelCol: {
    xs: { span: 24 },
    sm: { span: 6 },
  },
  wrapperCol: {
    xs: { span: 24 },
    sm: { span: 12 },
  },
}

const tailFormItemLayout = {
  wrapperCol: {
    xs: {
      span: 24,
      offset: 0,
    },
    sm: {
      span: 16,
      offset: 6,
    },
  },
}

export default Form.create()(props => {

  const handleSubmit = e => {
    e.preventDefault()
    props.form.validateFields((err, values) => {
      if (!err) {
        props.onSubmit(values)
      }
    })
  }

  useEffect(() => {
    // props.setFieldsValue()
  }, [])

  return (
    <Modal footer={null} maskClosable={false} onCancel={props.onCancel} visible={props.visible}>
      <Form {...formItemLayout} onSubmit={handleSubmit}>
        <Form.Item label="身份">
          {
            props.form.getFieldDecorator('roleId')(
              <Select>
                <Select.Option key="1" value="1">户主</Select.Option>
                <Select.Option key="2" value="2">租客</Select.Option>
                <Select.Option key="3" value="3">家属</Select.Option>
              </Select>
            )
          }
        </Form.Item>
        <Form.Item label="审核状态">
          {
            props.form.getFieldDecorator('verifyStatus')(
              <Select>
                <Select.Option key="1" value="1">审核通过</Select.Option>
                <Select.Option key="2" value="2">审核未通过</Select.Option>
                <Select.Option key="0" value="0">未审核</Select.Option>
              </Select>
            )
          }
        </Form.Item>
        <Form.Item {...tailFormItemLayout}>
          <Button type="primary" htmlType="submit">确定</Button>
          <Button onClick={props.onCancel} style={{ marginLeft: '48px' }}>取消</Button>
        </Form.Item>
      </Form>
    </Modal>
  )
})
