import React, { Component } from "react";
import {
  Button,
  Form,
  Input,
  Select,
  DatePicker
} from "antd";
// import moment from 'moment';
const dateFomate = 'YYYY-MM-DD';
import {

} from '../../../../services/api';
const { Option } = Select;
const { RangePicker } = DatePicker;
@Form.create()
export default class SearchForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
    }
  }
  componentDidMount() {
    this._search();
  }

  _search = (e) => {
    e && e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        // 缴费时间
        if (values.payDate.length == 0) {
          values.payStartDate = '';
          values.payEndDate = '';
        } else {
          values.payStartDate = values.payDate[0].format(dateFomate);
          values.payEndDate = values.payDate[1].format(dateFomate);
        }
        Reflect.deleteProperty(values, 'payDate');
        // practiceDate
        if (values.practiceDate.length == 0) {
          values.practiceStartDate = '';
          values.practiceEndDate = '';
        } else {
          values.practiceStartDate = values.practiceDate[0].format(dateFomate);
          values.practiceEndDate = values.practiceDate[1].format(dateFomate);
        }
        // 核对时间
        if (values.approveDate.length == 0) {
          values.approveStartDate = '';
          values.approveEndDate = '';
        } else {
          values.approveStartDate = values.approveDate[0].format(dateFomate);
          values.approveEndDate = values.approveDate[1].format(dateFomate);
        }
        Reflect.deleteProperty(values, 'practiceDate');
        Reflect.deleteProperty(values, 'approveDate');
        values.pageNumber = 1;
        this.props.onSearch(values);
      }
    });
  }
  _reset = () => {
    this.props.form.resetFields();
    this._search();
  }
  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <Form layout="inline" onSubmit={this._search}>
        <Form.Item style={{ marginTop: 10 }} label="关键词">
          {getFieldDecorator('keyword', {
            initialValue: ''
          })(
            <Input placeholder="请输入学员名称/身份证/手机号码" />
          )}
        </Form.Item>
        <Form.Item style={{ marginTop: 10 }} label="是否补考">
          {getFieldDecorator('isMakeUp', {
            initialValue: ''
          })(
            <Select style={{ minWidth: 150 }} >
              <Option value="">全部</Option>
              <Option value="0">否</Option>
              <Option value="1">是</Option>
            </Select>
          )}
        </Form.Item>
        {/* 0未审核，1审核通过，2审核不通过 */}
        <Form.Item style={{ marginTop: 10 }} label="材料核对状态">
          {getFieldDecorator('materialApproveStatus', {
            initialValue: ''
          })(
            <Select style={{ minWidth: 200 }} >
              <Option value="">全部</Option>
              <Option value="0">未核对</Option>
              <Option value="1">核对通过</Option>
              <Option value="2">核对不通过</Option>
            </Select>
          )}
        </Form.Item>
        <Form.Item style={{ marginTop: 10 }} label="保安公司名称">
          {getFieldDecorator('learnName', {
            initialValue: ''
          })(
            <Input placeholder="" />
          )}
        </Form.Item>
        <Form.Item style={{ marginTop: 10 }} label="实习状态">
          {getFieldDecorator('internStatus', {
            initialValue: ''
          })(
            <Select style={{ minWidth: 200 }} >
              <Option value="">全部</Option>
              <Option value="2">未实习</Option>
              <Option value="0">实习中</Option>
              <Option value="1">已完成</Option>
            </Select>
          )}
        </Form.Item>
        {/* <Form.Item style={{marginTop: 10}} label="报名比对状态">
          {getFieldDecorator('compareStatus', {
            initialValue: ''
          })(
            <Select style={{minWidth: 200}} >
              <Option value="">全部</Option>
              <Option value="0">待比对</Option>
              <Option value="1">可申请</Option>
              <Option value="2">不可申请</Option>
              <Option value="3">可修改</Option>
            </Select>
          )}
        </Form.Item> */}
        <Form.Item style={{ marginTop: 10 }} label="补贴比对状态">
          {getFieldDecorator('bonusCompareStatus', {
            initialValue: ''
          })(
            <Select style={{ minWidth: 200 }} >
              <Option value="">全部</Option>
              <Option value="0">待比对</Option>
              <Option value="1">可申请</Option>
              <Option value="2">不可申请</Option>
              <Option value="3">可修改</Option>
            </Select>
          )}
        </Form.Item>
        <Form.Item style={{ marginTop: 10 }} label="理论学习进度">
          {getFieldDecorator('trackLearnStatus', {
            initialValue: ''
          })(
            <Select style={{ minWidth: 200 }} >
              <Option value="">全部</Option>
              <Option value="0">未完成</Option>
              <Option value="1">已完成</Option>
            </Select>
          )}
        </Form.Item>

        <Form.Item style={{ marginTop: 10 }} label="缴费时间">
          {getFieldDecorator('payDate', {
            initialValue: []
          })(
            <RangePicker
              disabledDate={current => {
                // return current > moment().endOf('day')
                // return current && current > moment().endOf('day')
              }}
              // disabledTime={}
              format="YYYY-MM-DD"
            />
          )}
        </Form.Item>
        <Form.Item style={{ marginTop: 10 }} label="所属班级">
          {getFieldDecorator('className', {
            initialValue: ''
          })(
            <Input placeholder="" />
          )}
        </Form.Item>
        <Form.Item style={{ marginTop: 10 }} label="实操培训开班时间">
          {getFieldDecorator('practiceDate', {
            initialValue: []
          })(
            <RangePicker
              disabledDate={current => {
                // return current > moment().endOf('day')
                // return current && current > moment().endOf('day')
              }}
              // disabledTime={}
              format="YYYY-MM-DD"
            />
          )}
        </Form.Item>
        <Form.Item label="核对人" style={{ marginTop: 10 }}>
          {getFieldDecorator('approvePerKeyWord', {
            initialValue: ''
          })(
            <Input style={{ width: 200 }} placeholder="请输入姓名/身份证" />
          )}
        </Form.Item>
        <Form.Item label="核对时间" style={{ marginTop: 10 }}>
          {getFieldDecorator('approveDate', {
            initialValue: []
          })(
            <RangePicker
              format={dateFomate}
            />
          )}
        </Form.Item>
        <Form.Item label="协会审查结果" style={{ marginTop: 10 }}>
          {getFieldDecorator('checkStatus', {
            initialValue: ''
          })(
            <Select style={{ minWidth: 150 }} >
              <Option value="">全部</Option>
              <Option value="0">未审核</Option>
              <Option value="1">合格</Option>
              <Option value="2">不合格</Option>
              <Option value="3">已更新</Option>
              <Option value="4">已审核</Option>
            </Select>
          )}
        </Form.Item>
        {/* btns */}
        <Form.Item style={{ marginTop: 10 }} label=" " colon={false}>
          <Button type="primary" onClick={this._search}>搜索</Button>
        </Form.Item>
        <Form.Item style={{ marginTop: 10 }} label=" " colon={false}>
          <Button onClick={this._reset}>重置</Button>
        </Form.Item>
      </Form>
    );
  }
}
