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

export default Form.create()(props => {
  const [userId, setUserId] = useState()

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


  return (
    <Modal  footer={null} maskClosable={false} onCancel={props.onCancel} visible={props.visible}>
      <Form onSubmit={handleSubmit}>
        <Form.Item label="选择受理人">
          <Select onChange={e => setUserId(e)}>
            {
              (props.userList || []).map(user => (<Select.Option key={user.userId} value={user.userId}>{user.userName}</Select.Option>))
            }
          </Select>
        </Form.Item>
        <Form.Item>
          <Button type="primary" htmlType="submit">确定</Button>
          <Button onClick={props.onCancel} style={{ marginLeft: '48px' }}>取消</Button>
        </Form.Item>
      </Form>
    </Modal>
  )
})
