import { Space, Tooltip } from "antd"
import React from "react"
import style from './index.less'
import { BidModeEnum, OptimizationGoalEnum, PromotedObjectType, SiteSetEnum } from "@/services/launchAdq/enum";
import { adcreativeTemplate } from "./adcreativeCol";
let columns = () => {

    return [
        {
            title: '媒体账户',
            dataIndex: 'adAccountId',
            key: 'adAccountId',
            align: 'center',
            width: 85,
            fixed: 'left'
        },
        {
            title: '广告名称',
            dataIndex: 'adgroupName',
            key: 'adgroupName',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    <Tooltip title={b?.sysAdGroupData?.adgroupName}>
                        <span style={{ fontSize: "12px" }}>{b?.sysAdGroupData?.adgroupName}</span>
                    </Tooltip>
                </div>
            }
        },
        {
            title: '推广目标',
            dataIndex: 'promotedObjectType',
            key: 'promotedObjectType',
            align: 'center',
            width: 85,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{PromotedObjectType[a as keyof typeof PromotedObjectType]}</span>
            }
        },
        {
            title: '推广版位',
            dataIndex: 'sysAdGroupData',
            key: 'sysAdGroupData',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    <Tooltip title={a?.siteSet?.map((item: string) => SiteSetEnum[item as keyof typeof SiteSetEnum]).toString()}>
                        <span style={{ fontSize: "12px" }}>{a?.siteSet?.map((item: string) => SiteSetEnum[item as keyof typeof SiteSetEnum]).toString()}</span>
                    </Tooltip>
                </div>
            }
        },
        {
            title: '投放日期',
            dataIndex: 'beginDate',
            key: 'beginDate',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{b?.endDate ? b?.beginDate + '~' + b?.endDate : b?.beginDate + '~ 长期投放'}</span>
                }
                return <span style={{ fontSize: "12px" }}>{b?.sysAdGroupData?.endDate ? b?.sysAdGroupData?.beginDate + '~' + b?.sysAdGroupData?.endDate : b?.sysAdGroupData?.beginDate + '~ 长期投放'}</span>
            }
        },
        {
            title: '投放时段',
            dataIndex: 'date_set1',
            key: 'date_set1',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>全天投放</span>
            }
        },
        {
            title: '每日预算',
            dataIndex: 'dailyBudget',
            key: 'dailyBudget',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{b?.sysAdGroupData?.dailyBudget || '不限'}</span>
            }
        },
        {
            title: '出价方式',
            dataIndex: 'bidMode',
            key: 'bidMode',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{BidModeEnum[b?.sysAdGroupData?.bidMode as keyof typeof BidModeEnum]}</span>
            }
        },
        {
            title: '出价',
            dataIndex: 'bidAmount',
            key: 'bidAmount',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                if (a) {
                    return <span style={{ fontSize: "12px" }}>{a}</span>
                }
                return <span style={{ fontSize: "12px" }}>{b?.sysAdGroupData?.bidAmount}</span>
            }
        },
        {
            title: '优化目标',
            dataIndex: 'optimizationGoal',
            key: 'optimizationGoal',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{OptimizationGoalEnum[b?.sysAdGroupData?.optimizationGoal as keyof typeof OptimizationGoalEnum]}</span>
            }
        },
        {
            title: '出价类型',
            dataIndex: 'smartBidType',
            key: 'smartBidType',
            align: 'center',
            width: 80,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{b?.sysAdGroupData?.smartBidType === 'SMART_BID_TYPE_CUSTOM' ? '手动出价' : '自动出价'}</span>
            }
        },
        {
            title: '创意名称',
            dataIndex: 'adcreativeName',
            key: 'adcreativeName',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    <Tooltip title={b?.sysAdcreativeData?.adcreativeName}>
                        <span style={{ fontSize: "12px" }}>{b?.sysAdcreativeData?.adcreativeName}</span>
                    </Tooltip>
                </div>
            }
        },
        {
            title: '创意形式',
            dataIndex: 'adcreativeTemplateId',
            key: 'adcreativeTemplateId',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                let adcreativeTemplateId = b?.sysAdcreativeData?.adcreativeTemplateId
                if (adcreativeTemplateId) {
                    return <span style={{ fontSize: "12px" }}>{adcreativeTemplate?.find((item: any) => item?.adcreativeTemplateId === adcreativeTemplateId)?.adcreativeTemplateAppellation || '<空>'}</span>
                }
                return <span style={{ fontSize: "12px" }}>{b?.sysAdcreativeData?.adcreativeTemplateAppellation}</span>
            }
        },
        {
            title: '创意素材',
            dataIndex: 'mediaData',
            key: 'mediaData',
            width: 140,
            render: (a: any, b: any) => {
                let adcreativeElements = b?.sysAdcreativeData?.adcreativeElements
                if (adcreativeElements) {
                    let keys = Object.keys(adcreativeElements)
                    if (keys.includes('imageUrlList')) {
                        return <Space wrap>{adcreativeElements.imageUrlList.map((url: string, index: number) => <img key={index} src={url} height={25} />)}</Space>
                    } else if (keys.includes('elementStory')) {
                        return <Space wrap>{adcreativeElements.elementStory.map((url: string, index: number) => <img key={index} src={url} height={25} />)}</Space>
                    } else {
                        if (keys.includes('videoUrl') || keys.includes('shortVideo1Url')) {
                            return <Space>
                                {keys?.includes('imageUrl') && <img src={adcreativeElements.imageUrl} height={25}/>}
                                {keys?.includes('videoUrl') && <video src={adcreativeElements.videoUrl} style={{ height: 25 }}/>}
                                {keys?.includes('shortVideo1Url') && <video src={adcreativeElements.shortVideo1Url} style={{ height: 25 }}/>}
                            </Space>
                        } else {
                            return keys?.includes('imageUrl') ? <img src={adcreativeElements.imageUrl} height={25}/> : '无'
                        }
                    }
                }
                return <span style={{ fontSize: "12px" }}>无</span>
            }
        },
        {
            title: '创意文案',
            dataIndex: 'description',
            key: 'description',
            width: 200,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{b?.sysAdcreativeData?.adcreativeElements?.description}</span>
            }
        },
        {
            title: '文案',
            dataIndex: 'title',
            key: 'title',
            width: 150,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{b?.sysAdcreativeData?.adcreativeElements?.title || '<空>'}</span>
            }
        },
        {
            title: '落地页名称',
            dataIndex: 'pageData',
            key: 'pageData',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    <Tooltip title={a?.pageName}>
                        <span style={{ fontSize: "12px" }}>{a?.pageName}</span>
                    </Tooltip>
                </div>
            }
        },
        {
            title: '定向名称',
            dataIndex: 'targetingData',
            key: 'targetingData',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    {
                        a?.targetingName ? <Tooltip title={a?.targetingName}>
                            <span style={{ fontSize: "12px" }}>{a?.targetingName}</span>
                        </Tooltip> : '<空>'
                    }
                </div>
            }
        },
        {
            title: '定向用户群',
            dataIndex: 'customAudienceList',
            key: 'customAudienceList',
            align: 'center',
            width: 180,
            render: (a: any, b: any) => {
                let names = a?.map((item: any) => item.name)
                return <div className={style.twoText}>
                    {
                        names?.length > 0 ? <Tooltip title={names.toString()}>
                            <span style={{ fontSize: "12px" }}>{names.toString()}</span>
                        </Tooltip> : '<空>'
                    }
                </div>
            }
        },
        {
            title: '排除用户群',
            dataIndex: 'excludedCustomAudienceList',
            key: 'excludedCustomAudienceList',
            align: 'center',
            width: 180,
            render: (a: any, b: any) => {
                let names = a?.map((item: any) => item.name)
                return <div className={style.twoText}>
                    {
                        names?.length > 0 ? <Tooltip title={names.toString()}>
                            <span style={{ fontSize: "12px" }}>{names.toString()}</span>
                        </Tooltip> : '<空>'
                    }
                </div>
            }
        },
        {
            title: '商品',
            dataIndex: 'productList',
            key: 'productList',
            width: 180,
            align: 'center',
            render: (a: any, b: any) => {
                if (a && a?.length > 0) {
                    let data = a[0]
                    if (data) {
                        return <span style={{ fontSize: "12px" }}>{data?.productName + '-' + data?.firstCatalogName + '-' + data?.secondCatalogName}</span>
                    }
                    return '<空>'
                } else {
                    return '<空>'
                }
            }
        },
        {
            title: '数据源',
            dataIndex: 'userActionSetsList',
            key: 'userActionSetsList',
            width: 320,
            render: (a: any, b: any) => {
                if (a && a?.length > 0) {
                    return <span style={{ fontSize: "12px" }}>{a?.map((item: any) => item?.name + '>' + item?.type)?.toString() || '<空>'}</span>
                } else {
                    return '<空>'
                }
            }
        }
    ]
}

export default columns