import { copy } from "@/utils/utils"
import { Badge } from "antd"
import React from "react"



function tableConfig(tableIdClick: (props: {
    activeKey: string, parma: {
        accountId?: string,//账户ID
        campaignId?: string,//计划ID
        adgroupId?: string,//广告ID
        adcreativeId?: string,//创意ID
        pageId?: string,//落地页ID
        targetingId?: string,//定向ID
    }
}) => void): any {
    return [
        {
            title: '所属账号',
            dataIndex: 'accountId',
            key: 'accountId',
            align: 'center',
            width: 70,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '1', parma: { accountId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '广告ID',
            dataIndex: 'adgroupId',
            key: 'adgroupId',
            align: 'center',
            width: 85,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '3', parma: { adgroupId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '推广计划ID',
            dataIndex: 'campaignId',
            key: 'campaignId',
            align: 'center',
            width: 85,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '2', parma: { campaignId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '广告名称',
            dataIndex: 'adgroupName',
            key: 'adgroupName',
            width: 280,
            ellipsis: true,
            render: (a: string) => {
                return <a style={{ wordBreak: 'break-all' }} onClick={() => { copy(a) }}>{a}</a>
            }
        },
        {
            title: '执行时间',
            dataIndex: 'createTime',
            key: 'createTime',
            width: 140,
            align: 'center'
        },
        {
            title: '操作者名字',
            dataIndex: 'operationByName',
            key: 'operationByName',
            width: 65,
            align: 'center'
        },
        {
            title: '操作类型名称',
            dataIndex: 'operationName',
            key: 'operationName',
            width: 60,
            align: 'center'
        },
        {
            title: '操作数',
            dataIndex: 'operationCount',
            key: 'operationCount',
            width: 60,
            align: 'center'
        },
        {
            title: '成功数',
            dataIndex: 'successCount',
            key: 'successCount',
            width: 60,
            align: 'center'
        },
        {
            title: '失败数',
            dataIndex: 'failCount',
            key: 'failCount',
            width: 60,
            align: 'center',
            render: (a: number) => {
                return <span style={a > 0 ? { color: 'red' } : {}}>{a}</span>
            }
        },
        {
            title: '状态',
            dataIndex: 'status',
            key: 'status',
            width: 70,
            align: 'center',
            render: (a:any) => {
                let obj={
                    '成功':'success',
                    '失败':'error',
                    '执行中':'warning'
                }
                return <Badge status={obj[a]} text={a} />
            }
        },
        {
            title: '完成时间',
            dataIndex: 'updateTime',
            key: 'updateTime',
            width: 140,
            align: 'center'
        },
        {
            title: '错误消息',
            dataIndex: 'errorMsg',
            key: 'errorMsg',
            width: 400,
            ellipsis: true,
        },
    ]
}


export default tableConfig