

import { Row, Col, Popconfirm } from "antd"
import WidthEllipsis from "@/components/widthEllipsis"
import React from "react"

function columnsPos(toCode: (data: any) => void, editPack: (data: any) => void, del: (id: number) => void, handle: (data: any, type: string) => void) {

    let newArr: any = [
        {
            title: '游戏',
            dataIndex: 'gameName',
            key: 'gameName',
            align: 'center',
            width: 90,
            render: (a: string) => (<WidthEllipsis value={a} />)
        },
        {
            title: '礼包类型',
            dataIndex: 'codeTypeName',
            key: 'codeTypeName',
            align: 'center',
            width: 90,
            render: (a: string) => (<WidthEllipsis value={a} />)
        },
        {
            title: '礼包链接',
            dataIndex: 'codeLink',
            key: 'codeLink',
            width: 230,
            render: (a: string) => (<WidthEllipsis value={a} isCopy />)
        },
        {
            title: '付费区间（元）',
            dataIndex: 'pay',
            key: 'pay',
            width: 100,
            align: 'center',
            render: (_: any, b: any) => (b?.conditionDTO?.pay?.min !== null ? <WidthEllipsis value={b?.conditionDTO?.pay?.min + '~' + b?.conditionDTO?.pay?.max} /> : '--')
        },
        {
            title: '注册时间（分钟）',
            dataIndex: 'regTime',
            key: 'regTime',
            width: 100,
            align: 'center',
            render: (_: any, b: any) => (b?.conditionDTO?.regTime?.min !== null ? <WidthEllipsis value={b?.conditionDTO?.regTime?.min + '~' + b?.conditionDTO?.regTime?.max} /> : '--')
        },
        {
            title: '未登录时间（分钟）',
            dataIndex: 'unLogin',
            key: 'unLogin',
            width: 100,
            align: 'center',
            render: (_: any, b: any) => (b?.conditionDTO?.unLogin?.min !== null ? <WidthEllipsis value={b?.conditionDTO?.unLogin?.min + '~' + b?.conditionDTO?.unLogin?.max} /> : '--')
        },
        {
            title: '创建人',
            dataIndex: 'createByName',
            key: 'createByName',
            align: 'center',
            width: 100,
            render: (a: string) => (<WidthEllipsis value={a} />)
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            align: 'center',
            width: 135,
            render: (a: string) => (<WidthEllipsis value={a} />)
        },
        {
            title: '更新人',
            dataIndex: 'updateByName',
            key: 'updateByName',
            align: 'center',
            width: 100,
            render: (a: string) => (<WidthEllipsis value={a} />)
        },
        {
            title: '更新时间',
            dataIndex: 'updateTime',
            key: 'updateTime',
            align: 'center',
            width: 135,
            render: (a: string) => (<WidthEllipsis value={a} />)
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            width: 220,
            fixed: 'right',
            render: (a: string, b: any) => (
                <Row justify='center' gutter={[10, 0]}>
                    <Col><a style={{ fontSize: "12px" }} onClick={() => { toCode(b) }}>礼包码</a></Col>
                    <Col><a style={{ fontSize: "12px" }} onClick={() => { handle(b, 'log') }}>访问记录</a></Col>
                    <Col><a style={{ fontSize: "12px" }} onClick={() => { handle(b, 'lq') }}>领取记录</a></Col>
                    <Col><a style={{ fontSize: "12px" }} onClick={() => { editPack(b) }}>修改</a></Col>
                    <Col>
                        <Popconfirm
                            title="确定删除?"
                            onConfirm={() => { del(b.id) }}
                            okText="是"
                            cancelText="否"
                        >
                            <a style={{ fontSize: "12px", color: 'red' }}>删除</a>
                        </Popconfirm>
                    </Col>
                </Row>
            )
        }
    ]
    return newArr
}


export default columnsPos