import { ProColumns } from '@ant-design/pro-components';
import { useModel } from '@umijs/max';

export const columns = (): ProColumns<any>[] => {
  let { getEnum } = useModel('global')
  return [
    {
      title: 'openId',
      dataIndex: 'openId',
      align: 'center',
      width: 70,
      ellipsis: true,
      render: (_, row) => {
        return row?.wechatMiniappUser?.openId || "-"
      }
    },
    {
      title: '小说名称',
      dataIndex: 'bookName',
      key: 'bookName',
      align: 'center',
      width: 150,
      ellipsis: true,
      render: (a, b) => {
        return b?.bookInfo?.bookName || "-"
      },
    },
    {
      title: "作者笔名",
      dataIndex: 'authorName',
      key: "authorName",
      align: "center",
      render: (a, b) => {
        return b?.bookInfo?.authorInfo?.authorName || "-"
      },
    },
    {
      title: '章节名称',
      dataIndex: 'chapterId',
      align: 'center',
      width: 150,
      ellipsis: true,
      hideInSearch: true,
      render: (a, b) => {
        return b?.chapterInfo?.chapterName|| "-"
      },
    },
    {
      title: '应用名称',
      dataIndex: 'appName',
      key: 'appName',
      width: 120,
      align: 'center',
      ellipsis: true,
      render: (a, b) => {
        return b?.appInfo?.appName;
      },
    },
    {
      title: '分销商名称',
      dataIndex: 'companyName',
      key: 'companyName',
      width: 120,
      align: 'center',
      ellipsis: true,
      render: (a, b) => {
        return b?.distributorInfo?.companyName;
      },
    },
    {
      title: '变更类型',
      dataIndex: 'changeType',
      width: 120,
      align: 'center',
      ellipsis: true,
      valueEnum: getEnum("CHANGE_TYPE", "map")
    },
    {
      title: '变更数量',
      dataIndex: 'coinChangeNum',
      width: 120,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
    },
    {
      title: '剩余书币',
      dataIndex: 'coinRemainingNum',
      width: 120,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
    },
    {
      title: '变更时间',
      dataIndex: 'createTime',
      width: 120,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
    },
    {
      title: "用户注册时间",
      dataIndex: 'createTime',
      key: "createTime",
      hideInSearch: true,
      align: "center",
      render: (_, row) => {
        return row?.wechatMiniappUser?.createTime
      }
    },
    //搜索
    {
      title: '变更时间',
      dataIndex: 'time',
      valueType: 'dateRange',
      fieldProps: {
        style: { width: 250 },
      },
      hideInTable: true,
    },
  ];
};
