<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"
        :param="param"
        :isView="isView"
        :codingTaskId="codingTaskId"
        @addTools="addTools" 
        @queryTools="queryTools"
        @isReset="isReset"
      />
    </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: "PartLease",
  components: {
    Home,
    PageHeaderApply,
    AddTools,
    QueryTools,
  },
  data() {
    return {
      isShowComponent: "Home",
      pageContent: "",
      isEdit: false,
      editTaskId: "",
      editId: "",
      queryId: "",
      queryTaskId: "",
      param: {},
      isView: false,
      codingTaskId: "",
    };
  },

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