import { Statistic } from 'antd'
import { ColumnsType } from 'antd/lib/table'
import React from 'react'
import moment from 'moment'
import '../index.less'
const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
function columns() {
    let newArr: ColumnsType<any> = [
        // {
        //     title: '投手',
        //     dataIndex: 'pitcher',
        //     key: 'pitcher',
        //     align: 'center',
        //     width: 60,
        //     fixed: 'left',
        // },
        {
            title: '消耗时间(监控数据源)',
            dataIndex: 'cost_time',
            key: 'cost_time',
            align: 'center',
            width: 160,
            // sorter: true,
        },
        {
            title: '日期',
            dataIndex: 'date',
            key: 'date',
            align: 'center',
            width: 90,
            // sorter: true,
        },
        {
            title: '星期',
            dataIndex: 'week',
            key: 'week',
            width: 90,
            align: 'center',
            render: (a: any, b: any) => {
                return b?.date ? week[moment(b?.date).day()] : '--'
            }
        },
        {
            title: '10:00',
            dataIndex: 'ten_amount',
            key: 'ten_amount',
            width: 90,
            align: 'center',
            children: [
                {
                    title: '充值',
                    dataIndex: `ten_amount`,
                    key: `ten_amount`,
                    align: 'center',
                    width: 85,
                    render: (a: any) => {
                        return <Statistic value={a ? (a as number).toFixed(2) : a === 0 ? 0 : '--'} />
                    }
                },
                {
                    title: '环比',
                    dataIndex: `ten_rate`,
                    key: `ten_rate`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a <= 0.25 ? { backgroundColor: '#b9e19e' } : {}}>{(a * 100).toFixed(2) + '%'}</div>
                            : a === 0 ?
                                <div style={a <= 0.25 ? { backgroundColor: '#b9e19e' } : {}}>0</div>
                                : <div>--</div>
                    }
                },
                {
                    title: '回收率',
                    dataIndex: `ten_roi`,
                    key: `ten_roi`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a >= 0.5 ? { color: '#0f990f' } : {  color: 'red'  }}>{(a * 100).toFixed(2) + '%'}</div>
                            : a === 0 ?
                                <div>0</div>
                                : <div>--</div>
                    }
                },
            ]
        },
        {
            title: '14:00',
            dataIndex: 'fourteen_amount',
            key: 'fourteen_amount',
            width: 90,
            align: 'center',
            children: [
                {
                    title: '充值',
                    dataIndex: `fourteen_amount`,
                    key: `fourteen_amount`,
                    align: 'center',
                    width: 85,
                    render: (a: any) => {
                        return <Statistic value={a ? (a as number).toFixed(2) : a === 0 ? 0 : '--'} />
                    }
                },
                {
                    title: '环比',
                    dataIndex: `fourteen_rate`,
                    key: `fourteen_rate`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a <= 0.45 ? { backgroundColor: '#b9e19e' } : {}}>{(a * 100).toFixed(2) + '%'}</div>
                            : a === 0 ? <div style={a <= 0.45 ? { backgroundColor: '#b9e19e' } : {}}>0</div>
                                : <div>--</div>
                    }
                },
                {
                    title: '回收率',
                    dataIndex: `fourteen_roi`,
                    key: `fourteen_roi`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a >= 0.5 ? { color: '#0f990f' } : {  color: 'red'  }}>{(a * 100).toFixed(2) + '%'}</div>
                            : a === 0 ?
                                <div>0</div>
                                : <div>--</div>
                    }
                },
            ]
        },
        {
            title: '17:00',
            dataIndex: 'eighteen_amount',
            key: 'eighteen_amount',
            width: 90,
            align: 'center',
            children: [
                {
                    title: '充值',
                    dataIndex: `eighteen_amount`,
                    key: `eighteen_amount`,
                    align: 'center',
                    width: 85,
                    render: (a: any) => {
                        return <Statistic value={a ? (a as number).toFixed(2) : a === 0 ? 0 : '--'} />
                    }
                },
                {
                    title: '环比',
                    dataIndex: `eighteen_rate`,
                    key: `eighteen_rate`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a <= 0.6 ? { backgroundColor: '#ffbfbf' } : {}}>{a ? (a * 100).toFixed(2) + '%' : a === 0 ? 0 : '--'}</div>
                            : a === 0 ? <div style={a <= 0.6 ? { backgroundColor: '#ffbfbf' } : {}}>0</div>
                                : <div>--</div>
                    }
                },
                {
                    title: '回收率',
                    dataIndex: `eighteen_roi`,
                    key: `eighteen_roi`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a >= 0.5 ? { color: '#0f990f' } : {  color: 'red'  }}>{(a * 100).toFixed(2) + '%'}</div>
                            : a === 0 ?
                                <div>0</div>
                                : <div>--</div>
                    }
                },
            ]
        },
        {
            title: '24:00',
            dataIndex: 'twentyfour_amount',
            key: 'twentyfour_amount',
            width: 90,
            align: 'center',
            children: [
                {
                    title: '充值',
                    dataIndex: `twentyfour_amount`,
                    key: `twentyfour_amount`,
                    align: 'center',
                    width: 85,
                    render: (a: any) => {
                        return <Statistic value={a ? (a as number).toFixed(2) : a === 0 ? 0 : '--'} />
                    }
                },
                {
                    title: '环比',
                    dataIndex: `twentyfour_rate`,
                    key: `twentyfour_rate`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a < 1 ? { backgroundColor: '#ffbfbf' } : {}}>{a ? (a * 100).toFixed(2) + '%' : a === 0 ? 0 : '--'}</div>
                            : a === 0 ? <div style={a < 1 ? { backgroundColor: '#ffbfbf' } : {}}>0</div>
                                : <div>--</div>
                    }
                },
                {
                    title: '回收率',
                    dataIndex: `twentyfour_roi`,
                    key: `twentyfour_roi`,
                    width: 85,
                    align: 'center',
                    className: 'ringRatio',
                    render: (a: any) => {
                        return a === 999999999 ? <div>--</div> : a ?
                            <div style={a >= 0.5 ? { color: '#0f990f' } : {  color: 'red'  }}>{(a * 100).toFixed(2) + '%'}</div>
                            : a === 0 ?
                                <div>0</div>
                                : <div>--</div>
                    }
                },
                {
                    title: '消耗',
                    dataIndex: `twentyfour_cost`,
                    key: `twentyfour_cost`,
                    align: 'center',
                    width: 85,
                    render: (a: any) => {
                        return <Statistic value={a ? (a as number).toFixed(2) : a === 0 ? 0 : '--'} />
                    }
                },
            ]
        }
    ]
    return newArr
}
export { columns }