<template>
  <div id="engineering">
    <!-- 侧边栏 -->
    <!-- <div class="sidebar1">
      <SidebarTitle title="综合评判" />
      <div class="btn-box">
        <button
          @click="sidebarBtn(item, index)"
          v-for="(item, index) in $router.options.routes[2].children[1]
            .children"
          :key="index"
          :class="{ sidebarActive: sidebarIndex === index }"
        >
          {{ item.meta.pageName }}
        </button>
      </div>
    </div> -->

    <div class="sidebar2">
      <div class="box">
        <SidebarTitle2 title="综合评判" />
        <div class="btn-box">
          <!-- <a
            @click="changeBtnIndex(7)"
            :class="{ sidebarActive: sidebarIndex === 11 }"
            style="border-bottom: 0"
          >
            研判概述
          </a> -->
          <a
            @click="changeBtnIndex(0)"
            :class="{ sidebarActive: sidebarIndex === 0 }"
            style="border-bottom: 0"
          >
            综合评判
          </a>
        </div>
      </div>
      <div class="box">
        <SidebarTitle2 title="单参数评估" />
        <div class="btn-box">
          <a
            @click="changeBtnIndex(1)"
            :class="{ sidebarActive: sidebarIndex === 1 }"
          >
            水平位移
          </a>
          <a
            @click="changeBtnIndex(2)"
            :class="{ sidebarActive: sidebarIndex === 2 }"
          >
            垂直位移
          </a>
          <a
            @click="changeBtnIndex(3)"
            :class="{ sidebarActive: sidebarIndex === 3 }"
          >
            防渗墙应力应变
          </a>
          <a
            @click="changeBtnIndex(4)"
            :class="{ sidebarActive: sidebarIndex === 4 }"
          >
            坝体渗流
          </a>
          <a
            @click="changeBtnIndex(5)"
            :class="{ sidebarActive: sidebarIndex === 5 }"
            style="border-bottom: 0"
          >
            绕坝渗流
          </a>
        </div>
      </div>
      <div class="box">
        <SidebarTitle2 title="关联评估" />
        <div class="btn-box">
          <a
            @click="changeBtnIndex(6)"
            :class="{ sidebarActive: sidebarIndex === 6 }"
            style="border-bottom: 0"
          >
            关联周边环境
          </a>
        </div>
      </div>
      <div class="box">
        <SidebarTitle2 title="理论分析" />
        <div class="btn-box">
          <a
            @click="changeBtnIndex(7)"
            :class="{ sidebarActive: sidebarIndex === 7 }"
            style="border-bottom: 0"
          >
            理论分析反演
          </a>
        </div>
      </div>
      <div class="box">
        <SidebarTitle2 title="预警处置" />
        <div class="btn-box">
          <a
            @click="changeBtnIndex(8)"
            :class="{ sidebarActive: sidebarIndex === 8 }"
            style="border-bottom: 0"
          >
            预警处置
          </a>
        </div>
      </div>
    </div>

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

<script>
export default {
  name: 'Engineering',
  created () {
    const i = this.$router.options.routes[2].children[1].children.findIndex(item => item.path === this.$route.path)
    this.sidebarIndex = i
  },
  data () {
    return {
      sidebarIndex: 0,
      tg: 'btn1'
    }
  },
  methods: {
    changeBtnIndex (num) {
      this.sidebarIndex = num
      this.$router.push(this.$router.options.routes[2].children[1].children[num].path)
    },
    handleOpen (key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath)
    },
    sidebarBtn (item, index) {
      if (this.sidebarIndex === index) return
      this.sidebarIndex = index
      this.$router.replace(item.path)
    }
  }
}
</script>

<style lang="scss" scoped>
#engineering {
  display: flex;
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 966px;
  .sidebar1 {
    position: relative;
    padding-top: 70px;
    padding-left: 30px;
    width: 220px;
    height: 100%;
    background-color: #12386d;
    .btn-box {
      width: 100%;
      margin-top: 3px;
      button {
        display: flex;
        align-items: center;
        width: 100%;
        height: 50px;
        padding-left: 18px;
        border-width: 0 0 1px 0;
        border-color: #2d5c9e;
        border-style: solid;
        background: transparent;
        color: #b1ccf1;
        font-size: 16px;
        &:hover {
          color: #ffb330;
        }
      }
      .sidebarActive {
        color: #ffb330;
      }
    }
  }
  .sidebar2 {
    position: relative;
    width: 220px;
    height: 100%;
    padding: 20px 0 0 10px;
    background-color: #12386d;
    .box {
      .btn-box {
        width: 100%;
        margin-top: 3px;
        a {
          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;
          &:hover {
            color: #ffb330;
          }
          &.sidebarActive {
            color: #ffb330 !important;
          }
        }
      }
    }
  }
  .main {
    position: relative;
    width: 1700px;
    height: 100%;
    padding: 10px;
  }
}
</style>
