import { CampaignTypeEnum, ConfiguredStatusEnum, PromotedObjectType, SpeedMode } from '@/services/launchAdq/enum'
import { Badge, Switch } from 'antd'
import React from 'react'

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: '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: 'campaignName',
            key: 'campaignName',
            align: 'center',
            width: 350,
        },
        {
            title: '推广计划类型',
            dataIndex: 'campaignType',
            key: 'campaignType',
            align: 'center',
            width: 130,
            render: (a: string | number) => {
                return CampaignTypeEnum[a]
            }
        },
        {
            title: '推广目标类型',
            dataIndex: 'promotedObjectType',
            key: 'promotedObjectType',
            align: 'center',
            width: 130,
            render: (a: string | number) => {
                return PromotedObjectType[a]
            }
        },
        {
            title: '投放速度模式',
            dataIndex: 'speedMode',
            key: 'speedMode',
            align: 'center',
            width: 130,
            render: (a: string | number) => {
                return SpeedMode[a]
            }
        },
        {
            title: '广告组日预算(分)',
            dataIndex: 'dailyBudget',
            key: 'dailyBudget',
            align: 'center',
            width: 130,
        },
        {
            title: '推广计划总预算(分)',
            dataIndex: 'totalBudget',
            key: 'totalBudget',
            align: 'center',
            width: 130,
        },
        {
            title: '创建时间',
            dataIndex: 'createdTime',
            key: 'createdTime',
            align: 'center',
            width: 160,
        },
        {
            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: 'configuredStatus',
            key: 'configuredStatus',
            align: 'center',
            width: 70,
            fixed: 'right',
            render: (a: string) => {
                return <Badge status={a === 'AD_STATUS_NORMAL' ? "processing" : "error"} text={ConfiguredStatusEnum[a]} />
            }
        },
    ]
}
export default tableConfig