vxe-pc-ui 3.3.36 → 3.3.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/icon/style.css +1 -1
- package/es/pulldown/src/pulldown.js +2 -0
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/dom.js +1 -0
- package/es/ui/src/log.js +1 -1
- package/es/upload/src/upload.js +288 -74
- package/es/upload/style.css +38 -2
- package/es/upload/style.min.css +1 -1
- package/es/vxe-upload/style.css +38 -2
- package/es/vxe-upload/style.min.css +1 -1
- package/helper/vetur/attributes.json +1 -1
- package/helper/vetur/tags.json +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +270 -52
- package/lib/index.umd.min.js +1 -1
- package/lib/pulldown/src/pulldown.js +6 -0
- package/lib/pulldown/src/pulldown.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/dom.js +2 -0
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/upload/src/upload.js +257 -47
- package/lib/upload/src/upload.min.js +1 -1
- package/lib/upload/style/style.css +38 -2
- package/lib/upload/style/style.min.css +1 -1
- package/lib/vxe-upload/style/style.css +38 -2
- package/lib/vxe-upload/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/pulldown/src/pulldown.ts +3 -1
- package/packages/ui/src/dom.ts +2 -0
- package/packages/upload/src/upload.ts +306 -75
- package/styles/components/upload.scss +34 -2
- package/types/components/pulldown.d.ts +9 -1
- package/types/components/table.d.ts +4 -0
- package/types/components/upload.d.ts +10 -2
- /package/es/icon/{iconfont.1734331066100.ttf → iconfont.1734402650511.ttf} +0 -0
- /package/es/icon/{iconfont.1734331066100.woff → iconfont.1734402650511.woff} +0 -0
- /package/es/icon/{iconfont.1734331066100.woff2 → iconfont.1734402650511.woff2} +0 -0
- /package/es/{iconfont.1734331066100.ttf → iconfont.1734402650511.ttf} +0 -0
- /package/es/{iconfont.1734331066100.woff → iconfont.1734402650511.woff} +0 -0
- /package/es/{iconfont.1734331066100.woff2 → iconfont.1734402650511.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1734331066100.ttf → iconfont.1734402650511.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1734331066100.woff → iconfont.1734402650511.woff} +0 -0
- /package/lib/icon/style/{iconfont.1734331066100.woff2 → iconfont.1734402650511.woff2} +0 -0
- /package/lib/{iconfont.1734331066100.ttf → iconfont.1734402650511.ttf} +0 -0
- /package/lib/{iconfont.1734331066100.woff → iconfont.1734402650511.woff} +0 -0
- /package/lib/{iconfont.1734331066100.woff2 → iconfont.1734402650511.woff2} +0 -0
|
@@ -3,12 +3,12 @@ import { defineVxeComponent } from '../../ui/src/comp'
|
|
|
3
3
|
import XEUtils from 'xe-utils'
|
|
4
4
|
import { VxeUI, getConfig, getI18n, getIcon, globalMixins, createEvent, globalEvents, renderEmptyElement } from '../../ui'
|
|
5
5
|
import { getSlotVNs } from '../..//ui/src/vn'
|
|
6
|
-
import { errLog } from '../../ui/src/log'
|
|
7
|
-
import { getEventTargetNode, toCssUnit } from '../../ui/src/dom'
|
|
6
|
+
import { errLog, warnLog } from '../../ui/src/log'
|
|
7
|
+
import { tpImg, getEventTargetNode, toCssUnit } from '../../ui/src/dom'
|
|
8
8
|
import { readLocalFile } from './util'
|
|
9
9
|
import VxeButtonComponent from '../../button/src/button'
|
|
10
10
|
|
|
11
|
-
import type { VxeUploadDefines, VxeUploadPropTypes, UploadReactData, UploadInternalData, VxeUploadEmits, VxeComponentSizeType, VxeFormDefines, VxeFormConstructor, VxeFormPrivateMethods, ValueOf } from '../../../types'
|
|
11
|
+
import type { VxeUploadDefines, VxeUploadConstructor, VxeUploadPropTypes, UploadReactData, UploadInternalData, VxeUploadEmits, VxeComponentSizeType, VxeFormDefines, VxeFormConstructor, VxeFormPrivateMethods, ValueOf } from '../../../types'
|
|
12
12
|
|
|
13
13
|
function getUniqueKey () {
|
|
14
14
|
return XEUtils.uniqueId()
|
|
@@ -25,6 +25,46 @@ function handleTransferFiles (items: DataTransferItemList) {
|
|
|
25
25
|
return files
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
function showDropTip ($xeUpload: VxeUploadConstructor, evnt: DragEvent, dragEl: HTMLElement, dragPos: string) {
|
|
29
|
+
const { xID } = $xeUpload
|
|
30
|
+
|
|
31
|
+
const reactData = $xeUpload.reactData
|
|
32
|
+
|
|
33
|
+
const { showMorePopup } = reactData
|
|
34
|
+
const el = $xeUpload.$refs.refElem as HTMLDivElement
|
|
35
|
+
const popupEl = document.getElementById(`refPopupElem${xID}`) as HTMLDivElement
|
|
36
|
+
const wrapperEl = showMorePopup ? popupEl : el
|
|
37
|
+
if (!wrapperEl) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
const wrapperRect = wrapperEl.getBoundingClientRect()
|
|
41
|
+
const ddLineEl = $xeUpload.$refs.refDragLineElem as HTMLDivElement
|
|
42
|
+
const mdLineEl = document.getElementById(`refModalDragLineElem${xID}`) as HTMLDivElement
|
|
43
|
+
const currDLineEl = showMorePopup ? mdLineEl : ddLineEl
|
|
44
|
+
if (currDLineEl) {
|
|
45
|
+
const dragRect = dragEl.getBoundingClientRect()
|
|
46
|
+
currDLineEl.style.display = 'block'
|
|
47
|
+
currDLineEl.style.top = `${Math.max(1, dragRect.y - wrapperRect.y)}px`
|
|
48
|
+
currDLineEl.style.left = `${Math.max(1, dragRect.x - wrapperRect.x)}px`
|
|
49
|
+
currDLineEl.style.height = `${dragRect.height}px`
|
|
50
|
+
currDLineEl.style.width = `${dragRect.width - 1}px`
|
|
51
|
+
currDLineEl.setAttribute('drag-pos', dragPos)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function hideDropTip ($xeUpload: VxeUploadConstructor) {
|
|
56
|
+
const { xID } = $xeUpload
|
|
57
|
+
|
|
58
|
+
const ddLineEl = $xeUpload.$refs.refDragLineElem as HTMLDivElement
|
|
59
|
+
const mdLineEl = document.getElementById(`refModalDragLineElem${xID}`) as HTMLDivElement
|
|
60
|
+
if (ddLineEl) {
|
|
61
|
+
ddLineEl.style.display = ''
|
|
62
|
+
}
|
|
63
|
+
if (mdLineEl) {
|
|
64
|
+
mdLineEl.style.display = ''
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
28
68
|
export default defineVxeComponent({
|
|
29
69
|
name: 'VxeUpload',
|
|
30
70
|
model: {
|
|
@@ -73,6 +113,7 @@ export default defineVxeComponent({
|
|
|
73
113
|
type: Array as PropType<VxeUploadPropTypes.FileTypes>,
|
|
74
114
|
default: () => XEUtils.clone(getConfig().upload.fileTypes, true)
|
|
75
115
|
},
|
|
116
|
+
dragSort: Boolean as PropType<VxeUploadPropTypes.DragSort>,
|
|
76
117
|
dragToUpload: {
|
|
77
118
|
type: Boolean as PropType<VxeUploadPropTypes.DragToUpload>,
|
|
78
119
|
default: () => XEUtils.clone(getConfig().upload.dragToUpload, true)
|
|
@@ -184,14 +225,19 @@ export default defineVxeComponent({
|
|
|
184
225
|
data () {
|
|
185
226
|
const xID = XEUtils.uniqueId()
|
|
186
227
|
const reactData: UploadReactData = {
|
|
187
|
-
|
|
228
|
+
isDragUploadStatus: false,
|
|
188
229
|
showMorePopup: false,
|
|
189
230
|
isActivated: false,
|
|
190
231
|
fileList: [],
|
|
191
|
-
fileCacheMaps: {}
|
|
232
|
+
fileCacheMaps: {},
|
|
233
|
+
isDragMove: false,
|
|
234
|
+
dragIndex: -1,
|
|
235
|
+
dragTipText: ''
|
|
192
236
|
}
|
|
193
237
|
const internalData: UploadInternalData = {
|
|
194
|
-
imagePreviewTypes: ['jpg', 'jpeg', 'png', 'gif']
|
|
238
|
+
imagePreviewTypes: ['jpg', 'jpeg', 'png', 'gif'],
|
|
239
|
+
prevDragIndex: -1
|
|
240
|
+
// prevDragPos: ''
|
|
195
241
|
}
|
|
196
242
|
return {
|
|
197
243
|
xID,
|
|
@@ -866,7 +912,7 @@ export default defineVxeComponent({
|
|
|
866
912
|
}
|
|
867
913
|
})
|
|
868
914
|
},
|
|
869
|
-
|
|
915
|
+
handleUploadDragleaveEvent (evnt: DragEvent) {
|
|
870
916
|
const $xeUpload = this
|
|
871
917
|
const reactData = $xeUpload.reactData
|
|
872
918
|
|
|
@@ -875,11 +921,11 @@ export default defineVxeComponent({
|
|
|
875
921
|
if (targetElem) {
|
|
876
922
|
const { x: targetX, y: targetY, height: targetHeight, width: targetWidth } = targetElem.getBoundingClientRect()
|
|
877
923
|
if (clientX < targetX || clientX > targetX + targetWidth || clientY < targetY || clientY > targetY + targetHeight) {
|
|
878
|
-
reactData.
|
|
924
|
+
reactData.isDragUploadStatus = false
|
|
879
925
|
}
|
|
880
926
|
}
|
|
881
927
|
},
|
|
882
|
-
|
|
928
|
+
handleUploadDragoverEvent (evnt: DragEvent) {
|
|
883
929
|
const $xeUpload = this
|
|
884
930
|
const reactData = $xeUpload.reactData
|
|
885
931
|
|
|
@@ -888,7 +934,7 @@ export default defineVxeComponent({
|
|
|
888
934
|
const { items } = dataTransfer
|
|
889
935
|
if (items && items.length) {
|
|
890
936
|
evnt.preventDefault()
|
|
891
|
-
reactData.
|
|
937
|
+
reactData.isDragUploadStatus = true
|
|
892
938
|
}
|
|
893
939
|
}
|
|
894
940
|
},
|
|
@@ -923,7 +969,7 @@ export default defineVxeComponent({
|
|
|
923
969
|
}
|
|
924
970
|
$xeUpload.uploadFile(files, evnt)
|
|
925
971
|
},
|
|
926
|
-
|
|
972
|
+
handleUploadDropEvent (evnt: DragEvent) {
|
|
927
973
|
const $xeUpload = this
|
|
928
974
|
const reactData = $xeUpload.reactData
|
|
929
975
|
|
|
@@ -938,13 +984,15 @@ export default defineVxeComponent({
|
|
|
938
984
|
}
|
|
939
985
|
}
|
|
940
986
|
}
|
|
941
|
-
reactData.
|
|
987
|
+
reactData.isDragUploadStatus = false
|
|
942
988
|
},
|
|
943
989
|
handleMoreEvent () {
|
|
944
990
|
const $xeUpload = this
|
|
945
991
|
const props = $xeUpload
|
|
946
992
|
const reactData = $xeUpload.reactData
|
|
947
993
|
|
|
994
|
+
const { xID } = $xeUpload
|
|
995
|
+
|
|
948
996
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
949
997
|
const isImage = $xeUpload.computeIsImage
|
|
950
998
|
|
|
@@ -959,40 +1007,71 @@ export default defineVxeComponent({
|
|
|
959
1007
|
maskClosable: true,
|
|
960
1008
|
slots: {
|
|
961
1009
|
default (params, h) {
|
|
962
|
-
const { showErrorStatus, dragToUpload } = props
|
|
963
|
-
const {
|
|
964
|
-
const isDisabled = $xeUpload.computeIsDisabled
|
|
1010
|
+
const { showErrorStatus, dragToUpload, dragSort } = props
|
|
1011
|
+
const { isDragMove, isDragUploadStatus, dragIndex } = reactData
|
|
965
1012
|
const { fileList } = reactData
|
|
1013
|
+
const isDisabled = $xeUpload.computeIsDisabled
|
|
966
1014
|
|
|
967
1015
|
const ons: Record<string, any> = {}
|
|
968
|
-
if (dragToUpload) {
|
|
969
|
-
ons.dragover = $xeUpload.
|
|
970
|
-
ons.dragleave = $xeUpload.
|
|
971
|
-
ons.drop = $xeUpload.
|
|
1016
|
+
if (dragToUpload && dragIndex === -1) {
|
|
1017
|
+
ons.dragover = $xeUpload.handleUploadDragoverEvent
|
|
1018
|
+
ons.dragleave = $xeUpload.handleUploadDragleaveEvent
|
|
1019
|
+
ons.drop = $xeUpload.handleUploadDropEvent
|
|
972
1020
|
}
|
|
973
1021
|
|
|
974
1022
|
return h('div', {
|
|
1023
|
+
attrs: {
|
|
1024
|
+
id: `refPopupElem${xID}`
|
|
1025
|
+
},
|
|
975
1026
|
class: ['vxe-upload--more-popup', {
|
|
976
1027
|
'is--readonly': formReadonly,
|
|
977
1028
|
'is--disabled': isDisabled,
|
|
978
1029
|
'show--error': showErrorStatus,
|
|
979
|
-
'is--drag':
|
|
1030
|
+
'is--drag': isDragUploadStatus
|
|
980
1031
|
}],
|
|
981
1032
|
on: ons
|
|
982
1033
|
}, [
|
|
983
1034
|
isImage
|
|
984
|
-
?
|
|
985
|
-
|
|
986
|
-
|
|
1035
|
+
? (
|
|
1036
|
+
dragSort
|
|
1037
|
+
? h('transition-group', {
|
|
1038
|
+
props: {
|
|
1039
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1040
|
+
tag: 'div'
|
|
1041
|
+
},
|
|
1042
|
+
class: 'vxe-upload--image-more-list'
|
|
1043
|
+
}, $xeUpload.renderImageItemList(h, fileList, true).concat($xeUpload.renderImageAction(h, true)))
|
|
1044
|
+
: h('div', {
|
|
1045
|
+
class: 'vxe-upload--image-more-list'
|
|
1046
|
+
}, $xeUpload.renderImageItemList(h, fileList, true).concat($xeUpload.renderImageAction(h, true)))
|
|
1047
|
+
)
|
|
987
1048
|
: h('div', {
|
|
988
1049
|
class: 'vxe-upload--file-more-list'
|
|
989
1050
|
}, [
|
|
990
1051
|
$xeUpload.renderFileAction(h, true),
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1052
|
+
(
|
|
1053
|
+
dragSort
|
|
1054
|
+
? h('transition-group', {
|
|
1055
|
+
props: {
|
|
1056
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1057
|
+
tag: 'div'
|
|
1058
|
+
},
|
|
1059
|
+
class: 'vxe-upload--file-list'
|
|
1060
|
+
}, $xeUpload.renderFileItemList(h, fileList, true))
|
|
1061
|
+
: h('div', {
|
|
1062
|
+
class: 'vxe-upload--file-list'
|
|
1063
|
+
}, $xeUpload.renderFileItemList(h, fileList, true))
|
|
1064
|
+
)
|
|
994
1065
|
]),
|
|
995
|
-
|
|
1066
|
+
dragSort
|
|
1067
|
+
? h('div', {
|
|
1068
|
+
attrs: {
|
|
1069
|
+
id: `refModalDragLineElem${xID}`
|
|
1070
|
+
},
|
|
1071
|
+
class: 'vxe-upload--drag-line'
|
|
1072
|
+
})
|
|
1073
|
+
: renderEmptyElement($xeUpload),
|
|
1074
|
+
isDragUploadStatus
|
|
996
1075
|
? h('div', {
|
|
997
1076
|
class: 'vxe-upload--drag-placeholder'
|
|
998
1077
|
}, getI18n('vxe.upload.dragPlaceholder'))
|
|
@@ -1000,15 +1079,98 @@ export default defineVxeComponent({
|
|
|
1000
1079
|
])
|
|
1001
1080
|
}
|
|
1002
1081
|
},
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1082
|
+
events: {
|
|
1083
|
+
show () {
|
|
1084
|
+
reactData.showMorePopup = true
|
|
1085
|
+
},
|
|
1086
|
+
hide () {
|
|
1087
|
+
reactData.showMorePopup = false
|
|
1088
|
+
}
|
|
1008
1089
|
}
|
|
1009
1090
|
})
|
|
1010
1091
|
}
|
|
1011
1092
|
},
|
|
1093
|
+
// 拖拽
|
|
1094
|
+
handleDragSortDragstartEvent (evnt: DragEvent) {
|
|
1095
|
+
const $xeUpload = this
|
|
1096
|
+
const reactData = $xeUpload.reactData
|
|
1097
|
+
|
|
1098
|
+
if (evnt.dataTransfer) {
|
|
1099
|
+
const img = new Image()
|
|
1100
|
+
img.src = tpImg
|
|
1101
|
+
evnt.dataTransfer.setDragImage(img, 0, 0)
|
|
1102
|
+
}
|
|
1103
|
+
const dragEl = evnt.currentTarget as HTMLElement
|
|
1104
|
+
const parentEl = dragEl.parentElement as HTMLDivElement
|
|
1105
|
+
const dragIndex = XEUtils.findIndexOf(Array.from(parentEl.children), item => dragEl === item)
|
|
1106
|
+
reactData.isDragMove = true
|
|
1107
|
+
reactData.dragIndex = dragIndex
|
|
1108
|
+
setTimeout(() => {
|
|
1109
|
+
reactData.isDragMove = false
|
|
1110
|
+
}, 500)
|
|
1111
|
+
},
|
|
1112
|
+
handleDragSortDragoverEvent (evnt: DragEvent) {
|
|
1113
|
+
const $xeUpload = this
|
|
1114
|
+
const reactData = $xeUpload.reactData
|
|
1115
|
+
const internalData = $xeUpload.internalData
|
|
1116
|
+
|
|
1117
|
+
evnt.preventDefault()
|
|
1118
|
+
|
|
1119
|
+
const { dragIndex } = reactData
|
|
1120
|
+
if (dragIndex === -1) {
|
|
1121
|
+
return
|
|
1122
|
+
}
|
|
1123
|
+
const isImage = $xeUpload.computeIsImage
|
|
1124
|
+
const dragEl = evnt.currentTarget as HTMLElement
|
|
1125
|
+
const parentEl = dragEl.parentElement as HTMLDivElement
|
|
1126
|
+
const currIndex = XEUtils.findIndexOf(Array.from(parentEl.children), item => dragEl === item)
|
|
1127
|
+
let dragPos: 'top' | 'bottom' | 'left' | 'right' | '' = ''
|
|
1128
|
+
if (isImage) {
|
|
1129
|
+
const offsetX = evnt.clientX - dragEl.getBoundingClientRect().x
|
|
1130
|
+
dragPos = offsetX < dragEl.clientWidth / 2 ? 'left' : 'right'
|
|
1131
|
+
} else {
|
|
1132
|
+
const offsetY = evnt.clientY - dragEl.getBoundingClientRect().y
|
|
1133
|
+
dragPos = offsetY < dragEl.clientHeight / 2 ? 'top' : 'bottom'
|
|
1134
|
+
}
|
|
1135
|
+
if (dragIndex === currIndex) {
|
|
1136
|
+
showDropTip($xeUpload, evnt, dragEl, dragPos)
|
|
1137
|
+
return
|
|
1138
|
+
}
|
|
1139
|
+
showDropTip($xeUpload, evnt, dragEl, dragPos)
|
|
1140
|
+
internalData.prevDragIndex = currIndex
|
|
1141
|
+
internalData.prevDragPos = dragPos
|
|
1142
|
+
},
|
|
1143
|
+
handleDragSortDragendEvent (evnt: DragEvent) {
|
|
1144
|
+
const $xeUpload = this
|
|
1145
|
+
const reactData = $xeUpload.reactData
|
|
1146
|
+
const internalData = $xeUpload.internalData
|
|
1147
|
+
|
|
1148
|
+
const { fileList, dragIndex } = reactData
|
|
1149
|
+
const { prevDragIndex, prevDragPos } = internalData
|
|
1150
|
+
const oldIndex = dragIndex
|
|
1151
|
+
const targetIndex = prevDragIndex
|
|
1152
|
+
const dragOffsetIndex = prevDragPos === 'bottom' || prevDragPos === 'right' ? 1 : 0
|
|
1153
|
+
const oldItem = fileList[oldIndex]
|
|
1154
|
+
const newItem = fileList[targetIndex]
|
|
1155
|
+
if (oldItem && newItem) {
|
|
1156
|
+
fileList.splice(oldIndex, 1)
|
|
1157
|
+
const ptfIndex = XEUtils.findIndexOf(fileList, item => newItem === item)
|
|
1158
|
+
const nIndex = ptfIndex + dragOffsetIndex
|
|
1159
|
+
fileList.splice(nIndex, 0, oldItem)
|
|
1160
|
+
$xeUpload.dispatchEvent('sort-dragend', {
|
|
1161
|
+
oldItem: oldItem,
|
|
1162
|
+
newItem: newItem,
|
|
1163
|
+
dragPos: prevDragPos as any,
|
|
1164
|
+
offsetIndex: dragOffsetIndex,
|
|
1165
|
+
_index: {
|
|
1166
|
+
newIndex: nIndex,
|
|
1167
|
+
oldIndex: oldIndex
|
|
1168
|
+
}
|
|
1169
|
+
}, evnt)
|
|
1170
|
+
}
|
|
1171
|
+
hideDropTip($xeUpload)
|
|
1172
|
+
reactData.dragIndex = -1
|
|
1173
|
+
},
|
|
1012
1174
|
handleGlobalPasteEvent (evnt: ClipboardEvent) {
|
|
1013
1175
|
const $xeUpload = this
|
|
1014
1176
|
const props = $xeUpload
|
|
@@ -1057,7 +1219,7 @@ export default defineVxeComponent({
|
|
|
1057
1219
|
const slots = $xeUpload.$scopedSlots
|
|
1058
1220
|
const reactData = $xeUpload.reactData
|
|
1059
1221
|
|
|
1060
|
-
const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus } = props
|
|
1222
|
+
const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus, dragSort } = props
|
|
1061
1223
|
const { fileCacheMaps } = reactData
|
|
1062
1224
|
const isDisabled = $xeUpload.computeIsDisabled
|
|
1063
1225
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
@@ -1065,18 +1227,30 @@ export default defineVxeComponent({
|
|
|
1065
1227
|
const typeProp = $xeUpload.computeTypeProp
|
|
1066
1228
|
const cornerSlot = slots.corner
|
|
1067
1229
|
|
|
1230
|
+
const ons: Record<string, any> = {}
|
|
1231
|
+
if (dragSort) {
|
|
1232
|
+
ons.dragstart = $xeUpload.handleDragSortDragstartEvent
|
|
1233
|
+
ons.dragover = $xeUpload.handleDragSortDragoverEvent
|
|
1234
|
+
ons.dragend = $xeUpload.handleDragSortDragendEvent
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1068
1237
|
return currList.map((item, index) => {
|
|
1069
1238
|
const fileKey = $xeUpload.getFieldKey(item)
|
|
1070
1239
|
const cacheItem = fileCacheMaps[fileKey]
|
|
1071
1240
|
const isLoading = cacheItem && cacheItem.loading
|
|
1072
1241
|
const isError = cacheItem && cacheItem.status === 'error'
|
|
1073
1242
|
return h('div', {
|
|
1074
|
-
key: index,
|
|
1243
|
+
key: dragSort ? fileKey : index,
|
|
1075
1244
|
class: ['vxe-upload--file-item', {
|
|
1076
1245
|
'is--preview': showPreview,
|
|
1077
1246
|
'is--loading': isLoading,
|
|
1078
1247
|
'is--error': isError
|
|
1079
|
-
}]
|
|
1248
|
+
}],
|
|
1249
|
+
attrs: {
|
|
1250
|
+
fileid: fileKey,
|
|
1251
|
+
draggable: dragSort ? true : null
|
|
1252
|
+
},
|
|
1253
|
+
on: ons
|
|
1080
1254
|
}, [
|
|
1081
1255
|
h('div', {
|
|
1082
1256
|
class: 'vxe-upload--file-item-icon'
|
|
@@ -1218,8 +1392,8 @@ export default defineVxeComponent({
|
|
|
1218
1392
|
const props = $xeUpload
|
|
1219
1393
|
const reactData = $xeUpload.reactData
|
|
1220
1394
|
|
|
1221
|
-
const { moreConfig } = props
|
|
1222
|
-
const { fileList } = reactData
|
|
1395
|
+
const { moreConfig, dragSort } = props
|
|
1396
|
+
const { fileList, isDragMove } = reactData
|
|
1223
1397
|
const moreOpts = $xeUpload.computeMoreOpts
|
|
1224
1398
|
|
|
1225
1399
|
const { maxCount, showMoreButton, layout } = moreOpts
|
|
@@ -1246,9 +1420,19 @@ export default defineVxeComponent({
|
|
|
1246
1420
|
}]
|
|
1247
1421
|
}, [
|
|
1248
1422
|
currList.length
|
|
1249
|
-
?
|
|
1250
|
-
|
|
1251
|
-
|
|
1423
|
+
? (
|
|
1424
|
+
dragSort
|
|
1425
|
+
? h('transition-group', {
|
|
1426
|
+
attrs: {
|
|
1427
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1428
|
+
tag: 'div'
|
|
1429
|
+
},
|
|
1430
|
+
class: 'vxe-upload--file-list'
|
|
1431
|
+
}, $xeUpload.renderFileItemList(h, currList, false))
|
|
1432
|
+
: h('div', {
|
|
1433
|
+
class: 'vxe-upload--file-list'
|
|
1434
|
+
}, $xeUpload.renderFileItemList(h, currList, false))
|
|
1435
|
+
)
|
|
1252
1436
|
: renderEmptyElement($xeUpload),
|
|
1253
1437
|
showMoreButton && overMaxNum
|
|
1254
1438
|
? h('div', {
|
|
@@ -1279,7 +1463,7 @@ export default defineVxeComponent({
|
|
|
1279
1463
|
const slots = $xeUpload.$scopedSlots
|
|
1280
1464
|
const reactData = $xeUpload.reactData
|
|
1281
1465
|
|
|
1282
|
-
const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus } = props
|
|
1466
|
+
const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus, dragSort } = props
|
|
1283
1467
|
const { fileCacheMaps } = reactData
|
|
1284
1468
|
const isDisabled = $xeUpload.computeIsDisabled
|
|
1285
1469
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
@@ -1287,19 +1471,31 @@ export default defineVxeComponent({
|
|
|
1287
1471
|
const imgStyle = $xeUpload.computeImgStyle
|
|
1288
1472
|
const cornerSlot = slots.corner
|
|
1289
1473
|
|
|
1474
|
+
const ons: Record<string, any> = {}
|
|
1475
|
+
if (dragSort) {
|
|
1476
|
+
ons.dragstart = $xeUpload.handleDragSortDragstartEvent
|
|
1477
|
+
ons.dragover = $xeUpload.handleDragSortDragoverEvent
|
|
1478
|
+
ons.dragend = $xeUpload.handleDragSortDragendEvent
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1290
1481
|
return currList.map((item, index) => {
|
|
1291
1482
|
const fileKey = $xeUpload.getFieldKey(item)
|
|
1292
1483
|
const cacheItem = fileCacheMaps[fileKey]
|
|
1293
1484
|
const isLoading = cacheItem && cacheItem.loading
|
|
1294
1485
|
const isError = cacheItem && cacheItem.status === 'error'
|
|
1295
1486
|
return h('div', {
|
|
1296
|
-
key: index,
|
|
1487
|
+
key: dragSort ? fileKey : index,
|
|
1297
1488
|
class: ['vxe-upload--image-item', {
|
|
1298
1489
|
'is--preview': showPreview,
|
|
1299
1490
|
'is--circle': imageOpts.circle,
|
|
1300
1491
|
'is--loading': isLoading,
|
|
1301
1492
|
'is--error': isError
|
|
1302
|
-
}]
|
|
1493
|
+
}],
|
|
1494
|
+
attrs: {
|
|
1495
|
+
fileid: fileKey,
|
|
1496
|
+
draggable: dragSort ? true : null
|
|
1497
|
+
},
|
|
1498
|
+
on: ons
|
|
1303
1499
|
}, [
|
|
1304
1500
|
h('div', {
|
|
1305
1501
|
class: 'vxe-upload--image-item-box',
|
|
@@ -1455,9 +1651,11 @@ export default defineVxeComponent({
|
|
|
1455
1651
|
},
|
|
1456
1652
|
renderImageMode (h: CreateElement) {
|
|
1457
1653
|
const $xeUpload = this
|
|
1654
|
+
const props = $xeUpload
|
|
1458
1655
|
const reactData = $xeUpload.reactData
|
|
1459
1656
|
|
|
1460
|
-
const {
|
|
1657
|
+
const { dragSort } = props
|
|
1658
|
+
const { fileList, isDragMove } = reactData
|
|
1461
1659
|
const moreOpts = $xeUpload.computeMoreOpts
|
|
1462
1660
|
|
|
1463
1661
|
const { maxCount, showMoreButton } = moreOpts
|
|
@@ -1472,27 +1670,54 @@ export default defineVxeComponent({
|
|
|
1472
1670
|
key: 'image',
|
|
1473
1671
|
class: 'vxe-upload--image-wrapper'
|
|
1474
1672
|
}, [
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1673
|
+
dragSort
|
|
1674
|
+
? h('transition-group', {
|
|
1675
|
+
attrs: {
|
|
1676
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1677
|
+
tag: 'div'
|
|
1678
|
+
},
|
|
1679
|
+
class: 'vxe-upload--image-list'
|
|
1680
|
+
}, $xeUpload.renderImageItemList(h, currList, false).concat([
|
|
1681
|
+
showMoreButton && overMaxNum
|
|
1682
|
+
? h('div', {
|
|
1683
|
+
key: 'om',
|
|
1684
|
+
class: 'vxe-upload--image-over-more'
|
|
1685
|
+
}, [
|
|
1686
|
+
h(VxeButtonComponent, {
|
|
1687
|
+
props: {
|
|
1688
|
+
mode: 'text',
|
|
1689
|
+
content: getI18n('vxe.upload.moreBtnText', [fileList.length]),
|
|
1690
|
+
status: 'primary'
|
|
1691
|
+
},
|
|
1692
|
+
on: {
|
|
1693
|
+
click: $xeUpload.handleMoreEvent
|
|
1694
|
+
}
|
|
1695
|
+
})
|
|
1696
|
+
])
|
|
1697
|
+
: renderEmptyElement($xeUpload),
|
|
1698
|
+
$xeUpload.renderImageAction(h, false)
|
|
1699
|
+
]))
|
|
1700
|
+
: h('div', {
|
|
1701
|
+
class: 'vxe-upload--image-list'
|
|
1702
|
+
}, $xeUpload.renderImageItemList(h, currList, false).concat([
|
|
1703
|
+
showMoreButton && overMaxNum
|
|
1704
|
+
? h('div', {
|
|
1705
|
+
class: 'vxe-upload--image-over-more'
|
|
1706
|
+
}, [
|
|
1707
|
+
h(VxeButtonComponent, {
|
|
1708
|
+
props: {
|
|
1709
|
+
mode: 'text',
|
|
1710
|
+
content: getI18n('vxe.upload.moreBtnText', [fileList.length]),
|
|
1711
|
+
status: 'primary'
|
|
1712
|
+
},
|
|
1713
|
+
on: {
|
|
1714
|
+
click: $xeUpload.handleMoreEvent
|
|
1715
|
+
}
|
|
1716
|
+
})
|
|
1717
|
+
])
|
|
1718
|
+
: renderEmptyElement($xeUpload),
|
|
1719
|
+
$xeUpload.renderImageAction(h, false)
|
|
1720
|
+
]))
|
|
1496
1721
|
])
|
|
1497
1722
|
},
|
|
1498
1723
|
renderVN (h: CreateElement): VNode {
|
|
@@ -1500,18 +1725,18 @@ export default defineVxeComponent({
|
|
|
1500
1725
|
const props = $xeUpload
|
|
1501
1726
|
const reactData = $xeUpload.reactData
|
|
1502
1727
|
|
|
1503
|
-
const { showErrorStatus, dragToUpload, pasteToUpload } = props
|
|
1504
|
-
const {
|
|
1728
|
+
const { showErrorStatus, dragToUpload, pasteToUpload, dragSort } = props
|
|
1729
|
+
const { isDragUploadStatus, showMorePopup, isActivated, dragIndex } = reactData
|
|
1505
1730
|
const vSize = $xeUpload.computeSize
|
|
1506
1731
|
const isDisabled = $xeUpload.computeIsDisabled
|
|
1507
1732
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
1508
1733
|
const isImage = $xeUpload.computeIsImage
|
|
1509
1734
|
|
|
1510
1735
|
const ons: Record<string, any> = {}
|
|
1511
|
-
if (dragToUpload) {
|
|
1512
|
-
ons.dragover = $xeUpload.
|
|
1513
|
-
ons.dragleave = $xeUpload.
|
|
1514
|
-
ons.drop = $xeUpload.
|
|
1736
|
+
if (dragToUpload && dragIndex === -1) {
|
|
1737
|
+
ons.dragover = $xeUpload.handleUploadDragoverEvent
|
|
1738
|
+
ons.dragleave = $xeUpload.handleUploadDragleaveEvent
|
|
1739
|
+
ons.drop = $xeUpload.handleUploadDropEvent
|
|
1515
1740
|
}
|
|
1516
1741
|
|
|
1517
1742
|
return h('div', {
|
|
@@ -1523,12 +1748,18 @@ export default defineVxeComponent({
|
|
|
1523
1748
|
'is--disabled': isDisabled,
|
|
1524
1749
|
'is--paste': pasteToUpload,
|
|
1525
1750
|
'show--error': showErrorStatus,
|
|
1526
|
-
'is--drag':
|
|
1751
|
+
'is--drag': isDragUploadStatus
|
|
1527
1752
|
}],
|
|
1528
1753
|
on: ons
|
|
1529
1754
|
}, [
|
|
1530
1755
|
isImage ? $xeUpload.renderImageMode(h) : $xeUpload.renderAllMode(h),
|
|
1531
|
-
|
|
1756
|
+
dragSort
|
|
1757
|
+
? h('div', {
|
|
1758
|
+
ref: 'refDragLineElem',
|
|
1759
|
+
class: 'vxe-upload--drag-line'
|
|
1760
|
+
})
|
|
1761
|
+
: renderEmptyElement($xeUpload),
|
|
1762
|
+
isDragUploadStatus && !showMorePopup
|
|
1532
1763
|
? h('div', {
|
|
1533
1764
|
class: 'vxe-upload--drag-placeholder'
|
|
1534
1765
|
}, getI18n('vxe.upload.dragPlaceholder'))
|
|
@@ -1550,7 +1781,7 @@ export default defineVxeComponent({
|
|
|
1550
1781
|
errLog('vxe.error.errConflicts', ['multiple', 'single-mode'])
|
|
1551
1782
|
}
|
|
1552
1783
|
if (props.imageStyle) {
|
|
1553
|
-
|
|
1784
|
+
warnLog('vxe.error.delProp', ['image-style', 'image-config'])
|
|
1554
1785
|
}
|
|
1555
1786
|
}
|
|
1556
1787
|
globalEvents.on($xeUpload, 'paste', $xeUpload.handleGlobalPasteEvent)
|
|
@@ -1561,7 +1792,7 @@ export default defineVxeComponent({
|
|
|
1561
1792
|
const $xeUpload = this
|
|
1562
1793
|
const reactData = $xeUpload.reactData
|
|
1563
1794
|
|
|
1564
|
-
reactData.
|
|
1795
|
+
reactData.isDragUploadStatus = false
|
|
1565
1796
|
globalEvents.off($xeUpload, 'paste')
|
|
1566
1797
|
globalEvents.off($xeUpload, 'mousedown')
|
|
1567
1798
|
globalEvents.off($xeUpload, 'blur')
|
|
@@ -82,8 +82,7 @@
|
|
|
82
82
|
flex-direction: row;
|
|
83
83
|
align-items: center;
|
|
84
84
|
line-height: 1.5em;
|
|
85
|
-
|
|
86
|
-
padding: 0.1em var(--vxe-ui-layout-padding-half);
|
|
85
|
+
padding: var(--vxe-ui-layout-padding-half);
|
|
87
86
|
&:hover {
|
|
88
87
|
background-color: var(--vxe-ui-base-hover-background-color);
|
|
89
88
|
&:not(.is--loading) {
|
|
@@ -371,6 +370,39 @@
|
|
|
371
370
|
}
|
|
372
371
|
}
|
|
373
372
|
|
|
373
|
+
/*拖拽排序*/
|
|
374
|
+
.vxe-upload--drag-line {
|
|
375
|
+
display: none;
|
|
376
|
+
position: absolute;
|
|
377
|
+
top: 0;
|
|
378
|
+
left: 0;
|
|
379
|
+
z-index: 3;
|
|
380
|
+
pointer-events: none;
|
|
381
|
+
}
|
|
382
|
+
.vxe-upload--drag-line {
|
|
383
|
+
width: 1px;
|
|
384
|
+
height: 1px;
|
|
385
|
+
border: 2px solid transparent;
|
|
386
|
+
&[drag-pos="top"] {
|
|
387
|
+
border-top-color: var(--vxe-ui-font-primary-color);
|
|
388
|
+
}
|
|
389
|
+
&[drag-pos="bottom"] {
|
|
390
|
+
border-bottom-color: var(--vxe-ui-font-primary-color);
|
|
391
|
+
}
|
|
392
|
+
&[drag-pos="left"] {
|
|
393
|
+
border-left-color: var(--vxe-ui-font-primary-color);
|
|
394
|
+
}
|
|
395
|
+
&[drag-pos="right"] {
|
|
396
|
+
border-right-color: var(--vxe-ui-font-primary-color);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
.vxe-upload--drag-list-move {
|
|
400
|
+
transition: transform 0.2s;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.vxe-upload--more-popup {
|
|
404
|
+
position: relative;
|
|
405
|
+
}
|
|
374
406
|
.vxe-upload,
|
|
375
407
|
.vxe-upload--more-popup {
|
|
376
408
|
font-size: var(--vxe-ui-font-size-default);
|