<template>
  <div id="maintain">
    <div class="sidebar2">
      <div class="box">
        <SidebarTitle2 title="智慧运维" />
        <div class="btn-box">
          <p
            @click="changeBtnIndex(0)"
            :class="{ sidebarActive: sidebarIndex === 0 }"
          >
            日常巡检
          </p>
          <p
            @click="changeBtnIndex(1)"
            :class="{ sidebarActive: sidebarIndex === 1 }"
          >
            虚拟巡检
          </p>
          <p
            @click="changeBtnIndex(2)"
            :class="{ sidebarActive: sidebarIndex === 2 }"
          >
            设备管理
          </p>
          <p
            @click="changeBtnIndex(3)"
            :class="{ sidebarActive: sidebarIndex === 3 }"
          >
            任务文件管理
          </p>
        </div>
      </div>
    </div>

    <!-- 右侧内容 -->
    <div class="main">
      <router-view />
    </div>
  </div>
</template>

<script>
export default {
  name: 'maintain',
  data () {
    return {
      sidebarIndex: 0,
      sideArr: ['/maintain', '/maintain/xnxj', '/maintain/sbgl', '/maintain/file']
    }
  },
  mounted () {
    this.changeBtnIndex(0)
  },
  methods: {
    changeBtnIndex (num) {
      this.sidebarIndex = num
      this.$router.replace(this.sideArr[num])
    }
  }
}
</script>

<style lang="scss" scoped>
#maintain {
  display: flex;
  position: relative;
  width: 1920px;
  height: 966px;

  .sidebar2 {
    position: relative;
    width: 220px;
    height: 100%;
    padding: 20px 0 0 10px;
    background-color: #12386d;
    .box {
      .btn-box {
        width: 100%;
        margin-top: 3px;
        p {
          display: flex;
          align-items: center;
          width: 190px;
          height: 50px;
          margin-left: 20px;
          padding-left: 18px;
          border-width: 0 0 1px 0;
          border-color: #2d5c9e;
          border-style: solid;
          background: transparent;
          color: #b1ccf1;
          font-size: 16px;
          cursor: pointer;
          &:hover {
            color: #ffb330;
          }
          &.sidebarActive {
            color: #ffb330 !important;
          }
        }
      }
    }
  }
  .main {
    flex: 1;
    height: 100%;
    padding: 0 10px 10px;
  }
}
</style>
