import { MyColumns, MyPageContainer, MyProTableProps } 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 = '工单费用' }) {
  return (
    <MyPageContainer
      title={title}
      enableTabs={true}
      tabKey="house_work_order_payments"
      tabLabel={title}
    >
      <ProTable
        {...MyProTableProps.props}
        headerTitle="工单费用"
        request={async (params, sort) =>
          MyProTableProps.request(
            params,
            sort,
            Apis.WorkOrder.HouseWorkOrderPayments.List,
          )
        }
        columns={[
          MyColumns.ID({
            search: false,
          }),
          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: '支付时间',
            dataIndex: 'paid_time',
            render: (_, record) => {
              return record?.paid_time?.substring(0, 10);
            },
            search: false,
          },
          {
            title: '银行流水',
            dataIndex: ['house_order', 'accept_serial_number'],
            // search: false,
          },
          {
            title: '外部交易号',
            dataIndex: 'third_trade_no',
            // search: false,
          },
          // MyColumns.EnumTag({
          //   title: '审核状态',
          //   dataIndex: 'audit_status',
          //   valueEnum: HouseOrdersAuditStatusEnum,
          // }),
          {
            title: '收款单号',
            dataIndex: 'payment_no',
            search: false,
          },
          MyColumns.UpdatedAt(),
        ]}
      />
    </MyPageContainer>
  );
}
