import React from "react";
import { Spin, Button, Tabs, Table, message, Modal } from "antd";
import $ from "jquery/src/ajax";
const ZhuanjiaoDetail = React.createClass({
  getInitialState() {
    return {
      newVisible: false,
      colunmn: [
        {
          title: "序号",
          dataIndex: "id",
          key: "id",
        },
        {
          title: "客户姓名",
          dataIndex: "userName",
          key: "userName",
        },
        {
          title: "原管理员",
          dataIndex: "usedAName",
          key: "usedAName",
        },
        {
          title: "现管理员",
          dataIndex: "newAName",
          key: "newAName",
        },
        {
          title: "转交类型",
          dataIndex: "type",
          key: "type",
          render: text => {
            if(text == 1) {
              return "项目转交"
            }else {
              return "客户转交"
            }
          }
        },
        {
          title: "项目名称",
          dataIndex: "pName",
          key: "pName",
        },
        {
          title: "创建时间",
          dataIndex: "createDate",
          key: "createDate",
        },
      ]
    };
  },
  loadData() {
      this.setState({
        loading: true
      });
      $.ajax({
        method: "get",
        dataType: "json",
        crossDomain: false,
        url: globalConfig.context + "/api/admin/customer/transferList",
        data: {
          uid: this.props.id,
        },
        success: function (data) {
          if (data.error.length || data.data.list == "") {
            if (data.error && data.error.length) {
              message.warning(data.error[0].message);
            }
          } else {
            this.setState({
              dataSource: data.data,
            });
          }
        }.bind(this),
      }).always(
        function () {
          this.setState({
            loading: false,
          });
        }.bind(this)
      );

  },
  componentWillMount() {
    this.loadData()
  },
  render() {
    return (
      <Modal
        style={{ position: "relative" }}
        title="转交记录"
        visible={this.props.visible}
        onCancel={this.props.cancel}
        footer={null}
        destroyOnClose={true}
      >
        <Table
          columns={this.state.colunmn}
          dataSource={this.state.dataSource}
          pagination={false}
          scroll={{ x: "max-content", y: 0 }}
          bordered
          size="small"
        />
      </Modal>
    );
  },
});

export default ZhuanjiaoDetail;
