<template>
  <div>
    <a-card size="small" :bordered="false">
      <a-tabs default-active-key="1" @change="handleChange">
        <a-tab-pane key="1" tab="轮胎月度费用报表">
          <monthQueryList ref="tireMonthQueryList"></monthQueryList>
        </a-tab-pane>
        <a-tab-pane key="2" tab="轮胎季度费用报表" force-render>
          <quarterQueryList ref="tireQuarterQueryList"></quarterQueryList>
        </a-tab-pane>
        <a-tab-pane key="3" tab="轮胎年度费用报表" force-render>
          <yearQueryList ref="tireYearQueryList"></yearQueryList>
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </div>
</template>
<script>
import { commonMixin } from '@/utils/mixin'
// 组件
import monthQueryList from './monthQueryList.vue'
import quarterQueryList from './quarterQueryList.vue'
import yearQueryList from './yearQueryList.vue'
export default {
  name: 'TireFeeReportIndex',
  mixins: [commonMixin],
  components: { monthQueryList, quarterQueryList, yearQueryList },
  data () {
    return {
      tabVal: 1 // tab值  1轮胎月度费用报表 2轮胎季度费用报表 3轮胎年度费用报表 4轮胎费用明细报表
    }
  },
  methods: {
    // 切换tab值  change
    handleChange (val) {
      this.tabVal = val
    },
    // 初始化
    pageInit () {
      if (this.tabVal == 1) {
        this.$refs.tireMonthQueryList.pageInit()
      }
    }
  },
  mounted () {
    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
      this.pageInit()
    }
  },
  activated () {
    // 如果是新页签打开，则重置当前页面
    if (this.$store.state.app.isNewTab) {
      this.pageInit()
    }
  }
}

</script>
