import { copy } from "@/utils/utils";
import { DownOutlined } from "@ant-design/icons";
import { Badge, Button, Dropdown, Menu, Space } from "antd"
import React from "react"
function tableConfig(copyCreative: (data: any) => void): any {
    return [
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            align: 'center',
            width: 45,
        },
        {
            title: '媒体账户',
            dataIndex: 'accountId',
            key: 'accountId',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: '商品ID',
            dataIndex: 'productId',
            key: 'productId',
            width: 150,
            ellipsis: true,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: '品牌形象',
            dataIndex: 'promotedObjectId',
            key: 'promotedObjectId',
            width: 140,
            align: 'center',
            ellipsis: true,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: '创建状态',
            dataIndex: 'createStatus',
            key: 'createStatus',
            align: 'center',
            width: 90,
            render: (a: any, b: any) => {
                if (a) {
                    return a === 0 ? <Badge status="warning" text={<span style={{ fontSize: "12px" }}>创建中</span>} /> : a === 100 ? <Badge status="success" text={<span style={{ fontSize: "12px" }}>创建成功</span>} /> : <Badge status="error" text={<span style={{ fontSize: "12px" }}>创建失败</span>} />
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            align: 'center',
            width: 150,
            ellipsis: true,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: <span style={{ padding: '0 8px' }}>失败原因</span>,
            dataIndex: 'failMsg',
            key: 'failMsg',
            align: 'left',
            ellipsis: true,
            render: (a: any, b: any) => {
                return <a style={{ fontSize: "12px" }} onClick={() => copy(a)}>{a || '--'}</a>
            }
        },
        // {
        //     title: '操作',
        //     dataIndex: 'cz',
        //     key: 'cz',
        //     width: 100,
        //     align: 'center',
        //     render: (a: any, b: any) => {
        //         return <Dropdown trigger={['click']} overlay={<Menu items={[
        //             {
        //                 key: '1',
        //                 label: (<Button size="small" type="link" onClick={() => { copyCreative(b) }}>批量复制</Button>)
        //             }
        //         ]} />}>
        //             <a onClick={e => e.preventDefault()} style={{ fontSize: 12 }}>
        //                 <Space>
        //                     操作
        //                     <DownOutlined />
        //                 </Space>
        //             </a>
        //         </Dropdown>
        //     }
        // }
    ]
}

export default tableConfig