import WidthEllipsis from "@/components/widthEllipsis"
import LookRoleDetails from "@/pages/gameDataStatistics/player/role/lookRoleDetails"
import { Space, Statistic } from "antd"
import React from "react"

function columns12(assignHandle: (data: any) => void): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {

    return [
        {
            label: '基本信息',
            data: [
                {
                    title: '角色名称', dataIndex: 'roleName', label: '基本信息', align: 'center', width: 85, default: 1,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '角色ID', dataIndex: 'roleId', label: '基本信息', align: 'center', width: 85,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家名称', dataIndex: 'userName', label: '基本信息', align: 'center', width: 90, default: 2,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家ID', dataIndex: 'userId', label: '基本信息', align: 'center', width: 85,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '游戏名称', dataIndex: 'gameName', label: '基本信息', align: 'center', width: 85, default: 3,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '游戏ID', dataIndex: 'gameId', label: '基本信息', align: 'center', width: 85,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '区服名称', dataIndex: 'serverName', label: '基本信息', align: 'center', width: 80, default: 4,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '区服ID', dataIndex: 'serverId', label: '基本信息', align: 'center', width: 80,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '角色创建时间', dataIndex: 'createTime', label: '基本信息', align: 'center', width: 125, default: 5, sorter: true,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '角色等级', dataIndex: 'roleLevel', label: '基本信息', align: 'center', width: 60, sorter: true, default: 6,
                    render: (a: string) => <Statistic value={a || 0} />
                },
                {
                    title: '等级上报时间', dataIndex: 'levelTime', label: '基本信息', align: 'center', width: 120, default: 7, sorter: true,
                    render: (a: string) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '等级上报时间距今', dataIndex: 'levelTimeDiff', label: '角色游戏数据', align: 'center', width: 100, default: 8,
                    render: (_: any, b: any) => {
                        if (b?.createTime) {
                            let a = (new Date().getTime() / 1000) - (new Date(b?.levelTime).getTime() / 1000)
                            function secondsToDhms(seconds: any) {
                                const days = Math.floor(seconds / (3600 * 24));
                                const hours = Math.floor((seconds % (3600 * 24)) / 3600);
                                const minutes = Math.floor((seconds % 3600) / 60);
                                const remainingSeconds = seconds % 60;
                                return <span style={{ fontSize: 12, color: (hours + (days * 24)) > 1 ? 'red' : '#000' }}>{`${days ? days + "天" : ''}${hours ? hours + "小时" : ''}${minutes ? minutes + "分" : ''}${remainingSeconds ? remainingSeconds.toFixed(0) + "秒" : ''}`}</span>
                            }
                            return a ? secondsToDhms(a) : '--'
                        } else {
                            return '--'
                        }
                    }
                },
                {
                    title: '创角时间至今', dataIndex: 'createTimeDiff', label: '角色游戏数据', align: 'center', width: 100, default: 9,
                    render: (_: any, b: any) => {
                        if (b?.createTime) {
                            let a = (new Date().getTime() / 1000) - (new Date(b?.createTime).getTime() / 1000)
                            function secondsToDhms(seconds: any) {
                                const days = Math.floor(seconds / (3600 * 24));
                                const hours = Math.floor((seconds % (3600 * 24)) / 3600);
                                const minutes = Math.floor((seconds % 3600) / 60);
                                const remainingSeconds = seconds % 60;
                                return <span style={{ fontSize: 12, color: days > 5 ? 'red' : '#000' }}>{`${days ? days + "天" : ''}${hours ? hours + "小时" : ''}${minutes ? minutes + "分" : ''}${remainingSeconds ? remainingSeconds.toFixed(0) + "秒" : ''}`}</span>
                            }
                            return a ? secondsToDhms(a) : '--'
                        } else {
                            return '--'
                        }
                    }
                }

            ]
        },
        {
            label: '客户管理操作',
            data: [
                { title: 'GS', dataIndex: 'gsName', label: '客户管理操作', align: 'center', width: 80, default: 10, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '客服', dataIndex: 'customerServiceName', label: '客户管理操作', align: 'center', width: 80, default: 11, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '运营', dataIndex: 'operUserName', label: '客户管理操作', align: 'center', width: 80, default: 12, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '投手', dataIndex: 'putUserName', label: '客户管理操作', align: 'center', width: 80, default: 13, render: (a: string, b: any) => (<WidthEllipsis value={a} />) }
            ]
        },
        {
            label: '操作',
            data: [
                {
                    title: '操作',
                    dataIndex: 'cz',
                    align: 'center',
                    width: 60,
                    label: '操作',
                    default: 14,
                    render: (_: any, b: any) => {
                        return <Space>
                            <LookRoleDetails userId={b.userId} />
                            <a style={{ fontSize: 12 }} onClick={() => { assignHandle([b]) }}>指派</a>
                        </Space>
                    }
                }
            ]
        }
    ]
}

export default columns12