<template>
  <div class="wrap">
    <div class="chunk">
      <div class="title">
        <i class="el-icon-monitor"></i>
        <div class="text">首页组件模块</div>
      </div>
      <div class="content">
        <div
          class="item"
          v-for="(item, index) in dropElement"
          :key="index"
          draggable="true"
          @dragstart="dragstart($event, item)"
        >
          <i :class="item.icon"></i>
          {{ item.name }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  props: {
    dropElement: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  computed: {
    ...mapGetters(["elementList"]),
  },
  methods: {
    dragstart(e, item) {
      e.dataTransfer.setData("drop_element", JSON.stringify(item));
    },
  },
};
</script>

<style scoped lang='scss'>
.wrap {
  width: 100%;
  height: 100%;
  background-color: #fff;
  padding: 5px;
  > .chunk {
    > .title {
      display: flex;
      align-content: center;
      font-size: 14px;
      > .text {
        margin-left: 10px;
      }
    }
    > .content {
      display: flex;
      margin-top: 10px;
      align-items: center;
      flex-wrap: wrap;
      > .item {
        cursor: pointer;
        margin-top: 5px;
        width: 45%;
        font-size: 12px;
        margin-right: 5%;
        padding: 15px 10px;
        background-color: #f6f7fe;
      }
    }
  }
}
</style>
