<template>
  <div class="layout-padding">
    <div class="layout-padding-auto layout-padding-view">
      <el-tabs v-model="activeName" @tab-click="handleTabClick">
        <el-tab-pane label="按联系人统计" name="tab">
          <ContanctByUserStatic ref="tabIndexRef" />
        </el-tab-pane>
        <el-tab-pane label="按部门统计" name="static">
          <ContanctByDeptStatic ref="staticIndexRef" />
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script setup lang="ts" name="recruitstudentsignup-contanctStatic">
import { ref, defineAsyncComponent, nextTick } from 'vue'

const ContanctByUserStatic = defineAsyncComponent(() => import('./contanctByUserStatic.vue'))
const ContanctByDeptStatic = defineAsyncComponent(() => import('./contanctByDeptStatic.vue'))

// 状态
const activeName = ref('tab')
const tabIndexRef = ref()
const staticIndexRef = ref()

// Tab 切换
const handleTabClick = (tab: any) => {
  if (tab.paneName === 'tab') {
    nextTick(() => {
      tabIndexRef.value?.init()
    })
  } else {
    nextTick(() => {
      staticIndexRef.value?.init()
    })
  }
}
</script>

