<template>
  <div class="card">
    <div class="rounded-lg border border-gray-200 p-4 space-y-3">
      <LTitle title="近期集中申请提示" />

      <div v-if="hasAnyData" class="space-y-2 text-sm text-gray-700">
        <div class="flex justify-between">
          <span>最近在银行连续申请次数</span>
          <span class="font-bold text-[#111827]">{{ bankCons }} 次</span>
        </div>
        <div class="flex justify-between">
          <span>最近在银行连续申请天数</span>
          <span class="font-bold text-[#111827]">{{ bankDays }} 天</span>
        </div>
        <div class="flex justify-between">
          <span>最近在非银连续申请次数</span>
          <span class="font-bold text-[#111827]">{{ nbankCons }} 次</span>
        </div>
        <div class="flex justify-between">
          <span>最近在非银连续申请天数</span>
          <span class="font-bold text-[#111827]">{{ nbankDays }} 天</span>
        </div>
        <div class="flex justify-between">
          <span>距最近一次在银行机构申请</span>
          <span class="font-bold text-[#111827]">{{ bankGap }} 天</span>
        </div>
        <div class="flex justify-between">
          <span>距最近一次在非银机构申请</span>
          <span class="font-bold text-[#111827]">{{ nbankGap }} 天</span>
        </div>
      </div>

      <div v-else class="text-sm text-gray-400">
        暂未查询到明显的近期集中申请行为。
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import LTitle from '@/components/LTitle.vue'
import { getValue } from '../utils/dataParser'

const props = defineProps({
  data: {
    type: Object,
    required: true,
    default: () => ({}),
  },
  // 维度：id（身份证） / cell（手机号）
  dimension: {
    type: String,
    default: 'id',
  },
})

const bankCons = computed(() => {
  const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
  return getValue(props.data?.[`als_lst_${dimKey}_bank_consnum`])
})
const bankDays = computed(() => {
  const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
  return getValue(props.data?.[`als_lst_${dimKey}_bank_csinteday`])
})
const nbankCons = computed(() => {
  const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
  return getValue(props.data?.[`als_lst_${dimKey}_nbank_consnum`])
})
const nbankDays = computed(() => {
  const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
  return getValue(props.data?.[`als_lst_${dimKey}_nbank_csinteday`])
})

const bankGap = computed(() => {
  const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
  return getValue(props.data?.[`als_lst_${dimKey}_bank_inteday`])
})
const nbankGap = computed(() => {
  const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
  return getValue(props.data?.[`als_lst_${dimKey}_nbank_inteday`])
})

const hasAnyData = computed(() => {
  return (
    (bankCons.value || 0) > 0 ||
    (bankDays.value || 0) > 0 ||
    (nbankCons.value || 0) > 0 ||
    (nbankDays.value || 0) > 0 ||
    (bankGap.value || 0) > 0 ||
    (nbankGap.value || 0) > 0
  )
})
</script>

<style scoped>
.card {
  background: #ffffff;
}
</style>


