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

<script>
import List from "./components/List.vue";
import Add from "./components/Add.vue";

export default {
  name: "AppMassNotification",
  label: "群发通知",
  props: {
    instance: Function,
    dict: Object,
  },
  components: {Add, List},
  data() {
    return {
      component: "List",
      params: {},
      include: [],
    }
  },
  computed: {
    currentPage() {
      const {hash} = this.$route
      return hash == "#add" ? Add : List
    },
  },
  methods: {
    onChange(data) {
      if (data.type === "Add") {
        this.$router.push({hash: "#add", query: data.params})
      } else {
        this.$router.push({})
      }
    },
  },
}
</script>

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