index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="board-column">
  3. <div class="board-column-header">
  4. {{ headerText }}
  5. </div>
  6. <draggable
  7. :list="list"
  8. v-bind="$attrs"
  9. class="board-column-content"
  10. :set-data="setData"
  11. >
  12. <div v-for="element in list" :key="element.id" class="board-item">
  13. {{ element.name }} {{ element.id }}
  14. </div>
  15. </draggable>
  16. </div>
  17. </template>
  18. <script>
  19. import draggable from 'vuedraggable'
  20. export default {
  21. name: 'DragKanbanDemo',
  22. components: {
  23. draggable
  24. },
  25. props: {
  26. headerText: {
  27. type: String,
  28. default: 'Header'
  29. },
  30. options: {
  31. type: Object,
  32. default() {
  33. return {}
  34. }
  35. },
  36. list: {
  37. type: Array,
  38. default() {
  39. return []
  40. }
  41. }
  42. },
  43. methods: {
  44. setData(dataTransfer) {
  45. // to avoid Firefox bug
  46. // Detail see : https://github.com/RubaXa/Sortable/issues/1012
  47. dataTransfer.setData('Text', '')
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .board-column {
  54. min-width: 300px;
  55. min-height: 100px;
  56. height: auto;
  57. overflow: hidden;
  58. background: #f0f0f0;
  59. border-radius: 3px;
  60. .board-column-header {
  61. height: 50px;
  62. line-height: 50px;
  63. overflow: hidden;
  64. padding: 0 20px;
  65. text-align: center;
  66. background: #333;
  67. color: #fff;
  68. border-radius: 3px 3px 0 0;
  69. }
  70. .board-column-content {
  71. height: auto;
  72. overflow: hidden;
  73. border: 10px solid transparent;
  74. min-height: 60px;
  75. display: flex;
  76. justify-content: flex-start;
  77. flex-direction: column;
  78. align-items: center;
  79. .board-item {
  80. cursor: pointer;
  81. width: 100%;
  82. height: 64px;
  83. margin: 5px 0;
  84. background-color: #fff;
  85. text-align: left;
  86. line-height: 54px;
  87. padding: 5px 10px;
  88. box-sizing: border-box;
  89. box-shadow: 0px 1px 3px 0 rgba(0, 0, 0, 0.2);
  90. }
  91. }
  92. }
  93. </style>