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

<script>
import electionList from "./components/electionList.vue";
import electionAdd from "./components/electionAdd.vue";

export default {
  name: "AppGeneralElection",
  label: "换届选举",
  props: {
    instance: Function,
    dict: Object,
  },
  components: {electionAdd, electionList},
  data() {
    return {
      component: "electionList",
      params: {},
      include: [],
    }
  },
  methods: {
    onChange(data) {
      if (data.type === "electionAdd") {
        this.component = "electionAdd";
        this.params = data.params;
      }

      if (data.type === "electionList") {
        this.component = "electionList";
        this.params = data.params;

        this.$nextTick(() => {
          if (data.isRefresh) {
            this.$refs.component.getList();
          }
        });
      }
    },
  },
  created() {
    // this.dict.load("portalUserStatus", "enterpriseStatus", "userEnterpriseStatus","enterpriseType")
  }
}
</script>

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