import {
  MyColumns,
  MyPageContainer,
  MyProTableProps,
  usePageTabs,
} from '@/common';
import { Apis } from '@/gen/Apis';
import {
  HouseOrdersOrderStatusEnum,
  HouseOrdersPaymentMethodEnum,
} from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';

export default function Index({ title = '支付明细' }) {
  // 注册当前页面为标签页
  usePageTabs({
    tabKey: 'house_order_payments',
    tabLabel: title,
  });

  return (
    <MyPageContainer
      title={title}
      enableTabs={true}
      tabKey="house_order"
      tabLabel={title}
    >
      <ProTable
        {...MyProTableProps.props}
        request={async (params, sort) =>
          MyProTableProps.request(
            params,
            sort,
            Apis.HouseOrder.HouseOrderPayments.List,
          )
        }
        // toolBarRender={(action) => [
        //   <MyImportModal
        //     key="ImportHouse"
        //     title="批量导入"
        //     type="danger"
        //     size="middle"
        //     templateApi={Apis.Bill.HouseBills.DownloadTemplate}
        //     importApi={Apis.Bill.HouseBills.Import}
        //     reload={action?.reload}
        //   />,
        // ]}
        columns={[
          MyColumns.ID(),

          MyColumns.EnumTag({
            title: '支付状态',
            dataIndex: 'payment_status',
            valueEnum: HouseOrdersOrderStatusEnum,
          }),
          MyColumns.EnumTag({
            title: '支付方式',
            dataIndex: 'payment_method',
            valueEnum: HouseOrdersPaymentMethodEnum,
          }),
          {
            title: '账单金额',
            dataIndex: 'amount',
            render: (value: any) => `${value / 100}元`,
            search: false,
          },
          {
            title: '实际金额',
            dataIndex: 'actual_amount',
            render: (value: any) => `${value / 100}元`,
            search: false,
          },

          {
            title: '支付人',
            render: (record: any) =>
              `${record?.customer?.name || ''}${record?.customer?.phone || ''}`,

            search: false,
          },
          {
            title: '备注',
            dataIndex: 'remark',
            search: false,
          },
          {
            title: '支付单号',
            dataIndex: 'payment_no',
            search: false,
          },
          MyColumns.UpdatedAt(),
        ]}
      />
    </MyPageContainer>
  );
}
