<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="wait"></el-tab-pane>
          <el-tab-pane label="历史记录" name="his"></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 MeterSendEntrust from './EntrustRegister'
import MeterSendEntrustHis from './EntrustRegisterHis'
export default {
  name: 'MeterSendEntrustIndex',
  components: {
    // eslint-disable-next-line vue/no-unused-components
    MeterSendEntrust,
    // eslint-disable-next-line vue/no-unused-components
    MeterSendEntrustHis
  },
  data() {
    return {
      activeName: 'wait',
      currentComponent: ''
    }
  },
  mounted() {
    this.activeName = 'wait'
    this.currentComponent = 'MeterSendEntrust'
    this.$nextTick(() => {
      this.$refs.refModal._page()
    })
  },
  methods: {
    _changeTabs(tab, event) {
      if (tab.name === 'wait') {
        this.currentComponent = 'MeterSendEntrust'
        this.$nextTick(() => {
          this.$refs.refModal._page()
        })
      } else {
        this.currentComponent = 'MeterSendEntrustHis'
        this.$nextTick(() => {
          this.$refs.refModal._page()
        })
      }
    }
  }
}
</script>

<style scoped>
</style>
