import React from "react";
import { Modal, Tabs } from "antd";
const TabPane = Tabs.TabPane;
import ajax from "jquery/src/ajax/xhr.js";
import $ from "jquery/src/ajax";
import ContactPerson from "./detail/contactPerson"; //联系人
import Visit from './detail/visit';

const ChannelDetail = React.createClass({
  getInitialState() {
    return {
      modalVisible: false,
      switchState: false,
      contactData: [],
      contactState: true,
      IntentionState: false,
      businessState: false,
      visitState: false,
      accountState: false,
      basicState: false,
    };
  },

  detailsModal() {
    this.setState({
      basicState: false,
      modalVisible: false,
    });
    this.props.closeDesc(false, true);
  },
  //详情tab切换数据处理
  callback(e) {
    if (e == "1") {
      this.setState({
        IntentionState: true,
        contactState: false,
        accountState: false,
        visitState: false,
        businessState: false,
        basicState: true,
      });
    }
    if (e == "2") {
      this.setState({
        IntentionState: false,
        contactState: true,
        accountState: false,
        visitState: false,
        businessState: false,
        basicState: false,
      });
    }

    if (e == "4") {
      this.setState({
        IntentionState: false,
        contactState: false,
        accountState: false,
        visitState: true,
        businessState: false,
        basicState: false,
      });
    }
    if (e == "5") {
      this.setState({
        IntentionState: false,
        contactState: false,
        accountState: false,
        visitState: false,
        businessState: true,
        basicState: false,
      });
    }
    this.setState({
      callnub: e,
    });
  },
  //取消函数
  closeDetail(e, s) {
    this.setState({
      basicState: false,
      modalVisible: e,
    });
    if (s) {
      this.props.closeDesc(false, true);
    }
  },

  componentWillReceiveProps(nextProps) {

  },
  render() {
    return (
      <div>
        <Modal
          className="customeDetails"
          title="渠道详情"
          width="1800px"
          visible={this.props.visible == "detail"}
          onCancel={this.props.cancel}
          footer=""
        >
          <Tabs defaultActiveKey="1">
            <TabPane tab="联系人信息" key="1">
              <ContactPerson
                isCustomerAdmin={this.props.isCustomerAdmin}
                closeDetail={this.closeDetail}
                name={this.props.IntentionData.name}
                data={this.props.IntentionData}
                // contactState={this.state.contactState}
              />
            </TabPane>
            <TabPane tab="渠道跟进" key="2">
              <Visit
                categoryArr={this.props.categoryArr}
                closeDetail={this.closeDetail}
                data={this.props.IntentionData}
                // visitState={this.state.visitState}
              />
            </TabPane>
          </Tabs>
        </Modal>
      </div>
    );
  },
});
export default ChannelDetail;
