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',
    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.HouseOrders.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(),
          MyColumns.EnumTag({
            title: '支付状态',
            dataIndex: 'order_status',
            valueEnum: HouseOrdersOrderStatusEnum,
          }),
          MyColumns.EnumTag({
            title: '支付渠道',
            dataIndex: 'payment_method',
            valueEnum: HouseOrdersPaymentMethodEnum,
          }),

          {
            title: '订单编号',
            dataIndex: 'order_code',
            search: false,
          },

          {
            title: '账单金额',
            dataIndex: 'amount',
            search: false,
          },
          {
            title: '优惠金额',
            dataIndex: 'discount_amount',
            search: false,
          },
          {
            title: '滞纳金',
            dataIndex: 'late_fee',
            search: false,
          },
          {
            title: '应付金额',
            dataIndex: 'total_payable_amount',
            search: false,
          },
          {
            title: '关联项目',
            dataIndex: ['asset_project', 'name'],
            search: false,
          },
          {
            title: '关联机构',
            dataIndex: ['company', 'name'],
            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>
  );
}
