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

<script>
  import Detail from './components/Detail'
  import Add from './components/Add'
  import List from './components/List'

  export default {
    name: "AppDispatchManagement",
    label: '公文流转',

    components: {List, Detail, Add},

    props: {
      instance: Function,
      dict: Object,
      permissions: Function
    },
    data() {
      return {
        component: 'List',
        params: {},
        include: []
      }
    },
    created(){
    },
    methods:{
      onChange (data) {
        if (data.type === 'detail') {
          this.component = 'Detail'
          this.params = data.params
        }

        if (data.type === 'add') {
          console.log(123)
          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 lang="scss" scoped>
.appDispatchManagement{
  width: 100%;
  height: 100%;
}
</style>
