import { Tooltip } from "antd"
import React from "react"
import style from './index.less'
import dic from "./components/Dic"
let columns = () => {
    return [
        {
            title: '服务商',
            dataIndex: 'service_name',
            key: 'service_name',
            align: 'center',
            width: 200,
            render: (a: any, b: any) => {
                return <span className={style.twoText}>{a}</span>
            }
        },
        {
            title: '公众号',
            dataIndex: 'wechat_name',
            key: 'wechat_name',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '计划名称',
            dataIndex: 'adgroup_name',
            key: 'adgroup_name',
            align: 'center',
            width: 110,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    <Tooltip title={b?.adgroup?.adgroup_name}>
                        <span style={{ fontSize: "12px" }}>{b?.adgroup?.adgroup_name}</span>
                    </Tooltip>
                </div>
            }
        },
        {
            title: '推广目标',
            dataIndex: 'tg_target',
            key: 'tg_target',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '流量位',
            dataIndex: 'site_set',
            key: 'site_set',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{dic.siteSet[b?.adgroup?.site_set[0]]}</span>
            }
        },
        {
            title: '创意样式',
            dataIndex: 'adcreative_template_id',
            key: 'adcreative_template_id',
            align: 'center',
            width: 110,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{dic.adcreativeTemplate[b?.adcreative?.adcreative_template_id]}</span>
            }
        },
        {
            title: '投放日期',
            dataIndex: 'date_set',
            key: 'date_set',
            align: 'center',
            width: 110,
            render: (a: any, b: any) => {
                return <span className={style.twoText}>{b.adgroup.begin_date + '~' + b.adgroup.end_date}</span>
            }
        },
        {
            title: '投放时段',
            dataIndex: 'date_set1',
            key: 'date_set1',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>全天投放</span>
            }
        },
        {
            title: '广告预算',
            dataIndex: 'daily_budget',
            key: 'daily_budget',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{b?.adgroup?.daily_budget && Number(b?.adgroup?.daily_budget) / 100 || 0}</span>
            }
        },
        {
            title: '出价方式',
            dataIndex: 'cpm',
            key: 'cpm',
            align: 'center',
            width: 90,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{b?.adgroup?.bid_mode ? dic.bidModes[b?.adgroup?.bid_mode] : '(空)'}</span>
            }
        },
        {
            title: '出价',
            dataIndex: 'bid_amount',
            key: 'bid_amount',
            align: 'center',
            width: 100,
            render: (a: any, b: any) => {
                return <span style={{ fontSize: "12px" }}>{b?.adgroup?.bid_amount && Number(b?.adgroup?.bid_amount) / 100 || 0}</span>
            }
        },
        {
            title: '创意名称',
            dataIndex: 'adcreative_name',
            key: 'adcreative_name',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    <Tooltip title={b?.adcreative?.adcreative_name}>
                        <span style={{ fontSize: "12px" }}>{b?.adcreative?.adcreative_name}</span>
                    </Tooltip>
                </div>
            }
        },
        {
            title: '推广页名称',
            dataIndex: 'page_spec',
            key: 'page_spec',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    <Tooltip title={a?.name}>
                        <span style={{ fontSize: "12px" }}>{a?.name}</span>
                    </Tooltip>
                </div>
            }
        },
        {
            title: '定向人群包名称',
            dataIndex: 'human_info_package',
            key: 'human_info_package',
            align: 'center',
            width: 200,
            render: (a: any, b: any) => {
                return <div className={style.twoText}>
                    {
                        (a['name'] && a['name']?.length > 0) ? <Tooltip title={a['name'].map((name: any, index: number) => {
                            return index + 1 < a['name'].length ? name + ',' : name
                        })}>
                            <span style={{ fontSize: "12px" }}>{a['name'].map((name: any, index: number) => {
                                return index + 1 < a['name'].length ? name + ',' : name
                            })}</span>
                        </Tooltip> : '<空>'
                    }

                </div>
            }
        },
        {
            title: '商品',
            dataIndex: 'human_info_goods',
            key: 'human_info_goods',
            align: 'center',
            width: 200,
            render: (a: any, b: any) => {
                if (a) {
                    let data = a?.data
                    if (data && data?.length > 0) {
                        return <span style={{ fontSize: "12px" }}>{data[0]?.productName + '-' + data[0]?.author}</span>
                    }
                    return '--'
                } else {
                    return '--'
                }

            }
        }
    ]
}

export default columns