|
|
@@ -45,6 +45,7 @@
|
|
45
|
45
|
|
|
46
|
46
|
<script>
|
|
47
|
47
|
import { getToken } from "@/utils/auth"
|
|
|
48
|
+import Sortable from 'sortablejs'
|
|
48
|
49
|
|
|
49
|
50
|
export default {
|
|
50
|
51
|
props: {
|
|
|
@@ -61,22 +62,27 @@ export default {
|
|
61
|
62
|
// 图片数量限制
|
|
62
|
63
|
limit: {
|
|
63
|
64
|
type: Number,
|
|
64
|
|
- default: 5,
|
|
|
65
|
+ default: 5
|
|
65
|
66
|
},
|
|
66
|
67
|
// 大小限制(MB)
|
|
67
|
68
|
fileSize: {
|
|
68
|
69
|
type: Number,
|
|
69
|
|
- default: 5,
|
|
|
70
|
+ default: 5
|
|
70
|
71
|
},
|
|
71
|
72
|
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
|
72
|
73
|
fileType: {
|
|
73
|
74
|
type: Array,
|
|
74
|
|
- default: () => ["png", "jpg", "jpeg"],
|
|
|
75
|
+ default: () => ["png", "jpg", "jpeg"]
|
|
75
|
76
|
},
|
|
76
|
77
|
// 是否显示提示
|
|
77
|
78
|
isShowTip: {
|
|
78
|
79
|
type: Boolean,
|
|
79
|
80
|
default: true
|
|
|
81
|
+ },
|
|
|
82
|
+ // 拖动排序
|
|
|
83
|
+ drag: {
|
|
|
84
|
+ type: Boolean,
|
|
|
85
|
+ default: true
|
|
80
|
86
|
}
|
|
81
|
87
|
},
|
|
82
|
88
|
data() {
|
|
|
@@ -93,6 +99,20 @@ export default {
|
|
93
|
99
|
fileList: []
|
|
94
|
100
|
}
|
|
95
|
101
|
},
|
|
|
102
|
+ mounted() {
|
|
|
103
|
+ if (this.drag) {
|
|
|
104
|
+ this.$nextTick(() => {
|
|
|
105
|
+ const element = document.querySelector('.el-upload-list')
|
|
|
106
|
+ Sortable.create(element, {
|
|
|
107
|
+ onEnd: (evt) => {
|
|
|
108
|
+ const movedItem = this.fileList.splice(evt.oldIndex, 1)[0]
|
|
|
109
|
+ this.fileList.splice(evt.newIndex, 0, movedItem)
|
|
|
110
|
+ this.$emit("input", this.listToString(this.fileList))
|
|
|
111
|
+ }
|
|
|
112
|
+ })
|
|
|
113
|
+ })
|
|
|
114
|
+ }
|
|
|
115
|
+ },
|
|
96
|
116
|
watch: {
|
|
97
|
117
|
value: {
|
|
98
|
118
|
handler(val) {
|