import React from "react"
import { Row, Col, Badge } from "antd"
import { FormOutlined } from "@ant-design/icons"
let columns = (synchro: (bookId: number) => void, launchHandle: (value: any) => void) => [
    {
        title: '广告主名称',
        dataIndex: 'bookName',
        key: 'bookName',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '账户ID',
        dataIndex: 'author',
        key: 'author',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '投手',
        dataIndex: 'protagonist',
        key: 'protagonist',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '服务商',
        dataIndex: 'platformInfo',
        key: 'platformInfo',
        align: 'center',
        render: (a: any, b: any) => {
            return <>
                {
                    a?.platformName && <span style={{fontSize: "12px"}}>{a.platformName}</span>
                }
            </>
        }
    },
    
    
    {
        title: '广告主类型',
        dataIndex: 'channel',
        key: 'channel',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '主体',
        dataIndex: 'bookTypeInfo',
        key: 'bookTypeInfo',
        align: 'center',
        render: (a: any, b: any) => {
            return <>
                {
                    a?.name && <span style={{fontSize: "12px"}}>{a.name}</span>
                }
            </>
        }
    },
    {
        title: '广告主行业',
        dataIndex: 'source',
        key: 'source',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '账户余额',
        dataIndex: 'wordCount',
        key: 'wordCount',
        align: 'center',
        render: (a: any, b: any) => {
            return <>
                {
                    a && <span style={{fontSize: "12px"}}>{a}万字</span>
                }
            </>
        }
    },
    {
        title: '预计消费(天)',
        dataIndex: 'ratios',
        key: 'ratios',
        align: 'center',
        width: 150,
        render: (a: any, b: any) => {
            return <>
                {
                    a?.length > 0 && <span style={{fontSize: "12px"}}>{Number(a[0].nodePrice) + "%"}</span>
                }
            </>
        }
    },
    {
        title: '昨日总消耗(元)',
        dataIndex: 'ratios',
        key: 'ratios',
        align: 'center',
        render: (a: any, b: any) => {
            return <>
                {
                    a?.length > 0 && <span style={{fontSize: "12px"}}>{a[0].ratio}</span>
                }
            </>
        }
    },
    {
        title: '今日总消耗(元)',
        dataIndex: 'ratios',
        key: 'ratios',
        align: 'center',
        render: (a: any, b: any) => {
            return <>
                {
                    a?.length > 0 && <span style={{fontSize: "12px"}}>{a[0].type}</span>
                }
            </>
        }
    },
    {
        title: '账户状态',
        dataIndex: 'status',
        key: 'status',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>
                {
                    a=='排期'? <span><Badge color="pink"/>排期</span> : a=='测书'? <span><Badge status="processing" />测书</span> : a=='等数据' ? <span><Badge status="warning" />等数据</span> : a=='投手独家中' ? <span><Badge color="lime" />投手独家中</span> : a=='公司独家中' ? <span><Badge color="volcano" />公司独家中</span> : a=='弃书' ? <span><Badge status="error" />弃书</span> : <span><Badge status="success" />开放可投</span> 
                }
            </span>
        }
    },
    {
        title: '最近更新时间',
        dataIndex: 'remark',
        key: 'remark',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '备注',
        dataIndex: 'remark',
        key: 'remark',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}}>{a}</span>
        }
    },
    {
        title: '操作',
        dataIndex: 'cz',
        key: 'cz',
        align: 'center',
        width: 200,
        render: (a: string, b: any) => (
            <Row justify='center' gutter={[10, 0]}>
                <Col><a onClick={() => synchro(b.id)} style={{fontSize: "12px"}}><FormOutlined /> 立即同步</a></Col>
                <Col><a onClick={() => launchHandle(b)} style={{fontSize: "12px"}}><FormOutlined /> 广告投放</a></Col>
            </Row>
        )
    }
]

export default columns