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 ChargeInfo(props: MyBetaModalFormProps) {
  const { item } = props;

  return (
    <Space direction="vertical" style={{ width: '100%' }}>
      <ProCard title="基本信息">
        <ProDescriptions bordered column={3}>
          <ProDescriptions.Item label="收费标准名称">
            {item?.name}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="关联项目">
            {item?.asset_project?.name || '-'}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="收费项">
            <renderTextHelper.Tag
              Enums={HouseBillsTypeEnum}
              value={item?.charge_type}
            />
          </ProDescriptions.Item>
          <ProDescriptions.Item label="收款帐号">
            {item?.company_receipt_account?.company_bank}：
            {item?.company_receipt_account?.company_account}
          </ProDescriptions.Item>
          {item?.apportionment_method ? (
            <ProDescriptions.Item label="分摊方式">
              <renderTextHelper.Tag
                Enums={HouseChargeStandardsApportionmentMethodEnum}
                value={item?.apportionment_method}
              />
            </ProDescriptions.Item>
          ) : (
            ''
          )}
          <ProDescriptions.Item label="是否公摊">
            {item?.is_apportionment ? '是' : '否'}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="计量单位">
            <renderTextHelper.Tag
              Enums={HouseChargeStandardsCalculationMethodEnum}
              value={item?.calculation_method}
            />
          </ProDescriptions.Item>
          <ProDescriptions.Item label="计费模式">
            <renderTextHelper.Tag
              Enums={HouseChargeStandardsCalculationModeEnum}
              value={item?.calculation_mode}
            />
          </ProDescriptions.Item>
          <ProDescriptions.Item label="计费算法">
            <renderTextHelper.Tag
              Enums={HouseChargeStandardsPriceAlgorithmEnum}
              value={item?.price_algorithm}
            />
          </ProDescriptions.Item>
          <ProDescriptions.Item label="固定单价">
            ¥{item?.price}元
          </ProDescriptions.Item>
          {item?.calculation_method !== 'PerUnit' ? (
            <ProDescriptions.Item label="阶梯标准" span={2}>
              <Space direction="vertical">
                {item?.tiered_rates?.map((rate: any, index: number) => (
                  <div key={`item_${index}`}>
                    阶梯范围：{rate?.min_quantity}-{rate?.max_quantity}{' '}
                    阶梯单价：¥{rate?.price}元
                  </div>
                ))}
              </Space>
            </ProDescriptions.Item>
          ) : (
            ''
          )}
          <ProDescriptions.Item label="计费周期">
            <renderTextHelper.Tag
              Enums={HouseChargeStandardsCalculationPeriodEnum}
              value={item?.calculation_period}
            />
          </ProDescriptions.Item>
          <ProDescriptions.Item label="账单自动生成日期">
            {item?.auto_date}
          </ProDescriptions.Item>
          {item?.has_late_fee ? (
            <ProDescriptions.Item label="滞纳金计算" span={2}>
              <Space direction="vertical">
                <div>有滞纳金：{item?.has_late_fee ? '是' : '否'}</div>
                <div>起算天数：生成账单后{item?.late_fee_start_days}天</div>
                <div>收取费率：每日{item?.late_fee_rate}%</div>
                <div>封顶天数：最多{item?.late_fee_cap_days}天</div>
              </Space>
            </ProDescriptions.Item>
          ) : (
            ''
          )}
          <ProDescriptions.Item label="备注" span={2}>
            {item?.remark}
          </ProDescriptions.Item>
        </ProDescriptions>
      </ProCard>
    </Space>
  );
}
