import { AdStatusEnum, OptimizationGoalEnum, PromotedObjectType } from '@/services/launchAdq/enum'
import React from 'react'
import { Badge, Switch } from 'antd'
import PreviewAd from '../../components/previewAd'
function tableConfig(
    switchHandle: (data: any, Status: any) => void,
    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: 'qt',
            key: 'qt',
            align: 'center',
            width: 50,
            fixed: 'left',
            render: (a: string, b: any) => {
                return <Switch defaultChecked={b?.configuredStatus === 'AD_STATUS_NORMAL'} onChange={(checked: boolean) => {
                    switchHandle(b, checked)
                }} />
            }
        },
        {
            title: '所属账号',
            dataIndex: 'accountId',
            key: 'accountId',
            align: 'center',
            width: 90,
            fixed: 'left',
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '1', parma: { accountId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '广告ID',
            dataIndex: 'adgroupId',
            key: 'adgroupId',
            align: 'center',
            width: 100,
            fixed: 'left',
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '3', parma: { adgroupId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '所属计划ID',
            dataIndex: 'campaignId',
            key: 'campaignId',
            align: 'center',
            width: 100,
            fixed: 'left',
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '2', parma: { campaignId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '广告名称',
            dataIndex: 'adgroupName',
            key: 'adgroupName',
            align: 'center',
            width: 300,
        },
        {
            title: '推广目标类型',
            dataIndex: 'promotedObjectType',
            key: 'promotedObjectType',
            align: 'center',
            width: 130,
            render: (a: string | number) => {
                return PromotedObjectType[a]
            }
        },
        {
            title: '广告优化目标类型',
            dataIndex: 'optimizationGoal',
            key: 'optimizationGoal',
            align: 'center',
            width: 130,
            render: (a: string | number) => {
                return OptimizationGoalEnum[a]
            }
        },
        {
            title: '投放日期',
            dataIndex: 'beginDate',
            key: 'beginDate',
            align: 'center',
            width: 160,
            render: (a: string, b: { endDate: string }) => {
                return b?.endDate ? a + '~' + b.endDate : a + '~' + '长期投放'
            }
        },
        {
            title: '首日开始投放时间',
            dataIndex: 'firstDayBeginTime',
            key: 'firstDayBeginTime',
            align: 'center',
            width: 130,
        },
        {
            title: '广告出价(元)',
            dataIndex: 'bidAmount',
            key: 'bidAmount',
            align: 'center',
            width: 130,
        },
        {
            title: '广告组日预算(分)',
            dataIndex: 'dailyBudget',
            key: 'dailyBudget',
            align: 'center',
            width: 130,
        },
        {
            title: '是否开启自动版位功能',
            dataIndex: 'automaticSiteEnabled',
            key: 'automaticSiteEnabled',
            align: 'center',
            width: 150,
            render: (a: any, b: any) => {
                return a ? '开' : '关'
            }
        },
        {
            title: '创建时间',
            dataIndex: 'createdTime',
            key: 'createdTime',
            align: 'center',
            width: 160,
        },
        // {
        //     title: '客户设置的状态',
        //     dataIndex: 'configuredStatus',
        //     key: 'configuredStatus',
        //     align: 'center',
        //     width:130,
        //     render:(a:string)=>{
        //         return  <Badge status={a==='AD_STATUS_NORMAL' ? "processing" :"error" } text={ConfiguredStatusEnum[a]} />
        //     }
        // },
        {
            title: '是否已删除',
            dataIndex: 'isDeleted',
            key: 'isDeleted',
            align: 'center',
            width: 70,
            fixed: 'right',
            render: (a: any, b: any) => {
                return <Badge status={!a ? "processing" : "error"} text={a ? '是' : '否'} />
            }
        },
        {
            title: '广告状态',
            dataIndex: 'status',
            key: 'status',
            align: 'center',
            width: 70,
            fixed: 'right',
            render: (a: string) => {
                return AdStatusEnum[a]
            }
        },
        // {
        //     title: '预览',
        //     dataIndex: 'preview',
        //     key: 'preview',
        //     align: 'center',
        //     width: 40,
        //     fixed: 'right',
        //     render: (a: string, b: any) => {
        //         return <PreviewAd adgroupId={b?.adgroupId} accountId={b?.accountId}/>
        //     }
        // },
    ]
}
export default tableConfig