import HocError from '@/Hoc/HocError'
import React, { useMemo } from 'react'
import { useModel } from 'umi'
import TableData from '../../components/TableData'
import { columns } from './tableConfig'
function Page() {
    const { state: { dataSource }, getChannelOrderTrend } = useModel('useData.useTableData')
    //加工数据
    const data = useMemo(() => {
        let arr: any[] = []
        if (dataSource) {
            dataSource?.forEach((item: any, index: number) => {
                item['id'] = index
                arr.push(item)
            })
        }
        return arr
    }, [dataSource])
    //获取排序列表
    const sortArr = useMemo(() => {
        let arr: any[] = []
        columns().map((item: any) => {
            if (typeof item.title === 'string') {
                arr.push({ title: item.title, value: item.dataIndex, key: item.dataIndex })
            }
            if (typeof item.title === 'object' && typeof item.title.props.children[0] === 'string') {
                arr.push({ title: item.title, value: item.dataIndex, key: item.dataIndex })
            }
        })
        return arr
    }, [columns])
    return <>
        <TableData
            isGroupTab={false}
            isAdmin
            isDownload
            isSelctAccTags
            isUserId
            isDataSelectPitcher
            isDataSelectPitcher_isDisabled
            isTableDateArr
            isZj
            sortArr={sortArr}
            ajax={getChannelOrderTrend}
            columns={columns}
            dataSource={data}
            title='公众号单号付费趋势'
            // tableTotal={tableTotal}
            scroll={{ x: 1000, y: 600 }}
        />
    </>
}

export default HocError(Page)