import { copy } from "@/utils/utils"
import { Space, Popconfirm, TableProps, Tag } from "antd"
import React from "react"


const columns = (del: (id: number) => void): TableProps<any>['columns'] => {


    const data: TableProps<any>['columns'] = [
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            align: 'center',
            width: 70,
            render: (_, b) => {
                return <Space>
                    <Popconfirm
                        title="确定删除?"
                        onConfirm={() => del(b.id)}
                        okText="是"
                        cancelText="否"
                    >
                        <a style={{ color: 'red', fontSize: 12 }}>删除</a>
                    </Popconfirm>
                </Space>
            }
        },
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            width: 50,
            align: 'center',
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '游戏名称',
            dataIndex: 'gameName',
            key: 'gameName',
            ellipsis: true,
            width: 180,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '游戏类型',
            dataIndex: 'gameType',
            key: 'gameType',
            width: 100,
            align: 'center',
            render: (a) => {
                return a === 'WXGAME' ? <Tag color="#f50">微信小游戏</Tag> : '--'
            }
        },
        {
            title: 'appId',
            dataIndex: 'appId',
            key: 'appId',
            ellipsis: true,
            render: (a) => {
                return <a style={{ fontSize: "12px" }} onClick={() => copy(a)}>{a}</a>
            }
        },
        {
            title: '创建人',
            dataIndex: 'createByName',
            key: 'createByName',
            align: 'center',
            width: 75,
            ellipsis: true,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: '更新人',
            dataIndex: 'createByName',
            key: 'createByName',
            align: 'center',
            width: 75,
            ellipsis: true,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            align: 'center',
            width: 140,
            ellipsis: true,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        }
    ]

    return data
}

export default columns