<template>
  <div style="width: 100%;">
    <router-view />
    <template v-if="!$route.query.type">
      <el-tabs v-model="activeName" type="border-card">
        <el-tab-pane label="我的店铺" name="store">
          <Store ref="storeRef" @changeTab="changeTab" />
        </el-tab-pane>
        <el-tab-pane label="我的企业" name="enterprise">
          <Enterprise ref="enterpriseRef" v-if="activeName === 'enterprise'" />
        </el-tab-pane>
      </el-tabs>
    </template>
  </div>
</template>

<script>
export default {
  name: 'SmbLogManage',
  components: {
    Store: () => import('./components/Store.vue'),
    Enterprise: () => import('./components/Enterprise.vue')
  },
  data() {
    return {
      activeName: 'store'
    }
  },
  created() {
    if (this.$route.query && this.$route.query.activeName) {
      this.activeName = this.$route.query.activeName
    } else {
      this.activeName = 'store'
    }
  },
  watch: {
    activeName: {
      handler(val) {
        if (val === 'store') {
          setTimeout(() => {
            // this.$refs.storeRef.fetchData()
            // this.$refs.storeRef.queryAllTransCode()
          }, 300)
        } else {
          setTimeout(() => {
            // this.$refs.enterpriseRef.fetchData()
            // this.$refs.enterpriseRef.queryAllTransCode()
          }, 300)
        }
      },
      immediate: true
    }
  },
  methods: {
    changeTab(val) {
      this.activeName = val
    }
  }
}
</script>

<style lang="scss">

</style>
