<template>
  <div style="height: 100%;">
    <transition name="fade-transform" mode="out-in">
      <keep-alive :include="['List']">
        <component ref="component" :is="component" @change="onChange" :params="params"></component>
      </keep-alive>
    </transition>
  </div>
</template>

<script>
  import List from './components/List.vue'
  import Detail from './components/Detail.vue'

  export default {
    name: 'StoreTrack',
    label: '店铺跟踪',

    components: {
      List,
      Detail
    },

    data () {
      return {
        component: 'List',
        params: {}
      }
    },

    methods: {
      onChange (data) {
        if (data.type === 'Detail') {
          this.component = 'Detail'
          this.params = data.params
        }

        if (data.type === 'List') {
          this.component = 'List'
          this.params = data.params

          this.$nextTick(() => {
            if (data.isRefresh) {
              setTimeout(() => {
                this.$refs.component.getList()
              }, 600)
            }
          })
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>

