<template>
  <section class="AppWorkOrder">
    <component ref="component" :is="currentPage" @change="onChange" v-bind="$props"/>
  </section>
</template>

<script>
import List from './components/List'
import Detail from './components/Detail'
import Setting from './components/Setting'
import settingDetail from "./components/settingDetail";

export default {
  name: 'AppWorkOrder',
  label: '工单管理',

  props: {
    instance: Function,
    dict: Object,
    menuName: {default: '工单管理'}
  },

  data() {
    return {
      component: 'List',
      params: {}
    }
  },
  computed: {
    currentPage() {
      let {hash, query: {id}} = this.$route
      return hash == "#Setting" ? Setting :
          hash == "#sd" ? settingDetail :
              !!id ? Detail : List
    }
  },
  components: {
    List,
    Detail,
    Setting
  },

  methods: {
    onChange(data) {
      this.$router.push({query: data.params, hash: data.type == "Setting" ? "#Setting" : ""})
    }
  }
}
</script>

<style lang="scss">
.AppWorkOrder {
  height: 100%;
  background: #F3F6F9;
  overflow: auto;
}
</style>
