import React, { useState, useEffect } from 'react';
import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, message } from 'antd';
import moment from 'moment';
import request from '../../../utils/request';
import apis from '../../../services/apis';
import Styles from './style.less';
import router from 'umi/router';
import withActions from '@/components/ActionList';
import Attribution from './components/attribution'
import AssistConsultant from './components/assistConsultant'
import BatchAssistConsultant from './components/BatchAssistConsultant'
import IntegralRecord from './components/integralRecord'
import ModalRecommendRecord from './components/recommend'
import ChangeStatus from './components/changeStatus'
import BuildSelect from '../../../components/SelectButton/BuildSelect'
import AuthButton from '@/components/AuthButton';
import Navigate from '@/components/Navigate';
import WxDictSelect from '@/components/SelectButton/WxDictSelect';
import Prompt from 'umi/prompt';
import EditIcon from '@/components/EditIcon';


const { Option } = Select;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { Meta } = Card;

/**
 *
 *
 * @param {*} props
 * @returns
 */
function body(props) {
  const { getFieldDecorator, getFieldsValue } = props.form

  // eslint-disable-next-line react-hooks/rules-of-hooks
  const [dataSource, setDataSource] = useState({ records: [] })
  // eslint-disable-next-line react-hooks/rules-of-hooks
  const [dataPub, setDataPub] = useState({ records: [] })
  // 默认私客
  // eslint-disable-next-line react-hooks/rules-of-hooks
  const [customerType, setCustomerType] = useState('public')

  // 调整归属 ============  start
  // eslint-disable-next-line react-hooks/rules-of-hooks
  const [gVisibleData, setGVisibleData] = useState({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
  // 调整归属 ============= end

  // 积分记录 ============  start
  // eslint-disable-next-line react-hooks/rules-of-hooks
  const [recordVisibleData, setRecordVisibleData] = useState({ visible: false, customerId: '' })
  // 积分记录 ============= end

  // 变更状态 ============  start
  // eslint-disable-next-line react-hooks/rules-of-hooks
  const [statusVisibleData, setStatusVisibleData] = useState({ visible: false, customerId: '', status: '' })
  // 变更状态 ============= end

  // 推荐客户
  const [recommendVisibleData, setRecommendVisibleData] = useState({ visible: false, customerId: '' })

  const [assistVisibleData, setAssistVisibleData] = useState({ visible: false, customerId: '', buildingId: '' })

  const [loadingStatus, setLoadingStatus] = useState(false)

  // 选中的公客信息
  const [personInfo, setPersonInfo] = useState([])

  const [batchAssistVisibleData, setBatchAssistVisibleData] = useState({ visible: false, customerId: [], buildingId: '' })

  const [currentSelectedRows, setSelectedRows] = useState([])

  const [selectedRowKeys, setSelectedRowKeys] = useState([])

  // eslint-disable-next-line react-hooks/rules-of-hooks
  useEffect(() => {
    // localStorage.setItem("state", JSON.stringify({ value }))
    if (localStorage.getItem("state")) {
      console.log(localStorage.getItem("state"), 'state')
      if (JSON.parse(localStorage.getItem("state")) == 'private') {
        const localStorageValue = JSON.parse(localStorage.getItem('priPageParams'))
        localStorageValue.startCreateDate = localStorageDate(localStorageValue.startCreateDate)
        localStorageValue.endCreateDate = localStorageDate(localStorageValue.endCreateDate)
        props.form.setFieldsValue(localStorageValue);
        getList({ pageNumber: 1, pageSize: 10, ...JSON.parse(localStorage.getItem("priPageParams")) })
      } else {
        setCustomerType('public')
        const localStorageValue = JSON.parse(localStorage.getItem("pubPageParams"))
        localStorageValue.startCreateDate = localStorageDate(localStorageValue.startCreateDate)
        localStorageValue.endCreateDate = localStorageDate(localStorageValue.endCreateDate)
        props.form.setFieldsValue(localStorageValue);
        getList({ pageNumber: 1, pageSize: 10, ...JSON.parse(localStorage.getItem("pubPageParams")) })
      }

    } else {
      localStorage.setItem("priPageParams", JSON.stringify({ pageNumber: 1, pageSize: 10, customerType }))
      getList({ pageNumber: 1, pageSize: 10, customerType })
    }
  }, [])

  function getList(params) {
    // 网路请求
    if (params.startCreateDate) {
      params.startCreateDate = moment(params.startCreateDate).format('YYYY-MM-DD HH:mm:ss');
    }
    if (params.endCreateDate) {
      params.endCreateDate = moment(params.endCreateDate).format('YYYY-MM-DD HH:mm:ss');
    }
    request({ ...apis.customer.customerRecommend, params: { ...params } }).then(res => {
      if (params.customerType === 'private') {
        setDataSource(res)
      } else {
        setDataPub(res)
      }
    }).catch(err => {
      // eslint-disable-next-line no-unused-expressions
      <Alert
        style={{
          marginBottom: 24,
        }}
        message={err}
        type="error"
        showIcon
      />
    })
  }

  function displayNone() {
    setRecordVisibleData({ visible: false, customerId: '' })
    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '' })
    setStatusVisibleData({ visible: false, customerId: '', status: '' })
    setRecommendVisibleData({ visible: false, customerId: '' })
  }

  // 提交事件
  function handleSubmit(e) {
    displayNone()

    setPersonInfo([])
    setSelectedRowKeys([])

    e.preventDefault();
    props.form.validateFields((err, values) => {
      if (!err) {
        if (values.startCreateDate) {
          values.startCreateDate = moment(values.startCreateDate).format('YYYY-MM-DD HH:mm:ss');
        }
        if (values.endCreateDate) {
          values.endCreateDate = moment(values.endCreateDate).format('YYYY-MM-DD HH:mm:ss');
        }
        if (customerType === 'private') {
          localStorage.setItem("priPageParams", JSON.stringify({ customerType: 'private', ...values }))
          getList(JSON.parse(localStorage.getItem("priPageParams")))
        } else {
          localStorage.setItem("pubPageParams", JSON.stringify({ customerType: 'public', ...values }))
          getList(JSON.parse(localStorage.getItem("pubPageParams")))
        }
        // getList({ pageNum: 1, pageSize: 10, customerType, ...values })


      }
    });
  }

  // Change 事件
  function handleSelectChange(e) {
    // eslint-disable-next-line no-console
    console.log(e)
  }

  const localStorageDate = (date) => date ? moment(date) : ''

  // 分页
  function onChange(pageNum) {
    // eslint-disable-next-line react-hooks/rules-of-hooks
    props.form.validateFields((err, values) => {
      if (!err) {
        localStorage.setItem("state", JSON.stringify(customerType))
        if (customerType === 'private') {
          localStorage.setItem("priPageParams", JSON.stringify({ pageNumber: pageNum, pageSize: 10, customerType: 'private', ...props.form.getFieldsValue() }))
          getList(JSON.parse(localStorage.getItem("priPageParams")))
        } else {
          localStorage.setItem("pubPageParams", JSON.stringify({ pageNumber: pageNum, pageSize: 10, customerType: 'public', ...props.form.getFieldsValue() }))
          getList(JSON.parse(localStorage.getItem("pubPageParams")))
        }


      }
    });
  }

  // 私客/公客切换
  function radioButtonHandleSizeChange(e) {

    displayNone()

    props.form.resetFields();
    const { value } = e.target
    setCustomerType(value)
    localStorage.setItem("state", JSON.stringify(value))
    if (value === 'private') {
      if (localStorage.getItem("priPageParams")) {
        const localStorageValue = JSON.parse(localStorage.getItem("priPageParams"))
        localStorageValue.startCreateDate = localStorageDate(localStorageValue.startCreateDate)
        localStorageValue.endCreateDate = localStorageDate(localStorageValue.endCreateDate)
        props.form.setFieldsValue(localStorageValue);
        getList(JSON.parse(localStorage.getItem("priPageParams")))
      } else {
        localStorage.setItem("priPageParams", JSON.stringify({ pageNumber: 1, pageSize: 10, customerType: value }))
        getList({ pageNumber: 1, pageSize: 10, customerType: value })
      }

    } else {

      if (localStorage.getItem("pubPageParams")) {
        const localStorageValue = JSON.parse(localStorage.getItem("pubPageParams"))
        localStorageValue.startCreateDate = localStorageDate(localStorageValue.startCreateDate)
        localStorageValue.endCreateDate = localStorageDate(localStorageValue.endCreateDate)
        props.form.setFieldsValue(localStorageValue);

        getList({ pageNumber: 1, pageSize: 10, customerType, ...JSON.parse(localStorage.getItem("pubPageParams")) })
      } else {
        localStorage.setItem("pubPageParams", JSON.stringify({ pageNumber: 1, pageSize: 10, customerType: 'public' }))
        getList({ pageNumber: 1, pageSize: 10, customerType: 'public' })
      }
    }

    //setColumns(value === 'private' ? privateColumns : publicColumns)

  }

  function handleReset() {
    props.form.resetFields();
    if (customerType === 'private') {
      localStorage.setItem("priPageParams", JSON.stringify({ pageNumber: 1, pageSize: 10, customerType: 'private' }));
      getList(JSON.parse(localStorage.getItem("priPageParams")))
    } else {
      localStorage.setItem("pubPageParams", JSON.stringify({ pageNumber: 1, pageSize: 10, customerType: 'public' }))
      getList(JSON.parse(localStorage.getItem("pubPageParams")))
    }

  }


  // 这里有个 Bug， 就是 Modal 弹框，会联动出现， 比如 我点击 调整归属的Model弹框， 那么 积分记录的Model弹框莫名其妙的也显示了
  // 所有这里临时解决方法是，弹出一个Modal对话框的时候，把其他的对话框给隐藏

  function showGM(record) {
    setGVisibleData({ visible: true, customerId: record.customerId, realtyConsultant: record.realtyConsultant, buildingId: record.buildingId })
    setRecordVisibleData({ visible: false, customerId: '' })
    setStatusVisibleData({ visible: false, customerId: '' })
    setRecommendVisibleData({ visible: false, customerId: '' })
    setBatchAssistVisibleData({ visible: false, customerId: '', buildingId: '' })
  }

  function showRecord(record) {
    setRecordVisibleData({ visible: true, customerId: record.personId })
    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
    setStatusVisibleData({ visible: false, customerId: '' })
    setRecommendVisibleData({ visible: false, customerId: '' })
    setBatchAssistVisibleData({ visible: false, customerId: '', buildingId: '' })
  }

  function showStatus(record) {
    setRecordVisibleData({ visible: false, customerId: '' })
    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
    setRecommendVisibleData({ visible: false, customerId: '' })
    setStatusVisibleData({ visible: true, customerId: record.customerId, status: record.status })
    setBatchAssistVisibleData({ visible: false, customerId: '', buildingId: '' })
  }

  // 推荐客户
  function showRecommend(personId) {
    setRecordVisibleData({ visible: false, customerId: '' })
    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
    setStatusVisibleData({ visible: false, customerId: '', status: '' })
    setRecommendVisibleData({ visible: true, customerId: personId })
    setBatchAssistVisibleData({ visible: false, customerId: '' })
  }

  //分配置业顾问
  function assistConsultant(personId, buildingId) {
    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
    setRecordVisibleData({ visible: false, customerId: '' })
    setStatusVisibleData({ visible: false, customerId: '' })
    setRecommendVisibleData({ visible: false, customerId: '' })
    setAssistVisibleData({ visible: true, customerId: personId, buildingId: buildingId })
    setBatchAssistVisibleData({ visible: false, customerId: '', buildingId: '' })
  }

  function batchAssistConsultant() {
    console.log(personInfo, 'personInfo')
    console.log(personInfo.length)
    if (personInfo.length <= 0) {
      return message.info('请至少选择一条数据');
    }

    const compareSet = new Set();
    personInfo.filter(record => {
      compareSet.add(record.buildingName)
    })

    if (compareSet.size != 1) {
      return message.info('选中的公客存在于不同项目中，请分开进行分配置业顾问操作');
    }

    // const newSelectedRows = personInfo.filter()  

    // console.log(newSelectedRows,'newSelectedRows')

    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
    setRecordVisibleData({ visible: false, customerId: '' })
    setStatusVisibleData({ visible: false, customerId: '' })
    setRecommendVisibleData({ visible: false, customerId: '' })
    setAssistVisibleData({ visible: false, customerId: '', buildingId: '' })
    setBatchAssistVisibleData({ visible: true, customerId: personInfo, buildingId: personInfo[0].buildingId })
  }

  function toCustomerDateil(record) {
    router.push({
      pathname: '/customer/customerlist/customerDetail',
      query: {
        id: record.customerId,
      },
    });
  }
  // 私客详情
  function publicCustomerDetail(record) {
    router.push({
      pathname: '/customer/customerlist/publicCustomerDetail',
      query: {
        id: record.personId,
      },
    });
  }

  function exportCustomer() {
    setLoadingStatus(true)
    const fieldsValue = getFieldsValue()
    if (fieldsValue.startCreateDate) {
      fieldsValue.startCreateDate = moment(fieldsValue.startCreateDate).format('YYYY-MM-DD HH:mm:ss');
    }
    if (fieldsValue.endCreateDate) {
      fieldsValue.endCreateDate = moment(fieldsValue.endCreateDate).format('YYYY-MM-DD HH:mm:ss');
    }
    request({ ...apis.customer.customerRecommendExport, responseType: 'blob', params: { ...fieldsValue, customerType } })
      .then(response => {
        download(response)
        setLoadingStatus(false)
      }).catch(error => {
        message.err('连接超时');
        setLoadingStatus(false)
      })
  }

  function download(data) {
    if (!data) {
      return
    }
    const url = window.URL.createObjectURL(new Blob([data]))
    const link = document.createElement('a')
    link.style.display = 'none'
    link.href = url
    link.setAttribute('download', '客户列表.xlsx')
    document.body.append(link)
    link.click()
  }

  // 关闭调整归属的窗口
  function closeAttribution() {
    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
    if (customerType === 'private') {
      getList(JSON.parse(localStorage.getItem('priPageParams')))
    } else {
      getList(JSON.parse(localStorage.getItem('pubPageParams')))
    }
  }
  // 回调关闭所有弹框
  function closeAll() {
    setRecordVisibleData({ visible: false, customerId: '' })
    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '', buildingId: '' })
    setStatusVisibleData({ visible: false, customerId: '', status: '' })
    setRecommendVisibleData({ visible: false, customerId: '' })
    setAssistVisibleData({ visible: false, customerId: '', buildingId: '' })
    setBatchAssistVisibleData({ visible: false, customerId: '' })
    if (customerType === 'private') {

      getList(JSON.parse(localStorage.getItem("priPageParams")))
    } else {

      getList(JSON.parse(localStorage.getItem("pubPageParams")))
    }
    // getList({ pageNum: 1, pageSize: 10, customerType, ...props.form.getFieldsValue() })
  }

  const rowSelection = {
    selectedRowKeys,
    onChange: (selectedRowKeys, selectedRows) => {
      console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
      setSelectedRowKeys(selectedRowKeys)
      const newSelectedRows = personInfo.filter(x => !selectedRows.some(y => x.customerId === y.customerId))     // 去重
        .concat(selectedRows)                                                                 // 新增选择
        .filter(x => selectedRowKeys.some(y => y === x.customerId))                             // 去掉未选的数据

      // setSelectedRows(newSelectedRows)
      console.log(newSelectedRows, "33333333333333333333")
      setPersonInfo(newSelectedRows)
    },
  };

  const publicColumns = [
    {
      title: '头像',
      dataIndex: 'picture',
      key: 'picture',
      align: 'center',
      width: '10%',
      // render: (_, record) => <Avatar shape="square" style={{ color: 'blue', cursor: 'pointer' }} onClick={() => publicCustomerDetail(record)} src={customerType === 'private' ? record.picture : record.avatarurl} size={64} icon="user" />,
      render: (_, record) => <Avatar shape="square" style={{ color: 'blue', cursor: 'pointer' }} onClick={() => publicCustomerDetail(record)} src={record.picture} size={64} icon="user" />,
    },
    {
      title: '姓名',
      dataIndex: 'name',
      key: 'name',
      align: 'center',
      // width: '10%',
      // eslint-disable-next-line no-nested-ternary
      render: (_, record) => <><Navigate onClick={() => publicCustomerDetail(record)}>{record.name || record.nickname}</Navigate></>,
    },
    {
      title: '电话',
      dataIndex: 'phone',
      key: 'phone',
      align: 'center',
      width: '15%',
    },
    // {
    //   title: '是否归属项目',
    //   dataIndex: '',
    //   key: '',
    //   align: 'center',
    //   width: '10%',
    //   render: (_, record) => <><span>{record.buildingId != null ? '是' : '否'}</span></>,
    // },
    // {
    //   title: '归属项目',
    //   dataIndex: 'buildingName',
    //   key: 'buildingName',
    //   align: 'center',
    //   width: '15%',
    // },
    // {
    //   title: '推广人员',
    //   dataIndex: 'sharePersonName',
    //   key: 'sharePersonName',
    //   align: 'center',
    //   width: '10%',
    // },
    {
      title: '性别',
      dataIndex: 'sex',
      key: 'sex',
      align: 'center',
      width: '10%',
      // eslint-disable-next-line no-nested-ternary
      render: (_, record) => <><span>{record.sex === 1 ? '男' : record.sex === 2 ? '女' : '未知'}</span></>,
    },
    {
      title: '操作',
      dataIndex: 'customerId',
      key: 'customerId',
      align: 'center',
      width: '20%',
      render: withActions((text, record) => [
        <EditIcon color="#FF4A4A" text="查看详情" onClick={() => publicCustomerDetail(record)} />,
        // <AuthButton name="admin.customer.recommend" noRight={null}>
        //   <Button className={customerType === 'private' ? Styles.displayS : Styles.text} type="link" onClick={() => showRecommend(record.personId)}>推荐客户</Button>
        // </AuthButton>,
        // <AuthButton name="admin.customer.assign" noRight={null}>
        //   <Button className={customerType === 'private' ? Styles.displayS : Styles.text} type="link" onClick={() => assistConsultant(record.customerId, record.buildingId)}>分配置业顾问</Button>
        // </AuthButton>,
        <AuthButton name="admin.mine.taPointsRecords.point.record" noRight={null}>
          <Button className={Styles.text} type="link" onClick={() => showRecord(record)}>积分记录</Button>
        </AuthButton>
      ]),
      // render: (_, record) => (
      //   <>
      //     {/* <AuthButton name="admin.customer.public.detail" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.displayS : Styles.text } type="link" onClick={() => publicCustomerDetail(record)}>查看详情</Button>
      //     </AuthButton>
      //     &nbsp;&nbsp; */}
      //     <AuthButton name="admin.customer.recommend" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.displayS : Styles.text} type="link" onClick={() => showRecommend(record.personId)}>推荐客户</Button>
      //     </AuthButton>
      //     <AuthButton name="admin.customer.assign" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.displayS : Styles.text} type="link" onClick={() => assistConsultant(record.customerId, record.buildingId)}>分配置业顾问</Button>
      //     </AuthButton>
      //     <AuthButton name="admin.mine.taPointsRecords.point.record" noRight={null}>
      //       <Button className={Styles.text} type="link" onClick={() => showRecord(record)}>积分记录</Button>
      //     </AuthButton>
      //   </>
      // ),
    },
  ]

  const privateColumns = [
    {
      title: '头像',
      dataIndex: 'picture',
      key: 'picture',
      align: 'center',
      width: '10%',
      render: (_, record) => <Avatar shape="square" style={{ color: 'blue', cursor: 'pointer' }} onClick={() => toCustomerDateil(record)} src={customerType === 'private' ? record.picture : record.avatarurl} size={64} icon="user" />,
    },
    {
      title: '姓名',
      dataIndex: 'name',
      key: 'name',
      align: 'center',
      width: '10%',
      // eslint-disable-next-line no-nested-ternary
      render: (_, record) => <><Navigate onClick={() => toCustomerDateil(record)}>{customerType === 'private' ? record.name : record.nickname}</Navigate></>,
    },
    {
      title: '电话',
      dataIndex: 'phone',
      key: 'phone',
      align: 'center',
      width: '10%',
    },
    {
      title: '性别',
      dataIndex: 'sex',
      key: 'sex',
      align: 'center',
      width: '10%',
      // eslint-disable-next-line no-nested-ternary
      render: (_, record) => <><span>{record.sex === 1 ? '男' : record.sex === 2 ? '女' : '未知'}</span></>,
    },
    {
      title: '置业顾问',
      dataIndex: 'consultantName',
      key: 'consultantName',
      align: 'center',
      width: '10%',
      // eslint-disable-next-line no-nested-ternary
      render: (_, record) => (
        <>
          <span>{record.consultantName}</span>
          <br />
          <span>{record.consultTel}</span>
        </>
      ),
    },
    {
      title: '归属项目',
      dataIndex: 'buildingName',
      key: 'buildingName',
      align: 'center',
      width: '10%',
    },
    {
      title: '推广人员',
      dataIndex: 'sharePersonName',
      key: 'sharePersonName',
      align: 'center',
      width: '10%',
    },
    {
      title: '客户状态',
      dataIndex: 'reportRecommendStatus',
      key: 'reportRecommendStatus',
      align: 'center',
      width: '10%',
      // eslint-disable-next-line no-nested-ternary
      render: (text, records) => {
        if (records.status === 1) { return '报备' }
        if (records.status === 2) { return '到访' }
        if (records.status === 3) { return '认购' }
        if (records.status === 4) { return '签约' }
      },
    },
    {
      title: '操作',
      dataIndex: 'customerId',
      key: 'customerId',
      align: 'center',
      width: '20%',
      render: withActions((text, record) => [
        <EditIcon color="#FF4A4A" text="查看详情" onClick={() => toCustomerDateil(record)} />,
        <AuthButton name="admin.customer.recommend.edit.id.put" noRight={null}>
          <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showStatus(record)}>变更状态</Button>
        </AuthButton>,

        <AuthButton name="admin.customer.recommend.belong" noRight={null}>
          <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showGM(record)}>调整归属</Button>
        </AuthButton>,

        <AuthButton name="admin.mine.taPointsRecords.point.record" noRight={null}>
          <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showRecord(record)}>积分记录</Button>
        </AuthButton>,

        <AuthButton name="admin.mine.taPointsRecords.id.get" noRight={null}>
          <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showRecommend(record.personId)}>推荐客户</Button>
        </AuthButton>
      ]),
      // render: (_, record) => (
      //   <>
      //     <AuthButton name="admin.customer.recommend.edit.id.put" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showStatus(record)}>变更状态</Button>
      //     </AuthButton>
      //     <AuthButton name="admin.customer.recommend.belong" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showGM(record)}>调整归属</Button>
      //     </AuthButton>

      //     {/* <AuthButton name="admin.customer.recommend.get" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => toCustomerDateil(record)}>查看详情</Button>
      //     </AuthButton>
      //       &nbsp;&nbsp; */}
      //     <AuthButton name="admin.mine.taPointsRecords.point.record" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showRecord(record)}>积分记录</Button>
      //     </AuthButton>
      //     <AuthButton name="admin.mine.taPointsRecords.id.get" noRight={null}>
      //       <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showRecommend(record.personId)}>推荐客户</Button>
      //     </AuthButton>

      //   </>
      // ),
    },
  ]

  return (
    <>
      <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
        {/* {customerType === 'public' && <Form.Item>
          {getFieldDecorator('belongStatus')(
            <Select style={{ width: '180px' }} placeholder="是否归属项目" onChange={handleSelectChange}>
              <Option value={1}>是</Option>
              <Option value={0}>否</Option>
            </Select>,
          )}
        </Form.Item>} */}
        {/* <Form.Item>
          {getFieldDecorator('buildingId')(
            <BuildSelect />,
          )}
        </Form.Item> */}
        {/* {customerType === 'private' && <Form.Item>
          {getFieldDecorator('status')(
            <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
              <Option value={1}>报备</Option>
              <Option value={2}>到访</Option>
              <Option value={3}>认筹</Option>
              <Option value={4}>签约</Option>
            </Select>,
          )}
        </Form.Item>} */}
        <Form.Item>
          {getFieldDecorator('name')(
            <Input
              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
              placeholder="姓名"
            />,
          )}
        </Form.Item>
        <Form.Item>
          {getFieldDecorator('tel')(
            <Input
              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
              placeholder="电话"
            />,
          )}
        </Form.Item>
        {/* {customerType === 'private' && <Form.Item>
          {getFieldDecorator('consultName')(
            <Input placeholder="置业顾问" />,
          )}
        </Form.Item>}
        {customerType === 'private' && <Form.Item>
          {getFieldDecorator('consultTel')(
            <Input placeholder="置业顾问电话" />,
          )}
        </Form.Item>} */}
        <Form.Item >
          {getFieldDecorator('startCreateDate')(
            <DatePicker placeholder="注册开始时间" format="YYYY-MM-DD HH:mm:ss" showTime={{ format: 'HH:mm:ss' }} />)}
        </Form.Item>
        <Form.Item >
          {getFieldDecorator('endCreateDate')(
            <DatePicker placeholder="注册结束时间" format="YYYY-MM-DD HH:mm:ss" showTime={{ format: 'HH:mm:ss' }} />)}
        </Form.Item>
        {/* <Form.Item>
          {getFieldDecorator('sceneType')(
            <WxDictSelect />,
          )}
        </Form.Item> */}
        {/* <Form.Item>
          {getFieldDecorator('sharePersonName')(
            <Input placeholder="推广人" />,
          )}
        </Form.Item> */}
        <Form.Item>
          <AuthButton name="admin.customer.recommend.search" noRight={null}>
            <Button type="primary" htmlType="submit" >
              搜索
              </Button>
          </AuthButton>
          <Button style={{ marginLeft: 8 }} onClick={handleReset}>
            重置
            </Button>
        </Form.Item>
      </Form>
      {
        customerType === 'private' ?
          <AuthButton name="admin.customer.import" noRight={null}>
            <Button type="primary" loading={loadingStatus} onClick={() => exportCustomer()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
              导出
          </Button>
          </AuthButton> :
          <>
            {/* <AuthButton name="admin.customer.import" noRight={null}>
              <Button type="primary" onClick={() => batchAssistConsultant()} style={{ float: 'right', margin: '20px 0', marginLeft: '20px', zIndex: 1 }}>
                批量分配置业顾问
          </Button>
            </AuthButton> */}
            <AuthButton name="admin.customer.import" noRight={null}>
              <Button type="primary" loading={loadingStatus} onClick={() => exportCustomer()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
                导出
          </Button>
            </AuthButton>
          </>
      }


      {/* <div style={{ margin: '20px 0' }}>
        <Radio.Group value={customerType} onChange={radioButtonHandleSizeChange} buttonStyle="solid">
          <Radio.Button value="private">私客</Radio.Button>
          <Radio.Button value="public">公客</Radio.Button>
        </Radio.Group>
      </div> */}
      {customerType === 'private' ?
        <Table
          // onRow={record => {
          //   return {
          //     onClick: () => toCustomerDateil(record),
          //   };
          // }}
          dataSource={dataSource.records} columns={privateColumns} pagination={{ current: dataSource.current, total: dataSource.total, pageSize: dataSource.size, onChange }} rowKey={r => r.customerId} /> :
        <Table rowSelection={rowSelection}
          // onRow={record => {
          //   return {
          //     onClick: () => publicCustomerDetail(record),
          //   };
          // }}
          dataSource={dataPub.records} columns={publicColumns} pagination={{ current: dataPub.current, total: dataPub.total, pageSize: dataPub.size, onChange }} rowKey={r => r.customerId} ></Table>
      }

      {/* 调整归属 */}
      <Attribution visibleData={gVisibleData} onCancel={() => closeAttribution()} />

      {/* 积分记录 */}
      <IntegralRecord visibleData={recordVisibleData} onCancel={() => closeAll()} />

      {/* 变更状态 */}
      <ChangeStatus visibleData={statusVisibleData} onCancel={() => closeAll()} />

      {/* 推荐客户 */}
      <ModalRecommendRecord visibleData={recommendVisibleData} onCancel={() => closeAll()} />

      {/* 分配置业顾问 */}
      <AssistConsultant visibleData={assistVisibleData} onCancel={() => closeAll()} />

      {/* 批量分配置业顾问 */}
      <BatchAssistConsultant visibleData={batchAssistVisibleData} onCancel={() => closeAll()} />

      <Prompt message={location =>
        location.pathname.startsWith("/customer/customerlist")
          ? true
          : (localStorage.removeItem("priPageParams"), localStorage.removeItem("pubPageParams"), localStorage.removeItem("state"))} />
    </>
  );
}

const WrappedBody = Form.create({ name: 'body' })(body);

export default WrappedBody
