import { Popconfirm, Tag } from "antd"
import React from "react"

function columnsPos(handle: (data: any) => void) {

    let newArr: any = [
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            align: 'center',
            width: 60
        },
        {
            title: '玩家ID',
            dataIndex: 'userId',
            key: 'userId',
            align: 'center',
            ellipsis: true,
            width: 120
        },
        {
            title: '玩家账号',
            dataIndex: 'userName',
            key: 'userName',
            align: 'center',
            width: 150,
            ellipsis: true,
        },
        {
            title: '玩家昵称',
            dataIndex: 'userNickName',
            key: 'userNickName',
            align: 'center',
            width: 120,
            ellipsis: true,
        },
        {
            title: '玩家注册时间',
            dataIndex: 'regTime',
            key: 'regTime',
            align: 'center',
            width: 120,
            ellipsis: true,
        },
        {
            title: '封禁时间',
            dataIndex: 'banTime',
            key: 'banTime',
            align: 'center',
            width: 120,
            ellipsis: true,
        },
        {
            title: '更新时间',
            dataIndex: 'updateTime',
            key: 'updateTime',
            align: 'center',
            width: 120,
            ellipsis: true,
        },
        {
            title: '当前封禁状态',
            dataIndex: 'status',
            key: 'status',
            align: 'center',
            width: 120,
            render: (a: number) => {
                if (a === 1) {
                    return <Tag color="#f50">封禁</Tag>
                }
                return <Tag color="#108ee9">已解封</Tag>
            }
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            align: 'center',
            width: 80,
            fixed: 'right',
            render: (a: string, b: any) => (
                <Popconfirm
                    title={b?.status === 1 ? '确定解封？' : '确定封禁？'}
                    onConfirm={() => { handle && handle(b) }}
                    okText="是"
                    cancelText="否"
                >
                    <a style={{ fontSize: "12px", color: b?.status === 1 ? '#108ee9' : '#f50' }}> {b?.status === 1 ? '解封' : '封禁'}</a>
                </Popconfirm>

            )
        }
    ]
    return newArr
}

export default columnsPos