<template>
  <!-- 新购验收绑定 -->
  <div class="app-container">
    <PageHeader
      v-if="isShowComponent != 'Home'"
      :pageContent="pageContent"
      @goBack="goBack"
    />
    <component 
            :is="isShowComponent" 
            :isEdit="isEdit"
            :editTaskId="editTaskId"
            :queryTaskId="queryTaskId"
            :isView="isView"
            :codingTaskId="codingTaskId"
            @bindTools="bindTools"
            @bindQrTools="bindQrTools"
            @addToolsSuccess="addToolsSuccess"
    />
  </div>
</template>
  
<script>
import PageHeader from "@/components/pageHeader";
import Home from "./component/home.vue"; // 主列表
import BindTools from './component/bindTools.vue' // 编码绑定
import BindQrTools from './component/bindQrTools.vue' // 二维码绑定
export default {
  components: {
    Home,
    PageHeader,
    BindTools,
    BindQrTools,
  },
  data() {
    return {
      isShowComponent: "Home",
      pageContent: "新增机具",
      isEdit: false,
      editTaskId: "",
      queryTaskId: "",
      isView: false,
      codingTaskId: "",
    };
  },

  methods: {
      /* 编码绑定 */
      bindTools(taskId) {
          this.editTaskId = taskId
          this.queryTaskId = ''
          this.pageContent = '编码绑定'
          this.isShowComponent = 'BindTools'
      },
      /* 新增成功 */
      addToolsSuccess() {
          this.isShowComponent = 'Home'
      },
      /* 二维码绑定 */
      bindQrTools(taskId) {
            this.pageContent = '二维码绑定'
            this.editTaskId = taskId
            this.isShowComponent = 'BindQrTools'
        },
      /* 编辑工机具 */
      editTools(id) {
            this.isEdit = true
            this.pageContent = '编辑机具'
            this.editTaskId = id
            this.isShowComponent = 'BindTools'
        },

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