/**
 * Created by zhouhuan on 2017/11/3.
 */
import React from 'react';
import { createForm } from 'rc-form';
import { View, ScrollView } from 'react-native';
import { Button, List, InputItem } from 'antd-mobile';
import { connect } from 'react-redux';
import { createAction } from '../../../utils';

@connect(({ peopleInfo }) => ({ peopleInfo }))
class AddPeopleInfo extends React.Component {
  componentDidMount() {
    // const { id } = this.props.navigation.state.params;
    // this.props.dispatch(createAction('peopleInfo/getPeopleDetail')(id));
  }
  onSubmit = () => {
    this.props.form.validateFields({ force: true }, (error, value) => {
      if (!error) {
        this.props.dispatch(createAction('peopleInfo/savePeopleInfo')(value));
      } else {
        console.log('Validation failed');
      }
    });
  };
  onEditBack = () => {
    this.props.dispatch(createAction('peopleInfo/onEBack')('clear'));
  };
  render() {
    console.log(this.props.peopleInfo);
    const { getFieldProps } = this.props.form;
    return (
      <ScrollView>
        <List>
          <InputItem
            {...getFieldProps('xingMing', {
              rules: [
                { required: true, message: '不允许为空' },
              ],
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            姓名
          </InputItem>
          <InputItem
            {...getFieldProps('identityCard', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            证件号码
          </InputItem>
          <InputItem
            {...getFieldProps('birthday', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            出生日期
          </InputItem>
          <InputItem
            {...getFieldProps('guoJi', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            国籍
          </InputItem>
          <InputItem
            {...getFieldProps('minZu', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            民族
          </InputItem>
          <InputItem
            {...getFieldProps('lianXiDianHua', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            联系电话
          </InputItem>
          <InputItem
            {...getFieldProps('lianXiDiZhi', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            联系地址
          </InputItem>
          <InputItem
            {...getFieldProps('yuHuZhuGuanXi', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            与户主关系
          </InputItem>
          <InputItem
            {...getFieldProps('zhengZhiMianMao', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            政治面貌
          </InputItem>
          <InputItem
            {...getFieldProps('hunYinZhuangKuang', {
            })}
            clear
            placeholder=""
            ref={(el) => { this.customFocusInst = el; }}
          >
            婚姻状况
          </InputItem>
          <List.Item>
            <View style={{ flexDirection: 'row' }}>
              <Button style={{ marginRight: 8 }} type="primary" onClick={this.onSubmit}>保存</Button>
              <Button onClick={this.onEditBack}>返回</Button>
            </View>
          </List.Item>
        </List>
      </ScrollView>
    );
  }
}
export default createForm()(AddPeopleInfo);

