import { Statistic } from "antd"
import React from "react"
let columns = (timeUnit: string) => [
    {
        title: '时间',
        dataIndex: 'time',
        key: 'time',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{timeUnit === 'hour' ? b?.time : b?.day}</span>
        }
    },
    {
        title: '曝光次数',
        dataIndex: 'viewCount',
        key: 'viewCount',
        align: 'center',
        sorter: true
    },
    {
        title: '点击次数',
        dataIndex: 'clickCount',
        key: 'clickCount',
        align: 'center',
        width: 120,
        sorter: true,
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '点击率',
        dataIndex: 'clickRate',
        key: 'clickRate',
        align: 'center',
        sorter: true,
        render: (a: any, b: any) => {
            return <Statistic value={a ? (a * 100).toFixed(2) : 0} precision={2} valueStyle={{ color: '#3f8600' }} suffix="%" />
        }
    },
    {
        title: '下单量',
        dataIndex: 'orderCount',
        key: 'orderCount',
        align: 'center',
        sorter: true,
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '下单率',
        dataIndex: 'orderRate',
        key: 'orderRate',
        align: 'center',
        sorter: true,
        render: (a: any, b: any) => {
            return <Statistic value={a ? (a * 100).toFixed(2) : 0} precision={2} valueStyle={{ color: '#3f8600' }} suffix="%" />
        }
    },
    {
        title: '消耗',
        dataIndex: 'cost',
        key: 'cost',
        align: 'center',
        sorter: true,
        render: (a: any, b: any) => {
            return <Statistic value={a || 0} />
        }
    },
]

export default columns