<template>
  <div class="board-column">
    <div class="board-column-header">
      {{ headerText }}
    </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 v-show="false">{{ element.id }} </span><span style="display: inline-block;width: 130px">{{ element.columnName }}</span>
        <el-input style="width: 100px" size="mini" type='number' v-model.trim="element.columnWidth" placeholder="宽度"></el-input>
      </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 []
      }
    }
  },
  methods: {
    setData(dataTransfer) {
      // console.log(dataTransfer);
      // console.log(this.options);
      // to avoid Firefox bug
      // Detail see : https://github.com/RubaXa/Sortable/issues/1012
      dataTransfer.setData('Text', '')
    }
  }
}
</script>
<style lang="scss" scoped>
.board-column {
  height: auto;
  overflow: hidden;
  border-radius: 3px;

  .board-column-header {
    height: 34px;
    line-height: 34px;
    overflow: hidden;
    padding: 0 20px;
    text-align: center;
    background: #66b1ff;
    color: #fff;
    border-radius: 3px 3px 0 0;
  }

  .board-column-content {
    height: 500px;
    overflow-y: auto;

    border: 10px solid transparent;
    display: flex;
    justify-content: flex-start;
    flex-direction: column;
    align-items: center;
    background-color: #EBEEF5;

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

