<template>
  <div class="home-page">
    <div class="hp-top">
      <wait-task v-if="dataReady"></wait-task>
    </div>

    <div class="tab-box tab-guide">
      <h2 class="tab-box-title">业务引导</h2>
      <home-guide class="tab-box-body"></home-guide>
    </div>
  </div>
</template>

<script>
import { mapActions } from "vuex";
import WaitTask from "@/modules/exam/views/WaitTask.vue";
import HomeGuide from "./HomeGuide.vue";

export default {
  name: "home-page",
  components: {
    WaitTask,
    HomeGuide,
  },
  data() {
    return {
      dataReady: false,
    };
  },
  created() {
    this.initData();
  },
  methods: {
    ...mapActions("exam", ["updateWaitTaskCount"]),
    async initData() {
      this.updateWaitTypes();
      await this.updateWaitTaskCount();
      this.dataReady = true;
    },
    updateWaitTypes() {
      const filterFunc = {
        flow: () => {
          return (
            this.checkPrivilege("link", "edit", "TaskApplyManage") ||
            this.checkPrivilege("link", "notReviewEdit", "TaskReviewManage")
          );
        },
        stmms: () => {
          return this.checkPrivilege("link", "MarkParamSetting", "MarkSetting");
        },
        analysis: () => {
          return this.checkPrivilege("link", "window", "DataInitManage");
        },
        mark: () => {
          return this.checkPrivilege("link", "Marking", "MarkEntrance");
        },
      };
      const waitTypes = Object.keys(filterFunc).filter((k) => filterFunc[k]());
      this.$store.commit("exam/setWaitTypes", waitTypes);
    },
  },
};
</script>
