import { ProColumns } from "@ant-design/pro-components";

export const columns = (enumList:any): ProColumns<any>[] => {
    let arr: any =enumList?.CHANGE_TYPE.values
    return [
        {
            title: "ID",
            dataIndex: 'id',
            hideInSearch: true,
            align: "center",
            key: "id"
        },
        {
            title: "用户ID",
            dataIndex: 'userId',
            key: "userId",
            align: "center",
            hideInSearch: true,
        },
        {
            title: "小说名称",
            dataIndex: 'bookInfo',
            key: "bookInfo",
            align: "center",
            hideInSearch: true,
            render: (a, b) => {
                return b?.bookInfo?.bookName || b?.bookInfo?.bookName
            },
        },
        {
            title: "章节/段落名称",
            dataIndex: 'longBookChapterName',
            key: "longBookChapterName",
            align: "center",
            hideInSearch: true,
            render: (a, b) => {
                return b?.paragraphId || b?.chapterInfo?.chapterName
            },
        },
        {
            title: "书币变更数量",
            tooltip: "（负数：消费、正数：充值）",
            dataIndex: 'coinChangeNum',
            key: "coinChangeNum",
            hideInSearch: true,
            align: "center",
        },
        {
            title: "书币变更后剩余书币",
            dataIndex: 'coinRemainingNum',
            key: "coinRemainingNum",
            hideInSearch: true,
            align: "center",
        },
        {
            title: "充值金额",
            dataIndex: 'rechargeMoney',
            key: "rechargeMoney",
            hideInSearch: true,
            align: "center",
        },
        {
            title: "书币变更类型",
            dataIndex: 'changeType',
            key: "changeType",
            hideInSearch: true,
            align: "center",
            render: (a: any) => {
                return new Map(arr?.map((item: { value: any; description: any; })=>[item.value,item.description])).get(a)
            }
        },
        {
            title: "使用时间",
            dataIndex: 'createTime',
            key: "createTime",
            hideInSearch: true,
            align: "center",
        },
        // 搜索条件
        {
            hideInTable: true,
            dataIndex: 'changeType',
            title:"书币变更类型",
            valueType:'select',
            valueEnum:new Map(arr?.map((item: { value: any; description: any; })=>[item.value,item.description]))
        },
        {
            title: "开始时间",
            dataIndex: 'startTime',
            valueType: 'dateTime',
            hideInTable: true
        },
        {
            title: "结束时间",
            dataIndex: 'endTime',
            valueType: 'dateTime',
            hideInTable: true
        },
    ];
}