import { Statistic } from 'antd'
import { ColumnsType } from 'antd/lib/table'
import React from 'react'
import './index.less'
function columns() {
    let newArr: ColumnsType<any> = [
        {
            title: '投手',
            dataIndex: 'pitcher',
            key: 'pitcher',
            align: 'center',
            width: 80,
        },
        {
            title: '消耗时间',
            dataIndex: 'cost_time',
            key: 'cost_time',
            align: 'center',
            width: 160,
            // sorter: true,
        },
        {
            title: '充值时间',
            dataIndex: 'order_time',
            key: 'order_time',
            align: 'center',
            width: 90,
            // sorter: true,
        },
        {
            title: '总消耗',
            dataIndex: `cost`,
            key: `cost`,
            align: 'center',
            width: 85,
            sorter: true,
            render: (a: any) => {
                return <Statistic value={a ? (a as number).toFixed(2) : a === 0 ? 0 : '--'} />
            }
        },
        {
            title: '总充值',
            dataIndex: `amount`,
            key: `amount`,
            align: 'center',
            width: 85,
            sorter: true,
            render: (a: any) => {
                return <Statistic value={a ? (a as number).toFixed(2) : a === 0 ? 0 : '--'} />
            }
        },
        {
            title: '回收率',
            dataIndex: `roi`,
            key: `roi`,
            width: 85,
            align: 'center',
            sorter: true,
            render: (a: any) => {
                return a === 999999999 ? <div>--</div> : a ?
                    <div style={a >= 1 ? {  color: 'red'  } : { color: '#0f990f' }}>{(a * 100).toFixed(2) + '%'}</div>
                    : a === 0 ?
                        <div>0</div>
                        : <div>--</div>
            }
        }
    ]
    return newArr
}
export { columns }