<template>
  <div class="board-column">
    <div class="board-column-header clear">
      <div class="title fl">{{ headerText }}</div>
      <div class="seach fl">
        <el-input
          v-model="input"
          :size="'mini'"
          @input="blur"
          prefix-icon="el-icon-search"
          placeholder="搜索人名"
        ></el-input>
      </div>

      <div class="length fl">{{ list.length }}</div>
    </div>
    <draggable
      :list="list"
      v-bind="$attrs"
      class="board-column-content"
      :set-data="setData"
    >
      <div v-for="element in list" :key="element.id" class="board-item">
        <span class="fl">{{ element.name }}</span>
        <span class="fr">{{ element.id }}</span>
      </div>
    </draggable>
  </div>
</template>

<script>
import draggable from "vuedraggable";

export default {
  name: "DragKanbanDemo",
  components: {
    draggable,
  },
  props: {
    headerText: {
      type: String,
      default: "Header",
    },
    options: {
      type: Object,
      default() {
        return {};
      },
    },
    list: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      input: "",
    };
  },
  methods: {
    blur(){
      console.log(this.input);
    },
    setData(dataTransfer) {
      // to avoid Firefox bug
      // Detail see : https://github.com/RubaXa/Sortable/issues/1012
      dataTransfer.setData("Text", "");
    },
  },
};
</script>
<style lang="scss" scoped>
.board-column {
  min-width: 300px;
  min-height: 100px;
  height: auto;
  overflow: hidden;
  background: #f0f0f0;
  border-radius: 3px;

  .board-column-header {
    // height: 40px;
    line-height: 40px;
    overflow: hidden;
    padding: 0 20px;
    text-align: left;
    background: #333;
    color: #fff;
    border-radius: 3px 3px 0 0;
    .title {
      width: 100px;
    }
    .length {
      width: 80px;
      text-align: right;
    }
    .seach {
      width: calc(100% - 180px);
      /deep/.el-input__inner {
        border-radius: 20px !important;
      }
      /deep/ input::-webkit-input-placeholder {
        font-size: 13px !important;
      }
      /deep/ input::-moz-placeholder {
        /* Mozilla Firefox 19+ */
        font-size: 13px !important;
      }
      /deep/ input:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 */
        font-size: 13px !important;
      }
      /deep/ input:-ms-input-placeholder {
        /* Internet Explorer 10-11 */
        font-size: 13px !important;
      }
    }
  }

  .board-column-content {
    height: auto;
    overflow: hidden;
    border: 10px solid transparent;
    min-height: 60px;
    display: flex;
    justify-content: flex-start;
    flex-direction: column;
    align-items: center;

    .board-item {
      cursor: pointer;
      width: 100%;
      // height: 44px;
      margin: 5px 0;
      background-color: #fff;
      text-align: left;
      line-height: 36px;
      padding: 6px 17px;
      box-sizing: border-box;
      box-shadow: 0px 1px 3px 0 rgba(0, 0, 0, 0.2);
    }
  }
}
</style>

