<!-- -->
<template>
  <el-menu
    v-if="items.length > 0"
    class="sidebar-el-menu blueStyle"
    default-active=""
    @open="handleOpen"
    @close="handleClose"
    :default-openeds="[items[0].euId]"
  >
    <!-- 遍历菜单 -->
    <template v-for="item in items">
      <!-- 含有子菜单 -->
      <template v-if="item.children">
        <!-- 第一层 含有子菜单菜单 -->
        <el-submenu :index="item.euId" :key="item.title">
          <template slot="title">
            <div slot="title" @click="handleClick(item)">{{ item.title }}</div>
          </template>
          <menu-list
            :items="item.children"
            v-bind="$attrs"
            v-on="$listeners"
          ></menu-list
          ><!--递归调用-->
        </el-submenu>
      </template>

      <!-- 第一层 不含子菜单  -->
      <template v-else>
        <el-menu-item :index="item.euId" :key="item.title">
          <div slot="title" @click="handleClick(item)">{{ item.title }}</div>
        </el-menu-item>
      </template>
    </template>
  </el-menu>
</template>

<script>
export default {
  name: "MenuList",
  props: {
    items: Array,
    isCollapse: Boolean,
  },
  inheritAttrs: false,
  methods: {
    handleOpen(key, keyPath) {},
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
    },
    handleClick(item) {
      // console.log(item.title);
      this.$emit("open", item);
    },
  },
};
</script>

<style lang="scss" scoped>
.el-menu {
  border-right: none;
}
.el-menu-item {
  background-color: #f5f5f9;
  font-size: 16px;
  // color: #2069c4;
  &:hover {
    background-color: #2069c4;
    color: #fff;
  }
}

.el-menu-item.is-active {
  color: #2069c4;
  font-weight: bold;
}
.blueStyle {
  background-image: url("@/assets/imgs/display/normal/bg.png");
  background-size: 1%;
  ::v-deep .el-menu-item {
    transition: all 0.5s ease;
    background: transparent;
    padding: 0 60px !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    &:hover {
      background: rgba($color: #fff, $alpha: 0.6);
      color: #2069c4;
      font-weight: bold;
    }
  }
}
</style>
