<!-- 左侧工具栏 -->
<template>
  <div class="left-tool-bar">
    <div class="btn-list">
      <ul>
        <li
          v-for="(item, index) in leftData"
          :key="index"
          :class="{ 'btn-active': chiceStatus == index }"
          @click="openTool(index)"
        >
          <!-- <img
            width="20px"
            height="20px"
            :src="chiceStatus == index ? item.activeIcon : item.icon"
            alt
          /> -->
          <span :class="['icon', 'iconfont', 'fontstyle', item.icon]"></span>
          <span>{{ item.name }}</span>
          <div class="btborder"></div>
        </li>
      </ul>
    </div>
    <el-drawer
      size="220px"
      :with-header="false"
      :destroy-on-close="true"
      :visible.sync="drawer"
      :direction="direction"
      :modal="false"
      :modal-append-to-body="false"
      :show-close="true"
      :before-close="handleClose"
      :wrapperClosable="false"
      custom-class="drawer-box"
    >
      <legendList :chiceStatus="chiceStatus"></legendList>
    </el-drawer>
  </div>
</template>
<script>
const leftData = [
  {
    id: "tongyong",
    name: "通用",
    icon: "icon-tongyong",
  },
  {
    id: "guanxian",
    name: "管线",
    icon: "icon-guanxian",
  },
  {
    id: "equipment",
    name: "设备",
    icon: "icon-shebei",
  },
  {
    id: "equipList",
    name: "设备组",
    icon: "icon-shebeizu",
  },
  {
    id: "space",
    name: "空间",
    icon: "icon-kongjian",
  },
  {
    id: "same",
    name: "楼层",
    icon: "icon-louceng",
  },
];
import legendList from "./leftToolBar/legendList.vue";
import { mapMutations } from "vuex";
export default {
  components: { legendList },
  data() {
    return {
      drawer: false,
      chiceStatus: -1, //选中按钮状态
      direction: "ltr",
      leftData,
    };
  },
  methods: {
    ...mapMutations(["SETCHOICELEHEND"]),
    handleClose() {
      this.drawer = false;
    },
    openTool(val) {
      if (val != this.chiceStatus) {
        this.chiceStatus = val;
        if (this.drawer) {
          this.drawer = false;
          4;
          setTimeout(() => {
            this.drawer = true;
          }, 300);
        } else {
          this.drawer = true;
        }
      } else {
        this.drawer = !this.drawer;
        this.chiceStatus = -1;
      }
    },
    choiceStatus() {
      this.chiceStatus = 0;
      this.drawer = false;
      this.SETCHOICELEHEND("");
    },
  },
};
</script>
<style lang="less" scoped>
ul,
li {
  margin: 0;
  padding: 0;
  list-style-type: none;
}
.left-tool-bar {
  height: calc(~"100% - 2px");
  position: relative;
  .btn-list {
    height: 100%;
    z-index: 99;
    position: relative;
    ul {
      width: 54px;
      height: 100%;
      border-top: 1px solid #eee;
      border-right: 1px solid #eee;
      li {
        width: 100%;
        height: 58px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        cursor: pointer;
        border-right: 2px solid rgba(0, 145, 255, 0);
        .btborder {
          width: 30px;
          height: 1px;
          background: #eee;
        }
        span {
          color: #8d9399;
          font-size: 12px;
        }
        .fontstyle {
          font-size: 18px;
        }
      }
      li:hover {
        background: #f5f6f7;
      }
      .btn-active {
        background: #e1f2ff !important;
        border-right: 2px solid #0091ff;
        span {
          color: #0091ff;
        }
      }
    }
  }
}
.el-drawer__wrapper {
  left: 64px;
  top: 86px;
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.1);
  width: 221px;
  border-right: 1px solid #eee;
}
</style>