vxe-pc-ui 3.3.35 → 3.3.37
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 +284 -72
- package/es/upload/style.css +37 -0
- package/es/upload/style.min.css +1 -1
- package/es/vxe-upload/style.css +37 -0
- 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 +267 -51
- 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 +254 -46
- package/lib/upload/src/upload.min.js +1 -1
- package/lib/upload/style/style.css +37 -0
- package/lib/upload/style/style.min.css +1 -1
- package/lib/vxe-upload/style/style.css +37 -0
- 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 +302 -73
- package/styles/components/upload.scss +33 -0
- package/types/components/pulldown.d.ts +9 -1
- package/types/components/table-module/keyboard.d.ts +1 -2
- package/types/components/table.d.ts +22 -0
- package/types/components/upload.d.ts +10 -2
- /package/es/icon/{iconfont.1734189926286.ttf → iconfont.1734347209149.ttf} +0 -0
- /package/es/icon/{iconfont.1734189926286.woff → iconfont.1734347209149.woff} +0 -0
- /package/es/icon/{iconfont.1734189926286.woff2 → iconfont.1734347209149.woff2} +0 -0
- /package/es/{iconfont.1734189926286.ttf → iconfont.1734347209149.ttf} +0 -0
- /package/es/{iconfont.1734189926286.woff → iconfont.1734347209149.woff} +0 -0
- /package/es/{iconfont.1734189926286.woff2 → iconfont.1734347209149.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1734189926286.ttf → iconfont.1734347209149.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1734189926286.woff → iconfont.1734347209149.woff} +0 -0
- /package/lib/icon/style/{iconfont.1734189926286.woff2 → iconfont.1734347209149.woff2} +0 -0
- /package/lib/{iconfont.1734189926286.ttf → iconfont.1734347209149.ttf} +0 -0
- /package/lib/{iconfont.1734189926286.woff → iconfont.1734347209149.woff} +0 -0
- /package/lib/{iconfont.1734189926286.woff2 → iconfont.1734347209149.woff2} +0 -0
|
@@ -4,11 +4,11 @@ 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
6
|
import { errLog } from '../../ui/src/log'
|
|
7
|
-
import { getEventTargetNode, toCssUnit } from '../../ui/src/dom'
|
|
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,44 @@ 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 el = $xeUpload.$refs.refElem as HTMLDivElement
|
|
34
|
+
if (!el) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const { showMorePopup } = reactData
|
|
38
|
+
const wrapperRect = el.getBoundingClientRect()
|
|
39
|
+
const ddLineEl = $xeUpload.$refs.refDragLineElem as HTMLDivElement
|
|
40
|
+
const mdLineEl = document.getElementById(`refModalDragLineElem${xID}`) as HTMLDivElement
|
|
41
|
+
const currDLineEl = showMorePopup ? mdLineEl : ddLineEl
|
|
42
|
+
if (currDLineEl) {
|
|
43
|
+
const dragRect = dragEl.getBoundingClientRect()
|
|
44
|
+
currDLineEl.style.display = 'block'
|
|
45
|
+
currDLineEl.style.top = `${Math.max(1, dragRect.y - wrapperRect.y)}px`
|
|
46
|
+
currDLineEl.style.left = `${Math.max(1, dragRect.x - wrapperRect.x)}px`
|
|
47
|
+
currDLineEl.style.height = `${dragRect.height}px`
|
|
48
|
+
currDLineEl.style.width = `${dragRect.width - 1}px`
|
|
49
|
+
currDLineEl.setAttribute('drag-pos', dragPos)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function hideDropTip ($xeUpload: VxeUploadConstructor) {
|
|
54
|
+
const { xID } = $xeUpload
|
|
55
|
+
|
|
56
|
+
const ddLineEl = $xeUpload.$refs.refDragLineElem as HTMLDivElement
|
|
57
|
+
const mdLineEl = document.getElementById(`refModalDragLineElem${xID}`) as HTMLDivElement
|
|
58
|
+
if (ddLineEl) {
|
|
59
|
+
ddLineEl.style.display = ''
|
|
60
|
+
}
|
|
61
|
+
if (mdLineEl) {
|
|
62
|
+
mdLineEl.style.display = ''
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
28
66
|
export default defineVxeComponent({
|
|
29
67
|
name: 'VxeUpload',
|
|
30
68
|
model: {
|
|
@@ -73,6 +111,7 @@ export default defineVxeComponent({
|
|
|
73
111
|
type: Array as PropType<VxeUploadPropTypes.FileTypes>,
|
|
74
112
|
default: () => XEUtils.clone(getConfig().upload.fileTypes, true)
|
|
75
113
|
},
|
|
114
|
+
dragSort: Boolean as PropType<VxeUploadPropTypes.DragSort>,
|
|
76
115
|
dragToUpload: {
|
|
77
116
|
type: Boolean as PropType<VxeUploadPropTypes.DragToUpload>,
|
|
78
117
|
default: () => XEUtils.clone(getConfig().upload.dragToUpload, true)
|
|
@@ -184,14 +223,19 @@ export default defineVxeComponent({
|
|
|
184
223
|
data () {
|
|
185
224
|
const xID = XEUtils.uniqueId()
|
|
186
225
|
const reactData: UploadReactData = {
|
|
187
|
-
|
|
226
|
+
isDragUploadStatus: false,
|
|
188
227
|
showMorePopup: false,
|
|
189
228
|
isActivated: false,
|
|
190
229
|
fileList: [],
|
|
191
|
-
fileCacheMaps: {}
|
|
230
|
+
fileCacheMaps: {},
|
|
231
|
+
isDragMove: false,
|
|
232
|
+
dragIndex: -1,
|
|
233
|
+
dragTipText: ''
|
|
192
234
|
}
|
|
193
235
|
const internalData: UploadInternalData = {
|
|
194
|
-
imagePreviewTypes: ['jpg', 'jpeg', 'png', 'gif']
|
|
236
|
+
imagePreviewTypes: ['jpg', 'jpeg', 'png', 'gif'],
|
|
237
|
+
prevDragIndex: -1
|
|
238
|
+
// prevDragPos: ''
|
|
195
239
|
}
|
|
196
240
|
return {
|
|
197
241
|
xID,
|
|
@@ -866,7 +910,7 @@ export default defineVxeComponent({
|
|
|
866
910
|
}
|
|
867
911
|
})
|
|
868
912
|
},
|
|
869
|
-
|
|
913
|
+
handleUploadDragleaveEvent (evnt: DragEvent) {
|
|
870
914
|
const $xeUpload = this
|
|
871
915
|
const reactData = $xeUpload.reactData
|
|
872
916
|
|
|
@@ -875,11 +919,11 @@ export default defineVxeComponent({
|
|
|
875
919
|
if (targetElem) {
|
|
876
920
|
const { x: targetX, y: targetY, height: targetHeight, width: targetWidth } = targetElem.getBoundingClientRect()
|
|
877
921
|
if (clientX < targetX || clientX > targetX + targetWidth || clientY < targetY || clientY > targetY + targetHeight) {
|
|
878
|
-
reactData.
|
|
922
|
+
reactData.isDragUploadStatus = false
|
|
879
923
|
}
|
|
880
924
|
}
|
|
881
925
|
},
|
|
882
|
-
|
|
926
|
+
handleUploadDragoverEvent (evnt: DragEvent) {
|
|
883
927
|
const $xeUpload = this
|
|
884
928
|
const reactData = $xeUpload.reactData
|
|
885
929
|
|
|
@@ -888,7 +932,7 @@ export default defineVxeComponent({
|
|
|
888
932
|
const { items } = dataTransfer
|
|
889
933
|
if (items && items.length) {
|
|
890
934
|
evnt.preventDefault()
|
|
891
|
-
reactData.
|
|
935
|
+
reactData.isDragUploadStatus = true
|
|
892
936
|
}
|
|
893
937
|
}
|
|
894
938
|
},
|
|
@@ -923,7 +967,7 @@ export default defineVxeComponent({
|
|
|
923
967
|
}
|
|
924
968
|
$xeUpload.uploadFile(files, evnt)
|
|
925
969
|
},
|
|
926
|
-
|
|
970
|
+
handleUploadDropEvent (evnt: DragEvent) {
|
|
927
971
|
const $xeUpload = this
|
|
928
972
|
const reactData = $xeUpload.reactData
|
|
929
973
|
|
|
@@ -938,13 +982,15 @@ export default defineVxeComponent({
|
|
|
938
982
|
}
|
|
939
983
|
}
|
|
940
984
|
}
|
|
941
|
-
reactData.
|
|
985
|
+
reactData.isDragUploadStatus = false
|
|
942
986
|
},
|
|
943
987
|
handleMoreEvent () {
|
|
944
988
|
const $xeUpload = this
|
|
945
989
|
const props = $xeUpload
|
|
946
990
|
const reactData = $xeUpload.reactData
|
|
947
991
|
|
|
992
|
+
const { xID } = $xeUpload
|
|
993
|
+
|
|
948
994
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
949
995
|
const isImage = $xeUpload.computeIsImage
|
|
950
996
|
|
|
@@ -959,16 +1005,16 @@ export default defineVxeComponent({
|
|
|
959
1005
|
maskClosable: true,
|
|
960
1006
|
slots: {
|
|
961
1007
|
default (params, h) {
|
|
962
|
-
const { showErrorStatus, dragToUpload } = props
|
|
963
|
-
const {
|
|
964
|
-
const isDisabled = $xeUpload.computeIsDisabled
|
|
1008
|
+
const { showErrorStatus, dragToUpload, dragSort } = props
|
|
1009
|
+
const { isDragMove, isDragUploadStatus, dragIndex } = reactData
|
|
965
1010
|
const { fileList } = reactData
|
|
1011
|
+
const isDisabled = $xeUpload.computeIsDisabled
|
|
966
1012
|
|
|
967
1013
|
const ons: Record<string, any> = {}
|
|
968
|
-
if (dragToUpload) {
|
|
969
|
-
ons.dragover = $xeUpload.
|
|
970
|
-
ons.dragleave = $xeUpload.
|
|
971
|
-
ons.drop = $xeUpload.
|
|
1014
|
+
if (dragToUpload && dragIndex === -1) {
|
|
1015
|
+
ons.dragover = $xeUpload.handleUploadDragoverEvent
|
|
1016
|
+
ons.dragleave = $xeUpload.handleUploadDragleaveEvent
|
|
1017
|
+
ons.drop = $xeUpload.handleUploadDropEvent
|
|
972
1018
|
}
|
|
973
1019
|
|
|
974
1020
|
return h('div', {
|
|
@@ -976,23 +1022,51 @@ export default defineVxeComponent({
|
|
|
976
1022
|
'is--readonly': formReadonly,
|
|
977
1023
|
'is--disabled': isDisabled,
|
|
978
1024
|
'show--error': showErrorStatus,
|
|
979
|
-
'is--drag':
|
|
1025
|
+
'is--drag': isDragUploadStatus
|
|
980
1026
|
}],
|
|
981
1027
|
on: ons
|
|
982
1028
|
}, [
|
|
983
1029
|
isImage
|
|
984
|
-
?
|
|
985
|
-
|
|
986
|
-
|
|
1030
|
+
? (
|
|
1031
|
+
dragSort
|
|
1032
|
+
? h('transition-group', {
|
|
1033
|
+
props: {
|
|
1034
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1035
|
+
tag: 'div'
|
|
1036
|
+
},
|
|
1037
|
+
class: 'vxe-upload--image-more-list'
|
|
1038
|
+
}, $xeUpload.renderImageItemList(h, fileList, true).concat($xeUpload.renderImageAction(h, true)))
|
|
1039
|
+
: h('div', {
|
|
1040
|
+
class: 'vxe-upload--image-more-list'
|
|
1041
|
+
}, $xeUpload.renderImageItemList(h, fileList, true).concat($xeUpload.renderImageAction(h, true)))
|
|
1042
|
+
)
|
|
987
1043
|
: h('div', {
|
|
988
1044
|
class: 'vxe-upload--file-more-list'
|
|
989
1045
|
}, [
|
|
990
1046
|
$xeUpload.renderFileAction(h, true),
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1047
|
+
(
|
|
1048
|
+
dragSort
|
|
1049
|
+
? h('transition-group', {
|
|
1050
|
+
props: {
|
|
1051
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1052
|
+
tag: 'div'
|
|
1053
|
+
},
|
|
1054
|
+
class: 'vxe-upload--file-list'
|
|
1055
|
+
}, $xeUpload.renderFileItemList(h, fileList, true))
|
|
1056
|
+
: h('div', {
|
|
1057
|
+
class: 'vxe-upload--file-list'
|
|
1058
|
+
}, $xeUpload.renderFileItemList(h, fileList, true))
|
|
1059
|
+
)
|
|
994
1060
|
]),
|
|
995
|
-
|
|
1061
|
+
dragSort
|
|
1062
|
+
? h('div', {
|
|
1063
|
+
attrs: {
|
|
1064
|
+
id: `refModalDragLineElem${xID}`
|
|
1065
|
+
},
|
|
1066
|
+
class: 'vxe-upload--drag-line'
|
|
1067
|
+
})
|
|
1068
|
+
: renderEmptyElement($xeUpload),
|
|
1069
|
+
isDragUploadStatus
|
|
996
1070
|
? h('div', {
|
|
997
1071
|
class: 'vxe-upload--drag-placeholder'
|
|
998
1072
|
}, getI18n('vxe.upload.dragPlaceholder'))
|
|
@@ -1000,15 +1074,98 @@ export default defineVxeComponent({
|
|
|
1000
1074
|
])
|
|
1001
1075
|
}
|
|
1002
1076
|
},
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1077
|
+
events: {
|
|
1078
|
+
show () {
|
|
1079
|
+
reactData.showMorePopup = true
|
|
1080
|
+
},
|
|
1081
|
+
hide () {
|
|
1082
|
+
reactData.showMorePopup = false
|
|
1083
|
+
}
|
|
1008
1084
|
}
|
|
1009
1085
|
})
|
|
1010
1086
|
}
|
|
1011
1087
|
},
|
|
1088
|
+
// 拖拽
|
|
1089
|
+
handleDragSortDragstartEvent (evnt: DragEvent) {
|
|
1090
|
+
const $xeUpload = this
|
|
1091
|
+
const reactData = $xeUpload.reactData
|
|
1092
|
+
|
|
1093
|
+
if (evnt.dataTransfer) {
|
|
1094
|
+
const img = new Image()
|
|
1095
|
+
img.src = tpImg
|
|
1096
|
+
evnt.dataTransfer.setDragImage(img, 0, 0)
|
|
1097
|
+
}
|
|
1098
|
+
const dragEl = evnt.currentTarget as HTMLElement
|
|
1099
|
+
const parentEl = dragEl.parentElement as HTMLDivElement
|
|
1100
|
+
const dragIndex = XEUtils.findIndexOf(Array.from(parentEl.children), item => dragEl === item)
|
|
1101
|
+
reactData.isDragMove = true
|
|
1102
|
+
reactData.dragIndex = dragIndex
|
|
1103
|
+
setTimeout(() => {
|
|
1104
|
+
reactData.isDragMove = false
|
|
1105
|
+
}, 500)
|
|
1106
|
+
},
|
|
1107
|
+
handleDragSortDragoverEvent (evnt: DragEvent) {
|
|
1108
|
+
const $xeUpload = this
|
|
1109
|
+
const reactData = $xeUpload.reactData
|
|
1110
|
+
const internalData = $xeUpload.internalData
|
|
1111
|
+
|
|
1112
|
+
evnt.preventDefault()
|
|
1113
|
+
|
|
1114
|
+
const { dragIndex } = reactData
|
|
1115
|
+
if (dragIndex === -1) {
|
|
1116
|
+
return
|
|
1117
|
+
}
|
|
1118
|
+
const isImage = $xeUpload.computeIsImage
|
|
1119
|
+
const dragEl = evnt.currentTarget as HTMLElement
|
|
1120
|
+
const parentEl = dragEl.parentElement as HTMLDivElement
|
|
1121
|
+
const currIndex = XEUtils.findIndexOf(Array.from(parentEl.children), item => dragEl === item)
|
|
1122
|
+
let dragPos: 'top' | 'bottom' | 'left' | 'right' | '' = ''
|
|
1123
|
+
if (isImage) {
|
|
1124
|
+
const offsetX = evnt.clientX - dragEl.getBoundingClientRect().x
|
|
1125
|
+
dragPos = offsetX < dragEl.clientWidth / 2 ? 'left' : 'right'
|
|
1126
|
+
} else {
|
|
1127
|
+
const offsetY = evnt.clientY - dragEl.getBoundingClientRect().y
|
|
1128
|
+
dragPos = offsetY < dragEl.clientHeight / 2 ? 'top' : 'bottom'
|
|
1129
|
+
}
|
|
1130
|
+
if (dragIndex === currIndex) {
|
|
1131
|
+
showDropTip($xeUpload, evnt, dragEl, dragPos)
|
|
1132
|
+
return
|
|
1133
|
+
}
|
|
1134
|
+
showDropTip($xeUpload, evnt, dragEl, dragPos)
|
|
1135
|
+
internalData.prevDragIndex = currIndex
|
|
1136
|
+
internalData.prevDragPos = dragPos
|
|
1137
|
+
},
|
|
1138
|
+
handleDragSortDragendEvent (evnt: DragEvent) {
|
|
1139
|
+
const $xeUpload = this
|
|
1140
|
+
const reactData = $xeUpload.reactData
|
|
1141
|
+
const internalData = $xeUpload.internalData
|
|
1142
|
+
|
|
1143
|
+
const { fileList, dragIndex } = reactData
|
|
1144
|
+
const { prevDragIndex, prevDragPos } = internalData
|
|
1145
|
+
const oldIndex = dragIndex
|
|
1146
|
+
const targetIndex = prevDragIndex
|
|
1147
|
+
const dragOffsetIndex = prevDragPos === 'bottom' || prevDragPos === 'right' ? 1 : 0
|
|
1148
|
+
const oldItem = fileList[oldIndex]
|
|
1149
|
+
const newItem = fileList[targetIndex]
|
|
1150
|
+
if (oldItem && newItem) {
|
|
1151
|
+
fileList.splice(oldIndex, 1)
|
|
1152
|
+
const ptfIndex = XEUtils.findIndexOf(fileList, item => newItem === item)
|
|
1153
|
+
const nIndex = ptfIndex + dragOffsetIndex
|
|
1154
|
+
fileList.splice(nIndex, 0, oldItem)
|
|
1155
|
+
$xeUpload.dispatchEvent('sort-dragend', {
|
|
1156
|
+
oldItem: oldItem,
|
|
1157
|
+
newItem: newItem,
|
|
1158
|
+
dragPos: prevDragPos as any,
|
|
1159
|
+
offsetIndex: dragOffsetIndex,
|
|
1160
|
+
_index: {
|
|
1161
|
+
newIndex: nIndex,
|
|
1162
|
+
oldIndex: oldIndex
|
|
1163
|
+
}
|
|
1164
|
+
}, evnt)
|
|
1165
|
+
}
|
|
1166
|
+
hideDropTip($xeUpload)
|
|
1167
|
+
reactData.dragIndex = -1
|
|
1168
|
+
},
|
|
1012
1169
|
handleGlobalPasteEvent (evnt: ClipboardEvent) {
|
|
1013
1170
|
const $xeUpload = this
|
|
1014
1171
|
const props = $xeUpload
|
|
@@ -1057,7 +1214,7 @@ export default defineVxeComponent({
|
|
|
1057
1214
|
const slots = $xeUpload.$scopedSlots
|
|
1058
1215
|
const reactData = $xeUpload.reactData
|
|
1059
1216
|
|
|
1060
|
-
const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus } = props
|
|
1217
|
+
const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus, dragSort } = props
|
|
1061
1218
|
const { fileCacheMaps } = reactData
|
|
1062
1219
|
const isDisabled = $xeUpload.computeIsDisabled
|
|
1063
1220
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
@@ -1065,18 +1222,30 @@ export default defineVxeComponent({
|
|
|
1065
1222
|
const typeProp = $xeUpload.computeTypeProp
|
|
1066
1223
|
const cornerSlot = slots.corner
|
|
1067
1224
|
|
|
1225
|
+
const ons: Record<string, any> = {}
|
|
1226
|
+
if (dragSort) {
|
|
1227
|
+
ons.dragstart = $xeUpload.handleDragSortDragstartEvent
|
|
1228
|
+
ons.dragover = $xeUpload.handleDragSortDragoverEvent
|
|
1229
|
+
ons.dragend = $xeUpload.handleDragSortDragendEvent
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1068
1232
|
return currList.map((item, index) => {
|
|
1069
1233
|
const fileKey = $xeUpload.getFieldKey(item)
|
|
1070
1234
|
const cacheItem = fileCacheMaps[fileKey]
|
|
1071
1235
|
const isLoading = cacheItem && cacheItem.loading
|
|
1072
1236
|
const isError = cacheItem && cacheItem.status === 'error'
|
|
1073
1237
|
return h('div', {
|
|
1074
|
-
key: index,
|
|
1238
|
+
key: dragSort ? fileKey : index,
|
|
1075
1239
|
class: ['vxe-upload--file-item', {
|
|
1076
1240
|
'is--preview': showPreview,
|
|
1077
1241
|
'is--loading': isLoading,
|
|
1078
1242
|
'is--error': isError
|
|
1079
|
-
}]
|
|
1243
|
+
}],
|
|
1244
|
+
attrs: {
|
|
1245
|
+
fileid: fileKey,
|
|
1246
|
+
draggable: dragSort ? true : null
|
|
1247
|
+
},
|
|
1248
|
+
on: ons
|
|
1080
1249
|
}, [
|
|
1081
1250
|
h('div', {
|
|
1082
1251
|
class: 'vxe-upload--file-item-icon'
|
|
@@ -1218,8 +1387,8 @@ export default defineVxeComponent({
|
|
|
1218
1387
|
const props = $xeUpload
|
|
1219
1388
|
const reactData = $xeUpload.reactData
|
|
1220
1389
|
|
|
1221
|
-
const { moreConfig } = props
|
|
1222
|
-
const { fileList } = reactData
|
|
1390
|
+
const { moreConfig, dragSort } = props
|
|
1391
|
+
const { fileList, isDragMove } = reactData
|
|
1223
1392
|
const moreOpts = $xeUpload.computeMoreOpts
|
|
1224
1393
|
|
|
1225
1394
|
const { maxCount, showMoreButton, layout } = moreOpts
|
|
@@ -1246,9 +1415,19 @@ export default defineVxeComponent({
|
|
|
1246
1415
|
}]
|
|
1247
1416
|
}, [
|
|
1248
1417
|
currList.length
|
|
1249
|
-
?
|
|
1250
|
-
|
|
1251
|
-
|
|
1418
|
+
? (
|
|
1419
|
+
dragSort
|
|
1420
|
+
? h('transition-group', {
|
|
1421
|
+
attrs: {
|
|
1422
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1423
|
+
tag: 'div'
|
|
1424
|
+
},
|
|
1425
|
+
class: 'vxe-upload--file-list'
|
|
1426
|
+
}, $xeUpload.renderFileItemList(h, currList, false))
|
|
1427
|
+
: h('div', {
|
|
1428
|
+
class: 'vxe-upload--file-list'
|
|
1429
|
+
}, $xeUpload.renderFileItemList(h, currList, false))
|
|
1430
|
+
)
|
|
1252
1431
|
: renderEmptyElement($xeUpload),
|
|
1253
1432
|
showMoreButton && overMaxNum
|
|
1254
1433
|
? h('div', {
|
|
@@ -1279,7 +1458,7 @@ export default defineVxeComponent({
|
|
|
1279
1458
|
const slots = $xeUpload.$scopedSlots
|
|
1280
1459
|
const reactData = $xeUpload.reactData
|
|
1281
1460
|
|
|
1282
|
-
const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus } = props
|
|
1461
|
+
const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus, dragSort } = props
|
|
1283
1462
|
const { fileCacheMaps } = reactData
|
|
1284
1463
|
const isDisabled = $xeUpload.computeIsDisabled
|
|
1285
1464
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
@@ -1287,19 +1466,31 @@ export default defineVxeComponent({
|
|
|
1287
1466
|
const imgStyle = $xeUpload.computeImgStyle
|
|
1288
1467
|
const cornerSlot = slots.corner
|
|
1289
1468
|
|
|
1469
|
+
const ons: Record<string, any> = {}
|
|
1470
|
+
if (dragSort) {
|
|
1471
|
+
ons.dragstart = $xeUpload.handleDragSortDragstartEvent
|
|
1472
|
+
ons.dragover = $xeUpload.handleDragSortDragoverEvent
|
|
1473
|
+
ons.dragend = $xeUpload.handleDragSortDragendEvent
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1290
1476
|
return currList.map((item, index) => {
|
|
1291
1477
|
const fileKey = $xeUpload.getFieldKey(item)
|
|
1292
1478
|
const cacheItem = fileCacheMaps[fileKey]
|
|
1293
1479
|
const isLoading = cacheItem && cacheItem.loading
|
|
1294
1480
|
const isError = cacheItem && cacheItem.status === 'error'
|
|
1295
1481
|
return h('div', {
|
|
1296
|
-
key: index,
|
|
1482
|
+
key: dragSort ? fileKey : index,
|
|
1297
1483
|
class: ['vxe-upload--image-item', {
|
|
1298
1484
|
'is--preview': showPreview,
|
|
1299
1485
|
'is--circle': imageOpts.circle,
|
|
1300
1486
|
'is--loading': isLoading,
|
|
1301
1487
|
'is--error': isError
|
|
1302
|
-
}]
|
|
1488
|
+
}],
|
|
1489
|
+
attrs: {
|
|
1490
|
+
fileid: fileKey,
|
|
1491
|
+
draggable: dragSort ? true : null
|
|
1492
|
+
},
|
|
1493
|
+
on: ons
|
|
1303
1494
|
}, [
|
|
1304
1495
|
h('div', {
|
|
1305
1496
|
class: 'vxe-upload--image-item-box',
|
|
@@ -1455,9 +1646,11 @@ export default defineVxeComponent({
|
|
|
1455
1646
|
},
|
|
1456
1647
|
renderImageMode (h: CreateElement) {
|
|
1457
1648
|
const $xeUpload = this
|
|
1649
|
+
const props = $xeUpload
|
|
1458
1650
|
const reactData = $xeUpload.reactData
|
|
1459
1651
|
|
|
1460
|
-
const {
|
|
1652
|
+
const { dragSort } = props
|
|
1653
|
+
const { fileList, isDragMove } = reactData
|
|
1461
1654
|
const moreOpts = $xeUpload.computeMoreOpts
|
|
1462
1655
|
|
|
1463
1656
|
const { maxCount, showMoreButton } = moreOpts
|
|
@@ -1472,27 +1665,54 @@ export default defineVxeComponent({
|
|
|
1472
1665
|
key: 'image',
|
|
1473
1666
|
class: 'vxe-upload--image-wrapper'
|
|
1474
1667
|
}, [
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1668
|
+
dragSort
|
|
1669
|
+
? h('transition-group', {
|
|
1670
|
+
attrs: {
|
|
1671
|
+
name: `vxe-upload--drag-list${isDragMove ? '' : '-disabled'}`,
|
|
1672
|
+
tag: 'div'
|
|
1673
|
+
},
|
|
1674
|
+
class: 'vxe-upload--image-list'
|
|
1675
|
+
}, $xeUpload.renderImageItemList(h, currList, false).concat([
|
|
1676
|
+
showMoreButton && overMaxNum
|
|
1677
|
+
? h('div', {
|
|
1678
|
+
key: 'om',
|
|
1679
|
+
class: 'vxe-upload--image-over-more'
|
|
1680
|
+
}, [
|
|
1681
|
+
h(VxeButtonComponent, {
|
|
1682
|
+
props: {
|
|
1683
|
+
mode: 'text',
|
|
1684
|
+
content: getI18n('vxe.upload.moreBtnText', [fileList.length]),
|
|
1685
|
+
status: 'primary'
|
|
1686
|
+
},
|
|
1687
|
+
on: {
|
|
1688
|
+
click: $xeUpload.handleMoreEvent
|
|
1689
|
+
}
|
|
1690
|
+
})
|
|
1691
|
+
])
|
|
1692
|
+
: renderEmptyElement($xeUpload),
|
|
1693
|
+
$xeUpload.renderImageAction(h, false)
|
|
1694
|
+
]))
|
|
1695
|
+
: h('div', {
|
|
1696
|
+
class: 'vxe-upload--image-list'
|
|
1697
|
+
}, $xeUpload.renderImageItemList(h, currList, false).concat([
|
|
1698
|
+
showMoreButton && overMaxNum
|
|
1699
|
+
? h('div', {
|
|
1700
|
+
class: 'vxe-upload--image-over-more'
|
|
1701
|
+
}, [
|
|
1702
|
+
h(VxeButtonComponent, {
|
|
1703
|
+
props: {
|
|
1704
|
+
mode: 'text',
|
|
1705
|
+
content: getI18n('vxe.upload.moreBtnText', [fileList.length]),
|
|
1706
|
+
status: 'primary'
|
|
1707
|
+
},
|
|
1708
|
+
on: {
|
|
1709
|
+
click: $xeUpload.handleMoreEvent
|
|
1710
|
+
}
|
|
1711
|
+
})
|
|
1712
|
+
])
|
|
1713
|
+
: renderEmptyElement($xeUpload),
|
|
1714
|
+
$xeUpload.renderImageAction(h, false)
|
|
1715
|
+
]))
|
|
1496
1716
|
])
|
|
1497
1717
|
},
|
|
1498
1718
|
renderVN (h: CreateElement): VNode {
|
|
@@ -1500,18 +1720,18 @@ export default defineVxeComponent({
|
|
|
1500
1720
|
const props = $xeUpload
|
|
1501
1721
|
const reactData = $xeUpload.reactData
|
|
1502
1722
|
|
|
1503
|
-
const { showErrorStatus, dragToUpload, pasteToUpload } = props
|
|
1504
|
-
const {
|
|
1723
|
+
const { showErrorStatus, dragToUpload, pasteToUpload, dragSort } = props
|
|
1724
|
+
const { isDragUploadStatus, showMorePopup, isActivated, dragIndex } = reactData
|
|
1505
1725
|
const vSize = $xeUpload.computeSize
|
|
1506
1726
|
const isDisabled = $xeUpload.computeIsDisabled
|
|
1507
1727
|
const formReadonly = $xeUpload.computeFormReadonly
|
|
1508
1728
|
const isImage = $xeUpload.computeIsImage
|
|
1509
1729
|
|
|
1510
1730
|
const ons: Record<string, any> = {}
|
|
1511
|
-
if (dragToUpload) {
|
|
1512
|
-
ons.dragover = $xeUpload.
|
|
1513
|
-
ons.dragleave = $xeUpload.
|
|
1514
|
-
ons.drop = $xeUpload.
|
|
1731
|
+
if (dragToUpload && dragIndex === -1) {
|
|
1732
|
+
ons.dragover = $xeUpload.handleUploadDragoverEvent
|
|
1733
|
+
ons.dragleave = $xeUpload.handleUploadDragleaveEvent
|
|
1734
|
+
ons.drop = $xeUpload.handleUploadDropEvent
|
|
1515
1735
|
}
|
|
1516
1736
|
|
|
1517
1737
|
return h('div', {
|
|
@@ -1523,12 +1743,18 @@ export default defineVxeComponent({
|
|
|
1523
1743
|
'is--disabled': isDisabled,
|
|
1524
1744
|
'is--paste': pasteToUpload,
|
|
1525
1745
|
'show--error': showErrorStatus,
|
|
1526
|
-
'is--drag':
|
|
1746
|
+
'is--drag': isDragUploadStatus
|
|
1527
1747
|
}],
|
|
1528
1748
|
on: ons
|
|
1529
1749
|
}, [
|
|
1530
1750
|
isImage ? $xeUpload.renderImageMode(h) : $xeUpload.renderAllMode(h),
|
|
1531
|
-
|
|
1751
|
+
dragSort
|
|
1752
|
+
? h('div', {
|
|
1753
|
+
ref: 'refDragLineElem',
|
|
1754
|
+
class: 'vxe-upload--drag-line'
|
|
1755
|
+
})
|
|
1756
|
+
: renderEmptyElement($xeUpload),
|
|
1757
|
+
isDragUploadStatus && !showMorePopup
|
|
1532
1758
|
? h('div', {
|
|
1533
1759
|
class: 'vxe-upload--drag-placeholder'
|
|
1534
1760
|
}, getI18n('vxe.upload.dragPlaceholder'))
|
|
@@ -1549,6 +1775,9 @@ export default defineVxeComponent({
|
|
|
1549
1775
|
if (props.multiple && props.singleMode) {
|
|
1550
1776
|
errLog('vxe.error.errConflicts', ['multiple', 'single-mode'])
|
|
1551
1777
|
}
|
|
1778
|
+
if (props.imageStyle) {
|
|
1779
|
+
errLog('vxe.error.delProp', ['image-style', 'image-config'])
|
|
1780
|
+
}
|
|
1552
1781
|
}
|
|
1553
1782
|
globalEvents.on($xeUpload, 'paste', $xeUpload.handleGlobalPasteEvent)
|
|
1554
1783
|
globalEvents.on($xeUpload, 'mousedown', $xeUpload.handleGlobalMousedownEvent)
|
|
@@ -1558,7 +1787,7 @@ export default defineVxeComponent({
|
|
|
1558
1787
|
const $xeUpload = this
|
|
1559
1788
|
const reactData = $xeUpload.reactData
|
|
1560
1789
|
|
|
1561
|
-
reactData.
|
|
1790
|
+
reactData.isDragUploadStatus = false
|
|
1562
1791
|
globalEvents.off($xeUpload, 'paste')
|
|
1563
1792
|
globalEvents.off($xeUpload, 'mousedown')
|
|
1564
1793
|
globalEvents.off($xeUpload, 'blur')
|
|
@@ -371,6 +371,39 @@
|
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
/*拖拽排序*/
|
|
375
|
+
.vxe-upload--drag-line {
|
|
376
|
+
display: none;
|
|
377
|
+
position: absolute;
|
|
378
|
+
top: 0;
|
|
379
|
+
left: 0;
|
|
380
|
+
z-index: 3;
|
|
381
|
+
pointer-events: none;
|
|
382
|
+
}
|
|
383
|
+
.vxe-upload--drag-line {
|
|
384
|
+
width: 1px;
|
|
385
|
+
height: 1px;
|
|
386
|
+
border: 2px solid transparent;
|
|
387
|
+
&[drag-pos="top"] {
|
|
388
|
+
border-top-color: var(--vxe-ui-font-primary-color);
|
|
389
|
+
}
|
|
390
|
+
&[drag-pos="bottom"] {
|
|
391
|
+
border-bottom-color: var(--vxe-ui-font-primary-color);
|
|
392
|
+
}
|
|
393
|
+
&[drag-pos="left"] {
|
|
394
|
+
border-left-color: var(--vxe-ui-font-primary-color);
|
|
395
|
+
}
|
|
396
|
+
&[drag-pos="right"] {
|
|
397
|
+
border-right-color: var(--vxe-ui-font-primary-color);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
.vxe-upload--drag-list-move {
|
|
401
|
+
transition: transform 0.2s;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.vxe-upload--more-popup {
|
|
405
|
+
position: relative;
|
|
406
|
+
}
|
|
374
407
|
.vxe-upload,
|
|
375
408
|
.vxe-upload--more-popup {
|
|
376
409
|
font-size: var(--vxe-ui-font-size-default);
|
|
@@ -110,7 +110,8 @@ export type VxePulldownEmits = [
|
|
|
110
110
|
'click',
|
|
111
111
|
'option-click',
|
|
112
112
|
'show-panel',
|
|
113
|
-
'hide-panel'
|
|
113
|
+
'hide-panel',
|
|
114
|
+
'visible-change'
|
|
114
115
|
]
|
|
115
116
|
|
|
116
117
|
export namespace VxePulldownDefines {
|
|
@@ -126,6 +127,10 @@ export namespace VxePulldownDefines {
|
|
|
126
127
|
|
|
127
128
|
export interface ShowPanelEventParams extends PulldownEventParams {}
|
|
128
129
|
export interface HidePanelEventParams extends PulldownEventParams {}
|
|
130
|
+
|
|
131
|
+
export interface VisibleChangeEventParams extends PulldownEventParams {
|
|
132
|
+
visible: boolean
|
|
133
|
+
}
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
export type VxePulldownEventProps = {
|
|
@@ -133,6 +138,7 @@ export type VxePulldownEventProps = {
|
|
|
133
138
|
onOptionClick?: VxePulldownEvents.OptionClick
|
|
134
139
|
onShowPanel?: VxePulldownEvents.ShowPanel
|
|
135
140
|
onHidePanel?: VxePulldownEvents.HidePanel
|
|
141
|
+
onVisibleChange?: VxePulldownEvents.VisibleChange
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
export interface VxePulldownListeners {
|
|
@@ -140,6 +146,7 @@ export interface VxePulldownListeners {
|
|
|
140
146
|
optionClick?: VxePulldownEvents.OptionClick
|
|
141
147
|
showPanel?: VxePulldownEvents.ShowPanel
|
|
142
148
|
hidePanel?: VxePulldownEvents.HidePanel
|
|
149
|
+
visibleChange?: VxePulldownEvents.VisibleChange
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
export namespace VxePulldownEvents {
|
|
@@ -147,6 +154,7 @@ export namespace VxePulldownEvents {
|
|
|
147
154
|
export type OptionClick = (params: VxePulldownDefines.OptionClickEventParams) => void
|
|
148
155
|
export type ShowPanel = (params: VxePulldownDefines.ShowPanelEventParams) => void
|
|
149
156
|
export type HidePanel = (params: VxePulldownDefines.HidePanelEventParams) => void
|
|
157
|
+
export type VisibleChange = (params: VxePulldownDefines.VisibleChangeEventParams) => void
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
export namespace VxePulldownSlotTypes {
|