<template>
  <!-- 退料申请 -->
  <div class="app-container">
    <PageHeader v-if="isShowComponent !== 'Home'" :pageContent="pageContent" @goBack="goBack" />
    <component
      :is="isShowComponent"
      :backId="backId"
      :agreementId="agreementId"
      :isView="isView"
      @returnApply="returnApply"
      @returnEdit="returnEdit"
      @queryReturn="queryReturn"
      @goBackPage="goBack"
    />
  </div>
</template>

<script>
import PageHeader from '@/components/pageHeader'
import Home from './component/home.vue'
import AddReturn from './component/addReturn.vue'
import QueryReturn from './component/queryReturn.vue'
export default {
  components: {
    PageHeader,
    Home,
    AddReturn,
    QueryReturn
  },
  data() {
    return {
      isShowComponent: 'Home',
      pageContent: '',
      backId: '',
      agreementId: '',
      isView: false
    }
  },
  methods: {
    // 退料申请
    returnApply() {
      this.backId = ''
      this.pageContent = '新建退料任务'
      this.isShowComponent = 'AddReturn'
    },
    // 退料编辑
    returnEdit(id) {
      this.backId = id
      this.pageContent = '编辑退料任务'
      this.isShowComponent = 'AddReturn'
    },
    /* 查询 */
    queryReturn(id) {
      this.isView = true
      this.backId = id
      this.pageContent = '查看退料任务'
      this.isShowComponent = 'QueryReturn'
    },
    goBack() {
      this.isShowComponent = 'Home'
    }
  }
}
</script>
