<template>
  <div>
    <div class="layout-content-padding">
      <div class="layout-content-main">
        <el-tabs v-model="activeName" @tab-click="_changeTabs">
          <el-tab-pane label="待完成" name="entrust"></el-tab-pane>
          <el-tab-pane label="历史记录" name="sample"></el-tab-pane>
        </el-tabs>
        <keep-alive>
          <!-- eslint-disable-next-line vue/require-component-is -->
          <component ref="refModal" :is="currentComponent"></component>
        </keep-alive>
      </div>
    </div>
  </div>
</template>

<script>
import ReceiveByEntrust from './ReceiveByEntrust'
import ReceiveBySample from './ReceiveBySample'

export default {
  name: 'MeterSummaryEntrustIndex',
  components: {
    // eslint-disable-next-line vue/no-unused-components
    ReceiveByEntrust,
    // eslint-disable-next-line vue/no-unused-components
    ReceiveBySample
  },
  data() {
    return {
      activeName: 'entrust',
      currentComponent: ''
    }
  },
  mounted() {
    this.activeName = 'entrust'
    this._page()
  },
  methods: {
    _changeTabs(tab, event) {
      if (tab.name === 'entrust') {
        this._page()
      } else {
        this.currentComponent = 'ReceiveBySample'
        this.$nextTick(() => {
          this.$refs.refModal._page()
        })
        // this.$refs.sampleTabs._page()
      }
    },
    _page() {
      this.currentComponent = 'ReceiveByEntrust'
      this.$nextTick(() => {
        this.$refs.refModal._page()
      })
      // this.$refs.entrustTabs._page()
    }
  }
}
</script>

<style scoped>
</style>
