<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="waitTabs"></el-tab-pane>
          <el-tab-pane label="录入历史" name="queryTabs"></el-tab-pane>
        </el-tabs>
        <keep-alive>
          <component ref="refModal" :is="currentComponent"></component>
        </keep-alive>
      </div>
    </div>
  </div>
</template>

<script>
import SampleBackupsManage from './TestInput'
import SampleBackupsQuery from './TestInputHis'

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