MenuList.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <v-list>
  3. <v-subheader>{{ title }}</v-subheader>
  4. <draggable v-model="draggableList" @sort="onSort">
  5. <transition-group type="transition" name="flip-list">
  6. <v-list-item
  7. v-for="link in draggableList"
  8. class="draggable-item"
  9. :key="link.id"
  10. @click=""
  11. >
  12. <v-list-item-icon>
  13. <v-icon>mdi-view-dashboard</v-icon>
  14. </v-list-item-icon>
  15. <v-list-item-content>
  16. <v-row>
  17. <v-col>
  18. <v-list-item-title>
  19. {{ link.title }}
  20. </v-list-item-title>
  21. <v-list-item-subtitle>
  22. {{ link.url }}
  23. </v-list-item-subtitle>
  24. </v-col>
  25. <v-col class="text-right">
  26. <v-btn small tile color="success" @click="$emit('openEdit', link)">
  27. <v-icon center> mdi-pencil</v-icon>
  28. </v-btn>
  29. <v-btn small tile color="error" @click="$emit('delete', link)">
  30. <v-icon center> mdi-delete-outline </v-icon>
  31. </v-btn>
  32. </v-col>
  33. </v-row>
  34. </v-list-item-content>
  35. </v-list-item>
  36. </transition-group>
  37. </draggable>
  38. </v-list>
  39. </template>
  40. <script>
  41. import draggable from "vuedraggable";
  42. export default {
  43. components: {
  44. draggable,
  45. },
  46. props: {
  47. list: {
  48. type: Array,
  49. required: true,
  50. },
  51. title: {
  52. type: String,
  53. required: true,
  54. },
  55. },
  56. data: () => ({
  57. draggableList: [],
  58. }),
  59. watch: {
  60. list: {
  61. handler() {
  62. this.draggableList = this.list.slice();
  63. },
  64. },
  65. },
  66. mounted() {
  67. this.draggableList = this.list.slice();
  68. },
  69. methods: {
  70. onSort() {
  71. this.$emit('drag', this.draggableList)
  72. },
  73. },
  74. };
  75. </script>
  76. <style lang="less" scoped>
  77. .draggable-item {
  78. cursor: move;
  79. }
  80. .flip-list-move {
  81. transition: transform 0.2s;
  82. }
  83. </style>