<template>
  <section class="AppOrganizationChange">
    <keep-alive :include="['List']">
      <component :is="currentPage" :instance="instance" :selected.sync="selected" :params="params" :dict="dict" @change="onChange"/>
    </keep-alive>
  </section>
</template>

<script>
import {mapState} from "vuex";
import List from "./components/List.vue";
import organizationSetting from "./components/organizationSetting.vue";

export default {
  name: "AppOrganizationChange",
  label: "组织换届",
  provide() {
    return {
      ...this.$props
    }
  },
  props: {
    instance: Function,
    dict: Object,
    permissions: Function
  },
  components: {
    List,
    organizationSetting,
  },
  computed: {
    ...mapState(['user']),
    currentPage() {
      const {hash} = this.$route
      if (["#add","#makeup"].includes(hash)) {
        return organizationSetting
      } else return List
    }
  },
  data() {
    return {
      params: {},
      include: [],
      selected: {},
    }
  },
  methods: {
    onChange(data) {
      this.params = data.params;
    },
  },
}
</script>

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