import { AdStatusEnum, BidModeEnum, BidStrategyEnum, OptimizationGoalEnum, PromotedObjectType } from '@/services/launchAdq/enum'
import React from 'react'
import { Badge, Space } from 'antd'
import Box from '@/pages/adMonitor/adMonitorList/components/box'
import SwitchStatus from './switchStatus'
import TimeSeriesLook from './timeSeriesLook'
import { ReactComponent as RocketSvg } from '@/assets/rocket.svg'
import '../index.less'
import { CopyOutlined } from '@ant-design/icons'
import { copy } from '@/utils/utils'
import InputUpdate from './inputUpdate'
function tableConfig(
    onChange: () => void,
    details: (data: any) => void,
    handleSave: (data: 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: 'configuredStatus',
            key: 'configuredStatus',
            align: 'center',
            width: 40,
            fixed: 'left',
            render: (a: string, b: any) => {
                return <SwitchStatus configuredStatus={a} isDeleted={b?.isDeleted} adgroupId={b?.adgroupId} onChange={onChange} />
            }
        },
        {
            title: '所属账号',
            dataIndex: 'accountId',
            key: 'accountId',
            align: 'center',
            width: 80,
            ellipsis: true,
            render: (a: string) => {
                return <Space>
                    <a onClick={() => copy(a)} >{a}</a>
                    {/* <a onClick={() => {
                        tableIdClick({ activeKey: '1', parma: { accountId: a } })
                    }}>{a} */}
                    {/* </a> */}
                </Space>
            }
        },
        {
            title: '腾讯备注',
            dataIndex: 'memo',
            key: 'memo',
            align: 'center',
            width: 80,
            ellipsis: true,
        },
        {
            title: '本地备注',
            dataIndex: 'remark',
            key: 'remark',
            align: 'center',
            width: 80,
            ellipsis: true,
        },
        {
            title: '广告ID',
            dataIndex: 'adgroupId',
            key: 'adgroupId',
            align: 'center',
            width: 100,
            ellipsis: true,
            render: (a: string, b: any) => {
                return <Space>
                    <a onClick={() => copy(a)} >{a}</a>
                </Space>
            }
        },
        {
            title: '所属计划ID',
            dataIndex: 'campaignId',
            key: 'campaignId',
            align: 'center',
            width: 100,
            ellipsis: true,
            render: (a: string, b: any) => {
                return <Space >
                    <a onClick={() => copy(a)} >{a}</a>
                </Space>
            }
        },
        {
            title: '广告名称',
            dataIndex: 'adgroupName',
            key: 'adgroupName',
            width: 280,
            ellipsis: true,
            render: (a: string, b: any) => {
                return <InputUpdate title={a} dataIndex={'adgroupName'} record={b} handleSave={handleSave} />
            }
        },
        {
            title: '推广目标类型',
            dataIndex: 'promotedObjectType',
            key: 'promotedObjectType',
            align: 'center',
            width: 75,
            ellipsis: true,
            render: (a: string | number) => {
                return PromotedObjectType[a]
            }
        },
        // {
        //     title: '广告优化目标类型',
        //     dataIndex: 'optimizationGoal',
        //     key: 'optimizationGoal',
        //     align: 'center',
        //     width: 70,
        //     render: (a: string | number) => {
        //         return OptimizationGoalEnum[a]
        //     }
        // },
        {
            title: '投放日期',
            dataIndex: 'beginDate',
            key: 'beginDate',
            align: 'center',
            width: 150,
            ellipsis: true,
            render: (a: string, b: { endDate: string }) => {
                return b?.endDate ? a + '~' + b.endDate : a + '~' + '长期投放'
            }
        },
        {
            title: '投放时间',
            dataIndex: 'timeSeries',
            key: 'timeSeries',
            align: 'center',
            width: 55,
            render: (a: string, b: { endDate: string }) => {
                return <TimeSeriesLook timeSeries={a} />
            }
        },
        {
            title: '首日开始投放时间',
            dataIndex: 'firstDayBeginTime',
            key: 'firstDayBeginTime',
            align: 'center',
            width: 70,
        },
        {
            title: '出价',
            dataIndex: 'bidAmount',
            key: 'bidAmount',
            width: 140,
            ellipsis: true,
            render: (a: string, b: { bidMode: string, optimizationGoal: string }) => {
                return `${BidModeEnum[b?.bidMode]} ${a}元/${b?.bidMode === 'BID_MODE_CPM' ? '千次曝光' : b?.bidMode === 'BID_MODE_CPC' ? '点击' : OptimizationGoalEnum[b?.optimizationGoal]}`
            }
        },
        {
            title: '出价类型',
            dataIndex: 'smartBidType',
            key: 'smartBidType',
            align: 'center',
            width: 80,
            ellipsis: true,
            render: (a: string, b: { endDate: string }) => {
                return a === 'SMART_BID_TYPE_CUSTOM' ? '手动出价' : '自动出价'
            }
        },
        {
            title: '出价类型',
            dataIndex: 'bidStrategy',
            key: 'bidStrategy',
            align: 'center',
            width: 70,
            ellipsis: true,
            render: (a: string, b: { endDate: string }) => {
                return BidStrategyEnum[a]
            }
        },
        {
            title: '广告组日预算(分)',
            dataIndex: 'dailyBudget',
            key: 'dailyBudget',
            align: 'center',
            width: 70,
        },
        {
            title: '是否开启自动版位功能',
            dataIndex: 'automaticSiteEnabled',
            key: 'automaticSiteEnabled',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                return a ? '开' : '关'
            }
        },
        {
            title: '创建时间',
            dataIndex: 'createdTime',
            key: 'createdTime',
            align: 'center',
            width: 140,
            ellipsis: true,
        },
        // {
        //     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: 60,
            render: (a: any, b: any) => {
                return <Badge status={!a ? "processing" : "error"} text={a ? '是' : '否'} />
            }
        },
        {
            title: '广告状态',
            dataIndex: 'status',
            key: 'status',
            align: 'center',
            width: 70,
            fixed: 'right',
            ellipsis: true,
            render: (a: string) => {
                return AdStatusEnum[a]
            }
        },
        {
            title: '创意预览',
            dataIndex: 'creativePreview',
            key: 'creativePreview',
            width: 70,
            align: 'center',
            fixed: 'right',
            render: (a: any, b: any) => {
                return <Box b={b} />
            }
        },
        {
            title: '单位时间消耗速度',
            dataIndex: 'costSpeed',
            key: 'costSpeed',
            align: 'center',
            width: 80,
            className: 'padding2',
            fixed: 'right',
            render: (a: any, b: any) => {
                return <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', lineHeight: 'normal', fontSize: 10 }}>
                    <RocketSvg /> <a onClick={() => details(b)} style={{ marginLeft: 10 }}>详情</a>
                </div>
            }
        },
        {
            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?query={%22operation_status%22:[%22CALCULATE_STATUS_EXCLUDE_DEL%22],%22system_status%22:[],%22search_name%22:%22${b.adgroupId}%22}`)} target="_blank">腾讯广告</a>
            }
        },
    ]
}
export default tableConfig