import { CampaignTypeEnum, ConfiguredStatusEnum, PromotedObjectType, SpeedMode } from '@/services/launchAdq/enum'
import { copy } from '@/utils/utils'
import { CopyOutlined } from '@ant-design/icons'
import { Badge, Space, 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',
            ellipsis: true,
            render: (a: string) => {
                return <Space>
                   <a onClick={() => copy(a)} >{a}</a>
                </Space>
            }
        },
        {
            title: '计划ID',
            dataIndex: 'campaignId',
            key: 'campaignId',
            align: 'center',
            width: 100,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <Space>
                   <a onClick={() => copy(a)} >{a}</a>
                </Space>
            }
        },
        {
            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]} />
            }
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            width: 65,
            align: 'center',
            fixed: 'right',
            render: (a: any, b: any) => {
                return <a style={{ color: '#1890ff' }} onClick={() => window.open(`https://ad.qq.com/atlas/${b?.accountId}/admanage/adgroup?campaignid=${b?.campaignId}&query={%22operation_status%22:[%22CALCULATE_STATUS_EXCLUDE_DEL%22],%22system_status%22:[]}`)} target="_blank">腾讯计划</a>
            }
        },
    ]
}
export default tableConfig