collapseItem.vue 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!--
  2. * @Description: 折叠组件
  3. * @Author: kcz
  4. * @Date: 2020-01-13 00:37:54
  5. * @LastEditors: kcz
  6. * @LastEditTime: 2020-03-28 11:32:39
  7. -->
  8. <template>
  9. <draggable
  10. tag="ul"
  11. :value="list"
  12. v-bind="{
  13. group: { name: 'form-draggable', pull: 'clone', put: false },
  14. sort: false,
  15. animation: 180,
  16. ghostClass: 'moving'
  17. }"
  18. @start="handleStart($event, list)"
  19. >
  20. <li
  21. v-for="(val, index) in list"
  22. :key="index"
  23. @dragstart="$emit('generateKey', list, index)"
  24. @click="$emit('handleListPush', val)"
  25. >
  26. <svg v-if="val.icon" class="icon" aria-hidden="true">
  27. <use :xlink:href="`#${val.icon}`"></use>
  28. </svg>
  29. {{ val.label }}
  30. </li>
  31. </draggable>
  32. </template>
  33. <script>
  34. import draggable from "vuedraggable";
  35. export default {
  36. name: "collapseItem",
  37. props: ["list"],
  38. components: {
  39. draggable
  40. },
  41. methods: {
  42. handleStart(e, list) {
  43. this.$emit("start", list[e.oldIndex].type);
  44. }
  45. }
  46. };
  47. </script>