import { UserSwitchOutlined } from '@ant-design/icons'
import { Badge, Button, Space, Tooltip } from 'antd'
import React from 'react'
export function columns(putUserHandle:(b:any)=>void):any {
    return [
        {
            title: '账户ID',
            dataIndex: 'accountId',
            key: 'accountId',
            align: 'center',
            width: 120,
        },
        {
            title: '账号名称',
            dataIndex: 'accountName',
            key: 'accountName',
            align: 'center',
            width: 200,
        },
        {
            title: '组名称',
            dataIndex: 'groupName',
            key: 'groupName',
            align: 'center',
            width: 120,
        },
        {
            title: '投手',
            dataIndex: 'putUser',
            key: 'putUser',
            width: 70,
            align: 'center',
            ellipsis: true,
            render: (a: any, b: any) => {
                return <span>{a?.nickname || '-1'}</span>
            }
        },
        {
            title: '投放助理',
            dataIndex: 'operationUserList',
            key: 'operationUserList',
            align: 'center',
            width: 200,
            render:(a:any)=>{
                return a?.map((item: { nickName: any })=>item?.nickName)?.join()
            }
        },
        {
            title: '是否有效',
            dataIndex: 'enabled',
            key: 'enabled',
            align: 'center',
            width: 60,
            render: (a: any, b: any) => {
                return <Badge status={a ? "processing" : "error"} text={a ? '是' : '否'} />
            }
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            align: 'center',
            width: 90,
            fixed: 'right',
            render: (a: any, b: any) => {
                return <Space>
                    {b?.belongUser ?<Tooltip title="指派投放助理">
                        <Button size="small" style={{ color: '#0eb83a' }} onClick={() => {putUserHandle(b) }} icon={<UserSwitchOutlined />}></Button>
                    </Tooltip>:<span style={{color:'red'}}>无权限操作</span>}
                </Space>
            }
        }
    ]
}