<template>
  <div class="card institution-total-section">
    <div class="rounded-lg border border-gray-200 pb-2 mb-4">
      <div class="mt-4">
        <!-- Tab切换 -->
        <div class="mb-6">
          <LTitle title="申请机构总数详情" />
          <div class="bg-white px-4 py-2">
            <van-tabs v-model:active="activeTab" color="var(--color-primary)">
              <van-tab v-for="(period, index) in periods" :key="period.key" :title="period.label">
                <div class="p-4">
                  <!-- 银行机构 -->
                  <BankOrgSection :data="data" :period="period.key" :dimension="dimension" />

                  <!-- 非银机构 -->
                  <NBankOrgSection :data="data" :period="period.key" :dimension="dimension" />
                </div>
              </van-tab>
            </van-tabs>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import LTitle from '@/components/LTitle.vue'
import BankOrgSection from './BankOrgSection.vue'
import NBankOrgSection from './NBankOrgSection.vue'

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

const activeTab = ref(5) // 默认显示12个月

const periods = [
  { key: 'd7', label: '7天' },
  { key: 'd15', label: '15天' },
  { key: 'm1', label: '1个月' },
  { key: 'm3', label: '3个月' },
  { key: 'm6', label: '6个月' },
  { key: 'm12', label: '12个月' }
]
</script>

<style lang="scss" scoped>
.card {
  background: #ffffff;
}

.institution-total-section :deep(.van-tabs) {
  border: unset !important;
}

.institution-total-section :deep(.van-tabs__wrap) {
  height: 32px !important;
  background-color: transparent !important;
  padding: 0 !important;
  border-bottom: 1px solid #DDDDDD !important;
}

.institution-total-section :deep(.van-tabs__nav) {
  background-color: transparent !important;
  gap: 0 !important;
  height: 32px !important;
  border: unset !important;
}

.institution-total-section :deep(.van-tabs__nav--card) {
  border: unset !important;
}

.institution-total-section :deep(.van-tab) {
  color: #999999 !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  border-right: unset !important;
  background-color: transparent !important;
  border-radius: unset !important;
  max-width: 80px !important;
}

.institution-total-section :deep(.van-tab--card) {
  color: #999999 !important;
  border-right: unset !important;
  background-color: transparent !important;
  border-radius: unset !important;
}

.institution-total-section :deep(.van-tab--active) {
  color: var(--van-theme-primary) !important;
  background-color: unset !important;
}

.institution-total-section :deep(.van-tabs__line) {
  height: 4px !important;
  border-radius: 1px !important;
  background-color: var(--van-theme-primary) !important;
  width: 20px;
  border-radius: 14px;
}
</style>
