<template>
  <!-- 业务中心 -->
  <div class="business whiteBlock">
    <div class="business">
      <el-menu
        :default-active="activeIndex"
        @select="handleSelect"
        class="business-menu-demo"
        mode="horizontal"
        text-color="#262D47"
        active-text-color="#5181F6"
      >
        <el-menu-item
          v-permission="{
            key: 'inspectionLedger_rectificationRecord',
            menuPath: '/project/safeSame/inspectionLedger',
          }"
          index="1"
          >全部整改记录</el-menu-item
        >
        <el-menu-item
          v-permission="{
            key: 'inspectionLedger_myToDoList',
            menuPath: '/project/safeSame/inspectionLedger',
          }"
          index="2"
          >我的待办</el-menu-item
        >
        <el-menu-item
          v-permission="{
            key: 'inspectionLedger_pendingReview',
            menuPath: '/project/safeSame/inspectionLedger',
          }"
          index="3"
          >延期待审</el-menu-item
        >
        <el-menu-item
          v-permission="{
            key: 'inspectionLedger_myHiddenTrouble',
            menuPath: '/project/safeSame/inspectionLedger',
          }"
          index="4"
          >我的隐患上报记录</el-menu-item
        >
        <el-menu-item
          v-permission="{
            key: 'inspectionLedger_hazardousWorkDistribution',
            menuPath: '/project/safeSame/inspectionLedger',
          }"
          index="5"
          >隐患工单派发</el-menu-item
        >
        <el-menu-item
          v-permission="{
            key: 'inspectionLedger_hiddenDangerAnalysis',
            menuPath: '/project/safeSame/inspectionLedger',
          }"
          index="6"
          >隐患治理数据分析</el-menu-item
        >
      </el-menu>

      <!-- <InspectionLedger
        v-if="activeIndex == '1'"
        style="width: 100%; height: calc(100% - 49px)"
      ></InspectionLedger> -->
      <RectificationRecord
        v-if="activeIndex == '1'"
        style="width: 100%; height: calc(100% - 49px)"
      ></RectificationRecord>
      <MyToDoList
        v-if="activeIndex == '2'"
        style="width: 100%; height: calc(100% - 49px)"
      ></MyToDoList>
      <PendingReview
        v-if="activeIndex == '3'"
        style="width: 100%; height: calc(100% - 49px)"
      ></PendingReview>
      <MyHiddenTroubleList
        v-if="activeIndex == '4'"
        style="width: 100%; height: calc(100% - 49px)"
      ></MyHiddenTroubleList>
      <HazardousWorkDistribution
        v-if="activeIndex == '5'"
        style="width: 100%; height: calc(100% - 49px)"
      ></HazardousWorkDistribution>
      <HiddenDangerAnalysis
        v-if="activeIndex == '6'"
        style="width: 100%; height: calc(100% - 49px)"
      ></HiddenDangerAnalysis>
    </div>
  </div>
</template>
<script>
import InspectionLedger from "./inspectionLedger.vue";
import MyToDoList from "./hiddenDangerModule/myToDoList.vue";
import PendingReview from "./hiddenDangerModule/pendingReview.vue";
import RectificationRecord from "./rectificationRecord.vue";
import MyHiddenTroubleList from "@/views/projectFront/safeManage/v2/hiddenTroubleComponents/myHiddenTroubleList.vue";
import HazardousWorkDistribution from "@/views/projectFront/safeManage/v2/hiddenTroubleComponents/hazardousWorkDistribution.vue";
import HiddenDangerAnalysis from "@/views/projectFront/safeManage/v2/hiddenTroubleComponents/hiddenDangerAnalysis.vue";
export default {
  name: "business",
  components: {
    InspectionLedger,
    MyToDoList,
    PendingReview,
    RectificationRecord,
    MyHiddenTroubleList,
    HazardousWorkDistribution,
    HiddenDangerAnalysis,
  },
  data() {
    return {
      activeIndex: "1",
    };
  },
  created() {
    const find = this.$store.state.menuList.find(item => item.path == "/project/safeSame/inspectionLedger");
    if(find) {
      const findAction = ['inspectionLedger_rectificationRecord', 'inspectionLedger_myToDoList', 'inspectionLedger_pendingReview', 'inspectionLedger_myHiddenTrouble', 'inspectionLedger_hazardousWorkDistribution', 'inspectionLedger_hiddenDangerAnalysis'];
      const findIndex = findAction.findIndex(item => find.actionList.some(i => i.actionCode == item));
      this.activeIndex = `${findIndex + 1}`;
      console.log(447788, find.actionList, findIndex)
    }
  },
  methods: {
    handleSelect(key, keyPath) {
      // console.log(key, keyPath);
      this.activeIndex = key;
    },
  },
};
</script>
<style lang="less" scoped>
.business {
  width: 100%;
  height: 100%;
}
.business-menu-demo {
  height: 49px;
  width: 100%;
  line-height: 49px;
  background-color: transparent;
  .el-menu-item {
    height: 49px;
    line-height: 49px;
  }
}
.el-menu.el-menu--horizontal {
  border-bottom-color: @borderColor;
}
</style>
