

import WidthEllipsis from "@/components/widthEllipsis"
import React from "react"
import { Tag } from "antd"
import EnabledSwitch from "./enabledSwitch"

function columnsPosCode(linkId: number, refresh: () => void) {

    let newArr: any = [
        {
            title: '礼包码',
            dataIndex: 'code',
            key: 'code',
            width: 100,
            render: (a: string) => (<WidthEllipsis value={a} isCopy/>)
        },
        {
            title: '是否领取？',
            dataIndex: 'isSend',
            key: 'isSend',
            align: 'center',
            width: 70,
            render: (a: boolean, b: any) => {
                return a ? <Tag color="success">已经领取</Tag> : <Tag color="default">待领取</Tag>
            }
        },
        {
            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',
            align: 'center',
            width: 90,
            fixed: 'right',
            render: (_: string, b: any) => (<EnabledSwitch linkId={linkId} id={b.id} onChange={refresh}/>)
        }
    ]
    return newArr
}


export default columnsPosCode