import React from 'react';
import { Button, Drawer, Space } from 'antd';
import StaffSearch from '@/components/Staff/StaffSearch';

export default (props) => {

  const { open, onOpenChange, onChange } = props;

  const [vals, setVals] = React.useState([]);

  const onClose = () => {
    if (onOpenChange) {
      onOpenChange(false);
    }
  }

  const handleChange = (...args) => {
    setVals(args);
  }

  const onSubmit = () => {
    onOpenChange(false);
    if (onChange) {
      onChange(...(vals || []));
    }
  }

  return (
    <Drawer
      title="请选择员工"
      placement="right"
      open={open}
      width={720}
      bodyStyle={{ paddingBottom: 80 }}
      onClose={onClose}
      extra={
        <Space>
          <Button onClick={onClose}>Cancel</Button>
          <Button onClick={onSubmit} type="primary">
            确定
          </Button>
        </Space>
      }
    >
      <StaffSearch onChange={handleChange} />
    </Drawer>
  )
}

