import { MyBetaModalFormProps, renderTextHelper } from '@/common';
import {
  HouseBillsTypeEnum,
  HouseChargeStandardsApportionmentMethodEnum,
  HouseChargeStandardsCalculationMethodEnum,
  HouseChargeStandardsCalculationModeEnum,
  HouseChargeStandardsCalculationPeriodEnum,
  HouseChargeStandardsPriceAlgorithmEnum,
} from '@/gen/Enums';

import { ProCard, ProDescriptions } from '@ant-design/pro-components';
import { Space } from 'antd';

export default function ChargeStandardInfo(props: MyBetaModalFormProps) {
  const model = props?.item?.model?.new_data;

  return (
    <>
      <Space direction="vertical" style={{ width: '100%' }}>
        <ProCard title="收费标准申请信息" size="small">
          <ProDescriptions size="small" column={2}>
            <ProDescriptions.Item label="申请事项" span={2}>
              {props?.item?.title || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="关联项目">
              {props?.item?.asset_project?.name || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="收费标准名称">
              {model?.name || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="收款帐号">
              {model?.company_receipt_account?.company_bank}：
              {model?.company_receipt_account?.company_account || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="收费类型">
              <renderTextHelper.Tag
                Enums={HouseBillsTypeEnum}
                value={model?.charge_type}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="是否公摊">
              {model?.is_apportionment ? '是' : '否'}
            </ProDescriptions.Item>
            {model?.apportionment_method && (
              <ProDescriptions.Item label="分摊方式">
                <renderTextHelper.Tag
                  Enums={HouseChargeStandardsApportionmentMethodEnum}
                  value={model?.apportionment_method}
                />
              </ProDescriptions.Item>
            )}
            <ProDescriptions.Item label="计量单位">
              <renderTextHelper.Tag
                Enums={HouseChargeStandardsCalculationMethodEnum}
                value={model?.calculation_method}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="计费模式">
              <renderTextHelper.Tag
                Enums={HouseChargeStandardsCalculationModeEnum}
                value={model?.calculation_mode}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="计费算法">
              <renderTextHelper.Tag
                Enums={HouseChargeStandardsPriceAlgorithmEnum}
                value={model?.price_algorithm}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="价格">
              {model?.price_algorithm === 'Fixed'
                ? `${model?.price || '-'} 元`
                : model?.tiered_rates?.map((rate: any, index: number) => (
                    <div key={index}>
                      {rate?.min_quantity} - {rate?.max_quantity}: {rate?.price}{' '}
                      元
                    </div>
                  )) || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="计费周期">
              <renderTextHelper.Tag
                Enums={HouseChargeStandardsCalculationPeriodEnum}
                value={model?.calculation_period}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="生成日期">
              {model?.auto_date || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="启用滞纳金">
              {model?.has_late_fee ? '是' : '否'}
            </ProDescriptions.Item>
            {model?.has_late_fee && (
              <>
                <ProDescriptions.Item label="滞纳金起算天数">
                  {model?.late_fee_start_days || '-'} 天
                </ProDescriptions.Item>
                <ProDescriptions.Item label="滞纳金费率">
                  {model?.late_fee_rate || '-'} %/天
                </ProDescriptions.Item>
                <ProDescriptions.Item label="滞纳金封顶天数">
                  {model?.late_fee_cap_days || '-'} 天
                </ProDescriptions.Item>
              </>
            )}
            <ProDescriptions.Item label="申请人">
              {props?.item?.applicant_name || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="申请时间">
              {props?.item?.created_at || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="申请说明" span={2}>
              {model?.remark || '-'}
            </ProDescriptions.Item>
          </ProDescriptions>
        </ProCard>
      </Space>
    </>
  );
}
