<template>
  <div class="nav-menu" :style="navMenuStyle">
    <el-row class="height-100">
      <el-col :span="5">
        <div class="header-panel font-14">
          <slot name="headline"></slot>
        </div>
      </el-col>
      <el-col :span="15">
        <el-menu
          class="el-menu-demo"
          mode="horizontal"
          :background-color="backgroundColor"
          text-color="#9EA6AE"
          active-text-color="#ffd04b"
          :style="menuStyle"
        >
          <template v-for="(item,idx) in dataList">
            <el-submenu
              v-if="item.children!=null  && item.children.length>0"
              :index="idx+1+''"
              :key="idx+1"
            >
              <div slot="title" :style="subMenuStyle">{{item.menuName}}</div>
              <el-menu-item
                v-for="(sub,sidx) of item.children"
                :key="sidx"
                :index="idx+1+sidx+1+''"
              >
                <span>{{sub.menuName}}</span>
              </el-menu-item>
            </el-submenu>
            <el-menu-item :style="menuStyle" v-else :index="idx+1+''" :key="idx+1+''">
              <span :class="['icon',item.icon]">
                <span class="path1"></span>
                <span class="path2"></span>
              </span>
              <span>{{item.menuName}}</span>
            </el-menu-item>
          </template>
        </el-menu>
      </el-col>
      <el-col :span="4">
        <slot name="user"></slot>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "nav-menu",
  props: {
    width: {
      default: "100%"
    },
    height: {
      default: "50px"
    },
    backgroundColor: {
      default: "#313445 "
    },
    dataList: {
      type: Array
    },
    activeStyle: {},
    barStyle: {}
  },
  computed: {
    navMenuStyle() {
      return {
        width: this.width,
        height: this.height,
        lineHeight: this.height,
        backgroundColor: this.backgroundColor
      };
    },
    menuStyle() {
      return {
        border: "none",
        height: this.height,
        lineHeight: this.height
      };
    },
    subMenuStyle() {
      return {
        height: this.height,
        lineHeight: this.height,
        display: "inline-block"
      };
    }
  },
  data() {
    return {
      orgActiveStyle: {},
      orgStyle: {},
      defaultActiveStyle: {
        color: "#000"
      },
      defaultStyle: {
        color: "#f5f5f5"
      }
    };
  },
  mounted() {
    this.initData();
  },
  methods: {
    initData() {
      this.orgActiveStyle = { ...this.defaultActiveStyle, ...this.activeStyle };
      this.orgStyle = { ...this.defaultStyle, ...this.barStyle };
      //console.log(this.orgStyle, "this.orgStyle====");
    }
  }
};
</script>
<style lang='scss'>
.nav-menu {
  .el-menu--horizontal > .el-menu-item,
  .el-submenu,
  .el-menu--horizontal > .el-submenu .el-submenu__title {
    height: 100% !important;
    min-width: 158px;
    text-align: center;
    line-height: 0;
  }
  .el-menu.el-menu--horizontal {
    border: none !important;
  }
  .el-menu--horizontal .el-menu .el-menu-item.is-active,
  .el-menu--horizontal el-submenu :hover,
  .el-menu--horizontal .el-menu-item:hover {
    color: #6abfff !important;
  }
  .el-menu--horizontal > .el-submenu.is-active .el-submenu__title,
  .el-menu--horizontal > .el-menu-item.is-active {
    border: none;
    z-index: 1000;
    height: 64px !important;
    color: white !important;
    text-align: center;
    background-size: 100% 100%;
    width: 157px;
    background: url(../../asset/images/menu-item.png) no-repeat !important;
  }
}
</style>
<style scoped lang='scss'>
.nav-menu {
}
</style>