import { DeleteOutlined } from "@ant-design/icons"
import { Col, Popconfirm, Row } from "antd"
import React from "react"
import style from "./table.less"
let columns = (del: (id: number) => void) => [
    {
        title: '书名',
        dataIndex: 'bookInfo',
        key: 'bookInfo',
        align: 'center',
        render: (a: any, b: any) => {
            return <>
                {
                    a?.bookName && <span style={{fontSize: "12px"}} className={b?.index !== "ok" ? style.deleteLine : ""}>{a.bookName}</span>
                }
            </>
        }
    },
    {
        title: '卡点(首日ROI)',
        dataIndex: 'nodePrice',
        key: 'nodePrice',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}} className={b?.index !== "ok" ? style.deleteLine : ""}>{Number(a) + "%"}</span>
        }
    },
    {
        title: '倍率',
        dataIndex: 'ratio',
        key: 'ratio',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}} className={b?.index !== "ok" ? style.deleteLine : ""}>{a}</span>
        }
    },
    {
        title: '投放渠道',
        dataIndex: 'type',
        key: 'type',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}} className={b?.index !== "ok" ? style.deleteLine : ""}>{a === 'corp' ? '企业微信' : a === 'BYTEDANCE' ? '快应用' : a}</span>
        }
    },
    {
        title: '生效时间',
        dataIndex: 'effectDay',
        key: 'effectDay',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}} className={b?.index !== "ok" ? style.deleteLine : ""}>{a}</span>
        }
    },
    {
        title: '结束时间',
        dataIndex: 'overDay',
        key: 'overDay',
        align: 'center',
        render: (a: any, b: any) => {
            return <span style={{fontSize: "12px"}} className={b?.index !== "ok" ? style.deleteLine : ""}>{a}</span>
        }
    },
    {
        title: '操作',
        dataIndex: 'cz',
        key: 'cz',
        align: 'center',
        render: (a: string, b: any) => (
            <Row justify='center' gutter={[10, 0]}>
                <Col>
                    <Popconfirm
                        title={`是否要删除?`}
                        onConfirm={() => del(b.id)}
                        okText="是"
                        cancelText="否"
                    >
                        <a style={{color: "red", fontSize: "12px"}}><DeleteOutlined /> 删除</a>
                    </Popconfirm>
                </Col>
            </Row>
        )
    }
]

export default columns