<template>
  <div>
    <el-menu
      style="border: 0"
      :key="index"
      background-color="#266999"
      text-color="rgba(255, 255, 255, 1)"
      active-text-color="#ffd04b"
      :collapse="isCollapse"
      :collapse-transition="false"
      router
      mode="vertical"
      :unique-opened="true"
      v-for="(menu, index) in menus"
    >
      <el-submenu :index="String(index)" v-if="menu.submenus != null">
        <template slot="title">
          <el-image :src="menu.url"></el-image>
          <span>{{ menu.name }}</span>
        </template>
        <el-menu-item
          v-for="submenu in menu.submenus"
          :index="submenu.path"
          :key="submenu.path"
        >
          <span style="margin-left: 40px">{{ submenu.name }}</span>
        </el-menu-item>
      </el-submenu>
      <el-menu-item
        v-if="menu.submenus == null"
        :key="menu.path"
        :index="menu.path"
      >
        <el-image :src="menu.url"></el-image>
        <span slot="title">
          {{ menu.name }}
        </span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  props: {
    isCollapse: Boolean,
  },
  data() {
    return {
      menus: [
        {
          url: require("@/assets/images/userManagement@3x.png"),
          name: "用户管理",
          submenus: [
            {
              name: "人员管理",
              path: "/home/user/person",
            },
            {
              name: "组织管理",
              path: "/home/user/group",
            },
          ],
        },
        {
          url: require("@/assets/images/roleManagement@3x.png"),
          name: "角色管理",
          path: "/home/role",
        },
        {
          url: require("@/assets/images/systemConfiguration@3x.png"),
          name: "系统配置",
          path: "/home/system",
          submenus: [
            {
              name: "策略配置",
              path: "/home/system/strategy",
            },
            {
              name: "消息配置",
              path: "/home/system/message",
            },
            {
              name: "信息配置",
              path: "/home/system/info",
            },
            {
              name: "指标配置",
              path: "/home/system/index",
            },
          ],
        },
        {
          url: require("@/assets/images/deviceManagement@3x.png"),
          name: "设备管理",
          path: "/home/device",
          submenus: [
            {
              name: "设备配置",
              path: "/home/device/config",
            },
            {
              name: "设备告警",
              path: "/home/device/warning",
            },
          ],
        },
        {
          url: require("@/assets/images/dataManagement@3x.png"),
          name: "数据管理",
          path: "/home/data",
          submenus: [
            {
              name: "报表配置",
              path: "/home/data/statement",
            },
            {
              name: "报告配置",
              path: "/home/data/report",
            },
            {
              name: "基础信息",
              path: "/home/data/basicInfo",
            },
          ],
        },
        {
          url: require("@/assets/images/serviceManagement@3x.png"),
          name: "服务管理",
          path: "/home/service",
        },
        {
          url: require("@/assets/images/securityManagement@3x.png"),
          name: "安全管理",
          path: "/home/security",
          submenus: [
            {
              name: "日志监控",
              path: "/home/security/logMonitor",
            },
            {
              name: "系统监控",
              path: "/home/security/systemMonitor",
            },
          ],
        },
      ],
    };
  },
};
</script>

<style lang="less" scoped>
/deep/.el-submenu__icon-arrow {
  display: none;
}

.el-image {
  position: relative;
  overflow: auto;
  float: left;
}

/deep/.el-image__inner {
  vertical-align: middle;
  width: 30px;
  height: 30px;
}

/deep/.el-menu-item-group__title {
  padding: 0;
}

.el-menu-item-group > .span {
  margin-left: 70px;
}

/deep/.el-menu--inline > {
  border: none;
  text-align: -webkit-right;
}

.el-menu-item {
  font-size: 18px;
  padding: 0 40px;
  cursor: pointer;
}

/deep/.el-submenu__title {
  font-size: 18px;
  padding: 0 40px;
}
</style>
