<template>
  <div class="card shadow-sm rounded-xl overflow-hidden">
    <!-- 基本信息 -->
    <BaseInfoSection :data="{ baseInfo: data.baseInfo }" />

    <!-- 身份信息核验 -->
    <StandLiveInfoSection :data="{ standLiveInfo: data.standLiveInfo }" />

    <!-- 命中风险标注 -->
    <RiskPointSection :data="{ riskPoint: data.riskPoint }" />

    <!-- 公安重点人员核验 -->
    <SecurityInfoSection :data="{ securityInfo: data.securityInfo }" />

    <!-- 涉赌涉诈人员核验 -->
    <AntiFraudInfoSection :data="{ antiFraudInfo: data.antiFraudInfo }" />

    <!-- 风险名单 -->
    <RiskListSection :data="{ riskList: data.riskList }" />

    <!-- 历史借贷行为 -->
    <ApplicationStatisticsSection :data="{ applicationStatistics: data.applicationStatistics }" />

    <!-- 近24个月放款情况 -->
    <LendingStatisticsSection :data="{ lendingStatistics: data.lendingStatistics }" />

    <!-- 履约情况 -->
    <PerformanceStatisticsSection :data="{ performanceStatistics: data.performanceStatistics }" />

    <!-- 历史逾期记录 -->
    <OverdueRecordSection :data="{ overdueRecord: data.overdueRecord }" />

    <!-- 授信详情 -->
    <CreditDetailSection :data="{ creditDetail: data.creditDetail }" />

    <!-- 租赁行为 -->
    <RentalBehaviorSection :data="{ rentalBehavior: data.rentalBehavior }" />

    <!-- 关联风险监督 -->
    <RiskSupervisionSection :data="{ riskSupervision: data.riskSupervision }" />

    <!-- 法院风险信息 -->
    <!-- <CourtRiskInfoSection 
      :data="{ judiciaRiskInfos: data.judiciaRiskInfos }"
    /> -->

  </div>
</template>

<script setup>
import { ref, computed, watch } from 'vue'
import { useRiskNotifier } from '@/composables/useRiskNotifier';
import BaseInfoSection from './components/BaseInfoSection.vue'
import StandLiveInfoSection from './components/StandLiveInfoSection.vue'
import RiskPointSection from './components/RiskPointSection.vue'
import SecurityInfoSection from './components/SecurityInfoSection.vue'
import AntiFraudInfoSection from './components/AntiFraudInfoSection.vue'
import RiskListSection from './components/RiskListSection.vue'
import ApplicationStatisticsSection from './components/ApplicationStatisticsSection.vue'
import LendingStatisticsSection from './components/LendingStatisticsSection.vue'
import PerformanceStatisticsSection from './components/PerformanceStatisticsSection.vue'
import OverdueRecordSection from './components/OverdueRecordSection.vue'
import CreditDetailSection from './components/CreditDetailSection.vue'
import RentalBehaviorSection from './components/RentalBehaviorSection.vue'
import RiskSupervisionSection from './components/RiskSupervisionSection.vue'
import CourtRiskInfoSection from './components/CourtRiskInfoSection.vue'

const props = defineProps({
  data: {
    type: Object,
    required: true,
    default: () => ({
      apiId: {
        type: String,
        default: '',
      },
      index: {
        type: Number,
        default: 0,
      },
      notifyRiskStatus: {
        type: Function,
        default: () => { },
      },
    })
  },
  params: {
    type: Object,
    default: () => ({})
  }
})

// 处理数据
const processedData = computed(() => {
  return props.data || {}
})

// 计算风险评分（0-100分，分数越高越安全）
// 司南报告是复合报告，需要汇总所有子模块的评分
const riskScore = computed(() => {
  // 司南报告由多个子模块组成，这里先返回一个默认值
  // 实际的评分应该由子模块计算后汇总
  // 暂时返回一个中等评分，等待子模块实现
  return 80;
});

// 使用 composable 通知父组件风险评分
useRiskNotifier(props, riskScore);

// 暴露给父组件
defineExpose({
  riskScore
});
</script>

<style lang="scss" scoped>
.card {
  @apply bg-white rounded-xl shadow-sm p-4 mb-4;
}
</style>
