import React from "react"
import { Space } from "antd"
import { AdStatus, PromotedObjectType, SpeedMode } from "@/services/launchAdq/enum"
import TargetingPopover from "../../components/targetingPopover"
import { EyeOutlined } from "@ant-design/icons"
function tableConfig(callback: (data: any, type: 'log' | 'page') => void): any {
    return [
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            align: 'center',
            width: 50,
        },
        {
            title: '计划名称',
            dataIndex: 'campaignName',
            key: 'campaignName',
            align: 'left',
            width: 180,
            ellipsis: true,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: '计划类型',
            dataIndex: 'campaignType',
            key: 'campaignType',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{a === 'CAMPAIGN_TYPE_NORMAL' ? '普通展示广告' : '微信朋友圈广告'}</span>
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '广告状态',
            dataIndex: 'configuredStatus',
            key: 'configuredStatus',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{AdStatus[a]}</span>
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '推广目标',
            dataIndex: 'promotedObjectType',
            key: 'promotedObjectType',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{PromotedObjectType[a]}</span>
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '投放速度模式',
            dataIndex: 'speedMode',
            key: 'speedMode',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{SpeedMode[a]}</span>
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '广告ID',
            dataIndex: 'sysAdgroupId',
            key: 'sysAdgroupId',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{a}</span>
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '定向ID',
            dataIndex: 'sysTargetingId',
            key: 'sysTargetingId',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                if (a) {
                    return <Space><span style={{ fontSize: "12px" }}>{a}</span><TargetingPopover id={b.sysTargetingId}/></Space> 
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '创意ID',
            dataIndex: 'sysAdcreativeId',
            key: 'sysAdcreativeId',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{a}</span>
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '落地页ID',
            dataIndex: 'sysPageId',
            key: 'sysPageId',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                if (a) {
                    return <Space><span style={{ fontSize: "12px" }}>{a}</span> <a style={{ color: '#1890ff', fontSize: 12 }} onClick={() => { callback(b.sysPageId, 'page') }}><EyeOutlined /></a></Space>
                } else {
                    return <span>--</span>
                }
            }
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            align: 'center',
            width: 140,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: <span style={{ marginLeft: 10 }}>操作</span>,
            dataIndex: 'taskName',
            key: 'taskName',
            fixed: 'right',
            render: (a: any, b: any) => {
                return <Space style={{ marginLeft: 10 }}>
                    <a style={{ color: '#1890ff', fontSize: 12 }} onClick={() => { callback({ taskId: b.id, campaignName: b.campaignName }, 'log') }}>日志</a>
                    {/* <Popconfirm
                    title={`你确定删除"${b?.taskName}"这个任务?`}
                    onConfirm={() => { del(b?.id) }}
                    okText="Yes"
                    cancelText="No"
                >
                    <a style={{ color: 'red', fontSize: 12 }}>删除</a>
                </Popconfirm> */}
                </Space>
            }
        }
    ]
}

export default tableConfig