ManualSorting.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div
  3. class="ManualSorting"
  4. style="border: 1px solid #E8E8E8;border-radius: 3px;"
  5. >
  6. <draggable :list="sort" @change="listChange">
  7. <div
  8. v-for="(item,key) in sort"
  9. :key="key"
  10. class="flexBetween flexItemsC"
  11. style="width:100%;font-size:16px;height:30px;padding:3px 0px;border-top: 1px solid #E8E8E8;"
  12. >
  13. <div>
  14. <span class="marleft10 marright20">{{key+1}}</span>
  15. <span
  16. style="color:black;"
  17. >{{item.deptName}}</span>
  18. <span class="marleft20">{{item.tableName}}</span>
  19. </div>
  20. <div class="flexItemsC marright20">
  21. <i
  22. @click="shangshen(key)"
  23. class="el-icon-top"
  24. :style="{'font-size':'20px','color':key==0 ?'#aaa':'#0A8CD5', 'cursor': key!=0?'pointer':'default'}"
  25. ></i>
  26. <i
  27. @click="xiajiang(key)"
  28. class="el-icon-bottom marleft5"
  29. :style="{'font-size':'20px','color':key==sort.length-1?'#aaa':'#0A8CD5', 'cursor': key!=sort.length-1?'pointer':'default'}"
  30. ></i>
  31. </div>
  32. </div>
  33. </draggable>
  34. </div>
  35. </template>
  36. <script>
  37. import draggable from 'vuedraggable'
  38. export default {
  39. components: {
  40. draggable,
  41. },
  42. props: ['sort'],
  43. methods: {
  44. xiajiang (key) {
  45. if (key != this.sort.length - 1) {
  46. let da = this.sort[key]
  47. this.sort[key] = this.sort[key + 1]
  48. this.sort[key + 1] = da
  49. this.$emit('bianhua')
  50. }
  51. console.log(this.sort);
  52. },
  53. shangshen (key) {
  54. if (key != 0) {
  55. let da = this.sort[key]
  56. this.sort[key] = this.sort[key - 1]
  57. this.sort[key - 1] = da
  58. this.$emit('bianhua')
  59. }
  60. },
  61. listChange(){
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .ManualSorting {
  68. width: 100%;
  69. height: 100%;
  70. }
  71. </style>