LeftToolBtn.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <li :draggable="btn.draggable"
  3. @click="clickBtn(btn)"
  4. @dragstart="dragstart($event, btn)"
  5. @dragend="dragend"
  6. :class="{active: btn.active}"
  7. >
  8. <i :class="['tools', btn.value+'-icon']"></i>
  9. <span>{{btn.name}}</span>
  10. </li>
  11. </template>
  12. <script>
  13. import {mapActions} from 'vuex'
  14. export default {
  15. props: {
  16. btn: {
  17. type: Object,
  18. require: true
  19. }
  20. },
  21. methods: {
  22. ...mapActions([
  23. 'toggle_isDragging'
  24. ]),
  25. clickBtn: function (type) {
  26. this.$emit('selectedBtn', type)
  27. },
  28. dragstart: function (event, item) {
  29. this.clickBtn(item)
  30. this.toggle_isDragging(true)
  31. event.dataTransfer.setData('item', JSON.stringify(item))
  32. },
  33. dragend: function (event) {
  34. // this.toggle_isDragging(false)
  35. this.$store.dispatch('toggle_isDragging', false)
  36. event.dataTransfer.clearData()
  37. }
  38. }
  39. }
  40. </script>
  41. <style scoped>
  42. li {
  43. list-style-type: none;
  44. height: 30px;
  45. line-height: 30px;
  46. margin-bottom: 2px;
  47. padding: 0 8px;
  48. border-radius: 4px;
  49. position: relative;
  50. border: 1px solid transparent;
  51. }
  52. li:hover {
  53. cursor: pointer;
  54. border: 1px solid #ACB9CB;
  55. }
  56. li.active {
  57. color: white;
  58. background-color: #ACB9CB;
  59. transition-property: background-color, color;
  60. transition-duration: .3s;
  61. transition-timing-function: ease-out;
  62. }
  63. i.tools {
  64. position: absolute;
  65. top: 8px;
  66. display: inline-block;
  67. width: 16px;
  68. height: 16px;
  69. overflow: hidden;
  70. }
  71. span {
  72. margin-left: 20px;
  73. }
  74. .select-icon {
  75. background: url('../assets/wf_tools.png');
  76. background-position: 0px 0px;
  77. }
  78. .addStartEnd-icon {
  79. background: url('../assets/wf_tools.png');
  80. background-position: 42px 0px;
  81. }
  82. .start-icon {
  83. background: url('../assets/wf_tools.png');
  84. background-position: 81px 0px;
  85. }
  86. .end-icon {
  87. background: url('../assets/wf_tools.png');
  88. background-position: 61px 0px;
  89. }
  90. .ordinary-icon {
  91. background: url('../assets/wf_tools.png');
  92. background-position: 0px 57px;
  93. }
  94. .block-icon {
  95. background: url('../assets/wf_tools.png');
  96. background-position: 80px 57px;
  97. }
  98. .subFlow-icon {
  99. background: url('../assets/wf_tools.png');
  100. background-position: 61px 57px;
  101. }
  102. .route-icon {
  103. background: url('../assets/wf_tools.png');
  104. background-position: 41px 57px;
  105. }
  106. .line-icon {
  107. background: url('../assets/wf_tools.png');
  108. background-position: 0 34px;
  109. }
  110. .polyline-icon {
  111. background: url('../assets/wf_tools.png');
  112. background-position: 81px 34px;
  113. }
  114. .loop-icon {
  115. background: url('../assets/wf_tools.png');
  116. background-position: 60px 34px;
  117. }
  118. </style>