<template>
    <!-- 新购验收绑定 -->
    <div class="app-container">
        <PageHeader
            @goBack="goBack"
            :pageContent="pageContent"
            v-if="isShowComponent != 'Home'"
        />
        <keep-alive include="Home">
            <component
                :queryId="queryId"
                :is="isShowComponent"
                :isView="isView"
                :queryType="queryType"
                :queryTaskId="queryTaskId"
                @openBindTools="openBindTools"
            />
        </keep-alive>
    </div>
</template>

<script>
import Home from './component/home.vue' // 主列表
import PageHeader from '@/components/pageHeader'
import BindTools from './component/bindTools.vue' // 编码绑定 查看
export default {
    name: 'GoodsBind',
    components: {
        Home,
        BindTools,
        PageHeader,
    },
    data() {
        return {
            queryType: '', //           二级页面类型
            pageContent: '', //         二级页面标题
            queryTaskId: '', //         二级页面查询 taskId
            queryId: '', //              二级页面查询 id
            isShowComponent: 'Home',
            isView: false,
        }
    },

    methods: {
        // 打开二级页面
        openBindTools(taskId, id, type) {
            this.queryId = id
            this.queryType = type
            this.queryTaskId = taskId
            if (type === 1) {
                this.isView = true 
                this.pageContent = '查看'
                this.isShowComponent = 'BindTools'
            }
            if (type === 2) {
                this.isView = false 
                this.pageContent = '编码绑定'
                this.isShowComponent = 'BindTools'
            }
        },

        // 返回按钮
        goBack() {
            this.isShowComponent = 'Home'
        },
    },
}
</script>
