import {
  MyColumns,
  MyPageContainer,
  MyProTableProps,
  usePageTabs,
} from '@/common';
import { Apis } from '@/gen/Apis';
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_payments"
      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}
        //   />,
        //   <BillCreate key="Create" reload={action?.reload} title={title} />,
        // ]}
        columns={[
          MyColumns.ID(),
          {
            title: '房屋',
            dataIndex: ['asset_house', 'full_name'],
            search: {
              transform: (value) => {
                return { full_name: value };
              },
            },
          },
          {
            title: '支付单号',
            dataIndex: 'payment_no',
            search: false,
          },
          {
            title: '交易单号',
            dataIndex: 'transaction_id',
            search: false,
          },
          {
            title: '第三方交易号',
            dataIndex: 'hird_trade_no',
            search: false,
          },
          MyColumns.CreatedAt(),
          // MyColumns.Option({
          //   render: (_, item: any, index, action) => (
          //     <Space key={index}>
          //       <BillUpdate item={item} reload={action?.reload} title={title} />
          //       <MyButtons.Delete
          //         onConfirm={() =>
          //           Apis.Common.Admins.Delete({ id: item.id }).then(() =>
          //             action?.reload(),
          //           )
          //         }
          //       />
          //     </Space>
          //   ),
          // }),
        ]}
      />
    </MyPageContainer>
  );
}
