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

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

  export default {
    name: 'AppVillageAlbum',
    label: '乡村相册',

    components: {
      List,
      Add
    },

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

    data () {
      return {
        currIndex: '0',
        component: 'List',
        params: {},
        areaId: '',
        isShowDetail: false
      }
    },

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

        if (data.type === 'detail') {
          this.component = 'Detail'
          this.params = data.params
        }

        if (data.type === 'add') {
          this.component = 'Add'
          this.params = data.params
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
  .AppVillageAlbum {
    height: 100%;
  }
</style>
