123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <template>
- <li :draggable="btn.draggable"
- @click="clickBtn(btn)"
- @dragstart="dragstart($event, btn)"
- @dragend="dragend"
- :class="{active: btn.active}"
- >
- <i :class="['tools', btn.value+'-icon']"></i>
- <span>{{btn.name}}</span>
- </li>
- </template>
- <script>
- import {mapActions} from 'vuex'
- export default {
- props: {
- btn: {
- type: Object,
- require: true
- }
- },
- methods: {
- ...mapActions([
- 'toggle_isDragging'
- ]),
- clickBtn: function (type) {
- this.$emit('selectedBtn', type)
- },
- dragstart: function (event, item) {
- this.clickBtn(item)
- this.toggle_isDragging(true)
- event.dataTransfer.setData('item', JSON.stringify(item))
- },
- dragend: function (event) {
- // this.toggle_isDragging(false)
- this.$store.dispatch('toggle_isDragging', false)
- event.dataTransfer.clearData()
- }
- }
- }
- </script>
- <style scoped>
- li {
- list-style-type: none;
- height: 30px;
- line-height: 30px;
- margin-bottom: 2px;
- padding: 0 8px;
- border-radius: 4px;
- position: relative;
- border: 1px solid transparent;
- }
- li:hover {
- cursor: pointer;
- border: 1px solid #ACB9CB;
- }
- li.active {
- color: white;
- background-color: #ACB9CB;
- transition-property: background-color, color;
- transition-duration: .3s;
- transition-timing-function: ease-out;
- }
- i.tools {
- position: absolute;
- top: 8px;
- display: inline-block;
- width: 16px;
- height: 16px;
- overflow: hidden;
- }
- span {
- margin-left: 20px;
- }
- .select-icon {
- background: url('../assets/wf_tools.png');
- background-position: 0px 0px;
- }
- .addStartEnd-icon {
- background: url('../assets/wf_tools.png');
- background-position: 42px 0px;
- }
- .start-icon {
- background: url('../assets/wf_tools.png');
- background-position: 81px 0px;
- }
- .end-icon {
- background: url('../assets/wf_tools.png');
- background-position: 61px 0px;
- }
- .ordinary-icon {
- background: url('../assets/wf_tools.png');
- background-position: 0px 57px;
- }
- .block-icon {
- background: url('../assets/wf_tools.png');
- background-position: 80px 57px;
- }
- .subFlow-icon {
- background: url('../assets/wf_tools.png');
- background-position: 61px 57px;
- }
- .route-icon {
- background: url('../assets/wf_tools.png');
- background-position: 41px 57px;
- }
- .line-icon {
- background: url('../assets/wf_tools.png');
- background-position: 0 34px;
- }
- .polyline-icon {
- background: url('../assets/wf_tools.png');
- background-position: 81px 34px;
- }
- .loop-icon {
- background: url('../assets/wf_tools.png');
- background-position: 60px 34px;
- }
- </style>
|