<template>
  <div class="AppActivitiesManagement">
    <keep-alive :include="['List']">
      <component ref="component" :is="component" @change="onChange" :params="params" :instance="instance" :dict="dict"></component>
    </keep-alive>
  </div>
</template>

<script>
  import activitiesList from './components/activitiesList'
  import activitiesAdd from './components/activitiesAdd'

  export default {
    name: 'AppHomeReport',
    label: '活动管理',

    props: {
      instance: Function,
      dict: Object
    },

    data () {
      return {
        component: 'activitiesList',
        params: {},
        include: []
      }
    },

    components: {
      activitiesList,
      activitiesAdd
    },

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

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

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

<style lang="scss">
.AppActivitiesManagement {
  height: 100%;
  background: #F3F6F9;
  overflow: auto;
}
</style>
