import React, { PureComponent } from 'react';
import style from 'styled-components';
import { connect } from 'dva';
// import { Modal, Button ,Form, Input, Select } from 'antd';

import {
  enterpriseInsComInsPromptInitEnterpriseIns //是否需要保险提示
} from '../../../services/api';
import GetPlanBook from '../../Enterprise/Organization/getPlanBook';

import './InsuranceMangerment.less';
// import Insurance from "./InsuranceBasic";
import Insurance from './../../Enterprise/Company/InsuranceBasic';
import styles from './../../Enterprise/Company/Company.less';
// import styles from './Company.less';
// const FormItem = Form.Item;
// const { Option } = Select;
// @Form.create()
@connect(state => state.insurance)
export default class EnterpriseInsurance extends PureComponent {
  constructor(props, context) {
    super(props, context);
    this.state = {
      //   shows: [true, false, false, false],//各个 tab 内容是否显示，这里按需加载
      // policyHolder: "百川信（厦门）网络信息服务有限公司",
      // contacts: "",
      // contactsinformation: "",
      // enterprises: "",
      // premium:[],
      // amountmoney:[],
      // accessbookvisible:false,
      // disabled: true,
      isIns: ''
    };
  }
  // // state = { accessbookvisible:false, }
  //   // 获取方案书
  //   showaccessbookModal = () => {
  //     this.setState({
  //       accessbookvisible:true,
  //     });
  //   }
  //   handlereducepeopleOk = (e) => {
  //     console.log(e);
  //     this.setState({
  //       accessbookvisible:false,
  //     });
  //   }
  //   handlereducepeopleCancel = (e) => {
  //     console.log(e);
  //     this.setState({
  //       accessbookvisible:false,
  //     });
  //   }
  //   handleSubmit = e => {
  //     e.preventDefault();
  //     this.props.form.validateFieldsAndScroll((err, values) => {
  //       if (!err) {
  //        console.log('表单提交中.........',values);
  //       }
  //     });
  //   };

  // 初始化温馨提示
  getPrimotInt = () => {
    if (!this.props.isShowPlanBook) {
      enterpriseInsComInsPromptInitEnterpriseIns().then(
        data => {
          console.log('是否初始化', data);
          this.setState({
            isIns: data.data.isIns
          });
          // “0”标识没有买保险，“1”标识投保人数不符合要求，“2”标识保险保额不符合要求，“3”标识投保人数和保险保额不符合要求，“9”标识不需要提示
          // if (data.data.isIns !== '9' && !this.props.isShowPlanBook) {
          //   this.setState({
          //     insurancetipsvisible: true
          //   });
          //   this.props.dispatch({
          //     type: 'insurance/showPlanBook',
          //     payload: true
          //   });
          // }
        },
        err => {
          console.log(err);
        }
      );
    }
  };

  componentDidMount() {
    this.getPrimotInt();
  }

  render() {
    // console.log('aa',this.state.disabled);
    //   console.log('bb',this.state.accessbookvisible);
    // const { submitting } = this.props;
    // const { getFieldDecorator } = this.props.form;

    // const formItemLayout = {
    //   labelCol: {
    //     xs: { span: 7 },
    //     sm: { span: 7 }
    //   },
    //   wrapperCol: {
    //     xs: { span: 15 },
    //     sm: { span: 15 },
    //     md: { span: 15 }
    //   }
    // };

    // const submitFormLayout = {
    //   wrapperCol: {
    //     xs: { span: 15, offset: 7 },
    //     sm: { span: 15, offset: 7 }
    //   }
    // };
    // // const { policyHolder, contacts, contactsinformation, enterprises, amountmoney,premium} = this.state;
    // const amountmoney = [
    //   {"code":0,"price":10},
    //   {"code":1,"price":20},
    // ];
    // const premium = [
    //   {"code":0,"price":10},
    //   {"code":1,"price":20},
    // ];
    return (
      <Container>
        <Insurance conGetPlanBook={value => {
          this.setState({
            insurancetipsvisible: value
            // accessbookvisible: true
          });
        }} props={this.props} styles={styles} />
        {/* <div>
          <Modal className="accessbook"
            title="获取方案书"
            visible={this.state.accessbookvisible}
            onOk={this.handlereducepeopleOk}
            onCancel={this.handlereducepeopleCancel}
            footer={null}>
            <div style={{paddingBottom:16}}>
              <Form onSubmit={this.handleSubmit} style={{ marginTop: 24 }}>
                <FormItem {...formItemLayout} label="投保人">
                  {getFieldDecorator("policyHolder", {
                    // {}
                    initialValue: this.state.policyHolder,
                    rules: [{ message: "请填写" }]
                  })(<Input disabled={this.state.disabled}/>)}
                </FormItem>
                <FormItem {...formItemLayout} label="联系人">
                  {getFieldDecorator("contacts", {
                    initialValue: this.state.contacts,
                    rules: [{ required: true, message: "请填写" }]
                  })(<Input/>)}
                </FormItem>
                <FormItem {...formItemLayout} label="联系方式">
                  {getFieldDecorator("contactsinformation", {
                    initialValue: this.state.contactsinformation,
                    rules: [{ required: true, message: "请填写" }]
                  })(<Input/>)}
                </FormItem>
                <FormItem {...formItemLayout} label="企业人数">
                  {getFieldDecorator("enterprises", {
                    initialValue: this.state.enterprises,
                    rules: [{ message: "请填写" }]
                  })(<Input/>)}
                </FormItem>
                <FormItem {...formItemLayout} label="保障金额不低于">
                  {getFieldDecorator("amountmoney", {
                    initialValue: this.state.amountmoney,
                    rules: [{ required: true, message: "请选择" }]
                  })(
                    <Select placeholder="请选择">
                      {amountmoney.map((val, index) => {
                        return (
                          <Option key={index} value={val.code}>
                            {val.price}
                          </Option>
                        );
                      })}
                    </Select>
                  )}
                </FormItem>
                <FormItem {...formItemLayout} label="保费不超过">
                  {getFieldDecorator("premium", {
                    initialValue: this.state.premium,
                    rules: [{ required: true, message: "请选择" }]
                  })(
                    <Select placeholder="请选择">
                      {premium.map((val, index) => {
                        return (
                          <Option key={index} value={val.code}>
                            {val.price}
                          </Option>
                        );
                      })}
                    </Select>
                  )}
                </FormItem>
                <FormItem {...submitFormLayout} style={{marginBottom:0}}>
                  <Button loading={submitting} onClick={this.handlereducepeopleCancel}>晚点再看</Button>
                  <Button type="primary" style={{ marginLeft: 8 }} htmlType="submit">下一步</Button>
                </FormItem>
              </Form>
            </div>
          </Modal>
        </div> */}
        {/* 初始化时保险弹窗 */}
        <GetPlanBook
          okorcancel={(field, value) => {
            this.setState({ [field]: value });
          }}
          conGetPlanBook={value => {
            this.setState({
              insurancetipsvisible: value
            });
          }}
          isIns={this.state.isIns}
          accessbookvisible={this.state.accessbookvisible}
          insurancetipsvisible={this.state.insurancetipsvisible}
        />
      </Container>
    );
  }
}

const Container = style.div`
  padding:10px 24px 24px;
`;
