index.vue
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
<el-card>
<div class="row">
<div class="col-6">
<draggable class="list-group" tag="ul" v-model="routeList" v-bind="dragOptions" @start="dragStart" @end="dragEnd">
<transition-group type="transition" :name="!drag ? 'flip-list' : null">
<li class="list-group-item" v-for="item in routeList" :key="item.routePriority">
<i :class="item.fixed ? 'fa fa-anchor' : 'glyphicon glyphicon-pushpin'
" @click="item.fixed = !item.fixed" aria-hidden="true"></i>
{{ item.route }}
</li>
</transition-group>
</draggable>
</div>
</div>
</el-card>
</template>
<script>
import draggable from "vuedraggable";
export default {
name: "YlDraggable",
props: {
routeList: {
// 航线
type: Array,
default: () => [],
},
dragOptions: {
// 拖拽配置
type: Object,
default: () => {
return {
animation: 200,
group: "description",
disabled: false,
ghostClass: "ghost"
}
},
},
},
components: {
draggable
},
data() {
return {};
},
created() {},
methods: {
// 排序
sort() {
this.routeList = this.routeList.sort((a, b) => a.routePriority - b.routePriority);
},
// 开始拖拽
dragStart() {
},
// 结束拖拽
dragEnd() {
this.$emit("dragEnd", this.routeList);
},
},
};
</script>
<style lang="scss">
.el-card__body {
padding: 15px 10px 0px 10px !important;
}
.list-group {
min-height: 20px;
max-height: 150px;
overflow: auto;
margin-top: 0;
padding: 0;
&::-webkit-scrollbar {
width: 7px;
height: 7px;
}
&::-webkit-scrollbar-track {
background-color: #fff;
}
&::-webkit-scrollbar-thumb {
background-color: #ccc;
border-radius: 20px;
}
&::-webkit-scrollbar-thumb:hover {
background-color: #409eff;
}
&::-webkit-scrollbar-track-piece {
background: #F2F6FC;
}
}
.list-group-item {
cursor: move;
padding: 5px 0px;
}
.list-group-item i {
cursor: pointer;
}
</style>