import React , { Component } from 'react';
import { Link } from 'react-router-dom';
import { Form,Input,Icon,DatePicker,Button} from 'antd'
import locale from 'antd/lib/date-picker/locale/zh_CN';
const  TextArea = Input.TextArea;
class WorkItem extends Component{
    
  constructor(props){
    super(props);
    this.state={
      //显示 隐藏
      isdisplay:false,
      orderid:'',
    }
    if(props.onRef){//如果父组件传来该方法 则调用方法将子组件this指针传过去
        props.onRef(this)
      }  
  }

  workeducation=(educationarray)=>{ 
    this.props.workeducation(educationarray);
  }

  cancel=()=>{
    //隐藏列表
    const isdisplay=this.state.isdisplay;
    this.setState({
        isdisplay:!isdisplay   
    }) 
  }

  CreateFormManFun=()=>{
 
    // 创建Form表单
 
    const CreateFormMan = Form.create()(props => {
 
         const { dispatch,form} = props;
 
         const { getFieldDecorator } = form;

         const formItemLayout = {
            labelCol: {
              xs: { span: 24 },
              sm: { span: 0 },
            },
            wrapperCol: {
              xs: { span: 24 },
              sm: { span: 24 },
            },
          };
 
         // 提交事件
 
         const searchMan = () => {
 
               const {dispatch}=this.props;
 
               form.validateFields((err, fieldsValue) => {
 
                   if (err) return;
                   this.workeducation(fieldsValue);
                   //console.log(values)
                //    const values = {...};
 
             })
 
     };
 
     return (
        <div>
       <Form.Item
        {...formItemLayout}
      >
        <Form.Item
                  style={{ display: 'inline-block', width: 'calc(20% - 12px)' }}
                >
                  {getFieldDecorator('begin_on', {
                    rules: [{
                      required: true,
                      message: '请选择开始日期',
                    }],
                  })(
                      <DatePicker
                        showToday={false}
                        placeholder="请选择开始日期"
                        // showTime={{format: 'HH:mm'}}
                          style={{width:180}}
                        locale={locale}
                        onChange={this.onChangeTimepublishs}
                      />
                  )}
              </Form.Item>
          
              <Form.Item
                  style={{ display: 'inline-block', width: 'calc(20% - 12px)' }}
                >
                  {getFieldDecorator('end_on', {
                    rules: [{
                      required: true,
                      message: '请选择结束日期',
                    }],
                  })(
                      <DatePicker
                        showToday={false}
                        placeholder="请选择结束日期"
                        // showTime={{format: 'HH:mm'}}
                          style={{width:180}}
                        locale={locale}
                        onChange={this.onChangeTimepublishs}
                      />
                  )}
              </Form.Item>

              <Form.Item>
              {getFieldDecorator(`school`, {
                validateTrigger: ['onChange', 'onBlur'],
                rules: [
                  {
                    required: true, message: "不能为空"
                  },
                ],
              })(<Input placeholder="请输入公司名称" style={{ width:'60%',marginRight:8 }} />)}
              </Form.Item> 

              <Form.Item>
              {getFieldDecorator(`des`, {
                validateTrigger: ['onChange', 'onBlur'],
                rules: [
                  {
                    required: true, message: "不能为空"
                  },
                ],
              })(<TextArea placeholder="请输入公司描述" rows={4} style={{ width:'60%',marginRight:8 }} />)}
              </Form.Item> 
            <div style={{width:'100%',margin:'auto',marginLeft:200}}>
                <Button type="primary" onClick={searchMan} >
                    保存
                </Button>
                <Button type="danger" style={{marginLeft:15}} onClick={this.cancel}>
                    取消
                </Button>
            </div>
        </Form.Item>
       
    
      </div>
        );
 
});
 
return <CreateFormMan />
 
}

  render(){
    return(
        <div style={{display:this.state.isdisplay?'':'none'}}>
             {this.CreateFormManFun()}
        </div>
    )
  }
}
export default WorkItem;