import { MyColumns, MyProTableProps } from '@/common';
import { Selects } from '@/components/Select';
import { Apis } from '@/gen/Apis';
import { BillPaymentsTypeEnum, BillsStatusEnum } from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';
import PayCreate from '../modals/DepositPayCreate';

export default function Index() {
  return (
    <ProTable
      {...MyProTableProps.props}
      headerTitle="账单列表"
      request={async (params, sort) =>
        MyProTableProps.request(
          { ...params, type: 'RenovationDeposit' },
          sort,
          Apis.Bill.Bills.List,
        )
      }
      columns={[
        MyColumns.ID({}),
        Selects?.AssetProjects({
          title: '选择项目',
          key: 'id',
          hidden: true,
        }),
        // MyColumns.EnumTag({
        //   title: '费用类型',
        //   dataIndex: 'flow_type',
        //   valueEnum: ContractBillsCostTypeEnum,
        //   search: false,
        // }),
        MyColumns.EnumTag({
          title: '费用项目',
          dataIndex: 'type',
          valueEnum: BillPaymentsTypeEnum,
          search: false,
        }),
        {
          title: '收款金额',
          dataIndex: 'amount',
          render: (_, item) => `${item?.amount}元`,
          search: false,
        },
        // {
        //   title: '收款账号',
        //   dataIndex: 'receipt_account',
        //   render: (_, record) => {
        //     return `${record.receipt_account?.company_name}
        //       ${record.receipt_account.company_account?.slice(0, 4)}
        //       ****
        //       ${record.receipt_account.company_account?.slice(-4)}`;
        //   },
        //   search: false,
        // },
        {
          title: '付款人',
          dataIndex: 'payer',
        },
        {
          title: '付款人电话',
          dataIndex: 'phone',
        },
        MyColumns.EnumTag({
          title: '状态',
          dataIndex: 'status',
          valueEnum: BillsStatusEnum,
        }),
        // MyColumns.EnumTag({
        //   title: '支付方式',
        //   dataIndex: 'payment_method',
        //   valueEnum: HouseOrdersPaymentMethodEnum,
        //   search: false,
        // }),

        {
          title: '支付时间',
          dataIndex: 'paid_time',
          search: false,
        },
        {
          title: '退款金额',
          render: (_, item) => `${item?.refund_amount}元`,
          search: false,
        },
        {
          title: '退款时间',
          dataIndex: 'refund_time',
          search: false,
        },
        MyColumns.UpdatedAt(),
        MyColumns.Option({
          render: (_, item: any, index, action) => (
            <Space key={`item_${index}`}>
              <PayCreate item={item} reload={action?.reload} title="收款" />
            </Space>
          ),
        }),
      ]}
    />
  );
}
