<template>
    <!-- 领料申请主页面 -->
    <div class="app-container">
        <PageHeader
            v-if="isShowComponent !== 'Home'"
            :pageContent="pageContent"
            @goBack="goBack"
        />
        <component
            :is="isShowComponent"
            :viewTaskId="viewTaskId"
            :isView="isView"
            :isEdit="isEdit"
            :rejectTaskStatus="rejectTaskStatus"
            @addPicking="addPicking"
            @viewPicking="viewPicking"
            @editPicking="editPicking"
            @goBackPage="goBack"
        />
    </div>
</template>

<script>
import PageHeader from '@/components/pageHeader'
// import Home from './component/home.vue' // 主列表
import Home from './component/home1.vue' // 主列表
// import AddPicking from './component/AddPicking.vue' // 新增领料
import AddPicking from './component/AddPicking1.vue' // 新增领料
export default {
    components: {
        Home,
        AddPicking,
        PageHeader,
    },
    data() {
        return {
            isShowComponent: 'Home',
            pageContent: '新增领料任务',
            viewTaskId: '',
            rejectTaskStatus: '',
            isView: false,
            isEdit: false,
        }
    },
    methods: {
        /* 新建领料任务 */
        addPicking() {
            this.viewTaskId = ''
            this.isView = true
            this.isEdit = false
            this.pageContent = '新增领料任务'
            this.isShowComponent = 'AddPicking'
        },
        /* 查看领料任务 */
        viewPicking(taskId) {
            this.viewTaskId = taskId
            this.pageContent = '领料任务详情'
            this.isView = false
            this.isEdit = true
            this.isShowComponent = 'AddPicking'
        },
        /* 编辑和驳回提交 */
        editPicking(taskId, taskStatus) {
            this.viewTaskId = taskId
            this.rejectTaskStatus = taskStatus || null
            this.isView = true
            this.isEdit = true
            this.pageContent = '领料任务编辑'
            this.isShowComponent = 'AddPicking'
        },
        goBack() {
            this.isShowComponent = 'Home'
        },
    },
}
</script>
