

import { Row, Col, Popconfirm } from "antd"
import { BranchesOutlined, DeleteOutlined, EditOutlined } from "@ant-design/icons"
import WidthEllipsis from "@/components/widthEllipsis"
import React from "react"

function columnsPos(editGameServer: (data: any) => void, del: (id: number) => void, handleAssign: (data: any, type: 'GAME_SERVER_ASSIGN_CUSTOMER' | 'GAME_SERVER_ASSIGN_GS') => void) {

    let newArr: any[] = [
        {
            title: '游戏名称',
            dataIndex: 'gameName',
            key: 'gameName',
            align: 'center',
            width: 90,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '区服名称',
            dataIndex: 'serverName',
            key: 'serverName',
            align: 'center',
            width: 100,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '区服ID',
            dataIndex: 'serverId',
            key: 'serverId',
            align: 'center',
            width: 100,
            render: (a: string, b: any) => (<WidthEllipsis isCopy value={a} />)
        },
        {
            title: '区服冠名',
            dataIndex: 'nickName',
            key: 'nickName',
            align: 'center',
            width: 100,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '开服时间',
            dataIndex: 'startTime',
            key: 'startTime',
            align: 'center',
            width: 135,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            align: 'center',
            width: 135,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '更新时间',
            dataIndex: 'updateTime',
            key: 'updateTime',
            align: 'center',
            width: 135,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '是否参与过合服',
            dataIndex: 'isMerge',
            key: 'isMerge',
            align: 'center',
            width: 100,
            render: (a: string, b: any) => (<WidthEllipsis value={a ? "是" : "否"} />)
        },
        {
            title: '是否原始服',
            dataIndex: 'isSourceServer',
            key: 'isSourceServer',
            align: 'center',
            width: 100,
            render: (a: string, b: any) => (<WidthEllipsis value={a ? "是" : "否"} />)
        },
        {
            title: '合服时间',
            dataIndex: 'mergeTime',
            key: 'mergeTime',
            align: 'center',
            width: 100,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '合服的主服名称',
            dataIndex: 'mainServerName',
            key: 'mainServerName',
            align: 'center',
            width: 100,
            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
        },
        {
            title: '合服包含的子服',
            dataIndex: 'sonServerList',
            key: 'sonServerList',
            align: 'center',
            width: 100,
            render: (a: any) => {
                let arr = a?.map((item: { serverName: any }) => {
                    return item.serverName
                })
                return <WidthEllipsis value={arr?.join()} />
            }
        },
        {
            title: '合服包含的原始服',
            dataIndex: 'sourceServerList',
            key: 'sourceServerList',
            align: 'center',
            width: 100,
            render: (a: any) => {
                let arr = a?.map((item: { serverName: any }) => {
                    return item.serverName
                })
                return <WidthEllipsis value={arr?.join()} />
            }
        },
        {
            title: '客服',
            dataIndex: 'customerList',
            key: 'customerList',
            align: 'center',
            width: 150,
            render: (a: any[]) => {
                return <WidthEllipsis value={a?.map(item => item.userName)?.toString()} />
            }
        },
        {
            title: 'GS',
            dataIndex: 'gsList',
            key: 'gsList',
            align: 'center',
            width: 150,
            render: (a: any[]) => {
                return <WidthEllipsis value={a?.map(item => item.userName)?.toString()} />
            }
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            align: 'center',
            width: 145,
            fixed: 'right',
            render: (a: string, b: any) => (
                <Row justify='center' gutter={[10, 0]}>
                    <Col><a style={{ fontSize: "12px" }} onClick={() => { handleAssign(b, 'GAME_SERVER_ASSIGN_GS') }}><BranchesOutlined /> 指派GS</a></Col>
                    <Col><a style={{ fontSize: "12px" }} onClick={() => { handleAssign(b, 'GAME_SERVER_ASSIGN_CUSTOMER') }}><BranchesOutlined /> 指派客服</a></Col>
                    {b?.isSourceServer ? <>
                        <Col><a style={{ fontSize: "12px" }} onClick={() => { editGameServer(b) }}><EditOutlined /> 修改</a></Col>
                        <Col>
                            <Popconfirm
                                title="确定删除?"
                                onConfirm={() => { del(b.id) }}
                                okText="是"
                                cancelText="否"
                            >
                                <a style={{ fontSize: "12px", color: 'red' }}><DeleteOutlined /> 删除</a>
                            </Popconfirm>
                        </Col>
                    </> : <>--</>}
                </Row>
            )
        }
    ]
    return newArr
}


export default columnsPos