import {
  MyBetaModalFormProps,
  MyColumns,
  MyProTableProps,
  renderTextHelper,
} from '@/common';
import { MyModal } from '@/components/MyModal';

import {
  HouseBillsTypeEnum,
  HouseOrdersAuditStatusEnum,
  HouseOrdersPaymentMethodEnum,
} from '@/gen/Enums';
import { ProCard, ProDescriptions, ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';

export default function Show(props: MyBetaModalFormProps) {
  return (
    <MyModal
      title={props.title || '查看'}
      width={800}
      // onOpen={() => getShow()}
      node={
        <Space direction="vertical" style={{ width: '100%' }}>
          <ProCard size="small">
            <ProDescriptions bordered size="small" column={2}>
              <ProDescriptions.Item label="房屋名称" span={2}>
                <Space>
                  {props?.item?.house_order_items?.[0].asset_house?.full_name ||
                    '-'}
                  <renderTextHelper.Tag
                    Enums={HouseOrdersAuditStatusEnum}
                    value={props?.item?.audit_status}
                  />
                </Space>
              </ProDescriptions.Item>
              <ProDescriptions.Item label="收款账号" span={2}>
                {props?.item?.receipt_account?.company_name} ；
                {props?.item?.receipt_account?.company_bank} ；
                {props?.item?.receipt_account?.company_account}
              </ProDescriptions.Item>
              <ProDescriptions.Item label="关联流水" span={2}>
                {props?.item?.accept_serial_number || '-'}
              </ProDescriptions.Item>
              <ProDescriptions.Item label="收款方式">
                {Object.values(HouseOrdersPaymentMethodEnum).find(
                  (item) => item.value === props?.item?.payment_method,
                )?.text || '-'}
              </ProDescriptions.Item>
              <ProDescriptions.Item label="收款日期">
                {props?.item?.paid_time || '-'}
              </ProDescriptions.Item>

              <ProDescriptions.Item label="收款金额">
                {props?.item?.actual_paid_amount || '-'}
              </ProDescriptions.Item>
              <ProDescriptions.Item label="录入人">
                {props?.item?.creator || '-'}-
                {props?.item?.creator_phone || '-'}
              </ProDescriptions.Item>
              <ProDescriptions.Item label="录入时间">
                {props?.item?.created_at || '-'}
              </ProDescriptions.Item>
              <ProDescriptions.Item label="审核状态" span={2}>
                <renderTextHelper.Tag
                  Enums={HouseOrdersAuditStatusEnum}
                  value={props?.item?.audit_status}
                />
              </ProDescriptions.Item>
              <ProDescriptions.Item label="驳回原因" span={2}>
                {props?.item?.reason || '-'}
              </ProDescriptions.Item>
            </ProDescriptions>
          </ProCard>
          <ProCard size="small">
            <ProTable
              {...MyProTableProps.props}
              search={false}
              toolBarRender={false}
              pagination={false}
              dataSource={props?.item?.house_order_items}
              rowKey={(record, index) => record?.id || index}
              size="small"
              columns={[
                {
                  title: '关联账单',
                  render: (_, record) => {
                    return `${record.house_bill.year}-${String(
                      record.house_bill.month,
                    ).padStart(2, '0')}`;
                  },
                },
                MyColumns.EnumTag({
                  title: '类型',
                  dataIndex: ['house_bill', 'type'],
                  valueEnum: HouseBillsTypeEnum,
                }),
                {
                  title: '未收金额',
                  dataIndex: 'amount',
                  search: false,
                },
                {
                  title: '本次收取金额',
                  dataIndex: 'paid_amount',
                  search: false,
                },
              ]}
            />
          </ProCard>
        </Space>
      }
    />
  );
}
