import { Statistic } from "antd";
import { ColumnsType } from "antd/lib/table";
import React from "react";


const columns = (): ColumnsType<any> => {

    return [
        {
            title: '创意名称',
            dataIndex: 'dynamic_creative_name',
            key: 'dynamic_creative_name',
            width: 100,
            ellipsis: true
        },
        {
            title: '创意ID',
            dataIndex: 'dynamic_creative_id',
            key: 'dynamic_creative_id',
            width: 80,
            ellipsis: true,
            align: 'center'
        },
        {
            title: '广告ID',
            dataIndex: 'adgroup_id',
            key: 'adgroup_id',
            width: 80,
            ellipsis: true,
            align: 'center'
        },
        {
            title: '素材ID',
            dataIndex: 'material_id',
            key: 'material_id',
            width: 80,
            ellipsis: true,
            align: 'center'
        },
        {
            title: '创建时间',
            dataIndex: 'created_time',
            key: 'created_time',
            width: 130,
            sorter: true,
            ellipsis: true,
        },
        {
            title: '消耗',
            dataIndex: 'cost',
            key: 'cost',
            width: 75,
            sorter: true,
        },
        {
            title: '点击率',
            dataIndex: 'ctr',
            key: 'ctr',
            width: 75,
            sorter: true,
            render: (a: number) => <Statistic value={a} precision={2} valueStyle={!a ? {} : a >= 0.5 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
        },
        {
            title: '目标转化成本',
            dataIndex: 'conversions_cost',
            key: 'conversions_cost',
            width: 75,
            sorter: true,
        },
        {
            title: '目标转化量',
            dataIndex: 'conversions_count',
            key: 'conversions_count',
            width: 75,
            sorter: true,
        },
        {
            title: '目标转化率',
            dataIndex: 'conversions_rate',
            key: 'conversions_rate',
            width: 75,
            sorter: true,
            render: (a: number) => <Statistic value={a} precision={2} valueStyle={!a ? {} : a >= 0.5 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
        },
    ];
}

export default columns