<template>
  <div class="spare-parts-box">
    <el-menu
      :default-active="activeName"
      mode="horizontal"
      @select="handleSelect"
    >
      <el-menu-item index="sparePartsStock">备件库存</el-menu-item>
      <el-menu-item index="sparePartsRecord">备件记录</el-menu-item>
    </el-menu>
    <section>
      <router-view />
    </section>
  </div>
</template>
<script>
export default {
  name: 'SpareParts',
  data() {
    return {
      activeName: ''
    }
  },
  mounted() {
    this.activeName = this.$route.name
  },
  methods: {
    handleSelect(name) {
      this.$router.push({ name: name })
    }
  },
  watch: {
    $route: {
      handler: function (val) {
        this.activeName = val.name
      }
    }
  }
}
</script>
<style lang="scss">
.spare-parts-box {
  .el-menu {
    background-color: #f2f4f9;
  }
  .el-menu.el-menu--horizontal {
    border-bottom: none;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 8px 8px;
    .el-menu-item {
      height: 48px;
      line-height: 48px;
      width: 49.4%;
      border-radius: 8px;
      background-color: #fff;
      font-size: 16px;
      color: rgba(22, 22, 22, 0.65);
      text-align: center;
    }
  }
  .el-tabs__active-bar {
    display: none;
  }
}
</style>
