import { useAjax } from "@/Hook/useAjax" import { getPromoteAgainListApi } from "@/services/gameData/extensionData" import { Col, Drawer, Empty, Progress, Row, Spin, Statistic, Table } from "antd" import React, { useEffect, useMemo } from "react" import style from './table.less' import './index.less' import moment from "moment" import { FallOutlined, RiseOutlined } from "@ant-design/icons" import { useAddTime } from "@/utils/utils" interface Props { accountId?: number, agentId?: number, beginDate?: string sourceSystem?: string visible?: boolean onClose?: () => void } /** * 推广 复充趋势 * @returns */ const RechargeTrend: React.FC = ({ visible, onClose, accountId, agentId, beginDate, sourceSystem }) => { /************************************* */ const getPromoteAgainList = useAjax((params) => getPromoteAgainListApi(params)) // 推广 /************************************* */ useEffect(() => { getPromoteAgainList.run({ accountId, agentId, beginDate, sourceSystem }) }, [accountId, visible, agentId, beginDate, sourceSystem]) const TableTrend = useMemo(() => { if (getPromoteAgainList?.data && JSON.stringify(getPromoteAgainList?.data) !== '{}') { let col: any[] = [] let data: any[] = [{ count: '1', id: 1 }, { count: '2', id: 2 }, { count: '3', id: 3 }, { count: '4', id: 4 }, { count: '5', id: 5 }, { count: '5-10', id: 6 }, { count: '10-20', id: 7 }, { count: '20次以上', id: 8 }] let date: string = '' let width = 110 Object.keys(getPromoteAgainList?.data).forEach((key, index) => { date = key col.push({ title: key, dataIndex: 'd' + (index + 1), key: 'd' + (index + 1), align: 'center', width, render: (value1: any, value2: any) => { return 原: 现: 增: } /> 移: } />
比:
{(value1?.rate * 100)?.toFixed(2) || '0.00'}%
} }) getPromoteAgainList?.data[key]?.forEach((item: any, eq: number) => { data[eq][`d${index + 1}`] = item }) }) let nullCol: any[] = [] if (col.length < 30) { Array(30 - col.length).fill('').forEach((item, index) => { nullCol.push({ title: useAddTime(index, 'days', 'YYYY-MM-DD', date || moment().format('YYYY-MM-DD')), dataIndex: 'd' + (index + 1), key: 'd' + (index + 1), align: 'center', width, className: 'zdred', render: () => { return '--' } }) }) } const columns: any = [ { title: '充值次数', dataIndex: 'count', key: 'count', width: 50, align: 'center' }, ...col, ...nullCol ] return } else { return } }, [getPromoteAgainList?.data]) return onClose?.()} width={'90%'}> {TableTrend} } export default React.memo(RechargeTrend)