import { Space, Popconfirm, TableProps } from "antd"
import React from "react"


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


    const data: TableProps<any>['columns'] = [
        {
            title: '应用名称',
            dataIndex: 'name',
            key: 'name',
            ellipsis: true,
            width: 150,
            fixed: 'left',
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '应用ID',
            dataIndex: 'applicationId',
            key: 'applicationId',
            ellipsis: true,
            width: 100,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '应用类型',
            dataIndex: 'type',
            key: 'type',
            ellipsis: true,
            width: 90,
            align: 'center',
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a === 'ANDROID' ? 'Android' : 'Ios'}</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>
            }
        },
        {
            title: '更新人',
            dataIndex: 'createByName',
            key: 'createByName',
            align: 'center',
            width: 75,
            ellipsis: true,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
            }
        },
        {
            title: '更新时间',
            dataIndex: 'updateTime',
            key: 'updateTime',
            align: 'center',
            width: 140,
            ellipsis: true,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            fixed: 'right',
            render: (_, b) => {
                return <Space>
                    <a style={{ fontSize: 12 }} onClick={() => { update(b) }}>修改</a>
                    <Popconfirm
                        title="确定删除?"
                        onConfirm={() => del(b.id)}
                        okText="是"
                        cancelText="否"
                    >
                        <a style={{ color: 'red', fontSize: 12 }}>删除</a>
                    </Popconfirm>
                </Space>
            }
        }
    ]

    return data
}

export default columns