<template>
  <a-tabs v-model:activeKey="activeKey" @change="handleTabChange">
    <a-tab-pane key="1" tab="能耗统计">
      <energyConsumption ref="energyConsumptionRef" />
    </a-tab-pane>
    <a-tab-pane key="2" tab="碳排统计" force-render>
      <carbonEmissions ref="carbonEmissionsRef" />
    </a-tab-pane>
    <a-tab-pane key="3" tab="碳排速算">
      <quickCalculation ref="quickCalculationRef" />
    </a-tab-pane>
  </a-tabs>
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
  import energyConsumption from './energyConsumption/index.vue';
  import carbonEmissions from './carbonEmissions/index.vue';
  import quickCalculation from './quickCalculation/index.vue';
  defineOptions({
    name: 'CarbonEmissionStatisticsIndex', // 与页面路由name一致缓存才可生效
  });
  const activeKey = ref('1');
  // 切换tab页的回调
  const handleTabChange = (key) => {
    console.log('Tab changed:', key);
    // 在这里可以执行需要在页面切换时执行的逻辑
    // if(key==='1'){
    //    if (energyConsumptionRef.value) {
    //     energyConsumptionRef.value.getTableList(); // 调用子组件的方法
    //   }
    // }
  };
</script>
