import { AdStatusEnum, BidModeEnum, BidStrategyEnum, OptimizationGoalEnum, PromotedObjectType } from '@/services/launchAdq/enum'
import React from 'react'
import { Badge, Switch } from 'antd'
import Box from '@/pages/adMonitor/adMonitorList/components/box'
import { copy } from '@/utils/utils'
import SwitchStatus from './switchStatus'
import TimeSeriesLook from './timeSeriesLook'
function tableConfig(
    onChange: () => 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: 55,
            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: 70,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '1', parma: { accountId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '腾讯备注',
            dataIndex: 'memo',
            key: 'memo',
            align: 'center',
            width: 100,
            fixed: 'left',
            ellipsis: true,
        },
        {
            title: '本地备注',
            dataIndex: 'remark',
            key: 'remark',
            align: 'center',
            width: 100,
            fixed: 'left',
            ellipsis: true,
        },
        {
            title: '广告ID',
            dataIndex: 'adgroupId',
            key: 'adgroupId',
            align: 'center',
            width: 85,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '3', parma: { adgroupId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '所属计划ID',
            dataIndex: 'campaignId',
            key: 'campaignId',
            align: 'center',
            width: 85,
            fixed: 'left',
            ellipsis: true,
            render: (a: string) => {
                return <a onClick={() => {
                    tableIdClick({ activeKey: '2', parma: { campaignId: a } })
                }}>{a}</a>
            }
        },
        {
            title: '广告名称',
            dataIndex: 'adgroupName',
            key: 'adgroupName',
            width: 280,
            ellipsis: true,
            editable: true
        },
        {
            title: '推广目标类型',
            dataIndex: 'promotedObjectType',
            key: 'promotedObjectType',
            align: 'center',
            width: 85,
            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: 160,
            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: 75,
        },
        {
            title: '出价',
            dataIndex: 'bidAmount',
            key: 'bidAmount',
            width: 150,
            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,
            render: (a: string, b: { endDate: string }) => {
                return a === 'SMART_BID_TYPE_CUSTOM' ? '手动出价' : '自动出价'
            }
        },
        {
            title: '出价类型',
            dataIndex: 'bidStrategy',
            key: 'bidStrategy',
            align: 'center',
            width: 80,
            render: (a: string, b: { endDate: string }) => {
                return BidStrategyEnum[a]
            }
        },
        {
            title: '广告组日预算(分)',
            dataIndex: 'dailyBudget',
            key: 'dailyBudget',
            align: 'center',
            width: 80,
        },
        {
            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,
        },
        // {
        //     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,
            fixed: 'right',
            render: (a: any, b: any) => {
                return <Badge status={!a ? "processing" : "error"} text={a ? '是' : '否'} />
            }
        },
        {
            title: '广告状态',
            dataIndex: 'status',
            key: 'status',
            align: 'center',
            width: 80,
            fixed: 'right',
            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: 'cz',
        //     key: 'cz',
        //     width: 65,
        //     align: 'center',
        //     fixed: 'right',
        //     render: (a: any, b: any) => {
        //         return <Space>
        //             {b?.status !== 'STATUS_DELETED' && <Popconfirm
        //                 title="确定删除?"
        //                 onConfirm={() => deleteHandle(0, b?.adgroupId)}
        //                 okText="是"
        //                 cancelText="否"
        //             >
        //                 <Button danger type='text' size='small'>删除</Button>
        //             </Popconfirm>}
        //         </Space>
        //     }
        // },
    ]
}
export default tableConfig