<template>
  <div class="navitem">
    <el-radio-group class="logo">
      <IconSvg :W="44" :H="44" name="item-logo" />
    </el-radio-group>
    <el-menu
      text-color="#fff"
      background-color="rgba(41, 109, 227, 1)"
      :default-active="ItemIndex"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      :collapse="isCollapse"
      @select="select"
      router
    >
      <el-menu-item index="/home">
        <div class="icons">
          <IconSvg
            :W="28"
            :H="26"
            :name="ItemIndex == '/home' ? 'home-active' : 'home'"
          />
        </div>
        <span slot="title">房态管理</span>
      </el-menu-item>
      <el-menu-item index="/order">
        <div class="icons">
          <IconSvg
            :W="21"
            :H="26"
            :name="ItemIndex == '/order' ? 'order-active' : 'order'"
          />
        </div>
        <span slot="title">订单管理</span>
      </el-menu-item>
      <el-menu-item index="/staff">
        <div class="icons">
          <IconSvg
            :W="26"
            :H="24"
            :name="ItemIndex == '/staff' ? 'staff-active' : 'staff'"
          />
        </div>
        <span slot="title">员工管理</span>
      </el-menu-item>
      <el-menu-item index="/account">
        <div class="icons">
          <IconSvg
            :W="26"
            :H="20"
            :name="ItemIndex == '/account' ? 'account-active' : 'account'"
          />
        </div>
        <span slot="title">账号管理</span>
      </el-menu-item>
      <el-menu-item index="/stat">
        <div class="icons">
          <IconSvg
            :W="22"
            :H="22"
            :name="ItemIndex == '/stat' ? 'stat-active' : 'stat'"
          />
        </div>
        <span slot="title">统计报表</span>
      </el-menu-item>
      <el-menu-item index="system">
        <div class="icons">
          <IconSvg
            :W="26"
            :H="25"
            :name="ItemIndex == '/system' ? 'system-active' : 'system'"
          />
        </div>
        <span slot="title">系统设置</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "NavbarItem",
  data() {
    return {
      isCollapse: false,
    };
  },
  mounted() {},
  computed: {
    ItemIndex: {
      get() {
        // console.log(this.$store.state.itemPath);
        return this.$store.state.itemPath;
      },
      set(val) {},
    },
  },
  methods: {
    select(index, indexPath) {
      this.ItemIndex = index;
      this.$store.commit("itemP", index);
    },

    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style scoped lang="scss">
.navitem {
  width: 260px;

  .logo {
    height: 96px;
    border-bottom: 1px solid rgba(255, 255, 255, 1);
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .el-menu {
    margin-top: 33px;

    .is-active {
      background-color: #fff !important;
      color: rgba(41, 109, 227, 1);
    }

    .el-menu-item {
      height: 52px;
      line-height: 0;
      margin-bottom: 13px;
      font-size: 18px;
      display: flex;
      align-items: center;
      border: 1px solid transparent;
      box-sizing: border-box;

      .icons {
        margin-left: 27px;
      }

      span {
        width: 87px;
        height: 26px;
        display: flex;
        align-items: center;
        padding-left: 16px;
      }
    }
  }
}
</style>