import Constants from '@/constants';
import {
    pbcUsersPageUsingPost,
  } from '@/services/pop-b2b2c/pbcUsersController';
  import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
  import { PageContainer } from '@ant-design/pro-layout';
  import React, { useRef } from 'react';
  
  /**
   * 查询表格
   * @param param0
   */
  const fetchData = async (params: API.PageVO) => {
    const msg = await pbcUsersPageUsingPost(params);
    return {
      data: msg.data?.records,
      total: msg.data?.total,
      success: msg.retcode,
    } as any;
  };
  
  // eslint-disable-next-line @typescript-eslint/ban-types
  const TableList: React.FC<{}> = () => {
    const actionRef = useRef<ActionType>();
  
    const columns: ProColumns<API.PbcBusiness>[] = [
      {
        title: '商户编号',
        dataIndex: 'pbcBusinessCode',
        search: false
      },
      {
        title: '商户名称',
        dataIndex: 'pbcBusinessName',
        search: false
      },
      {
        title: '渠道',
        dataIndex: 'pbcVisitSourceEnum',
        valueType: 'select',
        valueEnum: Constants.pbcVisitSourceEnum
      },
      {
        title: '访问时间',
        dataIndex: 'pbcCreateAt',
        width: 150,
        hideInTable: true,
        valueType: 'dateTimeRange',
        render: (text, record) => record.pbcCreateAt,
      },
    ];
    return (
      <PageContainer
        header={{
          title: '',
          breadcrumb: {},
        }}
      >
        <ProTable<API.PbcBusiness>
          columns={columns}
          actionRef={actionRef}
          request={fetchData}
          rowKey="pbcId"
          size="small"
          bordered
          search={{
            labelWidth: 'auto',
            span: 6,
          }}
          pagination={{
            defaultPageSize: 20,
            showSizeChanger: true,
          }}
          scroll={{
            y: 'calc(100vh - 320px)',
          }}
          dateFormatter="string"
          options={false}
          toolBarRender={() => []}
        />
      </PageContainer>
    );
  };
  
  export default TableList;
  