<template>
  <!-- 配件新购管理 -->
  <div class="app-container">
    <PageHeader
      v-if="isShowComponent != 'Home'"
      :pageContent="pageContent"
      @goBack="goBack"
    />
    <component 
            :is="isShowComponent" 
            :isEdit="isEdit"
            :editTaskId="editTaskId"
            :editId="editId"
            :queryTaskId="queryTaskId"
            :queryId="queryId"
            :isView="isView"
            :codingTaskId="codingTaskId"
            @addTools="addTools"
            @editTools="editTools"
            @addToolsSuccess="addToolsSuccess"
            @queryTools="queryTools"
    />
  </div>
</template>
  
<script>
import PageHeader from "@/components/pageHeader";
import Home from "./component/home.vue"; // 主列表
import AddTools from './component/addTools.vue' // 新增配件新购 和 修改配件新购
import QueryTools from './component/queryTools.vue' // 查询配件新购 
export default {
  name: "PartArrived",
  components: {
    Home,
    PageHeader,
    AddTools,
    QueryTools
  },
  data() {
    return {
      isShowComponent: "Home",
      pageContent: "新增配件新购",
      isEdit: false,
      editTaskId: "",
      editId: "",
      queryId:"",
      queryTaskId: "",
      isView: false,
      codingTaskId: "",
    };
  },

  methods: {
      /* 新增配件新购 */
      addTools() {
          this.isEdit = false
          this.editTaskId = ''
          this.queryTaskId = ''
          this.pageContent = '新增配件新购'
          this.isShowComponent = 'AddTools'
      },
      /* 新增成功 */
      addToolsSuccess() {
          this.isShowComponent = 'Home'
      },
      /* 编辑配件新购 */
      editTools(taskId,id) {
            this.isEdit = true
            this.pageContent = '编辑配件新购'
            this.editTaskId = taskId
            this.editId = id
            this.isShowComponent = 'AddTools'
        },
      /* 查询配件新购 */
      queryTools(taskId,id) {
            this.isView = true
            this.pageContent = '详情信息'
            this.queryTaskId = taskId
            this.queryId = id
            this.isShowComponent = 'QueryTools'
        },
    /* 返回按钮 */
    goBack() {
      this.isShowComponent = "Home";
    },
  },
};
</script>