<template>
  <div class="AppPartyMember">
    <component ref="component" :is="component" :selected.sync="selected" :instance="instance"
               :dict="dict"/>
  </div>
</template>

<script>
import List from './components/List'
import Add from './components/Add'
import Detail from './components/Detail'
import {mapState} from "vuex";

export default {
  name: 'AppPartyMember',
  label: '党员管理',
  components: {
    Add,
    List,
    Detail
  },
  props: {
    instance: Function,
    dict: Object
  },
  data() {
    return {
      selected: {}
    }
  },
  computed: {
    ...mapState(['user']),
    component() {
      if (this.$route.hash == "#add") {
        return Add
      } else if (this.$route.query.id) {
        return Detail
      } else return List
    }
  },
  created() {
    let {organizationId: id, organizationName: name} = this.user.info
    this.selected = {id, name}
  },

}
</script>

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