<template>
    <!-- 新购配件验收 -->
    <div class="app-container">
        <PageHeader
            v-if="isShowComponent !== 'Home'"
            :pageContent="pageContent"
            @goBack="goBack"
        />
        <component
            :is="isShowComponent"
            :partsTaskId="partsTaskId"
            :isView="isView"
            :isEdit="isEdit"
            :isCheck="isCheck"
            :isDisabled="isDisabled"
            :isShow="isShow"
            @addParts="addParts"
            @queryParts="queryParts"
            @editParts="editParts"
            @acceptParts="acceptParts"
            @partsSaveSuccess="partsSaveSuccess"
        />
    </div>
</template>

<script>
import PageHeader from '@/components/pageHeader'
import Home from './component/home.vue' // 主列表
import AddParts from './component/addParts.vue' // 新增配件页面 查询 编辑 验收
export default {
    components: {
        Home,
        AddParts,
        PageHeader,
    },
    data() {
        return {
            isShowComponent: 'Home',
            pageContent: '新增配件',
            partsTaskId: undefined,
            isView: false,
            isEdit: false,
            isCheck: false,
            isDisabled: false,
            isShow: false,
        }
    },
    methods: {
        /* 新增配件 */
        addParts() {
            this.pageContent = '新增配件'
            this.isShowComponent = 'AddParts'
            this.partsTaskId = ''
            this.isView = false
            this.isDisabled = false
            this.isCheck = false
            this.isShow = true
        },
        /* 查询配件 */
        queryParts(taskId) {
            this.pageContent = '配件详情'
            this.partsTaskId = taskId
            this.isView = true
            this.isDisabled = true
            this.isCheck = false
            this.isShowComponent = 'AddParts'
        },
        /* 新增 修改保存成功 */
        partsSaveSuccess() {
            this.isShowComponent = 'Home'
        },
        /* 编辑配件 */
        editParts(taskId) {
            this.pageContent = '编辑配件'
            this.partsTaskId = taskId
            this.isView = true
            this.isEdit = true
            this.isCheck = false
            this.isShow = false
            this.isDisabled = false
            this.isShowComponent = 'AddParts'
        },
        /* 验收配件 */
        acceptParts(taskId) {
            this.pageContent = '配件验收'
            this.partsTaskId = taskId
            this.isView = true
            this.isDisabled = true
            this.isCheck = true
            this.isShow = false
            this.isShowComponent = 'AddParts'
        },
        /* 返回按钮 */
        goBack() {
            this.isShowComponent = 'Home'
        },
    },
}
</script>

<style>
</style>