<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 ReceiveBySample from '../test-task-manage-his/AllotByEntrust'
import ReceiveByEntrust from './AllotByEntrust'

export default {
  name: 'MeterSummaryEntrustIndex',
  // eslint-disable-next-line vue/no-unused-components
  components: { ReceiveByEntrust, 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>
