import {  TargetingSourceTypeEnum,  } from '@/services/launchAdq/enum'
import React from 'react'
import { Badge, Tooltip } from 'antd'
function tableConfig(): any {
    return [
        {
            title: '所属账号',
            dataIndex: 'accountId',
            key: 'accountId',
            align: 'center',
            width:70,
            render:(a:string)=>{
                return <a>{a}</a>
            }
        },
        {
            title: '定向ID',
            dataIndex: 'targetingId',
            key: 'targetingId',
            align: 'center',
            width: 100,
            render:(a:string)=>{
                return <a>{a}</a>
            }
        },
        {
            title: '定向名称',
            dataIndex: 'targetingName',
            key: 'targetingName',
            align: 'center',
            width: 250
        },
        {
            title: '定向描述',
            dataIndex: 'description',
            key: 'description',
            align: 'center',
            width: 250
        },
        {
            title: '地理位置',
            dataIndex: 'targetingTranslation',
            key: 'targetingTranslation',
            align: 'center',
            width: 600,
            render: (a: any) => {
                return <Tooltip
                    overlayInnerStyle={a?.length > 200 ? { width: 800 } :{}}
                    title={
                        <div style={{ display: 'flex', flexFlow: 'column' }}>
                            {
                                a?.split('；')?.filter((str: any) => !!str)?.map((str: string,index:number) => {
                                    let arr = str?.split('：')
                                    return <span key={index}>{arr[0]}：<a>{arr[1]}</a></span>
                                })
                            }
                        </div>
                    }>
                    <div style={{ display: 'flex', flexFlow: 'column' }}>
                        {
                            a?.split('；')?.filter((str: any) => !!str)?.map((str: string,index:number) => {
                                if (str.includes('地理位置')) {
                                    let arr = str?.split('：')
                                    return <span key={index}>{arr[0]}：<a>{arr[1]}....</a></span>
                                } else {
                                    return null
                                }
                            })
                        }
                    </div>
                </Tooltip>
            }
        },
        {
            title: '定向包来源',
            dataIndex: 'targetingSourceType',
            key: 'targetingSourceType',
            align: 'center',
            width: 170,
            render: (a: string | number, b: any) => {
                return <div style={{ display: 'flex', flexFlow: 'column' }}>
                    <span> {a && TargetingSourceTypeEnum[a]}</span>
                    {
                        !!b?.shareFromAccountId && <span>来源账号ID:<a>{b?.shareFromAccountId}</a></span>
                    }
                    {
                        !!b?.shareFromTargetingId && <span>来源包ID:<a>{b?.shareFromTargetingId}</a></span>
                    }
                </div>
            }
        },
        {
            title: '是否包含不支持定向',
            dataIndex: 'includeUnsupportedTargeting',
            key: 'includeUnsupportedTargeting',
            align: 'center',
            width: 120,
            render: (a: boolean) => {
                return <Badge status={!a ? "processing" : "error"} text={a ? '包含' : '不包含'} />
            }
        },
        {
            title: '创建时间',
            dataIndex: 'createdTime',
            key: 'createdTime',
            align: 'center',
            width: 160,
        },
        {
            title: '最后修改时间',
            dataIndex: 'lastModifiedTime',
            key: 'lastModifiedTime',
            align: 'center',
            width: 160,
        },

    ]
}
export default tableConfig