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


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


    const data: TableProps<any>['columns'] = [
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            align: 'center',
            width: 90,
            render: (_, b) => {
                return <Space>
                    <Popconfirm
                        title="确定删除?"
                        onConfirm={() => del(b.id)}
                        okText="是"
                        cancelText="否"
                    >
                        <a style={{ color: 'red', fontSize: 12 }}>删除</a>
                    </Popconfirm>
                    <a style={{ fontSize: 12 }} onClick={() => edit(b)}>修改</a>
                </Space>
            }
        },
        {
            title: '微信小程序名称',
            dataIndex: 'appletName',
            key: 'appletName',
            width: 160,
            ellipsis: true,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '微信小程序原始ID',
            dataIndex: 'appletId',
            key: 'appletId',
            width: 180,
            ellipsis: true,
            render: (a) => {
                return <a style={{ fontSize: "12px" }} onClick={() => copy(a)}>{a}</a>
            }
        },
        {
            title: '微信小程序路径',
            dataIndex: 'appletLink',
            key: 'appletLink',
            width: 380,
            ellipsis: true,
            render: (a) => {
                return <a style={{ fontSize: "12px" }} onClick={() => copy(a)}>{a}</a>
            }
        },
        {
            title: '详细描述',
            dataIndex: 'description',
            key: 'description',
            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: '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