<template>
  <!-- 修试审核 -->
  <div class="app-container">
    <PageHeaderApply
      v-if="isShowComponent != 'Home'"
      :pageContent="pageContent"
      @goBack="goBack"
    />
    <keep-alive include="Home">
      <component
        ref="componentRef"
        :is="isShowComponent"
        :isEdit="isEdit"
        :editTaskId="editTaskId"
        :editId="editId"
        :queryTaskId="queryTaskId"
        :queryId="queryId"
        :agreementId="agreementId"
        :param="param"
        :isView="isView"
        :codingTaskId="codingTaskId"
        @addTools="addTools" 
        @queryTools="queryTools"
        @reset="reset"
      />
    </keep-alive>
  </div>
</template>

<script>
import PageHeaderApply from "@/components/pageHeaderApply";
import Home from "./component/homeApply.vue"; // 主列表
import AddTools from "./component/addToolsApply.vue"; // 新增机具 和 修改机具
import QueryTools from "./component/queryToolsApply.vue"; // 查询机具 和 验收机具
export default {
  name: "ScrapManage",
  components: {
    Home,
    PageHeaderApply,
    AddTools,
    QueryTools,
  },
  data() {
    return {
      isShowComponent: "Home",
      pageContent: "报废审核",
      isEdit: false,
      editTaskId: "",
      editId: "",
      queryId: "",
      queryTaskId: "",
      agreementId: "",
      param: {},
      isView: false,
      codingTaskId: "",
    };
  },

  methods: { 
    addTools(taskId, id,row) {
      this.isEdit = true;
      this.pageContent = "报废审核";
      this.queryTaskId = taskId;
      this.queryId = id;
      this.agreementId = row.agreementId;
      this.param = row;
      this.isShowComponent = "AddTools";
    }, 
    queryTools(taskId, id, row) {
      this.isView = true;
      this.pageContent = "详情信息";
      this.queryTaskId = taskId;
      this.queryId = id;
      this.agreementId = row.agreementId;
      this.param = row;
      this.isShowComponent = "QueryTools";
    },
    /* 返回按钮 */
    goBack() {
      this.isShowComponent = "Home";
    },
    reset() {
      this.isShowComponent = "Home"
      this.$nextTick(() => {
        this.$refs.componentRef.resetQuery()
      })
    }
  },
};
</script>
