import { VerticalAlignTopOutlined } from "@ant-design/icons"
import { Button, Space } from "antd"
import React from "react"
let columnsDraw = (uploadRecord: (value: any) => void, addAndCreate: any): any => [
    {
        title: '服务商',
        dataIndex: 'name',
        key: 'name',
        align: 'center',
        render: (a: any, b: any) => {
            let { channelAccountAdqInfo, channelAccountMpInfo } = b
            if (channelAccountAdqInfo) {
                return <span style={{ fontSize: "12px" }}>{channelAccountAdqInfo?.channel?.accountName}</span>
            } else if (channelAccountMpInfo) {
                return <span style={{ fontSize: "12px" }}>{channelAccountMpInfo?.channel?.accountName}</span>
            } else {
                return null
            }
        }
    },
    {
        title: '广告主名称',
        dataIndex: 'title',
        key: 'title',
        align: 'center',
        render: (a: any, b: any) => {
            let { channelAccountAdqInfo, channelAccountMpInfo } = b
            if (channelAccountAdqInfo) {
                return <span style={{ fontSize: "12px" }}>{channelAccountAdqInfo?.uname}</span>
            } else if (channelAccountMpInfo) {
                return <span style={{ fontSize: "12px" }}>{channelAccountMpInfo?.uname}</span>
            } else {
                return null
            }
        }
    },
    {
        title: '投放渠道',
        dataIndex: 'accountType',
        key: 'accountType',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{ fontSize: "12px" }}>{a}</span>
        }
    },
    {
        title: '创建时间',
        dataIndex: 'createTime',
        key: 'createTime',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{ fontSize: "12px" }}>{a}</span>
        }
    },
    {
        title: '创建状态',
        dataIndex: 'createStatus',
        key: 'createStatus',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{ fontSize: "12px" }}>{a === -1 ? '创建失败' : a === 0 ? '创建中' : a === 100 ? '创建成功' : ''}</span>
        }
    },
    {
        title: '失败原因',
        dataIndex: 'failedMsg',
        key: 'failedMsg',
        align: 'center',
        ellipsis: true,
        width: 500,
        render: (a: any, b: any) => {
            return <span style={{ fontSize: "12px" }}>{a}</span>
        }
    },
    {
        title: '操作',
        dataIndex: 'cz',
        key: 'cz',
        align: 'center',
        width: 80,
        render: (a: string, b: any) => (<Space>
            {b?.createStatus === -1 && <Button onClick={() => uploadRecord(b)} type='link' style={{ fontSize: "12px", padding: 0 }} loading={addAndCreate?.loading}> {!addAndCreate?.loading && <VerticalAlignTopOutlined />} 同步</Button>}
        </Space>)
    }
]

export default columnsDraw