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


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


    const data: TableProps<any>['columns'] = [
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            width: 50,
            align: 'center',
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '账户资产共享组名称',
            dataIndex: 'accountGroupName',
            key: 'accountGroupName',
            ellipsis: true,
            width: 180,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '授权主账户',
            dataIndex: 'authMainAccountId',
            key: 'authMainAccountId',
            ellipsis: true,
            width: 85,
            align: 'center',
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '企业名称',
            dataIndex: 'corporationName',
            key: 'corporationName',
            ellipsis: true,
            width: 180,
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '授权类型',
            dataIndex: 'authType',
            key: 'authType',
            width: 90,
            align: 'center',
            render: (a) => {
                return a === 'material' ? <Tag color="#f50">素材</Tag> : a === 'conversion' ? <Tag color="#2db7f5">转化归因</Tag> : a=== 'wechatDownPage' ? <Tag color="#87d068">原生落地页</Tag> : '--'
            }
        },
        {
            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',
            render: (_, b) => {
                return <Space>
                    <a style={{ fontSize: 12 }} onClick={() => { handleSubAccount(b) }}>授权子户</a>
                    <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