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


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


    const data: TableProps<any>['columns'] = [
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            width: 70,
            align: 'center',
            render: (_, b) => {
                return <Space>
                    <Popconfirm
                        title="确定取消授权?"
                        onConfirm={() => del([b.accountId], b?.assetId)}
                        okText="是"
                        cancelText="否"
                    >
                        <a style={{ color: 'red', fontSize: 12 }}>取消授权</a>
                    </Popconfirm>
                </Space>
            }
        },
        {
            title: '子账户',
            dataIndex: 'accountId',
            key: 'accountId',
            ellipsis: true,
            width: 110,
            align: 'center',
            render: (a) => {
                return <span style={{ fontSize: "12px" }}>{a}</span>
            }
        },
        {
            title: '资产',
            dataIndex: 'assetId',
            key: 'assetId',
            ellipsis: true,
            render: (a, b) => {
                return a ? a + (b?.assetName ? `(${b?.assetName})` : '') : '--'
            }
        }
    ]

    return data
}

export default columns