<!--左侧工具栏 -- 图例列表-->
<template>
  <div class="lengend-list">
    <!-- 基础图例 -->
    <div class="base-item-list" v-if="chiceStatus==0">
      <Input
        class="baseItemInput"
        :width="188"
        iconType="search"
        v-model="baseItemVal"
        @pressEnter="pressEnter"
      />
      <div class="lengend-item" v-for="(item,index) in baseEditItems" :key="index">
        <span class="legend-title">{{item.title}}</span>
        <div class="legend-content" v-for="(itemList,i) in item.itemList" :key="i">
          <div class="title">{{itemList.title}}</div>
          <ul>
            <li
              :class="{ 'btn-active': choiceLegend== baseItem.id }"
              v-for="(baseItem,k) in itemList.itemList"
              :key="k"
              @click="drawItem(baseItem.id)"
              :title="baseItem.name"
            >
              <img class="icon" :src="baseItem.icon" />
              <span class="iconName">{{baseItem.name}}</span>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <!-- 设备类 -->
    <equipmentList v-if="chiceStatus==1"></equipmentList>
    <!-- 管线类 -->
    <pipeList v-if="chiceStatus==3"></pipeList>
  </div>
</template>
<script>
import { baseEditItems } from "./data";
import { mapMutations, mapState } from "vuex";
import pipeList from "./pipeList.vue";
import equipmentList from "./equipmentList.vue";
export default {
  components: { pipeList, equipmentList },
  props: ["chiceStatus"],
  data() {
    return {
      baseEditItems,
      baseItemVal: "", //基础组件搜索
      // choiceLegend: "" //选中绘制类型
    };
  },
  computed: {
    ...mapState(["choiceLegend"]),
  },
  methods: {
    ...mapMutations(["SETCHOICELEHEND"]),
    drawItem(item) {
      this.SETCHOICELEHEND(item);
    },
    pressEnter() {},
  },
};
</script>
<style scoped lang="less">
.lengend-list {
  width: 100%;
  .base-item-list {
    .baseItemInput {
      margin: 12px 0;
    }
    .lengend-item {
      width: 100%;
      .legend-title {
        display: block;
        font-size: 14px;
        height: 38px;
        line-height: 38px;
        margin-left: 10px;
        color: #8d9399;
        border-top: 1px solid #eee;
      }
      .legend-content {
        padding: 0 10 10px 10px;
        box-sizing: border-box;
        .title {
          margin-left: 10px;
          font-weight: bold;
          color: #1f2429;
          font-size: 14px;
          padding-top: 16px;
          padding-bottom: 16px;
        }
        ul {
          display: flex;
          flex-wrap: wrap;
          border-bottom: 1px solid #eee;
          li {
            font-size: 12px;
            width: 52px;
            height: 52px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            padding: 4px;
            box-sizing: border-box;
            margin: 0 10px 16px 10px;
            .icon {
              width: 28px;
              height: 28px;
              // background: red;
            }
            .iconName {
              width: 100%;
              display: flex;
              justify-content: center;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }
            cursor: pointer;
          }
          li:hover {
            background: #f5f6f7;
          }
          .btn-active {
            background: #e1f2ff !important;
          }
        }
      }
    }
  }
}
</style>