import React, { useState, useMemo, useRef } from 'react'; import { Avatar, Button, message } from 'antd'; import router from 'umi/router'; import QueryTable from '@/components/QueryTable'; import apis from '@/services/apis'; import request from '@/utils/request'; import withActions from '@/components/ActionList'; import AuthButton from '@/components/AuthButton'; import Styles from '../style.less'; import ChangeStatus from './components/ChangeStatus'; import Attribution from './components/Attribution'; import IntegralRecord from './components/IntegralRecord'; import Recommend from './components/Recommend'; import getSearchFields from './searchFields'; const actionList = { changeStatus: 'changeStatus', // 变更状态 attribution: 'attribution', //调整归属 integralRecord: 'integralRecord', //积分记录 recommend: 'recommend', //推荐客户 }; const PrivateCustomer = () => { const ref = useRef(); const [showModel, SetShowModel] = useState({}); const [exportLoding, setExportLoding] = useState(false); const handShowModel = (record, actionType) => { SetShowModel({ [actionList[actionType]]: { visible: true, data: record, }, }); }; function toCustomerDateil(record) { router.push({ pathname: '/customer/customerlist/privateCustomerDetail', query: { id: record.customerId, }, }); } const columns = useMemo(() => { return [ { title: '头像', dataIndex: 'picture', key: 'picture', align: 'center', width: '10%', render: (_, record) => ( ), }, { title: '姓名', dataIndex: 'name', key: 'name', align: 'center', width: '10%', // eslint-disable-next-line no-nested-ternary // render: (_, record) => ( // <> // toCustomerDateil(record)}>{record.name} // // ), }, { 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) => ( <> {record.sex === 1 ? '男' : record.sex === 2 ? '女' : '未知'} ), }, { title: '置业顾问', dataIndex: 'consultantName', key: 'consultantName', align: 'center', width: '10%', // eslint-disable-next-line no-nested-ternary render: (_, record) => ( <> {record.consultantName}
{record.consultTel} ), }, { 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: (_, 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((_, record) => [ , // toCustomerDateil(record)} />, , , ]), }, ]; }, []); //导出 function exportCustomer() { console.log(ref.current, 'ref'); setExportLoding(true); request({ ...apis.customer.customerRecommendExport, responseType: 'blob', params: ref.current.getSearchData, }) .then(response => { download(response); setExportLoding(false); }) .catch(() => { message.err('连接超时'); setExportLoding(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(); } const searchFields = useMemo(getSearchFields, []); //操作成功请求数据 const handleCancel = () => { SetShowModel({}); ref.current.reload(); }; const actionRender = () => { return ( ); }; return ( <> setPage(pg)} /> SetShowModel({})} > SetShowModel({})} /> SetShowModel({})} /> SetShowModel({})} /> ); }; export default PrivateCustomer;