<template>
  <div class="appjob">
    <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'
import Add from './components/Add'

export default {
  label: '招工就业',
  name: 'AppJob',
  // 组件
  components: { Add, List },
  props: {
    instance: Function,
    dict: Object,
    permissions: Function,
  },
  data() {
    return {
      component: 'List',
      params: {},
      include: [],
    }
  },
  // 计算
  computed: {},
  // 监听
  watch: {},
  // 实例创建后
  created() {},
  // 实例创建后
  onShow() {},
  // 实例渲染后
  mounted() {},
  // 方法
  methods: {
    onChange(data) {
      if (data.type === 'Add') {
        this.component = 'Add'
        this.params = data.params
      }

      if (data.type === 'list') {
        this.component = 'List'
        this.params = data.params

        this.$nextTick(() => {
          if (data.isRefresh) {
            this.$refs.component.getList()
          }
        })
      }
    },
  },
}
</script>

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