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



function tableConfig(): any {
    return [
        {
            title: '所属账号',
            dataIndex: 'accountId',
            key: 'accountId',
            align: 'center',
            width: 100,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <Space>
                    <a onClick={() => copy(a)} >{a}</a>
                </Space>
            }
        },
        {
            title: '广告ID',
            dataIndex: 'adgroupId',
            key: 'adgroupId',
            align: 'center',
            width: 120,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <Space>
                    <a onClick={() => copy(a)} >{a}</a>
                </Space>
            }
        },
        {
            title: '推广计划ID',
            dataIndex: 'campaignId',
            key: 'campaignId',
            align: 'center',
            width: 120,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <Space>
                    <a onClick={() => copy(a)} >{a}</a>
                </Space>
            }
        },
        {
            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,
        },
        {
            title: '操作参数',
            dataIndex: 'requestJson',
            key: 'requestJson',
            width: 400,
            ellipsis: true,
        },
    ]
}


export default tableConfig