<template> <div class="container"> <el-tabs v-model="activeName" type="card" @tab-click="handleClick"> <el-tab-pane label="指标完成情况" name="deptStatics"> <dept-statistics ref="dept"/> </el-tab-pane> <el-tab-pane label="指标统计结果" name="indexStatics"> <index-statistics v-if="activeName === 'indexStatics'" ref="index"/> </el-tab-pane> </el-tabs> </div> </template> <script> import DeptStatistics from './components/deptStatistics' import IndexStatistics from './components/indexStatistics' export default { name: 'ResultStatistic', components: { DeptStatistics, IndexStatistics }, data() { return { activeName: 'deptStatics' } }, created() { // 如果路径里带参数,自己解析deviceType参数 // if (window.location.href) { // const params = parseUrl(window.location.href) // if (params && params.deviceType) { // this.changeTab(params.deviceType) // } else { // this.caclActive() // } // } }, methods: { // 处理Tab点击事件,每次点击更新数据 handleClick(tab, event) { if (tab.name === 'deptStatics') { this.activeName = 'deptStatics' this.$refs.dept.fetchData() } else if (tab.name === 'indexStatics') { this.activeName = 'indexStatics' this.$refs.index.fetchData() } } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .container{ padding: 5px; } </style>