vxe-pc-ui 4.20.34 → 4.20.35
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/dist/all.esm.js +45718 -45038
- package/dist/all.esm.min.js +3 -3
- package/dist/style.css +307 -1
- package/dist/style.mini.css +1 -1
- package/es/alert/src/alert.js +117 -114
- package/es/anchor/src/anchor-link.js +110 -107
- package/es/anchor/src/anchor.js +212 -209
- package/es/avatar/src/avatar.js +132 -129
- package/es/backtop/src/backtop.js +267 -264
- package/es/badge/src/badge.js +102 -99
- package/es/breadcrumb/src/breadcrumb-item.js +104 -101
- package/es/breadcrumb/src/breadcrumb.js +70 -67
- package/es/button/src/button-group.js +88 -85
- package/es/calendar/src/calendar.js +1371 -1368
- package/es/card/src/card.js +235 -232
- package/es/carousel/src/carousel-item.js +78 -75
- package/es/carousel/src/carousel.js +392 -389
- package/es/cascader/src/cascader.js +1667 -1664
- package/es/checkbox/src/button.js +198 -195
- package/es/checkbox/src/checkbox.js +181 -178
- package/es/checkbox/src/group.js +210 -207
- package/es/collapse/src/collapse-pane.js +98 -95
- package/es/collapse/src/collapse.js +340 -337
- package/es/color-picker/src/color-picker.js +1116 -1113
- package/es/components.d.ts +1 -0
- package/es/components.js +3 -0
- package/es/context-menu/src/context-menu.js +601 -598
- package/es/countdown/src/countdown.js +224 -221
- package/es/date-panel/src/date-panel.js +1905 -1902
- package/es/date-picker/src/date-picker.js +1537 -1534
- package/es/date-range-picker/src/date-range-picker.js +1412 -1409
- package/es/divider/src/divider.js +80 -77
- package/es/drawer/src/drawer.js +778 -775
- package/es/empty/src/empty.js +100 -97
- package/es/form/src/form-group.js +74 -71
- package/es/form/src/form-item.js +76 -73
- package/es/form/src/form.js +789 -786
- package/es/icon/src/icon.js +59 -56
- package/es/icon/style.css +1 -1
- package/es/icon/style.mini.css +1 -1
- package/es/icon-picker/src/icon-picker.js +719 -716
- package/es/image/src/group.js +130 -127
- package/es/image/src/image.js +243 -240
- package/es/image/src/preview.js +627 -624
- package/es/index.esm.js +2 -0
- package/es/index.js +2 -0
- package/es/input/src/input.js +2700 -2697
- package/es/layout-aside/src/layout-aside.js +138 -135
- package/es/layout-body/src/layout-body.js +145 -142
- package/es/layout-container/src/layout-container.js +71 -68
- package/es/layout-footer/src/layout-footer.js +60 -57
- package/es/layout-header/src/layout-header.js +58 -55
- package/es/link/src/link.js +131 -128
- package/es/list/src/list.js +2174 -2171
- package/es/loading/src/loading.js +141 -138
- package/es/mention/src/mention.js +49 -46
- package/es/menu/src/menu.js +799 -796
- package/es/modal/src/modal.js +1519 -1527
- package/es/notice-bar/src/notice-bar.js +168 -165
- package/es/number-input/src/number-input.js +1094 -1091
- package/es/pager/src/pager.js +767 -764
- package/es/password-input/src/password-input.js +431 -428
- package/es/print/src/page-break.js +63 -60
- package/es/print/src/print.js +303 -300
- package/es/pulldown/src/pulldown.js +403 -400
- package/es/radio/src/button.js +214 -211
- package/es/radio/src/group.js +195 -192
- package/es/radio/src/radio.js +194 -191
- package/es/rate/src/rate.js +164 -161
- package/es/result/src/result.js +116 -113
- package/es/row/src/col.js +133 -130
- package/es/row/src/row.js +111 -108
- package/es/scrollbar/src/scrollbar.js +518 -515
- package/es/segmented/src/segmented.js +240 -237
- package/es/select/src/optgroup.js +44 -41
- package/es/select/src/option.js +39 -36
- package/es/select/src/select.js +1914 -1896
- package/es/slider/src/slider.js +419 -416
- package/es/space/src/space.js +190 -187
- package/es/splitter/src/splitter-panel.js +146 -143
- package/es/splitter/src/splitter.js +917 -914
- package/es/step-item/index.d.ts +76 -0
- package/es/step-item/index.js +17 -0
- package/es/steps/index.d.ts +288 -34
- package/es/steps/src/step-info.d.ts +6 -0
- package/es/steps/src/step-info.js +20 -0
- package/es/steps/src/step-item.d.ts +14 -0
- package/es/steps/src/step-item.js +39 -0
- package/es/steps/src/steps.d.ts +68 -8
- package/es/steps/src/steps.js +299 -47
- package/es/steps/src/util.d.ts +7 -0
- package/es/steps/src/util.js +44 -0
- package/es/steps/style.css +297 -0
- package/es/steps/style.mini.css +1 -0
- package/es/style.css +307 -1
- package/es/style.mini.css +1 -1
- package/es/switch/src/switch.js +228 -225
- package/es/table-select/src/table-select.js +865 -862
- package/es/table-transfer/src/table-transfer.js +61 -58
- package/es/tabs/src/tab-pane.js +102 -99
- package/es/tabs/src/tabs.js +936 -933
- package/es/tag/src/tag.js +163 -160
- package/es/text/src/text.js +232 -229
- package/es/text-ellipsis/src/text-ellipsis.js +252 -249
- package/es/textarea/src/textarea.js +434 -431
- package/es/timeline/src/timeline.js +74 -36
- package/es/timeline/src/util.js +7 -4
- package/es/tip/src/tip.js +117 -114
- package/es/tooltip/src/tooltip.js +552 -549
- package/es/tour/src/tour.js +49 -46
- package/es/transfer/src/transfer.js +95 -92
- package/es/tree/src/tree.js +3379 -3376
- package/es/tree-select/src/tree-select.js +969 -966
- package/es/ui/index.js +8 -2
- package/es/ui/src/log.js +1 -1
- package/es/upload/src/upload.js +1791 -1788
- package/es/vxe-icon/style.css +1 -1
- package/es/vxe-icon/style.mini.css +1 -1
- package/es/vxe-steps/style.css +297 -0
- package/es/vxe-steps/style.mini.css +1 -0
- package/es/watermark/src/watermark.js +158 -155
- package/lib/alert/src/alert.js +117 -114
- package/lib/anchor/src/anchor-link.js +110 -107
- package/lib/anchor/src/anchor.js +212 -209
- package/lib/avatar/src/avatar.js +132 -129
- package/lib/backtop/src/backtop.js +267 -264
- package/lib/badge/src/badge.js +102 -99
- package/lib/breadcrumb/src/breadcrumb-item.js +104 -101
- package/lib/breadcrumb/src/breadcrumb.js +70 -67
- package/lib/button/src/button-group.js +88 -85
- package/lib/calendar/src/calendar.js +1371 -1368
- package/lib/card/src/card.js +235 -232
- package/lib/carousel/src/carousel-item.js +78 -75
- package/lib/carousel/src/carousel.js +392 -389
- package/lib/cascader/src/cascader.js +1665 -1662
- package/lib/checkbox/src/button.js +198 -195
- package/lib/checkbox/src/checkbox.js +181 -178
- package/lib/checkbox/src/group.js +210 -207
- package/lib/collapse/src/collapse-pane.js +98 -95
- package/lib/collapse/src/collapse.js +340 -337
- package/lib/color-picker/src/color-picker.js +1116 -1113
- package/lib/components.js +3 -0
- package/lib/context-menu/src/context-menu.js +601 -598
- package/lib/countdown/src/countdown.js +224 -221
- package/lib/date-panel/src/date-panel.js +1905 -1902
- package/lib/date-picker/src/date-picker.js +1537 -1534
- package/lib/date-range-picker/src/date-range-picker.js +1412 -1409
- package/lib/divider/src/divider.js +80 -77
- package/lib/drawer/src/drawer.js +778 -775
- package/lib/empty/src/empty.js +100 -97
- package/lib/form/src/form-group.js +74 -71
- package/lib/form/src/form-item.js +76 -73
- package/lib/form/src/form.js +789 -786
- package/lib/icon/src/icon.js +59 -56
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.mini.css +1 -1
- package/lib/icon-picker/src/icon-picker.js +719 -716
- package/lib/image/src/group.js +130 -127
- package/lib/image/src/image.js +243 -240
- package/lib/image/src/preview.js +627 -624
- package/lib/index.common.js +2 -0
- package/lib/index.js +2 -0
- package/lib/index.umd.js +47411 -46732
- package/lib/index.umd.min.js +3 -3
- package/lib/input/src/input.js +2700 -2697
- package/lib/layout-aside/src/layout-aside.js +138 -135
- package/lib/layout-body/src/layout-body.js +145 -142
- package/lib/layout-container/src/layout-container.js +71 -68
- package/lib/layout-footer/src/layout-footer.js +60 -57
- package/lib/layout-header/src/layout-header.js +58 -55
- package/lib/link/src/link.js +131 -128
- package/lib/list/src/list.js +2173 -2170
- package/lib/loading/src/loading.js +141 -138
- package/lib/mention/src/mention.js +49 -46
- package/lib/menu/src/menu.js +799 -796
- package/lib/modal/src/modal.js +1519 -1527
- package/lib/notice-bar/src/notice-bar.js +168 -165
- package/lib/number-input/src/number-input.js +1094 -1091
- package/lib/pager/src/pager.js +767 -764
- package/lib/password-input/src/password-input.js +431 -428
- package/lib/print/src/page-break.js +63 -60
- package/lib/print/src/print.js +303 -300
- package/lib/pulldown/src/pulldown.js +403 -400
- package/lib/radio/src/button.js +214 -211
- package/lib/radio/src/group.js +195 -192
- package/lib/radio/src/radio.js +194 -191
- package/lib/rate/src/rate.js +164 -161
- package/lib/result/src/result.js +116 -113
- package/lib/row/src/col.js +133 -130
- package/lib/row/src/row.js +111 -108
- package/lib/scrollbar/src/scrollbar.js +518 -515
- package/lib/segmented/src/segmented.js +240 -237
- package/lib/select/src/optgroup.js +44 -41
- package/lib/select/src/option.js +39 -36
- package/lib/select/src/select.js +1915 -1897
- package/lib/slider/src/slider.js +419 -416
- package/lib/space/src/space.js +190 -187
- package/lib/splitter/src/splitter-panel.js +146 -143
- package/lib/splitter/src/splitter.js +917 -914
- package/lib/step-item/index.js +47 -0
- package/lib/steps/src/step-info.js +49 -0
- package/lib/steps/src/step-item.js +59 -0
- package/lib/steps/src/steps.js +298 -46
- package/lib/steps/src/util.js +74 -0
- package/lib/steps/style/style.css +297 -0
- package/lib/steps/style/style.mini.css +1 -0
- package/lib/style.css +307 -1
- package/lib/style.mini.css +1 -1
- package/lib/switch/src/switch.js +228 -225
- package/lib/table-select/src/table-select.js +865 -862
- package/lib/table-transfer/src/table-transfer.js +61 -58
- package/lib/tabs/src/tab-pane.js +102 -99
- package/lib/tabs/src/tabs.js +936 -933
- package/lib/tag/src/tag.js +163 -160
- package/lib/text/src/text.js +232 -229
- package/lib/text-ellipsis/src/text-ellipsis.js +252 -249
- package/lib/textarea/src/textarea.js +434 -431
- package/lib/timeline/src/timeline.js +74 -36
- package/lib/timeline/src/util.js +7 -4
- package/lib/tip/src/tip.js +117 -114
- package/lib/tooltip/src/tooltip.js +552 -549
- package/lib/tour/src/tour.js +49 -46
- package/lib/transfer/src/transfer.js +95 -92
- package/lib/tree/src/tree.js +3379 -3376
- package/lib/tree-select/src/tree-select.js +969 -966
- package/lib/ui/index.js +8 -2
- package/lib/ui/src/log.js +1 -1
- package/lib/upload/src/upload.js +1788 -1785
- package/lib/vxe-icon/style/style.css +1 -1
- package/lib/vxe-icon/style/style.mini.css +1 -1
- package/lib/vxe-steps/style/style.css +297 -0
- package/lib/vxe-steps/style/style.mini.css +1 -0
- package/lib/watermark/src/watermark.js +158 -155
- package/package.json +1 -1
- package/packages/alert/src/alert.ts +2 -2
- package/packages/anchor/src/anchor-link.ts +2 -2
- package/packages/anchor/src/anchor.ts +2 -2
- package/packages/avatar/src/avatar.ts +2 -2
- package/packages/backtop/src/backtop.ts +2 -2
- package/packages/badge/src/badge.ts +2 -2
- package/packages/breadcrumb/src/breadcrumb-item.ts +2 -2
- package/packages/breadcrumb/src/breadcrumb.ts +2 -2
- package/packages/button/src/button-group.ts +2 -2
- package/packages/calendar/src/calendar.ts +2 -2
- package/packages/card/src/card.ts +2 -2
- package/packages/carousel/src/carousel-item.ts +2 -2
- package/packages/carousel/src/carousel.ts +2 -2
- package/packages/cascader/src/cascader.ts +2 -2
- package/packages/checkbox/src/button.ts +3 -15
- package/packages/checkbox/src/checkbox.ts +2 -2
- package/packages/checkbox/src/group.ts +2 -2
- package/packages/collapse/src/collapse-pane.ts +2 -2
- package/packages/collapse/src/collapse.ts +2 -2
- package/packages/color-picker/src/color-picker.ts +2 -2
- package/packages/components.ts +3 -0
- package/packages/context-menu/src/context-menu.ts +3 -16
- package/packages/countdown/src/countdown.ts +2 -2
- package/packages/date-panel/src/date-panel.ts +2 -2
- package/packages/date-picker/src/date-picker.ts +2 -2
- package/packages/date-range-picker/src/date-range-picker.ts +2 -2
- package/packages/divider/src/divider.ts +2 -2
- package/packages/drawer/src/drawer.ts +2 -2
- package/packages/empty/src/empty.ts +2 -2
- package/packages/form/src/form-group.ts +2 -2
- package/packages/form/src/form-item.ts +2 -2
- package/packages/form/src/form.ts +2 -2
- package/packages/icon/src/icon.ts +2 -2
- package/packages/icon-picker/src/icon-picker.ts +2 -2
- package/packages/image/src/group.ts +2 -2
- package/packages/image/src/image.ts +2 -2
- package/packages/image/src/preview.ts +3 -16
- package/packages/index.ts +2 -2
- package/packages/input/src/input.ts +2 -2
- package/packages/layout-aside/src/layout-aside.ts +2 -2
- package/packages/layout-body/src/layout-body.ts +2 -2
- package/packages/layout-container/src/layout-container.ts +3 -14
- package/packages/layout-footer/src/layout-footer.ts +2 -2
- package/packages/layout-header/src/layout-header.ts +2 -2
- package/packages/link/src/link.ts +2 -2
- package/packages/list/src/list.ts +2 -2
- package/packages/loading/src/loading.ts +2 -2
- package/packages/mention/src/mention.ts +2 -2
- package/packages/menu/src/menu.ts +2 -2
- package/packages/modal/src/modal.ts +5 -20
- package/packages/notice-bar/src/notice-bar.ts +2 -2
- package/packages/number-input/src/number-input.ts +3 -17
- package/packages/pager/src/pager.ts +2 -2
- package/packages/password-input/src/password-input.ts +2 -2
- package/packages/print/src/page-break.ts +2 -2
- package/packages/print/src/print.ts +2 -2
- package/packages/pulldown/src/pulldown.ts +2 -2
- package/packages/radio/src/button.ts +3 -16
- package/packages/radio/src/group.ts +3 -17
- package/packages/radio/src/radio.ts +2 -2
- package/packages/rate/src/rate.ts +2 -2
- package/packages/result/src/result.ts +2 -2
- package/packages/row/src/col.ts +2 -2
- package/packages/row/src/row.ts +2 -2
- package/packages/scrollbar/src/scrollbar.ts +3 -4
- package/packages/segmented/src/segmented.ts +2 -2
- package/packages/select/src/optgroup.ts +2 -2
- package/packages/select/src/option.ts +2 -2
- package/packages/select/src/select.ts +33 -19
- package/packages/slider/src/slider.ts +2 -2
- package/packages/space/src/space.ts +2 -2
- package/packages/splitter/src/splitter-panel.ts +2 -2
- package/packages/splitter/src/splitter.ts +2 -2
- package/packages/step-item/index.ts +16 -0
- package/packages/steps/src/step-info.ts +18 -0
- package/packages/steps/src/step-item.ts +41 -0
- package/packages/steps/src/steps.ts +273 -13
- package/packages/steps/src/util.ts +44 -0
- package/packages/switch/src/switch.ts +2 -2
- package/packages/table-select/src/table-select.ts +2 -2
- package/packages/table-transfer/src/table-transfer.ts +3 -15
- package/packages/tabs/src/tab-pane.ts +2 -2
- package/packages/tabs/src/tabs.ts +2 -2
- package/packages/tag/src/tag.ts +2 -2
- package/packages/text/src/text.ts +2 -2
- package/packages/text-ellipsis/src/text-ellipsis.ts +2 -2
- package/packages/textarea/src/textarea.ts +2 -2
- package/packages/timeline/src/timeline-info.ts +17 -17
- package/packages/timeline/src/timeline.ts +93 -49
- package/packages/timeline/src/util.ts +44 -41
- package/packages/tip/src/tip.ts +2 -2
- package/packages/tooltip/src/tooltip.ts +2 -2
- package/packages/tour/src/tour.ts +2 -2
- package/packages/transfer/src/transfer.ts +2 -2
- package/packages/tree/src/tree.ts +2 -2
- package/packages/tree-select/src/tree-select.ts +2 -2
- package/packages/ui/index.ts +8 -1
- package/packages/upload/src/upload.ts +2 -2
- package/packages/watermark/src/watermark.ts +2 -2
- package/styles/all.scss +1 -0
- package/styles/components/step-item.scss +0 -0
- package/styles/components/steps.scss +354 -0
- package/styles/theme/base.scss +9 -0
- package/types/all.d.ts +3 -0
- package/types/components/gantt.d.ts +1 -3
- package/types/components/select.d.ts +1 -13
- package/types/components/step-item.d.ts +72 -0
- package/types/components/steps.d.ts +67 -8
- package/types/components/table.d.ts +7 -66
- package/types/handles/form-design.d.ts +1 -4
- package/types/ui/global-config.d.ts +2 -0
- package/types/ui/global-icon.d.ts +7 -0
- /package/dist/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
- /package/dist/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
- /package/dist/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
- /package/es/icon/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
- /package/es/icon/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
- /package/es/icon/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
- /package/es/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
- /package/es/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
- /package/es/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
- /package/es/vxe-icon/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
- /package/es/vxe-icon/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
- /package/es/vxe-icon/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
- /package/lib/icon/style/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
- /package/lib/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
- /package/lib/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
- /package/lib/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
- /package/lib/vxe-icon/style/{iconfont.1793330162657.ttf → iconfont.1793359478136.ttf} +0 -0
- /package/lib/vxe-icon/style/{iconfont.1793330162657.woff → iconfont.1793359478136.woff} +0 -0
- /package/lib/vxe-icon/style/{iconfont.1793330162657.woff2 → iconfont.1793359478136.woff2} +0 -0
package/es/upload/src/upload.js
CHANGED
|
@@ -29,1727 +29,1796 @@ function createInternalData() {
|
|
|
29
29
|
// prevDragPos: ''
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
var upload_default =
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
32
|
+
var upload_default = (
|
|
33
|
+
/* define-vxe-component start */
|
|
34
|
+
defineVxeComponent({
|
|
35
|
+
name: "VxeUpload",
|
|
36
|
+
props: {
|
|
37
|
+
modelValue: [Array, String, Object],
|
|
38
|
+
showList: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: () => getConfig().upload.showList
|
|
41
|
+
},
|
|
42
|
+
moreConfig: Object,
|
|
43
|
+
readonly: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: null
|
|
46
|
+
},
|
|
47
|
+
disabled: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: null
|
|
50
|
+
},
|
|
51
|
+
autoSubmit: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: () => getConfig().upload.autoSubmit
|
|
54
|
+
},
|
|
55
|
+
mode: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: () => getConfig().upload.mode
|
|
58
|
+
},
|
|
59
|
+
imageTypes: {
|
|
60
|
+
type: Array,
|
|
61
|
+
default: () => XEUtils.clone(getConfig().upload.imageTypes, true)
|
|
62
|
+
},
|
|
63
|
+
imageConfig: {
|
|
64
|
+
type: Object,
|
|
65
|
+
default: () => XEUtils.clone(getConfig().upload.imageConfig, true)
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* 已废弃,被 image-config 替换
|
|
69
|
+
* @deprecated
|
|
70
|
+
*/
|
|
71
|
+
imageStyle: {
|
|
72
|
+
type: Object,
|
|
73
|
+
default: () => XEUtils.clone(getConfig().upload.imageStyle, true)
|
|
74
|
+
},
|
|
75
|
+
fileTypes: {
|
|
76
|
+
type: Array,
|
|
77
|
+
default: () => XEUtils.clone(getConfig().upload.fileTypes, true)
|
|
78
|
+
},
|
|
79
|
+
dragSort: Boolean,
|
|
80
|
+
dragToUpload: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: () => XEUtils.clone(getConfig().upload.dragToUpload, true)
|
|
83
|
+
},
|
|
84
|
+
dragPlaceholder: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: () => getConfig().upload.dragPlaceholder
|
|
87
|
+
},
|
|
88
|
+
pasteToUpload: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: () => XEUtils.clone(getConfig().upload.pasteToUpload, true)
|
|
91
|
+
},
|
|
92
|
+
keyField: String,
|
|
93
|
+
singleMode: Boolean,
|
|
94
|
+
urlMode: Boolean,
|
|
95
|
+
urlArgs: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: () => getConfig().upload.urlArgs
|
|
98
|
+
},
|
|
99
|
+
multiple: Boolean,
|
|
100
|
+
limitSize: {
|
|
101
|
+
type: [String, Number],
|
|
102
|
+
default: () => getConfig().upload.limitSize
|
|
103
|
+
},
|
|
104
|
+
showLimitSize: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: () => getConfig().upload.showLimitSize
|
|
107
|
+
},
|
|
108
|
+
limitSizeText: {
|
|
109
|
+
type: [String, Number, Function],
|
|
110
|
+
default: () => getConfig().upload.limitSizeText
|
|
111
|
+
},
|
|
112
|
+
limitCount: {
|
|
113
|
+
type: [String, Number],
|
|
114
|
+
default: () => getConfig().upload.limitCount
|
|
115
|
+
},
|
|
116
|
+
showLimitCount: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: () => getConfig().upload.showLimitCount
|
|
119
|
+
},
|
|
120
|
+
limitCountText: {
|
|
121
|
+
type: [String, Number, Function],
|
|
122
|
+
default: () => getConfig().upload.limitCountText
|
|
123
|
+
},
|
|
124
|
+
nameField: {
|
|
125
|
+
type: String,
|
|
126
|
+
default: () => getConfig().upload.nameField
|
|
127
|
+
},
|
|
128
|
+
typeField: {
|
|
129
|
+
type: String,
|
|
130
|
+
default: () => getConfig().upload.typeField
|
|
131
|
+
},
|
|
132
|
+
urlField: {
|
|
133
|
+
type: String,
|
|
134
|
+
default: () => getConfig().upload.urlField
|
|
135
|
+
},
|
|
136
|
+
sizeField: {
|
|
137
|
+
type: String,
|
|
138
|
+
default: () => getConfig().upload.sizeField
|
|
139
|
+
},
|
|
140
|
+
showErrorStatus: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
default: () => getConfig().upload.showErrorStatus
|
|
143
|
+
},
|
|
144
|
+
showProgress: {
|
|
145
|
+
type: Boolean,
|
|
146
|
+
default: () => getConfig().upload.showProgress
|
|
147
|
+
},
|
|
148
|
+
progressText: {
|
|
149
|
+
type: [String, Number, Function],
|
|
150
|
+
default: () => getConfig().upload.progressText
|
|
151
|
+
},
|
|
152
|
+
previewImageConfig: Object,
|
|
153
|
+
showSubmitButton: Boolean,
|
|
154
|
+
autoHiddenButton: {
|
|
155
|
+
type: Boolean,
|
|
156
|
+
default: () => getConfig().upload.autoHiddenButton
|
|
157
|
+
},
|
|
158
|
+
showUploadButton: {
|
|
159
|
+
type: Boolean,
|
|
160
|
+
default: () => getConfig().upload.showUploadButton
|
|
161
|
+
},
|
|
162
|
+
buttonText: {
|
|
163
|
+
type: [String, Number, Function],
|
|
164
|
+
default: () => getConfig().upload.buttonText
|
|
165
|
+
},
|
|
166
|
+
buttonIcon: {
|
|
167
|
+
type: String,
|
|
168
|
+
default: () => getConfig().upload.buttonIcon
|
|
169
|
+
},
|
|
170
|
+
showButtonText: {
|
|
171
|
+
type: Boolean,
|
|
172
|
+
default: () => getConfig().upload.showButtonText
|
|
173
|
+
},
|
|
174
|
+
showButtonIcon: {
|
|
175
|
+
type: Boolean,
|
|
176
|
+
default: () => getConfig().upload.showButtonIcon
|
|
177
|
+
},
|
|
178
|
+
showRemoveButton: {
|
|
179
|
+
type: Boolean,
|
|
180
|
+
default: () => getConfig().upload.showRemoveButton
|
|
181
|
+
},
|
|
182
|
+
showDownloadButton: {
|
|
183
|
+
type: Boolean,
|
|
184
|
+
default: () => getConfig().upload.showDownloadButton
|
|
185
|
+
},
|
|
186
|
+
showPreview: {
|
|
187
|
+
type: Boolean,
|
|
188
|
+
default: () => getConfig().upload.showPreview
|
|
189
|
+
},
|
|
190
|
+
showTip: {
|
|
191
|
+
type: Boolean,
|
|
192
|
+
default: () => null
|
|
193
|
+
},
|
|
194
|
+
maxSimultaneousUploads: {
|
|
195
|
+
type: Number,
|
|
196
|
+
default: () => getConfig().upload.maxSimultaneousUploads
|
|
197
|
+
},
|
|
198
|
+
tipText: [String, Number, Function],
|
|
199
|
+
hintText: String,
|
|
200
|
+
previewMethod: Function,
|
|
201
|
+
beforeSelectMethod: Function,
|
|
202
|
+
uploadMethod: Function,
|
|
203
|
+
beforeRemoveMethod: Function,
|
|
204
|
+
removeMethod: Function,
|
|
205
|
+
beforeDownloadMethod: Function,
|
|
206
|
+
downloadMethod: Function,
|
|
207
|
+
getUrlMethod: Function,
|
|
208
|
+
getThumbnailUrlMethod: Function,
|
|
209
|
+
size: {
|
|
210
|
+
type: String,
|
|
211
|
+
default: () => getConfig().upload.size || getConfig().size
|
|
212
|
+
}
|
|
195
213
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const refElem = ref();
|
|
221
|
-
const refPopupElem = ref();
|
|
222
|
-
const refDragLineElem = ref();
|
|
223
|
-
const refModalDragLineElem = ref();
|
|
224
|
-
const reactData = reactive(createReactData());
|
|
225
|
-
const internalData = createInternalData();
|
|
226
|
-
const refMaps = {
|
|
227
|
-
refElem
|
|
228
|
-
};
|
|
229
|
-
const computeFormReadonly = computed(() => {
|
|
230
|
-
const { readonly } = props;
|
|
231
|
-
if (readonly === null) {
|
|
232
|
-
if ($xeForm) {
|
|
233
|
-
return $xeForm.props.readonly;
|
|
214
|
+
emits: ["update:modelValue", "change", "add", "remove", "remove-fail", "download", "download-fail", "upload-start", "upload-success", "upload-error", "upload-end", "upload-queue-start", "upload-queue-end", "sort-dragend", "more-visible"],
|
|
215
|
+
setup(props, context) {
|
|
216
|
+
const { emit, slots } = context;
|
|
217
|
+
const $xeForm = inject("$xeForm", null);
|
|
218
|
+
const formItemInfo = inject("xeFormItemInfo", null);
|
|
219
|
+
const $xeTable = inject("$xeTable", null);
|
|
220
|
+
const xID = XEUtils.uniqueId();
|
|
221
|
+
const { computeSize } = useFns.useSize(props);
|
|
222
|
+
const refElem = ref();
|
|
223
|
+
const refPopupElem = ref();
|
|
224
|
+
const refDragLineElem = ref();
|
|
225
|
+
const refModalDragLineElem = ref();
|
|
226
|
+
const reactData = reactive(createReactData());
|
|
227
|
+
const internalData = createInternalData();
|
|
228
|
+
const refMaps = {
|
|
229
|
+
refElem
|
|
230
|
+
};
|
|
231
|
+
const computeFormReadonly = computed(() => {
|
|
232
|
+
const { readonly } = props;
|
|
233
|
+
if (readonly === null) {
|
|
234
|
+
if ($xeForm) {
|
|
235
|
+
return $xeForm.props.readonly;
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
234
238
|
}
|
|
235
|
-
return
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return
|
|
239
|
+
return readonly;
|
|
240
|
+
});
|
|
241
|
+
const computeIsDisabled = computed(() => {
|
|
242
|
+
const { disabled } = props;
|
|
243
|
+
if (disabled === null) {
|
|
244
|
+
if ($xeForm) {
|
|
245
|
+
return $xeForm.props.disabled;
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
244
248
|
}
|
|
245
|
-
return
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return
|
|
249
|
+
return disabled;
|
|
250
|
+
});
|
|
251
|
+
const computeKeyField = computed(() => {
|
|
252
|
+
return props.keyField || "_X_KEY";
|
|
253
|
+
});
|
|
254
|
+
const computeIsImage = computed(() => {
|
|
255
|
+
return props.mode === "image";
|
|
256
|
+
});
|
|
257
|
+
const computeNameProp = computed(() => {
|
|
258
|
+
return props.nameField || "name";
|
|
259
|
+
});
|
|
260
|
+
const computeTypeProp = computed(() => {
|
|
261
|
+
return props.typeField || "type";
|
|
262
|
+
});
|
|
263
|
+
const computeUrlProp = computed(() => {
|
|
264
|
+
return props.urlField || "url";
|
|
265
|
+
});
|
|
266
|
+
const computeSizeProp = computed(() => {
|
|
267
|
+
return props.sizeField || "size";
|
|
268
|
+
});
|
|
269
|
+
const computeLimitMaxSize = computed(() => {
|
|
270
|
+
return XEUtils.toNumber(props.limitSize) * 1024 * 1024;
|
|
271
|
+
});
|
|
272
|
+
const computeLimitMaxCount = computed(() => {
|
|
273
|
+
return props.multiple ? XEUtils.toNumber(props.limitCount) : 1;
|
|
274
|
+
});
|
|
275
|
+
const computePreviewImageOpts = computed(() => {
|
|
276
|
+
const { showDownloadButton } = props;
|
|
277
|
+
return Object.assign(
|
|
278
|
+
{
|
|
279
|
+
showDownloadButton
|
|
280
|
+
},
|
|
281
|
+
getConfig().upload.previewImageConfig,
|
|
282
|
+
props.previewImageConfig
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
const computeOverCount = computed(() => {
|
|
286
|
+
const { multiple } = props;
|
|
287
|
+
const { fileList } = reactData;
|
|
288
|
+
const limitMaxCount = computeLimitMaxCount.value;
|
|
289
|
+
if (multiple) {
|
|
290
|
+
if (limitMaxCount) {
|
|
291
|
+
return fileList.length >= limitMaxCount;
|
|
292
|
+
}
|
|
293
|
+
return true;
|
|
290
294
|
}
|
|
291
|
-
return
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
return fileList.length >= 1;
|
|
296
|
+
});
|
|
297
|
+
const computeLimitSizeUnit = computed(() => {
|
|
298
|
+
const limitSize = XEUtils.toNumber(props.limitSize);
|
|
299
|
+
if (limitSize) {
|
|
300
|
+
if (limitSize > 1048576) {
|
|
301
|
+
return `${limitSize / 1048576}T`;
|
|
302
|
+
}
|
|
303
|
+
if (limitSize > 1024) {
|
|
304
|
+
return `${limitSize / 1024}G`;
|
|
305
|
+
}
|
|
306
|
+
return `${limitSize}M`;
|
|
300
307
|
}
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
return "";
|
|
309
|
+
});
|
|
310
|
+
const computedShowTipText = computed(() => {
|
|
311
|
+
const { showTip, tipText } = props;
|
|
312
|
+
if (XEUtils.isBoolean(showTip)) {
|
|
313
|
+
return showTip;
|
|
303
314
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
});
|
|
308
|
-
const computedShowTipText = computed(() => {
|
|
309
|
-
const { showTip, tipText } = props;
|
|
310
|
-
if (XEUtils.isBoolean(showTip)) {
|
|
311
|
-
return showTip;
|
|
312
|
-
}
|
|
313
|
-
const defShowTip = getConfig().upload.showTip;
|
|
314
|
-
if (XEUtils.isBoolean(defShowTip)) {
|
|
315
|
-
return defShowTip;
|
|
316
|
-
}
|
|
317
|
-
if (tipText) {
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
|
-
return false;
|
|
321
|
-
});
|
|
322
|
-
const computedDefTipText = computed(() => {
|
|
323
|
-
const { limitSize, fileTypes, multiple, limitCount } = props;
|
|
324
|
-
const tipText = props.tipText || props.hintText;
|
|
325
|
-
const isImage = computeIsImage.value;
|
|
326
|
-
const limitSizeUnit = computeLimitSizeUnit.value;
|
|
327
|
-
if (XEUtils.isString(tipText)) {
|
|
328
|
-
return tipText;
|
|
329
|
-
}
|
|
330
|
-
if (XEUtils.isFunction(tipText)) {
|
|
331
|
-
return `${tipText({})}`;
|
|
332
|
-
}
|
|
333
|
-
const defTips = [];
|
|
334
|
-
if (isImage) {
|
|
335
|
-
if (multiple && limitCount) {
|
|
336
|
-
defTips.push(getI18n("vxe.upload.imgCountHint", [limitCount]));
|
|
315
|
+
const defShowTip = getConfig().upload.showTip;
|
|
316
|
+
if (XEUtils.isBoolean(defShowTip)) {
|
|
317
|
+
return defShowTip;
|
|
337
318
|
}
|
|
338
|
-
if (
|
|
339
|
-
|
|
319
|
+
if (tipText) {
|
|
320
|
+
return true;
|
|
340
321
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
322
|
+
return false;
|
|
323
|
+
});
|
|
324
|
+
const computedDefTipText = computed(() => {
|
|
325
|
+
const { limitSize, fileTypes, multiple, limitCount } = props;
|
|
326
|
+
const tipText = props.tipText || props.hintText;
|
|
327
|
+
const isImage = computeIsImage.value;
|
|
328
|
+
const limitSizeUnit = computeLimitSizeUnit.value;
|
|
329
|
+
if (XEUtils.isString(tipText)) {
|
|
330
|
+
return tipText;
|
|
344
331
|
}
|
|
345
|
-
if (
|
|
346
|
-
|
|
332
|
+
if (XEUtils.isFunction(tipText)) {
|
|
333
|
+
return `${tipText({})}`;
|
|
347
334
|
}
|
|
348
|
-
|
|
349
|
-
|
|
335
|
+
const defTips = [];
|
|
336
|
+
if (isImage) {
|
|
337
|
+
if (multiple && limitCount) {
|
|
338
|
+
defTips.push(getI18n("vxe.upload.imgCountHint", [limitCount]));
|
|
339
|
+
}
|
|
340
|
+
if (limitSize && limitSizeUnit) {
|
|
341
|
+
defTips.push(getI18n("vxe.upload.imgSizeHint", [limitSizeUnit]));
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
if (fileTypes && fileTypes.length) {
|
|
345
|
+
defTips.push(getI18n("vxe.upload.fileTypeHint", [fileTypes.join("/")]));
|
|
346
|
+
}
|
|
347
|
+
if (limitSize && limitSizeUnit) {
|
|
348
|
+
defTips.push(getI18n("vxe.upload.fileSizeHint", [limitSizeUnit]));
|
|
349
|
+
}
|
|
350
|
+
if (multiple && limitCount) {
|
|
351
|
+
defTips.push(getI18n("vxe.upload.fileCountHint", [limitCount]));
|
|
352
|
+
}
|
|
350
353
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
stys.width = toCssUnit(width);
|
|
363
|
-
}
|
|
364
|
-
if (height) {
|
|
365
|
-
stys.height = toCssUnit(height);
|
|
366
|
-
}
|
|
367
|
-
return stys;
|
|
368
|
-
});
|
|
369
|
-
const computeMoreOpts = computed(() => {
|
|
370
|
-
return Object.assign({ showMoreButton: true }, props.moreConfig);
|
|
371
|
-
});
|
|
372
|
-
const computeMaps = {
|
|
373
|
-
computeUrlProp
|
|
374
|
-
};
|
|
375
|
-
const $xeUpload = {
|
|
376
|
-
xID,
|
|
377
|
-
props,
|
|
378
|
-
context,
|
|
379
|
-
reactData,
|
|
380
|
-
internalData,
|
|
381
|
-
getRefMaps: () => refMaps,
|
|
382
|
-
getComputeMaps: () => computeMaps
|
|
383
|
-
};
|
|
384
|
-
const getUniqueKey = () => {
|
|
385
|
-
return XEUtils.uniqueId();
|
|
386
|
-
};
|
|
387
|
-
const getFieldKey = (item) => {
|
|
388
|
-
const keyField = computeKeyField.value;
|
|
389
|
-
return item[keyField];
|
|
390
|
-
};
|
|
391
|
-
const updateFileList = () => {
|
|
392
|
-
const { modelValue, multiple } = props;
|
|
393
|
-
const formReadonly = computeFormReadonly.value;
|
|
394
|
-
const keyField = computeKeyField.value;
|
|
395
|
-
const nameProp = computeNameProp.value;
|
|
396
|
-
const typeProp = computeTypeProp.value;
|
|
397
|
-
const urlProp = computeUrlProp.value;
|
|
398
|
-
const sizeProp = computeSizeProp.value;
|
|
399
|
-
const fileList = modelValue ? (modelValue ? XEUtils.isArray(modelValue) ? modelValue : [modelValue] : []).map((item) => {
|
|
400
|
-
if (!item || XEUtils.isString(item)) {
|
|
401
|
-
const url = `${item || ""}`;
|
|
402
|
-
const urlObj = XEUtils.parseUrl(item);
|
|
403
|
-
const name2 = (urlObj ? urlObj.searchQuery[nameProp] : "") || parseFileName(url);
|
|
404
|
-
return {
|
|
405
|
-
[nameProp]: name2,
|
|
406
|
-
[typeProp]: (urlObj ? urlObj.searchQuery[typeProp] : "") || parseFileType(name2),
|
|
407
|
-
[urlProp]: url,
|
|
408
|
-
[sizeProp]: XEUtils.toNumber(urlObj ? urlObj.searchQuery[sizeProp] : 0) || 0,
|
|
409
|
-
[keyField]: getUniqueKey()
|
|
410
|
-
};
|
|
354
|
+
return defTips.join(getI18n("vxe.base.comma"));
|
|
355
|
+
});
|
|
356
|
+
const computeImageOpts = computed(() => {
|
|
357
|
+
return Object.assign({}, props.imageConfig || props.imageStyle);
|
|
358
|
+
});
|
|
359
|
+
const computeImgStyle = computed(() => {
|
|
360
|
+
const imageOpts = computeImageOpts.value;
|
|
361
|
+
const { width, height } = imageOpts;
|
|
362
|
+
const stys = {};
|
|
363
|
+
if (width) {
|
|
364
|
+
stys.width = toCssUnit(width);
|
|
411
365
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
return
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
366
|
+
if (height) {
|
|
367
|
+
stys.height = toCssUnit(height);
|
|
368
|
+
}
|
|
369
|
+
return stys;
|
|
370
|
+
});
|
|
371
|
+
const computeMoreOpts = computed(() => {
|
|
372
|
+
return Object.assign({ showMoreButton: true }, props.moreConfig);
|
|
373
|
+
});
|
|
374
|
+
const computeMaps = {
|
|
375
|
+
computeUrlProp
|
|
376
|
+
};
|
|
377
|
+
const $xeUpload = {
|
|
378
|
+
xID,
|
|
379
|
+
props,
|
|
380
|
+
context,
|
|
381
|
+
reactData,
|
|
382
|
+
internalData,
|
|
383
|
+
getRefMaps: () => refMaps,
|
|
384
|
+
getComputeMaps: () => computeMaps
|
|
385
|
+
};
|
|
386
|
+
const getUniqueKey = () => {
|
|
387
|
+
return XEUtils.uniqueId();
|
|
388
|
+
};
|
|
389
|
+
const getFieldKey = (item) => {
|
|
390
|
+
const keyField = computeKeyField.value;
|
|
391
|
+
return item[keyField];
|
|
392
|
+
};
|
|
393
|
+
const updateFileList = () => {
|
|
394
|
+
const { modelValue, multiple } = props;
|
|
395
|
+
const formReadonly = computeFormReadonly.value;
|
|
396
|
+
const keyField = computeKeyField.value;
|
|
397
|
+
const nameProp = computeNameProp.value;
|
|
398
|
+
const typeProp = computeTypeProp.value;
|
|
399
|
+
const urlProp = computeUrlProp.value;
|
|
400
|
+
const sizeProp = computeSizeProp.value;
|
|
401
|
+
const fileList = modelValue ? (modelValue ? XEUtils.isArray(modelValue) ? modelValue : [modelValue] : []).map((item) => {
|
|
402
|
+
if (!item || XEUtils.isString(item)) {
|
|
403
|
+
const url = `${item || ""}`;
|
|
404
|
+
const urlObj = XEUtils.parseUrl(item);
|
|
405
|
+
const name2 = (urlObj ? urlObj.searchQuery[nameProp] : "") || parseFileName(url);
|
|
406
|
+
return {
|
|
407
|
+
[nameProp]: name2,
|
|
408
|
+
[typeProp]: (urlObj ? urlObj.searchQuery[typeProp] : "") || parseFileType(name2),
|
|
409
|
+
[urlProp]: url,
|
|
410
|
+
[sizeProp]: XEUtils.toNumber(urlObj ? urlObj.searchQuery[sizeProp] : 0) || 0,
|
|
411
|
+
[keyField]: getUniqueKey()
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
const name = item[nameProp] || "";
|
|
415
|
+
item[nameProp] = name;
|
|
416
|
+
item[typeProp] = item[typeProp] || parseFileType(name);
|
|
417
|
+
item[urlProp] = item[urlProp] || "";
|
|
418
|
+
item[sizeProp] = item[sizeProp] || 0;
|
|
419
|
+
item[keyField] = item[keyField] || getUniqueKey();
|
|
420
|
+
return item;
|
|
421
|
+
}) : [];
|
|
422
|
+
reactData.fileList = formReadonly || multiple ? fileList : fileList.slice(0, 1);
|
|
423
|
+
};
|
|
424
|
+
const parseFileName = (url) => {
|
|
425
|
+
return decodeURIComponent(`${url || ""}`).split("/").pop() || "";
|
|
426
|
+
};
|
|
427
|
+
const parseFileType = (name) => {
|
|
428
|
+
const index = name.lastIndexOf(".");
|
|
429
|
+
if (index > 0) {
|
|
430
|
+
return name.substring(index + 1).toLowerCase();
|
|
431
|
+
}
|
|
432
|
+
return "";
|
|
433
|
+
};
|
|
434
|
+
const dispatchEvent = (type, params, evnt) => {
|
|
435
|
+
emit(type, createEvent(evnt, { $upload: $xeUpload }, params));
|
|
436
|
+
};
|
|
437
|
+
const emitModel = (value) => {
|
|
438
|
+
emit("update:modelValue", value);
|
|
439
|
+
};
|
|
440
|
+
const handleModel = (vals) => {
|
|
441
|
+
const { singleMode, urlMode, urlArgs } = props;
|
|
442
|
+
const urlProp = computeUrlProp.value;
|
|
443
|
+
const nameProp = computeNameProp.value;
|
|
444
|
+
let restList = vals ? vals.slice(0) : [];
|
|
445
|
+
if (urlMode) {
|
|
446
|
+
restList = restList.map((item) => {
|
|
447
|
+
const url = item[urlProp];
|
|
448
|
+
if (url && urlArgs) {
|
|
449
|
+
const urlObj = XEUtils.parseUrl(url);
|
|
450
|
+
if (!urlObj.searchQuery[nameProp]) {
|
|
451
|
+
if (url.indexOf("blob:") === -1) {
|
|
452
|
+
return `${url}${url.indexOf("?") === -1 ? "?" : "&"}${nameProp}=${encodeURIComponent(item[nameProp] || "")}`;
|
|
453
|
+
}
|
|
451
454
|
}
|
|
452
455
|
}
|
|
453
|
-
|
|
454
|
-
return url;
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
const value = singleMode ? restList[0] || null : restList;
|
|
458
|
-
emitModel(value);
|
|
459
|
-
return value;
|
|
460
|
-
};
|
|
461
|
-
const handleChangeEvent = (evnt, vals) => {
|
|
462
|
-
const value = handleModel(vals);
|
|
463
|
-
dispatchEvent("change", { value }, evnt);
|
|
464
|
-
return value;
|
|
465
|
-
};
|
|
466
|
-
const getThumbnailFileUrl = (item) => {
|
|
467
|
-
const getThumbnailUrlFn = props.getThumbnailUrlMethod || getConfig().upload.getThumbnailUrlMethod;
|
|
468
|
-
if (getThumbnailUrlFn) {
|
|
469
|
-
return getThumbnailUrlFn({
|
|
470
|
-
$upload: $xeUpload,
|
|
471
|
-
option: item
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
return getFileUrl(item);
|
|
475
|
-
};
|
|
476
|
-
const getFileUrl = (item) => {
|
|
477
|
-
const getUrlFn = props.getUrlMethod || getConfig().upload.getUrlMethod;
|
|
478
|
-
const urlProp = computeUrlProp.value;
|
|
479
|
-
return getUrlFn ? getUrlFn({
|
|
480
|
-
$upload: $xeUpload,
|
|
481
|
-
option: item
|
|
482
|
-
}) : item[urlProp];
|
|
483
|
-
};
|
|
484
|
-
const handleDefaultFilePreview = (item) => {
|
|
485
|
-
const { imageTypes, showDownloadButton } = props;
|
|
486
|
-
const typeProp = computeTypeProp.value;
|
|
487
|
-
const previewImageOpts = computePreviewImageOpts.value;
|
|
488
|
-
const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
|
|
489
|
-
const { imagePreviewTypes } = internalData;
|
|
490
|
-
if (imagePreviewTypes.concat(imageTypes || []).some((type) => `${type}`.toLowerCase() === `${item[typeProp]}`.toLowerCase())) {
|
|
491
|
-
if (VxeUI.previewImage) {
|
|
492
|
-
VxeUI.previewImage({
|
|
493
|
-
...previewImageOpts,
|
|
494
|
-
urlList: [getFileUrl(item)],
|
|
495
|
-
showDownloadButton,
|
|
496
|
-
beforeDownloadMethod: beforeDownloadFn ? () => {
|
|
497
|
-
return beforeDownloadFn({
|
|
498
|
-
$upload: $xeUpload,
|
|
499
|
-
option: item
|
|
500
|
-
});
|
|
501
|
-
} : void 0
|
|
456
|
+
return url;
|
|
502
457
|
});
|
|
503
458
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
459
|
+
const value = singleMode ? restList[0] || null : restList;
|
|
460
|
+
emitModel(value);
|
|
461
|
+
return value;
|
|
462
|
+
};
|
|
463
|
+
const handleChangeEvent = (evnt, vals) => {
|
|
464
|
+
const value = handleModel(vals);
|
|
465
|
+
dispatchEvent("change", { value }, evnt);
|
|
466
|
+
return value;
|
|
467
|
+
};
|
|
468
|
+
const getThumbnailFileUrl = (item) => {
|
|
469
|
+
const getThumbnailUrlFn = props.getThumbnailUrlMethod || getConfig().upload.getThumbnailUrlMethod;
|
|
470
|
+
if (getThumbnailUrlFn) {
|
|
471
|
+
return getThumbnailUrlFn({
|
|
511
472
|
$upload: $xeUpload,
|
|
512
473
|
option: item
|
|
513
474
|
});
|
|
514
|
-
} else {
|
|
515
|
-
handleDefaultFilePreview(item);
|
|
516
475
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
476
|
+
return getFileUrl(item);
|
|
477
|
+
};
|
|
478
|
+
const getFileUrl = (item) => {
|
|
479
|
+
const getUrlFn = props.getUrlMethod || getConfig().upload.getUrlMethod;
|
|
480
|
+
const urlProp = computeUrlProp.value;
|
|
481
|
+
return getUrlFn ? getUrlFn({
|
|
482
|
+
$upload: $xeUpload,
|
|
483
|
+
option: item
|
|
484
|
+
}) : item[urlProp];
|
|
485
|
+
};
|
|
486
|
+
const handleDefaultFilePreview = (item) => {
|
|
487
|
+
const { imageTypes, showDownloadButton } = props;
|
|
488
|
+
const typeProp = computeTypeProp.value;
|
|
489
|
+
const previewImageOpts = computePreviewImageOpts.value;
|
|
490
|
+
const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
|
|
491
|
+
const { imagePreviewTypes } = internalData;
|
|
492
|
+
if (imagePreviewTypes.concat(imageTypes || []).some((type) => `${type}`.toLowerCase() === `${item[typeProp]}`.toLowerCase())) {
|
|
493
|
+
if (VxeUI.previewImage) {
|
|
494
|
+
VxeUI.previewImage({
|
|
495
|
+
...previewImageOpts,
|
|
496
|
+
urlList: [getFileUrl(item)],
|
|
497
|
+
showDownloadButton,
|
|
498
|
+
beforeDownloadMethod: beforeDownloadFn ? () => {
|
|
499
|
+
return beforeDownloadFn({
|
|
500
|
+
$upload: $xeUpload,
|
|
501
|
+
option: item
|
|
502
|
+
});
|
|
503
|
+
} : void 0
|
|
504
|
+
});
|
|
505
|
+
}
|
|
544
506
|
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
file,
|
|
557
|
-
option: item,
|
|
558
|
-
updateProgress(percentNum) {
|
|
559
|
-
const { fileCacheMaps } = reactData;
|
|
560
|
-
const cacheItem = fileCacheMaps[getFieldKey(item)];
|
|
561
|
-
if (cacheItem) {
|
|
562
|
-
cacheItem.percent = Math.max(0, Math.min(99, XEUtils.toNumber(percentNum)));
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
})
|
|
566
|
-
).then((res) => {
|
|
567
|
-
const { fileCacheMaps } = reactData;
|
|
568
|
-
const cacheItem = fileCacheMaps[fileKey];
|
|
569
|
-
if (cacheItem) {
|
|
570
|
-
cacheItem.percent = 100;
|
|
571
|
-
cacheItem.status = "success";
|
|
572
|
-
cacheItem.response = res;
|
|
507
|
+
};
|
|
508
|
+
const handlePreviewFileEvent = (evnt, item) => {
|
|
509
|
+
const previewFn = props.previewMethod || getConfig().upload.previewMethod;
|
|
510
|
+
if (props.showPreview) {
|
|
511
|
+
if (previewFn) {
|
|
512
|
+
previewFn({
|
|
513
|
+
$upload: $xeUpload,
|
|
514
|
+
option: item
|
|
515
|
+
});
|
|
516
|
+
} else {
|
|
517
|
+
handleDefaultFilePreview(item);
|
|
573
518
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
const handlePreviewImageEvent = (evnt, item, index) => {
|
|
522
|
+
const { showDownloadButton } = props;
|
|
523
|
+
const { fileList } = reactData;
|
|
524
|
+
const previewImageOpts = computePreviewImageOpts.value;
|
|
525
|
+
const previewFn = props.previewMethod || getConfig().upload.previewMethod;
|
|
526
|
+
const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
|
|
527
|
+
if (props.showPreview) {
|
|
528
|
+
if (previewFn) {
|
|
529
|
+
previewFn({
|
|
530
|
+
$upload: $xeUpload,
|
|
531
|
+
option: item
|
|
532
|
+
});
|
|
533
|
+
} else if (VxeUI.previewImage) {
|
|
534
|
+
VxeUI.previewImage({
|
|
535
|
+
...previewImageOpts,
|
|
536
|
+
urlList: fileList.map((item2) => getFileUrl(item2)),
|
|
537
|
+
activeIndex: index,
|
|
538
|
+
showDownloadButton,
|
|
539
|
+
beforeDownloadMethod: beforeDownloadFn ? ({ index: index2 }) => {
|
|
540
|
+
return beforeDownloadFn({
|
|
541
|
+
$upload: $xeUpload,
|
|
542
|
+
option: fileList[index2]
|
|
543
|
+
});
|
|
544
|
+
} : void 0
|
|
545
|
+
});
|
|
583
546
|
}
|
|
584
|
-
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
const handleUploadResult = (item, file) => {
|
|
550
|
+
const { showErrorStatus } = props;
|
|
551
|
+
const fileKey = getFieldKey(item);
|
|
552
|
+
const uploadFn = props.uploadMethod || getConfig().upload.uploadMethod;
|
|
553
|
+
if (uploadFn) {
|
|
554
|
+
dispatchEvent("upload-start", { option: item }, null);
|
|
555
|
+
return Promise.resolve(
|
|
556
|
+
uploadFn({
|
|
557
|
+
$upload: $xeUpload,
|
|
558
|
+
file,
|
|
559
|
+
option: item,
|
|
560
|
+
updateProgress(percentNum) {
|
|
561
|
+
const { fileCacheMaps } = reactData;
|
|
562
|
+
const cacheItem = fileCacheMaps[getFieldKey(item)];
|
|
563
|
+
if (cacheItem) {
|
|
564
|
+
cacheItem.percent = Math.max(0, Math.min(99, XEUtils.toNumber(percentNum)));
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
})
|
|
568
|
+
).then((res) => {
|
|
569
|
+
const { fileCacheMaps } = reactData;
|
|
570
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
571
|
+
if (cacheItem) {
|
|
572
|
+
cacheItem.percent = 100;
|
|
573
|
+
cacheItem.status = "success";
|
|
574
|
+
cacheItem.response = res;
|
|
575
|
+
}
|
|
585
576
|
Object.assign(item, res);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
577
|
+
handleModel(reactData.fileList);
|
|
578
|
+
dispatchEvent("upload-success", { option: item, data: res }, null);
|
|
579
|
+
}).catch((res) => {
|
|
580
|
+
const { fileCacheMaps } = reactData;
|
|
581
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
582
|
+
if (cacheItem) {
|
|
583
|
+
cacheItem.status = "error";
|
|
584
|
+
cacheItem.response = res;
|
|
585
|
+
}
|
|
586
|
+
if (showErrorStatus) {
|
|
587
|
+
Object.assign(item, res);
|
|
588
|
+
} else {
|
|
589
|
+
reactData.fileList = reactData.fileList.filter((obj) => getFieldKey(obj) !== fileKey);
|
|
590
|
+
delete fileCacheMaps[fileKey];
|
|
591
|
+
}
|
|
592
|
+
handleModel(reactData.fileList);
|
|
593
|
+
dispatchEvent("upload-error", { option: item, data: res }, null);
|
|
594
|
+
}).finally(() => {
|
|
595
|
+
const { fileCacheMaps } = reactData;
|
|
596
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
597
|
+
if (cacheItem) {
|
|
598
|
+
cacheItem.loading = false;
|
|
599
|
+
}
|
|
600
|
+
const result = {
|
|
601
|
+
option: item,
|
|
602
|
+
status: cacheItem ? cacheItem.status : null,
|
|
603
|
+
response: cacheItem ? cacheItem.response : null
|
|
604
|
+
};
|
|
605
|
+
dispatchEvent("upload-end", { option: item, result }, null);
|
|
606
|
+
});
|
|
607
|
+
} else {
|
|
593
608
|
const { fileCacheMaps } = reactData;
|
|
594
609
|
const cacheItem = fileCacheMaps[fileKey];
|
|
595
610
|
if (cacheItem) {
|
|
596
611
|
cacheItem.loading = false;
|
|
597
612
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
dispatchEvent("upload-end", { option: item, result }, null);
|
|
604
|
-
});
|
|
605
|
-
} else {
|
|
613
|
+
}
|
|
614
|
+
return Promise.resolve();
|
|
615
|
+
};
|
|
616
|
+
const handleReUploadEvent = (evnt, item) => {
|
|
617
|
+
const { uploadMethod, urlMode } = props;
|
|
606
618
|
const { fileCacheMaps } = reactData;
|
|
619
|
+
const fileKey = getFieldKey(item);
|
|
607
620
|
const cacheItem = fileCacheMaps[fileKey];
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const uploadFn = uploadMethod || getConfig().upload.uploadMethod;
|
|
620
|
-
if (uploadFn && cacheItem) {
|
|
621
|
-
const file = cacheItem.file;
|
|
622
|
-
cacheItem.loading = true;
|
|
623
|
-
cacheItem.status = "pending";
|
|
624
|
-
cacheItem.percent = 0;
|
|
625
|
-
handleUploadResult(item, file).then(() => {
|
|
626
|
-
if (urlMode) {
|
|
627
|
-
handleChangeEvent(evnt, reactData.fileList);
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
const handleUploadFile = (files, evnt) => {
|
|
633
|
-
const { multiple, showLimitSize, limitSizeText, showLimitCount, limitCountText, autoSubmit } = props;
|
|
634
|
-
const { fileList } = reactData;
|
|
635
|
-
const beforeSelectFn = props.beforeSelectMethod || getConfig().upload.beforeSelectMethod;
|
|
636
|
-
const uploadFn = props.uploadMethod || getConfig().upload.uploadMethod;
|
|
637
|
-
const keyField = computeKeyField.value;
|
|
638
|
-
const nameProp = computeNameProp.value;
|
|
639
|
-
const typeProp = computeTypeProp.value;
|
|
640
|
-
const urlProp = computeUrlProp.value;
|
|
641
|
-
const sizeProp = computeSizeProp.value;
|
|
642
|
-
const limitMaxSize = computeLimitMaxSize.value;
|
|
643
|
-
const limitMaxCount = computeLimitMaxCount.value;
|
|
644
|
-
const limitSizeUnit = computeLimitSizeUnit.value;
|
|
645
|
-
let selectFiles = files;
|
|
646
|
-
if (multiple && limitMaxCount) {
|
|
647
|
-
if (showLimitCount && fileList.length >= limitMaxCount) {
|
|
648
|
-
if (VxeUI.modal) {
|
|
649
|
-
VxeUI.modal.notification({
|
|
650
|
-
title: getI18n("vxe.modal.errTitle"),
|
|
651
|
-
status: "error",
|
|
652
|
-
content: limitCountText ? `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}` : getI18n("vxe.upload.overCountErr", [limitMaxCount])
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
const overNum = selectFiles.length - (limitMaxCount - fileList.length);
|
|
658
|
-
if (showLimitCount && overNum > 0) {
|
|
659
|
-
const overExtraList = selectFiles.slice(limitMaxCount - fileList.length);
|
|
660
|
-
if (limitCountText) {
|
|
661
|
-
VxeUI.modal.notification({
|
|
662
|
-
title: getI18n("vxe.modal.errTitle"),
|
|
663
|
-
status: "error",
|
|
664
|
-
content: `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}`
|
|
665
|
-
});
|
|
666
|
-
} else if (VxeUI.modal) {
|
|
667
|
-
VxeUI.modal.notification({
|
|
668
|
-
title: getI18n("vxe.modal.errTitle"),
|
|
669
|
-
status: "error",
|
|
670
|
-
width: null,
|
|
671
|
-
slots: {
|
|
672
|
-
default() {
|
|
673
|
-
return h(
|
|
674
|
-
"div",
|
|
675
|
-
{
|
|
676
|
-
class: "vxe-upload--file-message-over-error"
|
|
677
|
-
},
|
|
678
|
-
[
|
|
679
|
-
h("div", {}, getI18n("vxe.upload.overCountExtraErr", [limitMaxCount, overNum])),
|
|
680
|
-
h(
|
|
681
|
-
"div",
|
|
682
|
-
{
|
|
683
|
-
class: "vxe-upload--file-message-over-extra"
|
|
684
|
-
},
|
|
685
|
-
overExtraList.map((file, index) => {
|
|
686
|
-
return h(
|
|
687
|
-
"div",
|
|
688
|
-
{
|
|
689
|
-
key: index,
|
|
690
|
-
class: "vxe-upload--file-message-over-extra-item"
|
|
691
|
-
},
|
|
692
|
-
file.name
|
|
693
|
-
);
|
|
694
|
-
})
|
|
695
|
-
)
|
|
696
|
-
]
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
});
|
|
701
|
-
}
|
|
621
|
+
const uploadFn = uploadMethod || getConfig().upload.uploadMethod;
|
|
622
|
+
if (uploadFn && cacheItem) {
|
|
623
|
+
const file = cacheItem.file;
|
|
624
|
+
cacheItem.loading = true;
|
|
625
|
+
cacheItem.status = "pending";
|
|
626
|
+
cacheItem.percent = 0;
|
|
627
|
+
handleUploadResult(item, file).then(() => {
|
|
628
|
+
if (urlMode) {
|
|
629
|
+
handleChangeEvent(evnt, reactData.fileList);
|
|
630
|
+
}
|
|
631
|
+
});
|
|
702
632
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
633
|
+
};
|
|
634
|
+
const handleUploadFile = (files, evnt) => {
|
|
635
|
+
const { multiple, showLimitSize, limitSizeText, showLimitCount, limitCountText, autoSubmit } = props;
|
|
636
|
+
const { fileList } = reactData;
|
|
637
|
+
const beforeSelectFn = props.beforeSelectMethod || getConfig().upload.beforeSelectMethod;
|
|
638
|
+
const uploadFn = props.uploadMethod || getConfig().upload.uploadMethod;
|
|
639
|
+
const keyField = computeKeyField.value;
|
|
640
|
+
const nameProp = computeNameProp.value;
|
|
641
|
+
const typeProp = computeTypeProp.value;
|
|
642
|
+
const urlProp = computeUrlProp.value;
|
|
643
|
+
const sizeProp = computeSizeProp.value;
|
|
644
|
+
const limitMaxSize = computeLimitMaxSize.value;
|
|
645
|
+
const limitMaxCount = computeLimitMaxCount.value;
|
|
646
|
+
const limitSizeUnit = computeLimitSizeUnit.value;
|
|
647
|
+
let selectFiles = files;
|
|
648
|
+
if (multiple && limitMaxCount) {
|
|
649
|
+
if (showLimitCount && fileList.length >= limitMaxCount) {
|
|
709
650
|
if (VxeUI.modal) {
|
|
710
651
|
VxeUI.modal.notification({
|
|
711
652
|
title: getI18n("vxe.modal.errTitle"),
|
|
712
653
|
status: "error",
|
|
713
|
-
content:
|
|
654
|
+
content: limitCountText ? `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}` : getI18n("vxe.upload.overCountErr", [limitMaxCount])
|
|
714
655
|
});
|
|
715
656
|
}
|
|
716
657
|
return;
|
|
717
658
|
}
|
|
659
|
+
const overNum = selectFiles.length - (limitMaxCount - fileList.length);
|
|
660
|
+
if (showLimitCount && overNum > 0) {
|
|
661
|
+
const overExtraList = selectFiles.slice(limitMaxCount - fileList.length);
|
|
662
|
+
if (limitCountText) {
|
|
663
|
+
VxeUI.modal.notification({
|
|
664
|
+
title: getI18n("vxe.modal.errTitle"),
|
|
665
|
+
status: "error",
|
|
666
|
+
content: `${XEUtils.isFunction(limitCountText) ? limitCountText({ maxCount: limitMaxCount }) : limitCountText}`
|
|
667
|
+
});
|
|
668
|
+
} else if (VxeUI.modal) {
|
|
669
|
+
VxeUI.modal.notification({
|
|
670
|
+
title: getI18n("vxe.modal.errTitle"),
|
|
671
|
+
status: "error",
|
|
672
|
+
width: null,
|
|
673
|
+
slots: {
|
|
674
|
+
default() {
|
|
675
|
+
return h(
|
|
676
|
+
"div",
|
|
677
|
+
{
|
|
678
|
+
class: "vxe-upload--file-message-over-error"
|
|
679
|
+
},
|
|
680
|
+
[
|
|
681
|
+
h("div", {}, getI18n("vxe.upload.overCountExtraErr", [limitMaxCount, overNum])),
|
|
682
|
+
h(
|
|
683
|
+
"div",
|
|
684
|
+
{
|
|
685
|
+
class: "vxe-upload--file-message-over-extra"
|
|
686
|
+
},
|
|
687
|
+
overExtraList.map((file, index) => {
|
|
688
|
+
return h(
|
|
689
|
+
"div",
|
|
690
|
+
{
|
|
691
|
+
key: index,
|
|
692
|
+
class: "vxe-upload--file-message-over-extra-item"
|
|
693
|
+
},
|
|
694
|
+
file.name
|
|
695
|
+
);
|
|
696
|
+
})
|
|
697
|
+
)
|
|
698
|
+
]
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
selectFiles = selectFiles.slice(0, limitMaxCount - fileList.length);
|
|
718
706
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
[urlProp]: URL.createObjectURL(file),
|
|
733
|
-
[keyField]: fileKey
|
|
734
|
-
};
|
|
735
|
-
if (uploadFn) {
|
|
736
|
-
cacheMaps[fileKey] = {
|
|
737
|
-
file,
|
|
738
|
-
loading: !!autoSubmit,
|
|
739
|
-
status: "pending",
|
|
740
|
-
percent: 0,
|
|
741
|
-
response: null
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
const item = reactive(fileObj);
|
|
745
|
-
if (!beforeSelectFn || beforeSelectFn({ $upload: $xeUpload, file })) {
|
|
746
|
-
if (uploadFn && autoSubmit) {
|
|
747
|
-
uploadPromiseRests.push(handleUploadResult(item, file));
|
|
707
|
+
if (showLimitSize && limitMaxSize) {
|
|
708
|
+
for (let i = 0; i < files.length; i++) {
|
|
709
|
+
const file = files[0];
|
|
710
|
+
if (file.size > limitMaxSize) {
|
|
711
|
+
if (VxeUI.modal) {
|
|
712
|
+
VxeUI.modal.notification({
|
|
713
|
+
title: getI18n("vxe.modal.errTitle"),
|
|
714
|
+
status: "error",
|
|
715
|
+
content: limitSizeText ? `${XEUtils.isFunction(limitSizeText) ? limitSizeText({ maxSize: limitMaxSize }) : limitSizeText}` : getI18n("vxe.upload.overSizeErr", [limitSizeUnit])
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
748
720
|
}
|
|
749
|
-
newFileList.push(item);
|
|
750
|
-
uploadFileList.push(item);
|
|
751
721
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
status: cacheItem ? cacheItem.status : null,
|
|
767
|
-
response: cacheItem ? cacheItem.response : null
|
|
722
|
+
dispatchEvent("upload-queue-start", { files: selectFiles }, evnt);
|
|
723
|
+
const cacheMaps = Object.assign({}, reactData.fileCacheMaps);
|
|
724
|
+
const uploadFileList = multiple ? fileList : [];
|
|
725
|
+
const newFileList = [];
|
|
726
|
+
const uploadPromiseRests = [];
|
|
727
|
+
selectFiles.forEach((file) => {
|
|
728
|
+
const { name } = file;
|
|
729
|
+
const fileKey = getUniqueKey();
|
|
730
|
+
const fileObj = {
|
|
731
|
+
[nameProp]: name,
|
|
732
|
+
[typeProp]: parseFileType(name),
|
|
733
|
+
[sizeProp]: file.size,
|
|
734
|
+
[urlProp]: URL.createObjectURL(file),
|
|
735
|
+
[keyField]: fileKey
|
|
768
736
|
};
|
|
737
|
+
if (uploadFn) {
|
|
738
|
+
cacheMaps[fileKey] = {
|
|
739
|
+
file,
|
|
740
|
+
loading: !!autoSubmit,
|
|
741
|
+
status: "pending",
|
|
742
|
+
percent: 0,
|
|
743
|
+
response: null
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
const item = reactive(fileObj);
|
|
747
|
+
if (!beforeSelectFn || beforeSelectFn({ $upload: $xeUpload, file })) {
|
|
748
|
+
if (uploadFn && autoSubmit) {
|
|
749
|
+
uploadPromiseRests.push(handleUploadResult(item, file));
|
|
750
|
+
}
|
|
751
|
+
newFileList.push(item);
|
|
752
|
+
uploadFileList.push(item);
|
|
753
|
+
}
|
|
769
754
|
});
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
755
|
+
reactData.fileList = uploadFileList;
|
|
756
|
+
reactData.fileCacheMaps = cacheMaps;
|
|
757
|
+
uploadFileList.forEach((item) => {
|
|
758
|
+
dispatchEvent("add", { option: item }, evnt);
|
|
759
|
+
});
|
|
760
|
+
Promise.all(uploadPromiseRests).then(() => {
|
|
761
|
+
const { fileCacheMaps } = reactData;
|
|
762
|
+
const restFileList = reactData.fileList;
|
|
763
|
+
const uploadResults = newFileList.map((option) => {
|
|
764
|
+
const fileKey = getFieldKey(option);
|
|
765
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
766
|
+
return {
|
|
767
|
+
option,
|
|
768
|
+
status: cacheItem ? cacheItem.status : null,
|
|
769
|
+
response: cacheItem ? cacheItem.response : null
|
|
770
|
+
};
|
|
771
|
+
});
|
|
772
|
+
const value = handleChangeEvent(evnt, restFileList);
|
|
773
|
+
dispatchEvent("upload-queue-end", { value, options: restFileList, results: uploadResults, files: selectFiles }, evnt);
|
|
774
|
+
if ($xeForm && formItemInfo) {
|
|
775
|
+
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
};
|
|
779
|
+
const handleChoose = (evnt) => {
|
|
780
|
+
const { multiple, imageTypes, fileTypes } = props;
|
|
781
|
+
const isDisabled = computeIsDisabled.value;
|
|
782
|
+
const isImage = computeIsImage.value;
|
|
783
|
+
if (isDisabled) {
|
|
784
|
+
return Promise.resolve({
|
|
785
|
+
status: false,
|
|
786
|
+
files: [],
|
|
787
|
+
file: null
|
|
788
|
+
});
|
|
774
789
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
if (isDisabled) {
|
|
782
|
-
return Promise.resolve({
|
|
783
|
-
status: false,
|
|
784
|
-
files: [],
|
|
785
|
-
file: null
|
|
790
|
+
return readLocalFile({
|
|
791
|
+
multiple,
|
|
792
|
+
types: isImage ? imageTypes : fileTypes
|
|
793
|
+
}).then((params) => {
|
|
794
|
+
handleUploadFile(params.files, evnt);
|
|
795
|
+
return params;
|
|
786
796
|
});
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
removeFn({
|
|
824
|
-
$upload: $xeUpload,
|
|
825
|
-
option: item
|
|
826
|
-
})
|
|
827
|
-
).then(() => {
|
|
797
|
+
};
|
|
798
|
+
const clickEvent = (evnt) => {
|
|
799
|
+
handleChoose(evnt).catch(() => {
|
|
800
|
+
});
|
|
801
|
+
};
|
|
802
|
+
const handleRemoveEvent = (evnt, item, index) => {
|
|
803
|
+
const { fileList } = reactData;
|
|
804
|
+
fileList.splice(index, 1);
|
|
805
|
+
handleChangeEvent(evnt, fileList);
|
|
806
|
+
if ($xeForm && formItemInfo) {
|
|
807
|
+
$xeForm.triggerItemEvent(evnt || { type: "remove" }, formItemInfo.itemConfig.field, fileList);
|
|
808
|
+
}
|
|
809
|
+
if (evnt) {
|
|
810
|
+
dispatchEvent("remove", { option: item }, evnt);
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
const removeFileEvent = (evnt, item, index) => {
|
|
814
|
+
const beforeRemoveFn = props.beforeRemoveMethod || getConfig().upload.beforeRemoveMethod;
|
|
815
|
+
const removeFn = props.removeMethod || getConfig().upload.removeMethod;
|
|
816
|
+
return Promise.resolve(
|
|
817
|
+
beforeRemoveFn ? beforeRemoveFn({
|
|
818
|
+
$upload: $xeUpload,
|
|
819
|
+
option: item
|
|
820
|
+
}) : true
|
|
821
|
+
).then((status) => {
|
|
822
|
+
if (status) {
|
|
823
|
+
if (removeFn) {
|
|
824
|
+
Promise.resolve(
|
|
825
|
+
removeFn({
|
|
826
|
+
$upload: $xeUpload,
|
|
827
|
+
option: item
|
|
828
|
+
})
|
|
829
|
+
).then(() => {
|
|
830
|
+
handleRemoveEvent(evnt, item, index);
|
|
831
|
+
}).catch((e) => e);
|
|
832
|
+
} else {
|
|
828
833
|
handleRemoveEvent(evnt, item, index);
|
|
829
|
-
}
|
|
834
|
+
}
|
|
830
835
|
} else {
|
|
831
|
-
|
|
836
|
+
if (evnt) {
|
|
837
|
+
dispatchEvent("remove-fail", { option: item }, evnt);
|
|
838
|
+
}
|
|
832
839
|
}
|
|
840
|
+
return status;
|
|
841
|
+
});
|
|
842
|
+
};
|
|
843
|
+
const handleDownloadEvent = (evnt, item) => {
|
|
844
|
+
dispatchEvent("download", { option: item }, evnt);
|
|
845
|
+
};
|
|
846
|
+
const downloadFileEvent = (evnt, item) => {
|
|
847
|
+
const beforeDownloadFn = props.beforeDownloadMethod || getConfig().upload.beforeDownloadMethod;
|
|
848
|
+
const downloadFn = props.downloadMethod || getConfig().upload.downloadMethod;
|
|
849
|
+
Promise.resolve(
|
|
850
|
+
beforeDownloadFn ? beforeDownloadFn({
|
|
851
|
+
$upload: $xeUpload,
|
|
852
|
+
option: item
|
|
853
|
+
}) : true
|
|
854
|
+
).then((status) => {
|
|
855
|
+
if (status) {
|
|
856
|
+
if (downloadFn) {
|
|
857
|
+
Promise.resolve(
|
|
858
|
+
downloadFn({
|
|
859
|
+
$upload: $xeUpload,
|
|
860
|
+
option: item
|
|
861
|
+
})
|
|
862
|
+
).then(() => {
|
|
863
|
+
handleDownloadEvent(evnt, item);
|
|
864
|
+
}).catch((e) => e);
|
|
865
|
+
} else {
|
|
866
|
+
handleDownloadEvent(evnt, item);
|
|
867
|
+
}
|
|
868
|
+
} else {
|
|
869
|
+
dispatchEvent("download-fail", { option: item }, evnt);
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
const handleUploadDragleaveEvent = (evnt) => {
|
|
874
|
+
const targetElem = evnt.currentTarget;
|
|
875
|
+
const { clientX, clientY } = evnt;
|
|
876
|
+
if (targetElem) {
|
|
877
|
+
const { x: targetX, y: targetY, height: targetHeight, width: targetWidth } = targetElem.getBoundingClientRect();
|
|
878
|
+
if (clientX < targetX || clientX > targetX + targetWidth || clientY < targetY || clientY > targetY + targetHeight) {
|
|
879
|
+
reactData.isDragUploadStatus = false;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
const handleUploadDragoverEvent = (evnt) => {
|
|
884
|
+
const dataTransfer = evnt.dataTransfer;
|
|
885
|
+
if (dataTransfer) {
|
|
886
|
+
const { items } = dataTransfer;
|
|
887
|
+
if (items && items.length) {
|
|
888
|
+
evnt.preventDefault();
|
|
889
|
+
reactData.isDragUploadStatus = true;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
const uploadTransferFileEvent = (evnt, files) => {
|
|
894
|
+
const { imageTypes, fileTypes } = props;
|
|
895
|
+
const { imagePreviewTypes } = internalData;
|
|
896
|
+
const isImage = computeIsImage.value;
|
|
897
|
+
if (isImage) {
|
|
898
|
+
const pasteImgTypes = imagePreviewTypes.concat(imageTypes && imageTypes.length ? imageTypes : []);
|
|
899
|
+
files = files.filter((file) => {
|
|
900
|
+
const fileType = `${file.type.split("/")[1] || ""}`.toLowerCase();
|
|
901
|
+
if (pasteImgTypes.some((type) => `${type}`.toLowerCase() === fileType)) {
|
|
902
|
+
return true;
|
|
903
|
+
}
|
|
904
|
+
return false;
|
|
905
|
+
});
|
|
833
906
|
} else {
|
|
907
|
+
if (fileTypes && fileTypes.length) {
|
|
908
|
+
const errTypes = [];
|
|
909
|
+
files.forEach((file) => {
|
|
910
|
+
const fileType = parseFileType(file.name);
|
|
911
|
+
if (!fileTypes.some((type) => `${type}`.toLowerCase() === fileType)) {
|
|
912
|
+
errTypes.push(fileType);
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
if (errTypes.length) {
|
|
916
|
+
if (VxeUI.modal) {
|
|
917
|
+
VxeUI.modal.message({
|
|
918
|
+
content: getI18n("vxe.error.notType", [errTypes.join(", ")]),
|
|
919
|
+
status: "error"
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
if (!files.length) {
|
|
927
|
+
if (VxeUI.modal) {
|
|
928
|
+
VxeUI.modal.notification({
|
|
929
|
+
title: getI18n("vxe.modal.errTitle"),
|
|
930
|
+
status: "error",
|
|
931
|
+
content: getI18n("vxe.upload.uploadTypeErr")
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
handleUploadFile(files, evnt);
|
|
937
|
+
};
|
|
938
|
+
const handleUploadDropEvent = (evnt) => {
|
|
939
|
+
const dataTransfer = evnt.dataTransfer;
|
|
940
|
+
if (dataTransfer) {
|
|
941
|
+
const { items } = dataTransfer;
|
|
942
|
+
if (items && items.length) {
|
|
943
|
+
evnt.preventDefault();
|
|
944
|
+
const files = handleTransferFiles(items);
|
|
945
|
+
if (files.length) {
|
|
946
|
+
uploadTransferFileEvent(evnt, files);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
reactData.isDragUploadStatus = false;
|
|
951
|
+
};
|
|
952
|
+
const handleTransferFiles = (items) => {
|
|
953
|
+
const files = [];
|
|
954
|
+
XEUtils.arrayEach(items, (item) => {
|
|
955
|
+
const file = item.getAsFile();
|
|
956
|
+
if (file) {
|
|
957
|
+
files.push(file);
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
return files;
|
|
961
|
+
};
|
|
962
|
+
const handleMoreEvent = (evntParams) => {
|
|
963
|
+
const formReadonly = computeFormReadonly.value;
|
|
964
|
+
const isImage = computeIsImage.value;
|
|
965
|
+
const evnt = evntParams.$event;
|
|
966
|
+
if (VxeUI.modal) {
|
|
967
|
+
VxeUI.modal.open({
|
|
968
|
+
id: internalData.moreId,
|
|
969
|
+
title: formReadonly ? getI18n("vxe.upload.morePopup.readTitle") : getI18n(`vxe.upload.morePopup.${isImage ? "imageTitle" : "fileTitle"}`),
|
|
970
|
+
width: 660,
|
|
971
|
+
height: 500,
|
|
972
|
+
escClosable: true,
|
|
973
|
+
showMaximize: true,
|
|
974
|
+
resize: true,
|
|
975
|
+
maskClosable: true,
|
|
976
|
+
slots: {
|
|
977
|
+
default() {
|
|
978
|
+
const { showErrorStatus, dragToUpload, dragSort, dragPlaceholder } = props;
|
|
979
|
+
const { isActivated, isDragMove, isDragUploadStatus, dragIndex } = reactData;
|
|
980
|
+
const { fileList } = reactData;
|
|
981
|
+
const isDisabled = computeIsDisabled.value;
|
|
982
|
+
const moreContSlot = slots.moreContent || slots["more-content"];
|
|
983
|
+
const ons = {};
|
|
984
|
+
if (dragToUpload && dragIndex === -1) {
|
|
985
|
+
ons.onDragover = handleUploadDragoverEvent;
|
|
986
|
+
ons.onDragleave = handleUploadDragleaveEvent;
|
|
987
|
+
ons.onDrop = handleUploadDropEvent;
|
|
988
|
+
}
|
|
989
|
+
return h(
|
|
990
|
+
"div",
|
|
991
|
+
{
|
|
992
|
+
ref: refPopupElem,
|
|
993
|
+
class: [
|
|
994
|
+
"vxe-upload--more-popup",
|
|
995
|
+
{
|
|
996
|
+
"is--readonly": formReadonly,
|
|
997
|
+
"is--disabled": isDisabled,
|
|
998
|
+
"is--active": isActivated,
|
|
999
|
+
"show--error": showErrorStatus,
|
|
1000
|
+
"is--drag": isDragUploadStatus
|
|
1001
|
+
}
|
|
1002
|
+
],
|
|
1003
|
+
...ons
|
|
1004
|
+
},
|
|
1005
|
+
moreContSlot ? getSlotVNs(moreContSlot({ options: fileList })) : [
|
|
1006
|
+
isImage ? dragSort ? h(
|
|
1007
|
+
TransitionGroup,
|
|
1008
|
+
{
|
|
1009
|
+
name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
|
|
1010
|
+
tag: "div",
|
|
1011
|
+
class: "vxe-upload--image-more-list"
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
default: () => renderImageItemList(fileList, true).concat(renderImageAction(true))
|
|
1015
|
+
}
|
|
1016
|
+
) : h(
|
|
1017
|
+
"div",
|
|
1018
|
+
{
|
|
1019
|
+
class: "vxe-upload--image-more-list"
|
|
1020
|
+
},
|
|
1021
|
+
renderImageItemList(fileList, true).concat(renderImageAction(true))
|
|
1022
|
+
) : h(
|
|
1023
|
+
"div",
|
|
1024
|
+
{
|
|
1025
|
+
class: "vxe-upload--file-more-list"
|
|
1026
|
+
},
|
|
1027
|
+
[
|
|
1028
|
+
renderFileAction(true),
|
|
1029
|
+
dragSort ? h(
|
|
1030
|
+
TransitionGroup,
|
|
1031
|
+
{
|
|
1032
|
+
name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
|
|
1033
|
+
tag: "div",
|
|
1034
|
+
class: "vxe-upload--file-list"
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
default: () => renderFileItemList(fileList, false)
|
|
1038
|
+
}
|
|
1039
|
+
) : h(
|
|
1040
|
+
"div",
|
|
1041
|
+
{
|
|
1042
|
+
class: "vxe-upload--file-list"
|
|
1043
|
+
},
|
|
1044
|
+
renderFileItemList(fileList, true)
|
|
1045
|
+
)
|
|
1046
|
+
]
|
|
1047
|
+
),
|
|
1048
|
+
dragSort ? h("div", {
|
|
1049
|
+
ref: refModalDragLineElem,
|
|
1050
|
+
class: "vxe-upload--drag-line"
|
|
1051
|
+
}) : renderEmptyElement($xeUpload),
|
|
1052
|
+
isDragUploadStatus ? h(
|
|
1053
|
+
"div",
|
|
1054
|
+
{
|
|
1055
|
+
class: "vxe-upload--drag-placeholder"
|
|
1056
|
+
},
|
|
1057
|
+
dragPlaceholder || getI18n("vxe.upload.dragPlaceholder")
|
|
1058
|
+
) : renderEmptyElement($xeUpload)
|
|
1059
|
+
]
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
onShow() {
|
|
1064
|
+
reactData.showMorePopup = true;
|
|
1065
|
+
},
|
|
1066
|
+
onHide({ $event }) {
|
|
1067
|
+
reactData.showMorePopup = false;
|
|
1068
|
+
if ($event) {
|
|
1069
|
+
dispatchEvent("more-visible", { visible: false }, $event);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
834
1073
|
if (evnt) {
|
|
835
|
-
dispatchEvent("
|
|
1074
|
+
dispatchEvent("more-visible", { visible: true }, evnt);
|
|
836
1075
|
}
|
|
837
1076
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
|
|
1077
|
+
};
|
|
1078
|
+
const showDropTip = (evnt, dragEl, dragPos) => {
|
|
1079
|
+
const { showMorePopup } = reactData;
|
|
1080
|
+
const el = refElem.value;
|
|
1081
|
+
const popupEl = refPopupElem.value;
|
|
1082
|
+
const wrapperEl = showMorePopup ? popupEl : el;
|
|
1083
|
+
if (!wrapperEl) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const wrapperRect = wrapperEl.getBoundingClientRect();
|
|
1087
|
+
const ddLineEl = refDragLineElem.value;
|
|
1088
|
+
const mdLineEl = refModalDragLineElem.value;
|
|
1089
|
+
const currDLineEl = showMorePopup ? mdLineEl : ddLineEl;
|
|
1090
|
+
if (currDLineEl) {
|
|
1091
|
+
const dragRect = dragEl.getBoundingClientRect();
|
|
1092
|
+
currDLineEl.style.display = "block";
|
|
1093
|
+
currDLineEl.style.top = `${Math.max(1, dragRect.y - wrapperRect.y)}px`;
|
|
1094
|
+
currDLineEl.style.left = `${Math.max(1, dragRect.x - wrapperRect.x)}px`;
|
|
1095
|
+
currDLineEl.style.height = `${dragRect.height}px`;
|
|
1096
|
+
currDLineEl.style.width = `${dragRect.width - 1}px`;
|
|
1097
|
+
currDLineEl.setAttribute("drag-pos", dragPos);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
const hideDropTip = () => {
|
|
1101
|
+
const ddLineEl = refDragLineElem.value;
|
|
1102
|
+
const mdLineEl = refModalDragLineElem.value;
|
|
1103
|
+
if (ddLineEl) {
|
|
1104
|
+
ddLineEl.style.display = "";
|
|
1105
|
+
}
|
|
1106
|
+
if (mdLineEl) {
|
|
1107
|
+
mdLineEl.style.display = "";
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
const handleDragSortDragstartEvent = (evnt) => {
|
|
1111
|
+
evnt.stopPropagation();
|
|
1112
|
+
if (evnt.dataTransfer) {
|
|
1113
|
+
evnt.dataTransfer.setDragImage(getTpImg(), 0, 0);
|
|
1114
|
+
}
|
|
1115
|
+
const dragEl = evnt.currentTarget;
|
|
1116
|
+
const parentEl = dragEl.parentElement;
|
|
1117
|
+
const dragIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
|
|
1118
|
+
reactData.isDragMove = true;
|
|
1119
|
+
reactData.dragIndex = dragIndex;
|
|
1120
|
+
setTimeout(() => {
|
|
1121
|
+
reactData.isDragMove = false;
|
|
1122
|
+
}, 500);
|
|
1123
|
+
};
|
|
1124
|
+
const handleDragSortDragoverEvent = (evnt) => {
|
|
1125
|
+
evnt.stopPropagation();
|
|
1126
|
+
evnt.preventDefault();
|
|
1127
|
+
const { dragIndex } = reactData;
|
|
1128
|
+
if (dragIndex === -1) {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
const isImage = computeIsImage.value;
|
|
1132
|
+
const dragEl = evnt.currentTarget;
|
|
1133
|
+
const parentEl = dragEl.parentElement;
|
|
1134
|
+
const currIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
|
|
1135
|
+
let dragPos = "";
|
|
1136
|
+
if (isImage) {
|
|
1137
|
+
const offsetX = evnt.clientX - dragEl.getBoundingClientRect().x;
|
|
1138
|
+
dragPos = offsetX < dragEl.clientWidth / 2 ? "left" : "right";
|
|
1139
|
+
} else {
|
|
1140
|
+
const offsetY = evnt.clientY - dragEl.getBoundingClientRect().y;
|
|
1141
|
+
dragPos = offsetY < dragEl.clientHeight / 2 ? "top" : "bottom";
|
|
1142
|
+
}
|
|
1143
|
+
if (dragIndex === currIndex) {
|
|
1144
|
+
showDropTip(evnt, dragEl, dragPos);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
showDropTip(evnt, dragEl, dragPos);
|
|
1148
|
+
internalData.prevDragIndex = currIndex;
|
|
1149
|
+
internalData.prevDragPos = dragPos;
|
|
1150
|
+
};
|
|
1151
|
+
const handleDragSortDragendEvent = (evnt) => {
|
|
1152
|
+
const { fileList, dragIndex } = reactData;
|
|
1153
|
+
const { prevDragIndex, prevDragPos } = internalData;
|
|
1154
|
+
const oldIndex = dragIndex;
|
|
1155
|
+
const targetIndex = prevDragIndex;
|
|
1156
|
+
const dragOffsetIndex = prevDragPos === "bottom" || prevDragPos === "right" ? 1 : 0;
|
|
1157
|
+
const oldItem = fileList[oldIndex];
|
|
1158
|
+
const newItem = fileList[targetIndex];
|
|
1159
|
+
if (oldItem && newItem) {
|
|
1160
|
+
fileList.splice(oldIndex, 1);
|
|
1161
|
+
const ptfIndex = XEUtils.findIndexOf(fileList, (item) => newItem === item);
|
|
1162
|
+
const nIndex = ptfIndex + dragOffsetIndex;
|
|
1163
|
+
fileList.splice(nIndex, 0, oldItem);
|
|
1164
|
+
dispatchEvent(
|
|
1165
|
+
"sort-dragend",
|
|
1166
|
+
{
|
|
1167
|
+
oldItem,
|
|
1168
|
+
newItem,
|
|
1169
|
+
dragPos: prevDragPos,
|
|
1170
|
+
offsetIndex: dragOffsetIndex,
|
|
1171
|
+
_index: {
|
|
1172
|
+
newIndex: nIndex,
|
|
1173
|
+
oldIndex
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1176
|
+
evnt
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
hideDropTip();
|
|
1180
|
+
reactData.dragIndex = -1;
|
|
1181
|
+
};
|
|
1182
|
+
const handleItemMousedownEvent = (evnt) => {
|
|
1183
|
+
if ($xeTable) {
|
|
1184
|
+
evnt.stopPropagation();
|
|
868
1185
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
if (clientX < targetX || clientX > targetX + targetWidth || clientY < targetY || clientY > targetY + targetHeight) {
|
|
877
|
-
reactData.isDragUploadStatus = false;
|
|
1186
|
+
reactData.isActivated = true;
|
|
1187
|
+
};
|
|
1188
|
+
const handleGlobalPasteEvent = (evnt) => {
|
|
1189
|
+
const { pasteToUpload } = props;
|
|
1190
|
+
const { isActivated } = reactData;
|
|
1191
|
+
if (!isActivated || !pasteToUpload) {
|
|
1192
|
+
return;
|
|
878
1193
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1194
|
+
const clipboardData = evnt.clipboardData || evnt.originalEvent.clipboardData;
|
|
1195
|
+
if (!clipboardData) {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
const { items } = clipboardData;
|
|
1199
|
+
if (!items) {
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
const files = handleTransferFiles(items);
|
|
1203
|
+
if (files.length) {
|
|
886
1204
|
evnt.preventDefault();
|
|
887
|
-
|
|
1205
|
+
uploadTransferFileEvent(evnt, files);
|
|
888
1206
|
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1207
|
+
};
|
|
1208
|
+
const handleGlobalClickEvent = (evnt) => {
|
|
1209
|
+
const el = refElem.value;
|
|
1210
|
+
const popupEl = refPopupElem.value;
|
|
1211
|
+
let isActivated = getEventTargetNode(evnt, el).flag;
|
|
1212
|
+
if (!isActivated && popupEl) {
|
|
1213
|
+
const parentEl = popupEl.parentElement || popupEl;
|
|
1214
|
+
const modalEl = parentEl ? parentEl.parentElement : parentEl;
|
|
1215
|
+
isActivated = getEventTargetNode(evnt, modalEl).flag;
|
|
1216
|
+
}
|
|
1217
|
+
reactData.isActivated = isActivated;
|
|
1218
|
+
};
|
|
1219
|
+
const handleGlobalBlurEvent = () => {
|
|
1220
|
+
reactData.isActivated = false;
|
|
1221
|
+
};
|
|
1222
|
+
const handleClearFile = (evnt) => {
|
|
1223
|
+
const { fileList } = reactData;
|
|
1224
|
+
const urlProp = computeUrlProp.value;
|
|
1225
|
+
const rest = [];
|
|
1226
|
+
XEUtils.lastEach(fileList, (item, index) => {
|
|
1227
|
+
rest.push(
|
|
1228
|
+
removeFileEvent(evnt, item, index).then((status) => {
|
|
1229
|
+
return { url: item[urlProp], status };
|
|
1230
|
+
})
|
|
1231
|
+
);
|
|
1232
|
+
});
|
|
1233
|
+
return Promise.all(rest);
|
|
1234
|
+
};
|
|
1235
|
+
const handleRemoveFile = (evnt, urlOrItem) => {
|
|
1236
|
+
const { fileList } = reactData;
|
|
1237
|
+
const urlProp = computeUrlProp.value;
|
|
1238
|
+
const urls = XEUtils.isArray(urlOrItem) ? urlOrItem : [urlOrItem];
|
|
1239
|
+
const rest = [];
|
|
1240
|
+
urls.forEach((obj) => {
|
|
1241
|
+
if (obj) {
|
|
1242
|
+
const url = XEUtils.isString(obj) ? obj : obj[urlProp];
|
|
1243
|
+
const index = XEUtils.findIndexOf(fileList, (fileItem) => fileItem[urlProp] === url);
|
|
1244
|
+
if (index > -1) {
|
|
1245
|
+
rest.push(
|
|
1246
|
+
removeFileEvent(evnt, fileList[index], index).then((status) => {
|
|
1247
|
+
return { url, status };
|
|
1248
|
+
})
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
901
1251
|
}
|
|
902
|
-
return false;
|
|
903
1252
|
});
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1253
|
+
return Promise.all(rest);
|
|
1254
|
+
};
|
|
1255
|
+
const uploadMethods = {
|
|
1256
|
+
dispatchEvent,
|
|
1257
|
+
choose() {
|
|
1258
|
+
return handleChoose(null);
|
|
1259
|
+
},
|
|
1260
|
+
clear() {
|
|
1261
|
+
return handleClearFile(null);
|
|
1262
|
+
},
|
|
1263
|
+
clearByEvent(evnt) {
|
|
1264
|
+
return handleClearFile(evnt);
|
|
1265
|
+
},
|
|
1266
|
+
getPendingFiles() {
|
|
1267
|
+
const { fileList, fileCacheMaps } = reactData;
|
|
1268
|
+
const pendingFiles = [];
|
|
1269
|
+
fileList.forEach((item) => {
|
|
1270
|
+
const fileKey = getFieldKey(item);
|
|
1271
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
1272
|
+
if (cacheItem && cacheItem.status === "pending") {
|
|
1273
|
+
pendingFiles.push(cacheItem.file);
|
|
911
1274
|
}
|
|
912
1275
|
});
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1276
|
+
return pendingFiles;
|
|
1277
|
+
},
|
|
1278
|
+
submit(isFull) {
|
|
1279
|
+
const { maxSimultaneousUploads } = props;
|
|
1280
|
+
const msNum = XEUtils.toNumber(maxSimultaneousUploads || 1) || 1;
|
|
1281
|
+
const { fileList, fileCacheMaps } = reactData;
|
|
1282
|
+
const allPendingList = fileList.filter((item) => {
|
|
1283
|
+
const fileKey = getFieldKey(item);
|
|
1284
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
1285
|
+
return cacheItem && (cacheItem.status === "pending" || isFull && cacheItem.status === "error");
|
|
1286
|
+
});
|
|
1287
|
+
const handleSubmit = (item) => {
|
|
1288
|
+
const fileKey = getFieldKey(item);
|
|
1289
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
1290
|
+
if (cacheItem) {
|
|
1291
|
+
const file = cacheItem.file;
|
|
1292
|
+
if (file && (cacheItem.status === "pending" || isFull && cacheItem.status === "error")) {
|
|
1293
|
+
cacheItem.loading = true;
|
|
1294
|
+
cacheItem.percent = 0;
|
|
1295
|
+
return handleUploadResult(item, file).then(handleNextSubmit);
|
|
1296
|
+
}
|
|
919
1297
|
}
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1298
|
+
return handleNextSubmit();
|
|
1299
|
+
};
|
|
1300
|
+
const handleNextSubmit = () => {
|
|
1301
|
+
if (allPendingList.length) {
|
|
1302
|
+
const item = allPendingList[0];
|
|
1303
|
+
allPendingList.splice(0, 1);
|
|
1304
|
+
return handleSubmit(item).then(handleNextSubmit);
|
|
1305
|
+
}
|
|
1306
|
+
return Promise.resolve();
|
|
1307
|
+
};
|
|
1308
|
+
return Promise.all(allPendingList.splice(0, msNum).map(handleSubmit)).then(() => {
|
|
930
1309
|
});
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1310
|
+
},
|
|
1311
|
+
getMoreVisible() {
|
|
1312
|
+
return reactData.showMorePopup;
|
|
1313
|
+
},
|
|
1314
|
+
openMore() {
|
|
1315
|
+
handleMoreEvent({ $event: new Event("click") });
|
|
1316
|
+
return nextTick();
|
|
1317
|
+
},
|
|
1318
|
+
openMoreByEvent(evnt) {
|
|
1319
|
+
handleMoreEvent({ $event: evnt });
|
|
1320
|
+
return nextTick();
|
|
1321
|
+
},
|
|
1322
|
+
closeMore() {
|
|
1323
|
+
if (VxeUI.modal) {
|
|
1324
|
+
VxeUI.modal.close(internalData.moreId);
|
|
945
1325
|
}
|
|
1326
|
+
return nextTick();
|
|
1327
|
+
},
|
|
1328
|
+
remove(urlOrItem) {
|
|
1329
|
+
return handleRemoveFile(null, urlOrItem);
|
|
1330
|
+
},
|
|
1331
|
+
removeByEvent(evnt, urlOrItem) {
|
|
1332
|
+
return handleRemoveFile(evnt, urlOrItem);
|
|
946
1333
|
}
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
1334
|
+
};
|
|
1335
|
+
const uploadPrivateMethods = {
|
|
1336
|
+
removeFileEvent
|
|
1337
|
+
};
|
|
1338
|
+
Object.assign($xeUpload, uploadMethods, uploadPrivateMethods);
|
|
1339
|
+
const renderFileItemList = (currList, isMoreView) => {
|
|
1340
|
+
const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
|
|
1341
|
+
const { fileList, fileCacheMaps } = reactData;
|
|
1342
|
+
const isDisabled = computeIsDisabled.value;
|
|
1343
|
+
const formReadonly = computeFormReadonly.value;
|
|
1344
|
+
const nameProp = computeNameProp.value;
|
|
1345
|
+
const typeProp = computeTypeProp.value;
|
|
1346
|
+
const optionSlot = slots.option;
|
|
1347
|
+
const actionSlot = slots.action;
|
|
1348
|
+
const cornerSlot = slots.corner;
|
|
1349
|
+
const nameSlot = slots.name;
|
|
1350
|
+
const ons = {};
|
|
1351
|
+
if (dragSort && currList.length > 1) {
|
|
1352
|
+
ons.onDragstart = handleDragSortDragstartEvent;
|
|
1353
|
+
ons.onDragover = handleDragSortDragoverEvent;
|
|
1354
|
+
ons.onDragend = handleDragSortDragendEvent;
|
|
956
1355
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1356
|
+
return currList.map((item, index) => {
|
|
1357
|
+
const fileKey = getFieldKey(item);
|
|
1358
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
1359
|
+
let isLoading = false;
|
|
1360
|
+
let isError = false;
|
|
1361
|
+
let isPending = false;
|
|
1362
|
+
const fileName = `${item[nameProp] || ""}`;
|
|
1363
|
+
if (cacheItem) {
|
|
1364
|
+
isLoading = cacheItem.loading;
|
|
1365
|
+
isError = cacheItem.status === "error";
|
|
1366
|
+
isPending = cacheItem.status === "pending";
|
|
1367
|
+
}
|
|
1368
|
+
return h(
|
|
1369
|
+
"div",
|
|
1370
|
+
{
|
|
1371
|
+
key: dragSort ? fileKey : index,
|
|
1372
|
+
class: [
|
|
1373
|
+
"vxe-upload--file-item",
|
|
1374
|
+
{
|
|
1375
|
+
"is--preview": showPreview,
|
|
1376
|
+
"is--loading": isLoading,
|
|
1377
|
+
"is--pending": isPending,
|
|
1378
|
+
"is--error": isError
|
|
1379
|
+
}
|
|
1380
|
+
],
|
|
1381
|
+
fileid: fileKey,
|
|
1382
|
+
draggable: dragSort ? true : null,
|
|
1383
|
+
...ons
|
|
1384
|
+
},
|
|
1385
|
+
optionSlot ? getSlotVNs(optionSlot({ option: item, isMoreView, options: fileList })) : [
|
|
1386
|
+
h(
|
|
988
1387
|
"div",
|
|
989
1388
|
{
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1389
|
+
class: "vxe-upload--file-item-icon"
|
|
1390
|
+
},
|
|
1391
|
+
[
|
|
1392
|
+
h("i", {
|
|
1393
|
+
class: getIcon()[`UPLOAD_FILE_TYPE_${`${item[typeProp]}`.toLocaleUpperCase()}`] || getIcon().UPLOAD_FILE_TYPE_DEFAULT
|
|
1394
|
+
})
|
|
1395
|
+
]
|
|
1396
|
+
),
|
|
1397
|
+
h(
|
|
1398
|
+
"div",
|
|
1399
|
+
{
|
|
1400
|
+
class: "vxe-upload--file-item-name",
|
|
1401
|
+
title: fileName,
|
|
1402
|
+
onClick(evnt) {
|
|
1403
|
+
if (!isLoading && !isError) {
|
|
1404
|
+
handlePreviewFileEvent(evnt, item);
|
|
999
1405
|
}
|
|
1000
|
-
|
|
1001
|
-
...ons
|
|
1406
|
+
}
|
|
1002
1407
|
},
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1408
|
+
nameSlot ? getSlotVNs(nameSlot({ option: item, isMoreView, options: fileList })) : fileName
|
|
1409
|
+
),
|
|
1410
|
+
isLoading ? h(
|
|
1411
|
+
"div",
|
|
1412
|
+
{
|
|
1413
|
+
class: "vxe-upload--file-item-loading-icon"
|
|
1414
|
+
},
|
|
1415
|
+
[
|
|
1416
|
+
h("i", {
|
|
1417
|
+
class: getIcon().UPLOAD_LOADING
|
|
1418
|
+
})
|
|
1419
|
+
]
|
|
1420
|
+
) : renderEmptyElement($xeUpload),
|
|
1421
|
+
showProgress && isLoading && cacheItem ? h(
|
|
1422
|
+
"div",
|
|
1423
|
+
{
|
|
1424
|
+
class: "vxe-upload--file-item-loading-text"
|
|
1425
|
+
},
|
|
1426
|
+
progressText ? XEUtils.toFormatString(`${XEUtils.isFunction(progressText) ? progressText({}) : progressText}`, { percent: cacheItem.percent }) : getI18n("vxe.upload.uploadProgress", [cacheItem.percent])
|
|
1427
|
+
) : renderEmptyElement($xeUpload),
|
|
1428
|
+
!isLoading && (isError && showErrorStatus || isPending && showSubmitButton && !autoSubmit) ? h(
|
|
1429
|
+
"div",
|
|
1430
|
+
{
|
|
1431
|
+
class: "vxe-upload--file-item-rebtn"
|
|
1432
|
+
},
|
|
1433
|
+
[
|
|
1434
|
+
h(VxeButtonComponent, {
|
|
1435
|
+
icon: isError ? getIcon().UPLOAD_IMAGE_RE_UPLOAD : getIcon().UPLOAD_IMAGE_UPLOAD,
|
|
1436
|
+
mode: "text",
|
|
1437
|
+
status: "primary",
|
|
1438
|
+
content: isError ? getI18n("vxe.upload.reUpload") : getI18n("vxe.upload.manualUpload"),
|
|
1439
|
+
onClick(evnt) {
|
|
1440
|
+
handleReUploadEvent(evnt, item);
|
|
1013
1441
|
}
|
|
1014
|
-
)
|
|
1442
|
+
})
|
|
1443
|
+
]
|
|
1444
|
+
) : renderEmptyElement($xeUpload),
|
|
1445
|
+
h(
|
|
1446
|
+
"div",
|
|
1447
|
+
{
|
|
1448
|
+
class: "vxe-upload--file-item-btn-wrapper"
|
|
1449
|
+
},
|
|
1450
|
+
actionSlot ? getSlotVNs(actionSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly })) : [
|
|
1451
|
+
cornerSlot ? h(
|
|
1015
1452
|
"div",
|
|
1016
1453
|
{
|
|
1017
|
-
class: "vxe-upload--
|
|
1454
|
+
class: "vxe-upload--file-item-action"
|
|
1018
1455
|
},
|
|
1019
|
-
|
|
1020
|
-
) :
|
|
1456
|
+
getSlotVNs(cornerSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly }))
|
|
1457
|
+
) : renderEmptyElement($xeUpload),
|
|
1458
|
+
showDownloadButton && !(isLoading || isPending) ? h(
|
|
1021
1459
|
"div",
|
|
1022
1460
|
{
|
|
1023
|
-
class: "vxe-upload--file-
|
|
1461
|
+
class: "vxe-upload--file-item-download-btn",
|
|
1462
|
+
onClick(evnt) {
|
|
1463
|
+
downloadFileEvent(evnt, item);
|
|
1464
|
+
}
|
|
1024
1465
|
},
|
|
1025
1466
|
[
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
{
|
|
1030
|
-
name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
|
|
1031
|
-
tag: "div",
|
|
1032
|
-
class: "vxe-upload--file-list"
|
|
1033
|
-
},
|
|
1034
|
-
{
|
|
1035
|
-
default: () => renderFileItemList(fileList, false)
|
|
1036
|
-
}
|
|
1037
|
-
) : h(
|
|
1038
|
-
"div",
|
|
1039
|
-
{
|
|
1040
|
-
class: "vxe-upload--file-list"
|
|
1041
|
-
},
|
|
1042
|
-
renderFileItemList(fileList, true)
|
|
1043
|
-
)
|
|
1467
|
+
h("i", {
|
|
1468
|
+
class: getIcon().UPLOAD_FILE_DOWNLOAD
|
|
1469
|
+
})
|
|
1044
1470
|
]
|
|
1045
|
-
),
|
|
1046
|
-
|
|
1047
|
-
ref: refModalDragLineElem,
|
|
1048
|
-
class: "vxe-upload--drag-line"
|
|
1049
|
-
}) : renderEmptyElement($xeUpload),
|
|
1050
|
-
isDragUploadStatus ? h(
|
|
1471
|
+
) : renderEmptyElement($xeUpload),
|
|
1472
|
+
showRemoveButton && !formReadonly && !isDisabled && !isLoading ? h(
|
|
1051
1473
|
"div",
|
|
1052
1474
|
{
|
|
1053
|
-
class: "vxe-upload--
|
|
1475
|
+
class: "vxe-upload--file-item-remove-btn",
|
|
1476
|
+
onClick(evnt) {
|
|
1477
|
+
removeFileEvent(evnt, item, index);
|
|
1478
|
+
}
|
|
1054
1479
|
},
|
|
1055
|
-
|
|
1480
|
+
[
|
|
1481
|
+
h("i", {
|
|
1482
|
+
class: getIcon().UPLOAD_FILE_REMOVE
|
|
1483
|
+
})
|
|
1484
|
+
]
|
|
1056
1485
|
) : renderEmptyElement($xeUpload)
|
|
1057
1486
|
]
|
|
1058
|
-
)
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
onShow() {
|
|
1062
|
-
reactData.showMorePopup = true;
|
|
1063
|
-
},
|
|
1064
|
-
onHide({ $event }) {
|
|
1065
|
-
reactData.showMorePopup = false;
|
|
1066
|
-
if ($event) {
|
|
1067
|
-
dispatchEvent("more-visible", { visible: false }, $event);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
});
|
|
1071
|
-
if (evnt) {
|
|
1072
|
-
dispatchEvent("more-visible", { visible: true }, evnt);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
const showDropTip = (evnt, dragEl, dragPos) => {
|
|
1077
|
-
const { showMorePopup } = reactData;
|
|
1078
|
-
const el = refElem.value;
|
|
1079
|
-
const popupEl = refPopupElem.value;
|
|
1080
|
-
const wrapperEl = showMorePopup ? popupEl : el;
|
|
1081
|
-
if (!wrapperEl) {
|
|
1082
|
-
return;
|
|
1083
|
-
}
|
|
1084
|
-
const wrapperRect = wrapperEl.getBoundingClientRect();
|
|
1085
|
-
const ddLineEl = refDragLineElem.value;
|
|
1086
|
-
const mdLineEl = refModalDragLineElem.value;
|
|
1087
|
-
const currDLineEl = showMorePopup ? mdLineEl : ddLineEl;
|
|
1088
|
-
if (currDLineEl) {
|
|
1089
|
-
const dragRect = dragEl.getBoundingClientRect();
|
|
1090
|
-
currDLineEl.style.display = "block";
|
|
1091
|
-
currDLineEl.style.top = `${Math.max(1, dragRect.y - wrapperRect.y)}px`;
|
|
1092
|
-
currDLineEl.style.left = `${Math.max(1, dragRect.x - wrapperRect.x)}px`;
|
|
1093
|
-
currDLineEl.style.height = `${dragRect.height}px`;
|
|
1094
|
-
currDLineEl.style.width = `${dragRect.width - 1}px`;
|
|
1095
|
-
currDLineEl.setAttribute("drag-pos", dragPos);
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
const hideDropTip = () => {
|
|
1099
|
-
const ddLineEl = refDragLineElem.value;
|
|
1100
|
-
const mdLineEl = refModalDragLineElem.value;
|
|
1101
|
-
if (ddLineEl) {
|
|
1102
|
-
ddLineEl.style.display = "";
|
|
1103
|
-
}
|
|
1104
|
-
if (mdLineEl) {
|
|
1105
|
-
mdLineEl.style.display = "";
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
const handleDragSortDragstartEvent = (evnt) => {
|
|
1109
|
-
evnt.stopPropagation();
|
|
1110
|
-
if (evnt.dataTransfer) {
|
|
1111
|
-
evnt.dataTransfer.setDragImage(getTpImg(), 0, 0);
|
|
1112
|
-
}
|
|
1113
|
-
const dragEl = evnt.currentTarget;
|
|
1114
|
-
const parentEl = dragEl.parentElement;
|
|
1115
|
-
const dragIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
|
|
1116
|
-
reactData.isDragMove = true;
|
|
1117
|
-
reactData.dragIndex = dragIndex;
|
|
1118
|
-
setTimeout(() => {
|
|
1119
|
-
reactData.isDragMove = false;
|
|
1120
|
-
}, 500);
|
|
1121
|
-
};
|
|
1122
|
-
const handleDragSortDragoverEvent = (evnt) => {
|
|
1123
|
-
evnt.stopPropagation();
|
|
1124
|
-
evnt.preventDefault();
|
|
1125
|
-
const { dragIndex } = reactData;
|
|
1126
|
-
if (dragIndex === -1) {
|
|
1127
|
-
return;
|
|
1128
|
-
}
|
|
1129
|
-
const isImage = computeIsImage.value;
|
|
1130
|
-
const dragEl = evnt.currentTarget;
|
|
1131
|
-
const parentEl = dragEl.parentElement;
|
|
1132
|
-
const currIndex = XEUtils.findIndexOf(Array.from(parentEl.children), (item) => dragEl === item);
|
|
1133
|
-
let dragPos = "";
|
|
1134
|
-
if (isImage) {
|
|
1135
|
-
const offsetX = evnt.clientX - dragEl.getBoundingClientRect().x;
|
|
1136
|
-
dragPos = offsetX < dragEl.clientWidth / 2 ? "left" : "right";
|
|
1137
|
-
} else {
|
|
1138
|
-
const offsetY = evnt.clientY - dragEl.getBoundingClientRect().y;
|
|
1139
|
-
dragPos = offsetY < dragEl.clientHeight / 2 ? "top" : "bottom";
|
|
1140
|
-
}
|
|
1141
|
-
if (dragIndex === currIndex) {
|
|
1142
|
-
showDropTip(evnt, dragEl, dragPos);
|
|
1143
|
-
return;
|
|
1144
|
-
}
|
|
1145
|
-
showDropTip(evnt, dragEl, dragPos);
|
|
1146
|
-
internalData.prevDragIndex = currIndex;
|
|
1147
|
-
internalData.prevDragPos = dragPos;
|
|
1148
|
-
};
|
|
1149
|
-
const handleDragSortDragendEvent = (evnt) => {
|
|
1150
|
-
const { fileList, dragIndex } = reactData;
|
|
1151
|
-
const { prevDragIndex, prevDragPos } = internalData;
|
|
1152
|
-
const oldIndex = dragIndex;
|
|
1153
|
-
const targetIndex = prevDragIndex;
|
|
1154
|
-
const dragOffsetIndex = prevDragPos === "bottom" || prevDragPos === "right" ? 1 : 0;
|
|
1155
|
-
const oldItem = fileList[oldIndex];
|
|
1156
|
-
const newItem = fileList[targetIndex];
|
|
1157
|
-
if (oldItem && newItem) {
|
|
1158
|
-
fileList.splice(oldIndex, 1);
|
|
1159
|
-
const ptfIndex = XEUtils.findIndexOf(fileList, (item) => newItem === item);
|
|
1160
|
-
const nIndex = ptfIndex + dragOffsetIndex;
|
|
1161
|
-
fileList.splice(nIndex, 0, oldItem);
|
|
1162
|
-
dispatchEvent(
|
|
1163
|
-
"sort-dragend",
|
|
1164
|
-
{
|
|
1165
|
-
oldItem,
|
|
1166
|
-
newItem,
|
|
1167
|
-
dragPos: prevDragPos,
|
|
1168
|
-
offsetIndex: dragOffsetIndex,
|
|
1169
|
-
_index: {
|
|
1170
|
-
newIndex: nIndex,
|
|
1171
|
-
oldIndex
|
|
1172
|
-
}
|
|
1173
|
-
},
|
|
1174
|
-
evnt
|
|
1175
|
-
);
|
|
1176
|
-
}
|
|
1177
|
-
hideDropTip();
|
|
1178
|
-
reactData.dragIndex = -1;
|
|
1179
|
-
};
|
|
1180
|
-
const handleItemMousedownEvent = (evnt) => {
|
|
1181
|
-
if ($xeTable) {
|
|
1182
|
-
evnt.stopPropagation();
|
|
1183
|
-
}
|
|
1184
|
-
reactData.isActivated = true;
|
|
1185
|
-
};
|
|
1186
|
-
const handleGlobalPasteEvent = (evnt) => {
|
|
1187
|
-
const { pasteToUpload } = props;
|
|
1188
|
-
const { isActivated } = reactData;
|
|
1189
|
-
if (!isActivated || !pasteToUpload) {
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
const clipboardData = evnt.clipboardData || evnt.originalEvent.clipboardData;
|
|
1193
|
-
if (!clipboardData) {
|
|
1194
|
-
return;
|
|
1195
|
-
}
|
|
1196
|
-
const { items } = clipboardData;
|
|
1197
|
-
if (!items) {
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
const files = handleTransferFiles(items);
|
|
1201
|
-
if (files.length) {
|
|
1202
|
-
evnt.preventDefault();
|
|
1203
|
-
uploadTransferFileEvent(evnt, files);
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
const handleGlobalClickEvent = (evnt) => {
|
|
1207
|
-
const el = refElem.value;
|
|
1208
|
-
const popupEl = refPopupElem.value;
|
|
1209
|
-
let isActivated = getEventTargetNode(evnt, el).flag;
|
|
1210
|
-
if (!isActivated && popupEl) {
|
|
1211
|
-
const parentEl = popupEl.parentElement || popupEl;
|
|
1212
|
-
const modalEl = parentEl ? parentEl.parentElement : parentEl;
|
|
1213
|
-
isActivated = getEventTargetNode(evnt, modalEl).flag;
|
|
1214
|
-
}
|
|
1215
|
-
reactData.isActivated = isActivated;
|
|
1216
|
-
};
|
|
1217
|
-
const handleGlobalBlurEvent = () => {
|
|
1218
|
-
reactData.isActivated = false;
|
|
1219
|
-
};
|
|
1220
|
-
const handleClearFile = (evnt) => {
|
|
1221
|
-
const { fileList } = reactData;
|
|
1222
|
-
const urlProp = computeUrlProp.value;
|
|
1223
|
-
const rest = [];
|
|
1224
|
-
XEUtils.lastEach(fileList, (item, index) => {
|
|
1225
|
-
rest.push(
|
|
1226
|
-
removeFileEvent(evnt, item, index).then((status) => {
|
|
1227
|
-
return { url: item[urlProp], status };
|
|
1228
|
-
})
|
|
1229
|
-
);
|
|
1230
|
-
});
|
|
1231
|
-
return Promise.all(rest);
|
|
1232
|
-
};
|
|
1233
|
-
const handleRemoveFile = (evnt, urlOrItem) => {
|
|
1234
|
-
const { fileList } = reactData;
|
|
1235
|
-
const urlProp = computeUrlProp.value;
|
|
1236
|
-
const urls = XEUtils.isArray(urlOrItem) ? urlOrItem : [urlOrItem];
|
|
1237
|
-
const rest = [];
|
|
1238
|
-
urls.forEach((obj) => {
|
|
1239
|
-
if (obj) {
|
|
1240
|
-
const url = XEUtils.isString(obj) ? obj : obj[urlProp];
|
|
1241
|
-
const index = XEUtils.findIndexOf(fileList, (fileItem) => fileItem[urlProp] === url);
|
|
1242
|
-
if (index > -1) {
|
|
1243
|
-
rest.push(
|
|
1244
|
-
removeFileEvent(evnt, fileList[index], index).then((status) => {
|
|
1245
|
-
return { url, status };
|
|
1246
|
-
})
|
|
1247
|
-
);
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
return Promise.all(rest);
|
|
1252
|
-
};
|
|
1253
|
-
const uploadMethods = {
|
|
1254
|
-
dispatchEvent,
|
|
1255
|
-
choose() {
|
|
1256
|
-
return handleChoose(null);
|
|
1257
|
-
},
|
|
1258
|
-
clear() {
|
|
1259
|
-
return handleClearFile(null);
|
|
1260
|
-
},
|
|
1261
|
-
clearByEvent(evnt) {
|
|
1262
|
-
return handleClearFile(evnt);
|
|
1263
|
-
},
|
|
1264
|
-
getPendingFiles() {
|
|
1265
|
-
const { fileList, fileCacheMaps } = reactData;
|
|
1266
|
-
const pendingFiles = [];
|
|
1267
|
-
fileList.forEach((item) => {
|
|
1268
|
-
const fileKey = getFieldKey(item);
|
|
1269
|
-
const cacheItem = fileCacheMaps[fileKey];
|
|
1270
|
-
if (cacheItem && cacheItem.status === "pending") {
|
|
1271
|
-
pendingFiles.push(cacheItem.file);
|
|
1272
|
-
}
|
|
1273
|
-
});
|
|
1274
|
-
return pendingFiles;
|
|
1275
|
-
},
|
|
1276
|
-
submit(isFull) {
|
|
1277
|
-
const { maxSimultaneousUploads } = props;
|
|
1278
|
-
const msNum = XEUtils.toNumber(maxSimultaneousUploads || 1) || 1;
|
|
1279
|
-
const { fileList, fileCacheMaps } = reactData;
|
|
1280
|
-
const allPendingList = fileList.filter((item) => {
|
|
1281
|
-
const fileKey = getFieldKey(item);
|
|
1282
|
-
const cacheItem = fileCacheMaps[fileKey];
|
|
1283
|
-
return cacheItem && (cacheItem.status === "pending" || isFull && cacheItem.status === "error");
|
|
1284
|
-
});
|
|
1285
|
-
const handleSubmit = (item) => {
|
|
1286
|
-
const fileKey = getFieldKey(item);
|
|
1287
|
-
const cacheItem = fileCacheMaps[fileKey];
|
|
1288
|
-
if (cacheItem) {
|
|
1289
|
-
const file = cacheItem.file;
|
|
1290
|
-
if (file && (cacheItem.status === "pending" || isFull && cacheItem.status === "error")) {
|
|
1291
|
-
cacheItem.loading = true;
|
|
1292
|
-
cacheItem.percent = 0;
|
|
1293
|
-
return handleUploadResult(item, file).then(handleNextSubmit);
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
return handleNextSubmit();
|
|
1297
|
-
};
|
|
1298
|
-
const handleNextSubmit = () => {
|
|
1299
|
-
if (allPendingList.length) {
|
|
1300
|
-
const item = allPendingList[0];
|
|
1301
|
-
allPendingList.splice(0, 1);
|
|
1302
|
-
return handleSubmit(item).then(handleNextSubmit);
|
|
1303
|
-
}
|
|
1304
|
-
return Promise.resolve();
|
|
1305
|
-
};
|
|
1306
|
-
return Promise.all(allPendingList.splice(0, msNum).map(handleSubmit)).then(() => {
|
|
1487
|
+
)
|
|
1488
|
+
]
|
|
1489
|
+
);
|
|
1307
1490
|
});
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
if (VxeUI.modal) {
|
|
1322
|
-
VxeUI.modal.close(internalData.moreId);
|
|
1323
|
-
}
|
|
1324
|
-
return nextTick();
|
|
1325
|
-
},
|
|
1326
|
-
remove(urlOrItem) {
|
|
1327
|
-
return handleRemoveFile(null, urlOrItem);
|
|
1328
|
-
},
|
|
1329
|
-
removeByEvent(evnt, urlOrItem) {
|
|
1330
|
-
return handleRemoveFile(evnt, urlOrItem);
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
const uploadPrivateMethods = {
|
|
1334
|
-
removeFileEvent
|
|
1335
|
-
};
|
|
1336
|
-
Object.assign($xeUpload, uploadMethods, uploadPrivateMethods);
|
|
1337
|
-
const renderFileItemList = (currList, isMoreView) => {
|
|
1338
|
-
const { showRemoveButton, showDownloadButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
|
|
1339
|
-
const { fileList, fileCacheMaps } = reactData;
|
|
1340
|
-
const isDisabled = computeIsDisabled.value;
|
|
1341
|
-
const formReadonly = computeFormReadonly.value;
|
|
1342
|
-
const nameProp = computeNameProp.value;
|
|
1343
|
-
const typeProp = computeTypeProp.value;
|
|
1344
|
-
const optionSlot = slots.option;
|
|
1345
|
-
const actionSlot = slots.action;
|
|
1346
|
-
const cornerSlot = slots.corner;
|
|
1347
|
-
const nameSlot = slots.name;
|
|
1348
|
-
const ons = {};
|
|
1349
|
-
if (dragSort && currList.length > 1) {
|
|
1350
|
-
ons.onDragstart = handleDragSortDragstartEvent;
|
|
1351
|
-
ons.onDragover = handleDragSortDragoverEvent;
|
|
1352
|
-
ons.onDragend = handleDragSortDragendEvent;
|
|
1353
|
-
}
|
|
1354
|
-
return currList.map((item, index) => {
|
|
1355
|
-
const fileKey = getFieldKey(item);
|
|
1356
|
-
const cacheItem = fileCacheMaps[fileKey];
|
|
1357
|
-
let isLoading = false;
|
|
1358
|
-
let isError = false;
|
|
1359
|
-
let isPending = false;
|
|
1360
|
-
const fileName = `${item[nameProp] || ""}`;
|
|
1361
|
-
if (cacheItem) {
|
|
1362
|
-
isLoading = cacheItem.loading;
|
|
1363
|
-
isError = cacheItem.status === "error";
|
|
1364
|
-
isPending = cacheItem.status === "pending";
|
|
1491
|
+
};
|
|
1492
|
+
const renderFileAction = (isMoreView) => {
|
|
1493
|
+
const { showUploadButton, buttonText, buttonIcon, showButtonText, showButtonIcon, autoHiddenButton } = props;
|
|
1494
|
+
const { fileList } = reactData;
|
|
1495
|
+
const isDisabled = computeIsDisabled.value;
|
|
1496
|
+
const formReadonly = computeFormReadonly.value;
|
|
1497
|
+
const showTipText = computedShowTipText.value;
|
|
1498
|
+
const defTipText = computedDefTipText.value;
|
|
1499
|
+
const overCount = computeOverCount.value;
|
|
1500
|
+
const defaultSlot = slots.default;
|
|
1501
|
+
const tipSlot = slots.tip || slots.hint;
|
|
1502
|
+
if (formReadonly || !showUploadButton) {
|
|
1503
|
+
return renderEmptyElement($xeUpload);
|
|
1365
1504
|
}
|
|
1366
1505
|
return h(
|
|
1367
1506
|
"div",
|
|
1368
1507
|
{
|
|
1369
|
-
|
|
1370
|
-
class: [
|
|
1371
|
-
"vxe-upload--file-item",
|
|
1372
|
-
{
|
|
1373
|
-
"is--preview": showPreview,
|
|
1374
|
-
"is--loading": isLoading,
|
|
1375
|
-
"is--pending": isPending,
|
|
1376
|
-
"is--error": isError
|
|
1377
|
-
}
|
|
1378
|
-
],
|
|
1379
|
-
fileid: fileKey,
|
|
1380
|
-
draggable: dragSort ? true : null,
|
|
1381
|
-
...ons
|
|
1508
|
+
class: "vxe-upload--file-action"
|
|
1382
1509
|
},
|
|
1383
|
-
|
|
1384
|
-
h(
|
|
1510
|
+
[
|
|
1511
|
+
autoHiddenButton && overCount ? renderEmptyElement($xeUpload) : h(
|
|
1385
1512
|
"div",
|
|
1386
1513
|
{
|
|
1387
|
-
class: "vxe-upload--file-
|
|
1514
|
+
class: "vxe-upload--file-action-btn",
|
|
1515
|
+
onClick: clickEvent
|
|
1388
1516
|
},
|
|
1389
|
-
[
|
|
1390
|
-
h(
|
|
1391
|
-
class:
|
|
1517
|
+
defaultSlot ? getSlotVNs(defaultSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : [
|
|
1518
|
+
h(VxeButtonComponent, {
|
|
1519
|
+
class: "vxe-upload--file-action-button",
|
|
1520
|
+
content: isMoreView || showButtonText ? buttonText ? `${XEUtils.isFunction(buttonText) ? buttonText({}) : buttonText}` : getI18n("vxe.upload.fileBtnText") : "",
|
|
1521
|
+
icon: showButtonIcon ? buttonIcon || getIcon().UPLOAD_FILE_ADD : "",
|
|
1522
|
+
disabled: isDisabled
|
|
1392
1523
|
})
|
|
1393
1524
|
]
|
|
1394
1525
|
),
|
|
1395
|
-
h(
|
|
1396
|
-
"div",
|
|
1397
|
-
{
|
|
1398
|
-
class: "vxe-upload--file-item-name",
|
|
1399
|
-
title: fileName,
|
|
1400
|
-
onClick(evnt) {
|
|
1401
|
-
if (!isLoading && !isError) {
|
|
1402
|
-
handlePreviewFileEvent(evnt, item);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
},
|
|
1406
|
-
nameSlot ? getSlotVNs(nameSlot({ option: item, isMoreView, options: fileList })) : fileName
|
|
1407
|
-
),
|
|
1408
|
-
isLoading ? h(
|
|
1409
|
-
"div",
|
|
1410
|
-
{
|
|
1411
|
-
class: "vxe-upload--file-item-loading-icon"
|
|
1412
|
-
},
|
|
1413
|
-
[
|
|
1414
|
-
h("i", {
|
|
1415
|
-
class: getIcon().UPLOAD_LOADING
|
|
1416
|
-
})
|
|
1417
|
-
]
|
|
1418
|
-
) : renderEmptyElement($xeUpload),
|
|
1419
|
-
showProgress && isLoading && cacheItem ? h(
|
|
1526
|
+
showTipText && (defTipText || tipSlot) ? h(
|
|
1420
1527
|
"div",
|
|
1421
1528
|
{
|
|
1422
|
-
class: "vxe-upload--file-
|
|
1529
|
+
class: "vxe-upload--file-action-tip"
|
|
1423
1530
|
},
|
|
1424
|
-
|
|
1425
|
-
) : renderEmptyElement($xeUpload)
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1531
|
+
tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
|
|
1532
|
+
) : renderEmptyElement($xeUpload)
|
|
1533
|
+
]
|
|
1534
|
+
);
|
|
1535
|
+
};
|
|
1536
|
+
const rendeFileMode = () => {
|
|
1537
|
+
const { showList, moreConfig, dragSort } = props;
|
|
1538
|
+
const { fileList, isDragMove } = reactData;
|
|
1539
|
+
const moreOpts = computeMoreOpts.value;
|
|
1540
|
+
const { maxCount, showMoreButton, layout, moreButtonText } = moreOpts;
|
|
1541
|
+
const isHorizontal = layout === "horizontal";
|
|
1542
|
+
const moreBtnSlot = slots.moreButton || slots["more-button"];
|
|
1543
|
+
let currList = fileList;
|
|
1544
|
+
let overMaxNum = 0;
|
|
1545
|
+
let isMoreMax = false;
|
|
1546
|
+
let isMiniMore = false;
|
|
1547
|
+
if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
|
|
1548
|
+
isMoreMax = true;
|
|
1549
|
+
isMiniMore = maxCount === 0;
|
|
1550
|
+
overMaxNum = fileList.length - maxCount;
|
|
1551
|
+
currList = fileList.slice(0, maxCount);
|
|
1552
|
+
}
|
|
1553
|
+
return h(
|
|
1554
|
+
"div",
|
|
1555
|
+
{
|
|
1556
|
+
key: "all",
|
|
1557
|
+
class: "vxe-upload--file-wrapper"
|
|
1558
|
+
},
|
|
1559
|
+
showList ? [
|
|
1560
|
+
showMoreButton && moreConfig && isHorizontal ? renderEmptyElement($xeUpload) : renderFileAction(true),
|
|
1443
1561
|
h(
|
|
1444
1562
|
"div",
|
|
1445
1563
|
{
|
|
1446
|
-
class:
|
|
1564
|
+
class: [
|
|
1565
|
+
"vxe-upload--file-list-wrapper",
|
|
1566
|
+
{
|
|
1567
|
+
"is--horizontal": isHorizontal
|
|
1568
|
+
}
|
|
1569
|
+
]
|
|
1447
1570
|
},
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1571
|
+
[
|
|
1572
|
+
currList.length ? dragSort ? h(
|
|
1573
|
+
TransitionGroup,
|
|
1451
1574
|
{
|
|
1452
|
-
|
|
1575
|
+
name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
|
|
1576
|
+
tag: "div",
|
|
1577
|
+
class: "vxe-upload--file-list"
|
|
1453
1578
|
},
|
|
1454
|
-
getSlotVNs(cornerSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly }))
|
|
1455
|
-
) : renderEmptyElement($xeUpload),
|
|
1456
|
-
showDownloadButton && !(isLoading || isPending) ? h(
|
|
1457
|
-
"div",
|
|
1458
1579
|
{
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
})
|
|
1468
|
-
]
|
|
1580
|
+
default: () => renderFileItemList(currList, false)
|
|
1581
|
+
}
|
|
1582
|
+
) : h(
|
|
1583
|
+
"div",
|
|
1584
|
+
{
|
|
1585
|
+
class: "vxe-upload--file-list"
|
|
1586
|
+
},
|
|
1587
|
+
renderFileItemList(currList, false)
|
|
1469
1588
|
) : renderEmptyElement($xeUpload),
|
|
1470
|
-
|
|
1589
|
+
showMoreButton && overMaxNum ? h(
|
|
1471
1590
|
"div",
|
|
1472
1591
|
{
|
|
1473
|
-
class: "vxe-upload--file-
|
|
1474
|
-
onClick(evnt) {
|
|
1475
|
-
removeFileEvent(evnt, item, index);
|
|
1476
|
-
}
|
|
1592
|
+
class: "vxe-upload--file-over-more"
|
|
1477
1593
|
},
|
|
1478
|
-
[
|
|
1479
|
-
h(
|
|
1480
|
-
|
|
1594
|
+
moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
|
|
1595
|
+
h(VxeButtonComponent, {
|
|
1596
|
+
mode: "text",
|
|
1597
|
+
content: moreButtonText ? XEUtils.isFunction(moreButtonText) ? moreButtonText({ $upload: $xeUpload, options: fileList }) : XEUtils.toFormatString(moreButtonText, [fileList.length]) : getI18n(isMoreMax && isMiniMore ? "vxe.upload.moreFileBtnText" : "vxe.upload.moreBtnText", [fileList.length]),
|
|
1598
|
+
status: "primary",
|
|
1599
|
+
onClick: handleMoreEvent
|
|
1481
1600
|
})
|
|
1482
1601
|
]
|
|
1483
|
-
) : renderEmptyElement($xeUpload)
|
|
1602
|
+
) : renderEmptyElement($xeUpload),
|
|
1603
|
+
showMoreButton && moreConfig && isHorizontal ? renderFileAction(false) : renderEmptyElement($xeUpload)
|
|
1484
1604
|
]
|
|
1485
1605
|
)
|
|
1486
|
-
]
|
|
1606
|
+
] : [renderFileAction(false)]
|
|
1487
1607
|
);
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
icon: showButtonIcon ? buttonIcon || getIcon().UPLOAD_FILE_ADD : "",
|
|
1520
|
-
disabled: isDisabled
|
|
1521
|
-
})
|
|
1522
|
-
]
|
|
1523
|
-
),
|
|
1524
|
-
showTipText && (defTipText || tipSlot) ? h(
|
|
1525
|
-
"div",
|
|
1526
|
-
{
|
|
1527
|
-
class: "vxe-upload--file-action-tip"
|
|
1528
|
-
},
|
|
1529
|
-
tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
|
|
1530
|
-
) : renderEmptyElement($xeUpload)
|
|
1531
|
-
]
|
|
1532
|
-
);
|
|
1533
|
-
};
|
|
1534
|
-
const rendeFileMode = () => {
|
|
1535
|
-
const { showList, moreConfig, dragSort } = props;
|
|
1536
|
-
const { fileList, isDragMove } = reactData;
|
|
1537
|
-
const moreOpts = computeMoreOpts.value;
|
|
1538
|
-
const { maxCount, showMoreButton, layout, moreButtonText } = moreOpts;
|
|
1539
|
-
const isHorizontal = layout === "horizontal";
|
|
1540
|
-
const moreBtnSlot = slots.moreButton || slots["more-button"];
|
|
1541
|
-
let currList = fileList;
|
|
1542
|
-
let overMaxNum = 0;
|
|
1543
|
-
let isMoreMax = false;
|
|
1544
|
-
let isMiniMore = false;
|
|
1545
|
-
if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
|
|
1546
|
-
isMoreMax = true;
|
|
1547
|
-
isMiniMore = maxCount === 0;
|
|
1548
|
-
overMaxNum = fileList.length - maxCount;
|
|
1549
|
-
currList = fileList.slice(0, maxCount);
|
|
1550
|
-
}
|
|
1551
|
-
return h(
|
|
1552
|
-
"div",
|
|
1553
|
-
{
|
|
1554
|
-
key: "all",
|
|
1555
|
-
class: "vxe-upload--file-wrapper"
|
|
1556
|
-
},
|
|
1557
|
-
showList ? [
|
|
1558
|
-
showMoreButton && moreConfig && isHorizontal ? renderEmptyElement($xeUpload) : renderFileAction(true),
|
|
1559
|
-
h(
|
|
1608
|
+
};
|
|
1609
|
+
const renderImageItemList = (currList, isMoreView) => {
|
|
1610
|
+
const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
|
|
1611
|
+
const { fileList, fileCacheMaps } = reactData;
|
|
1612
|
+
const isDisabled = computeIsDisabled.value;
|
|
1613
|
+
const formReadonly = computeFormReadonly.value;
|
|
1614
|
+
const imageOpts = computeImageOpts.value;
|
|
1615
|
+
const imgStyle = computeImgStyle.value;
|
|
1616
|
+
const optionSlot = slots.option;
|
|
1617
|
+
const actionSlot = slots.action;
|
|
1618
|
+
const cornerSlot = slots.corner;
|
|
1619
|
+
const ons = {
|
|
1620
|
+
onMousedown: handleItemMousedownEvent
|
|
1621
|
+
};
|
|
1622
|
+
if (dragSort && currList.length > 1) {
|
|
1623
|
+
ons.onDragstart = handleDragSortDragstartEvent;
|
|
1624
|
+
ons.onDragover = handleDragSortDragoverEvent;
|
|
1625
|
+
ons.onDragend = handleDragSortDragendEvent;
|
|
1626
|
+
}
|
|
1627
|
+
return currList.map((item, index) => {
|
|
1628
|
+
const fileKey = getFieldKey(item);
|
|
1629
|
+
const cacheItem = fileCacheMaps[fileKey];
|
|
1630
|
+
let isLoading = false;
|
|
1631
|
+
let isError = false;
|
|
1632
|
+
let isPending = false;
|
|
1633
|
+
if (cacheItem) {
|
|
1634
|
+
isLoading = cacheItem.loading;
|
|
1635
|
+
isError = cacheItem.status === "error";
|
|
1636
|
+
isPending = cacheItem.status === "pending";
|
|
1637
|
+
}
|
|
1638
|
+
return h(
|
|
1560
1639
|
"div",
|
|
1561
1640
|
{
|
|
1641
|
+
key: dragSort ? fileKey : index,
|
|
1562
1642
|
class: [
|
|
1563
|
-
"vxe-upload--
|
|
1643
|
+
"vxe-upload--image-item",
|
|
1564
1644
|
{
|
|
1565
|
-
"is--
|
|
1645
|
+
"is--preview": showPreview,
|
|
1646
|
+
"is--circle": imageOpts.circle,
|
|
1647
|
+
"is--loading": isLoading,
|
|
1648
|
+
"is--pending": isPending,
|
|
1649
|
+
"is--error": isError
|
|
1566
1650
|
}
|
|
1567
|
-
]
|
|
1651
|
+
],
|
|
1652
|
+
fileid: fileKey,
|
|
1653
|
+
draggable: dragSort ? true : null,
|
|
1654
|
+
...ons
|
|
1568
1655
|
},
|
|
1569
|
-
[
|
|
1570
|
-
|
|
1571
|
-
TransitionGroup,
|
|
1572
|
-
{
|
|
1573
|
-
name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
|
|
1574
|
-
tag: "div",
|
|
1575
|
-
class: "vxe-upload--file-list"
|
|
1576
|
-
},
|
|
1577
|
-
{
|
|
1578
|
-
default: () => renderFileItemList(currList, false)
|
|
1579
|
-
}
|
|
1580
|
-
) : h(
|
|
1581
|
-
"div",
|
|
1582
|
-
{
|
|
1583
|
-
class: "vxe-upload--file-list"
|
|
1584
|
-
},
|
|
1585
|
-
renderFileItemList(currList, false)
|
|
1586
|
-
) : renderEmptyElement($xeUpload),
|
|
1587
|
-
showMoreButton && overMaxNum ? h(
|
|
1656
|
+
optionSlot ? getSlotVNs(optionSlot({ option: item, isMoreView, options: fileList })) : [
|
|
1657
|
+
h(
|
|
1588
1658
|
"div",
|
|
1589
1659
|
{
|
|
1590
|
-
class: "vxe-upload--
|
|
1660
|
+
class: "vxe-upload--image-item-box",
|
|
1661
|
+
style: isMoreView ? null : imgStyle,
|
|
1662
|
+
onClick(evnt) {
|
|
1663
|
+
if (!isLoading && !isError) {
|
|
1664
|
+
handlePreviewImageEvent(evnt, item, index);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1591
1667
|
},
|
|
1592
|
-
|
|
1593
|
-
h(
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1668
|
+
[
|
|
1669
|
+
isLoading && cacheItem ? h(
|
|
1670
|
+
"div",
|
|
1671
|
+
{
|
|
1672
|
+
class: "vxe-upload--image-item-loading"
|
|
1673
|
+
},
|
|
1674
|
+
[
|
|
1675
|
+
h(
|
|
1676
|
+
"div",
|
|
1677
|
+
{
|
|
1678
|
+
class: "vxe-upload--image-item-loading-icon"
|
|
1679
|
+
},
|
|
1680
|
+
[
|
|
1681
|
+
h("i", {
|
|
1682
|
+
class: getIcon().UPLOAD_LOADING
|
|
1683
|
+
})
|
|
1684
|
+
]
|
|
1685
|
+
),
|
|
1686
|
+
showProgress ? h(
|
|
1687
|
+
"div",
|
|
1688
|
+
{
|
|
1689
|
+
class: "vxe-upload--image-item-loading-text"
|
|
1690
|
+
},
|
|
1691
|
+
progressText ? XEUtils.toFormatString(`${XEUtils.isFunction(progressText) ? progressText({}) : progressText}`, { percent: cacheItem.percent }) : getI18n("vxe.upload.uploadProgress", [cacheItem.percent])
|
|
1692
|
+
) : renderEmptyElement($xeUpload)
|
|
1693
|
+
]
|
|
1694
|
+
) : renderEmptyElement($xeUpload),
|
|
1695
|
+
h(
|
|
1696
|
+
"div",
|
|
1697
|
+
{
|
|
1698
|
+
class: "vxe-upload--image-item-img-wrapper",
|
|
1699
|
+
title: getI18n("vxe.upload.viewItemTitle")
|
|
1700
|
+
},
|
|
1701
|
+
[
|
|
1702
|
+
h("img", {
|
|
1703
|
+
class: "vxe-upload--image-item-img",
|
|
1704
|
+
src: getThumbnailFileUrl(item)
|
|
1705
|
+
})
|
|
1706
|
+
]
|
|
1707
|
+
),
|
|
1708
|
+
!isLoading && (isError && showErrorStatus || isPending && showSubmitButton && !autoSubmit) ? h(
|
|
1709
|
+
"div",
|
|
1710
|
+
{
|
|
1711
|
+
class: "vxe-upload--image-item-rebtn"
|
|
1712
|
+
},
|
|
1713
|
+
[
|
|
1714
|
+
h(VxeButtonComponent, {
|
|
1715
|
+
icon: isError ? getIcon().UPLOAD_IMAGE_RE_UPLOAD : getIcon().UPLOAD_IMAGE_UPLOAD,
|
|
1716
|
+
mode: "text",
|
|
1717
|
+
status: "primary",
|
|
1718
|
+
content: isError ? getI18n("vxe.upload.reUpload") : getI18n("vxe.upload.manualUpload"),
|
|
1719
|
+
onClick(evnt) {
|
|
1720
|
+
handleReUploadEvent(evnt, item);
|
|
1721
|
+
}
|
|
1722
|
+
})
|
|
1723
|
+
]
|
|
1724
|
+
) : renderEmptyElement($xeUpload),
|
|
1725
|
+
h(
|
|
1726
|
+
"div",
|
|
1727
|
+
{
|
|
1728
|
+
class: "vxe-upload--image-item-btn-wrapper",
|
|
1729
|
+
onClick(evnt) {
|
|
1730
|
+
evnt.stopPropagation();
|
|
1731
|
+
}
|
|
1732
|
+
},
|
|
1733
|
+
actionSlot ? getSlotVNs(actionSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly })) : [
|
|
1734
|
+
cornerSlot ? h(
|
|
1735
|
+
"div",
|
|
1736
|
+
{
|
|
1737
|
+
class: "vxe-upload--file-item-action"
|
|
1738
|
+
},
|
|
1739
|
+
getSlotVNs(cornerSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly }))
|
|
1740
|
+
) : renderEmptyElement($xeUpload),
|
|
1741
|
+
showRemoveButton && !formReadonly && !isDisabled && !isLoading ? h(
|
|
1742
|
+
"div",
|
|
1743
|
+
{
|
|
1744
|
+
class: "vxe-upload--image-item-remove-btn",
|
|
1745
|
+
onClick(evnt) {
|
|
1746
|
+
evnt.stopPropagation();
|
|
1747
|
+
removeFileEvent(evnt, item, index);
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
[
|
|
1751
|
+
h("i", {
|
|
1752
|
+
class: getIcon().UPLOAD_IMAGE_REMOVE
|
|
1753
|
+
})
|
|
1754
|
+
]
|
|
1755
|
+
) : renderEmptyElement($xeUpload)
|
|
1756
|
+
]
|
|
1757
|
+
)
|
|
1599
1758
|
]
|
|
1600
|
-
)
|
|
1601
|
-
showMoreButton && moreConfig && isHorizontal ? renderFileAction(false) : renderEmptyElement($xeUpload)
|
|
1759
|
+
)
|
|
1602
1760
|
]
|
|
1603
|
-
)
|
|
1604
|
-
|
|
1605
|
-
);
|
|
1606
|
-
};
|
|
1607
|
-
const renderImageItemList = (currList, isMoreView) => {
|
|
1608
|
-
const { showRemoveButton, showProgress, progressText, showPreview, showErrorStatus, dragSort, autoSubmit, showSubmitButton } = props;
|
|
1609
|
-
const { fileList, fileCacheMaps } = reactData;
|
|
1610
|
-
const isDisabled = computeIsDisabled.value;
|
|
1611
|
-
const formReadonly = computeFormReadonly.value;
|
|
1612
|
-
const imageOpts = computeImageOpts.value;
|
|
1613
|
-
const imgStyle = computeImgStyle.value;
|
|
1614
|
-
const optionSlot = slots.option;
|
|
1615
|
-
const actionSlot = slots.action;
|
|
1616
|
-
const cornerSlot = slots.corner;
|
|
1617
|
-
const ons = {
|
|
1618
|
-
onMousedown: handleItemMousedownEvent
|
|
1761
|
+
);
|
|
1762
|
+
});
|
|
1619
1763
|
};
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
const
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
isLoading = cacheItem.loading;
|
|
1633
|
-
isError = cacheItem.status === "error";
|
|
1634
|
-
isPending = cacheItem.status === "pending";
|
|
1764
|
+
const renderImageAction = (isMoreView) => {
|
|
1765
|
+
const { showUploadButton, buttonText, buttonIcon, showButtonText, showButtonIcon, autoHiddenButton } = props;
|
|
1766
|
+
const { fileList } = reactData;
|
|
1767
|
+
const formReadonly = computeFormReadonly.value;
|
|
1768
|
+
const showTipText = computedShowTipText.value;
|
|
1769
|
+
const defTipText = computedDefTipText.value;
|
|
1770
|
+
const overCount = computeOverCount.value;
|
|
1771
|
+
const imgStyle = computeImgStyle.value;
|
|
1772
|
+
const defaultSlot = slots.default;
|
|
1773
|
+
const tipSlot = slots.tip || slots.hint;
|
|
1774
|
+
if (formReadonly || !showUploadButton || autoHiddenButton && overCount) {
|
|
1775
|
+
return renderEmptyElement($xeUpload);
|
|
1635
1776
|
}
|
|
1636
1777
|
return h(
|
|
1637
1778
|
"div",
|
|
1638
1779
|
{
|
|
1639
|
-
key:
|
|
1640
|
-
class:
|
|
1641
|
-
"vxe-upload--image-item",
|
|
1642
|
-
{
|
|
1643
|
-
"is--preview": showPreview,
|
|
1644
|
-
"is--circle": imageOpts.circle,
|
|
1645
|
-
"is--loading": isLoading,
|
|
1646
|
-
"is--pending": isPending,
|
|
1647
|
-
"is--error": isError
|
|
1648
|
-
}
|
|
1649
|
-
],
|
|
1650
|
-
fileid: fileKey,
|
|
1651
|
-
draggable: dragSort ? true : null,
|
|
1652
|
-
...ons
|
|
1780
|
+
key: "action",
|
|
1781
|
+
class: "vxe-upload--image-action"
|
|
1653
1782
|
},
|
|
1654
|
-
|
|
1783
|
+
[
|
|
1655
1784
|
h(
|
|
1656
1785
|
"div",
|
|
1657
1786
|
{
|
|
1658
|
-
class: "vxe-upload--image-
|
|
1659
|
-
|
|
1660
|
-
onClick(evnt) {
|
|
1661
|
-
if (!isLoading && !isError) {
|
|
1662
|
-
handlePreviewImageEvent(evnt, item, index);
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1787
|
+
class: "vxe-upload--image-action-btn",
|
|
1788
|
+
onClick: clickEvent
|
|
1665
1789
|
},
|
|
1666
|
-
[
|
|
1667
|
-
|
|
1790
|
+
defaultSlot ? defaultSlot({ isMoreView, options: fileList, $upload: $xeUpload }) : [
|
|
1791
|
+
h(
|
|
1668
1792
|
"div",
|
|
1669
1793
|
{
|
|
1670
|
-
class: "vxe-upload--image-
|
|
1794
|
+
class: "vxe-upload--image-action-box",
|
|
1795
|
+
style: isMoreView ? null : imgStyle
|
|
1671
1796
|
},
|
|
1672
1797
|
[
|
|
1673
|
-
h(
|
|
1798
|
+
showButtonIcon ? h(
|
|
1674
1799
|
"div",
|
|
1675
1800
|
{
|
|
1676
|
-
class: "vxe-upload--image-
|
|
1801
|
+
class: "vxe-upload--image-action-icon"
|
|
1677
1802
|
},
|
|
1678
1803
|
[
|
|
1679
1804
|
h("i", {
|
|
1680
|
-
class: getIcon().
|
|
1805
|
+
class: buttonIcon || getIcon().UPLOAD_IMAGE_ADD
|
|
1681
1806
|
})
|
|
1682
1807
|
]
|
|
1683
|
-
),
|
|
1684
|
-
|
|
1685
|
-
"div",
|
|
1686
|
-
{
|
|
1687
|
-
class: "vxe-upload--image-item-loading-text"
|
|
1688
|
-
},
|
|
1689
|
-
progressText ? XEUtils.toFormatString(`${XEUtils.isFunction(progressText) ? progressText({}) : progressText}`, { percent: cacheItem.percent }) : getI18n("vxe.upload.uploadProgress", [cacheItem.percent])
|
|
1690
|
-
) : renderEmptyElement($xeUpload)
|
|
1691
|
-
]
|
|
1692
|
-
) : renderEmptyElement($xeUpload),
|
|
1693
|
-
h(
|
|
1694
|
-
"div",
|
|
1695
|
-
{
|
|
1696
|
-
class: "vxe-upload--image-item-img-wrapper",
|
|
1697
|
-
title: getI18n("vxe.upload.viewItemTitle")
|
|
1698
|
-
},
|
|
1699
|
-
[
|
|
1700
|
-
h("img", {
|
|
1701
|
-
class: "vxe-upload--image-item-img",
|
|
1702
|
-
src: getThumbnailFileUrl(item)
|
|
1703
|
-
})
|
|
1704
|
-
]
|
|
1705
|
-
),
|
|
1706
|
-
!isLoading && (isError && showErrorStatus || isPending && showSubmitButton && !autoSubmit) ? h(
|
|
1707
|
-
"div",
|
|
1708
|
-
{
|
|
1709
|
-
class: "vxe-upload--image-item-rebtn"
|
|
1710
|
-
},
|
|
1711
|
-
[
|
|
1712
|
-
h(VxeButtonComponent, {
|
|
1713
|
-
icon: isError ? getIcon().UPLOAD_IMAGE_RE_UPLOAD : getIcon().UPLOAD_IMAGE_UPLOAD,
|
|
1714
|
-
mode: "text",
|
|
1715
|
-
status: "primary",
|
|
1716
|
-
content: isError ? getI18n("vxe.upload.reUpload") : getI18n("vxe.upload.manualUpload"),
|
|
1717
|
-
onClick(evnt) {
|
|
1718
|
-
handleReUploadEvent(evnt, item);
|
|
1719
|
-
}
|
|
1720
|
-
})
|
|
1721
|
-
]
|
|
1722
|
-
) : renderEmptyElement($xeUpload),
|
|
1723
|
-
h(
|
|
1724
|
-
"div",
|
|
1725
|
-
{
|
|
1726
|
-
class: "vxe-upload--image-item-btn-wrapper",
|
|
1727
|
-
onClick(evnt) {
|
|
1728
|
-
evnt.stopPropagation();
|
|
1729
|
-
}
|
|
1730
|
-
},
|
|
1731
|
-
actionSlot ? getSlotVNs(actionSlot({ option: item, isMoreView, options: fileList, readonly: formReadonly })) : [
|
|
1732
|
-
cornerSlot ? h(
|
|
1808
|
+
) : renderEmptyElement($xeUpload),
|
|
1809
|
+
isMoreView || showButtonText ? h(
|
|
1733
1810
|
"div",
|
|
1734
1811
|
{
|
|
1735
|
-
class: "vxe-upload--
|
|
1812
|
+
class: "vxe-upload--image-action-content"
|
|
1736
1813
|
},
|
|
1737
|
-
|
|
1814
|
+
buttonText ? `${XEUtils.isFunction(buttonText) ? buttonText({}) : buttonText}` : getI18n("vxe.upload.imgBtnText")
|
|
1738
1815
|
) : renderEmptyElement($xeUpload),
|
|
1739
|
-
|
|
1816
|
+
showTipText && (defTipText || tipSlot) ? h(
|
|
1740
1817
|
"div",
|
|
1741
1818
|
{
|
|
1742
|
-
class: "vxe-upload--image-
|
|
1743
|
-
onClick(evnt) {
|
|
1744
|
-
evnt.stopPropagation();
|
|
1745
|
-
removeFileEvent(evnt, item, index);
|
|
1746
|
-
}
|
|
1819
|
+
class: "vxe-upload--image-action-hint"
|
|
1747
1820
|
},
|
|
1748
|
-
|
|
1749
|
-
h("i", {
|
|
1750
|
-
class: getIcon().UPLOAD_IMAGE_REMOVE
|
|
1751
|
-
})
|
|
1752
|
-
]
|
|
1821
|
+
tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
|
|
1753
1822
|
) : renderEmptyElement($xeUpload)
|
|
1754
1823
|
]
|
|
1755
1824
|
)
|
|
@@ -1757,110 +1826,66 @@ var upload_default = defineVxeComponent({
|
|
|
1757
1826
|
)
|
|
1758
1827
|
]
|
|
1759
1828
|
);
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
},
|
|
1795
|
-
[
|
|
1796
|
-
showButtonIcon ? h(
|
|
1829
|
+
};
|
|
1830
|
+
const renderImageMode = () => {
|
|
1831
|
+
const { showList, dragSort } = props;
|
|
1832
|
+
const { fileList, isDragMove } = reactData;
|
|
1833
|
+
const moreOpts = computeMoreOpts.value;
|
|
1834
|
+
const moreBtnSlot = slots.moreButton || slots["more-button"];
|
|
1835
|
+
const { maxCount, showMoreButton, moreButtonText } = moreOpts;
|
|
1836
|
+
let currList = fileList;
|
|
1837
|
+
let overMaxNum = 0;
|
|
1838
|
+
let isMoreMax = false;
|
|
1839
|
+
let isMiniMore = false;
|
|
1840
|
+
if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
|
|
1841
|
+
isMoreMax = true;
|
|
1842
|
+
isMiniMore = maxCount === 0;
|
|
1843
|
+
overMaxNum = fileList.length - maxCount;
|
|
1844
|
+
currList = fileList.slice(0, maxCount);
|
|
1845
|
+
}
|
|
1846
|
+
return h(
|
|
1847
|
+
"div",
|
|
1848
|
+
{
|
|
1849
|
+
key: "image",
|
|
1850
|
+
class: "vxe-upload--image-wrapper"
|
|
1851
|
+
},
|
|
1852
|
+
showList ? [
|
|
1853
|
+
dragSort ? h(
|
|
1854
|
+
TransitionGroup,
|
|
1855
|
+
{
|
|
1856
|
+
name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
|
|
1857
|
+
tag: "div",
|
|
1858
|
+
class: "vxe-upload--image-list"
|
|
1859
|
+
},
|
|
1860
|
+
{
|
|
1861
|
+
default: () => renderImageItemList(currList, false).concat([
|
|
1862
|
+
showMoreButton && overMaxNum ? h(
|
|
1797
1863
|
"div",
|
|
1798
1864
|
{
|
|
1799
|
-
|
|
1865
|
+
key: "om",
|
|
1866
|
+
class: "vxe-upload--image-over-more"
|
|
1800
1867
|
},
|
|
1801
|
-
[
|
|
1802
|
-
h(
|
|
1803
|
-
|
|
1868
|
+
moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
|
|
1869
|
+
h(VxeButtonComponent, {
|
|
1870
|
+
mode: "text",
|
|
1871
|
+
content: moreButtonText ? XEUtils.isFunction(moreButtonText) ? moreButtonText({ $upload: $xeUpload, options: fileList }) : XEUtils.toFormatString(moreButtonText, [fileList.length]) : getI18n(isMoreMax && isMiniMore ? "vxe.upload.moreImgBtnText" : "vxe.upload.moreBtnText", [fileList.length]),
|
|
1872
|
+
status: "primary",
|
|
1873
|
+
onClick: handleMoreEvent
|
|
1804
1874
|
})
|
|
1805
1875
|
]
|
|
1806
1876
|
) : renderEmptyElement($xeUpload),
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
{
|
|
1817
|
-
class: "vxe-upload--image-action-hint"
|
|
1818
|
-
},
|
|
1819
|
-
tipSlot ? getSlotVNs(tipSlot({ isMoreView, options: fileList, $upload: $xeUpload })) : `${defTipText}`
|
|
1820
|
-
) : renderEmptyElement($xeUpload)
|
|
1821
|
-
]
|
|
1822
|
-
)
|
|
1823
|
-
]
|
|
1824
|
-
)
|
|
1825
|
-
]
|
|
1826
|
-
);
|
|
1827
|
-
};
|
|
1828
|
-
const renderImageMode = () => {
|
|
1829
|
-
const { showList, dragSort } = props;
|
|
1830
|
-
const { fileList, isDragMove } = reactData;
|
|
1831
|
-
const moreOpts = computeMoreOpts.value;
|
|
1832
|
-
const moreBtnSlot = slots.moreButton || slots["more-button"];
|
|
1833
|
-
const { maxCount, showMoreButton, moreButtonText } = moreOpts;
|
|
1834
|
-
let currList = fileList;
|
|
1835
|
-
let overMaxNum = 0;
|
|
1836
|
-
let isMoreMax = false;
|
|
1837
|
-
let isMiniMore = false;
|
|
1838
|
-
if (XEUtils.isNumber(maxCount) && fileList.length > maxCount) {
|
|
1839
|
-
isMoreMax = true;
|
|
1840
|
-
isMiniMore = maxCount === 0;
|
|
1841
|
-
overMaxNum = fileList.length - maxCount;
|
|
1842
|
-
currList = fileList.slice(0, maxCount);
|
|
1843
|
-
}
|
|
1844
|
-
return h(
|
|
1845
|
-
"div",
|
|
1846
|
-
{
|
|
1847
|
-
key: "image",
|
|
1848
|
-
class: "vxe-upload--image-wrapper"
|
|
1849
|
-
},
|
|
1850
|
-
showList ? [
|
|
1851
|
-
dragSort ? h(
|
|
1852
|
-
TransitionGroup,
|
|
1853
|
-
{
|
|
1854
|
-
name: `vxe-upload--drag-list${isDragMove ? "" : "-disabled"}`,
|
|
1855
|
-
tag: "div",
|
|
1856
|
-
class: "vxe-upload--image-list"
|
|
1857
|
-
},
|
|
1858
|
-
{
|
|
1859
|
-
default: () => renderImageItemList(currList, false).concat([
|
|
1877
|
+
renderImageAction(false)
|
|
1878
|
+
])
|
|
1879
|
+
}
|
|
1880
|
+
) : h(
|
|
1881
|
+
"div",
|
|
1882
|
+
{
|
|
1883
|
+
class: "vxe-upload--image-list"
|
|
1884
|
+
},
|
|
1885
|
+
renderImageItemList(currList, false).concat([
|
|
1860
1886
|
showMoreButton && overMaxNum ? h(
|
|
1861
1887
|
"div",
|
|
1862
1888
|
{
|
|
1863
|
-
key: "om",
|
|
1864
1889
|
class: "vxe-upload--image-over-more"
|
|
1865
1890
|
},
|
|
1866
1891
|
moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
|
|
@@ -1874,136 +1899,114 @@ var upload_default = defineVxeComponent({
|
|
|
1874
1899
|
) : renderEmptyElement($xeUpload),
|
|
1875
1900
|
renderImageAction(false)
|
|
1876
1901
|
])
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
},
|
|
1889
|
-
moreBtnSlot ? getSlotVNs(moreBtnSlot({ options: fileList })) : [
|
|
1890
|
-
h(VxeButtonComponent, {
|
|
1891
|
-
mode: "text",
|
|
1892
|
-
content: moreButtonText ? XEUtils.isFunction(moreButtonText) ? moreButtonText({ $upload: $xeUpload, options: fileList }) : XEUtils.toFormatString(moreButtonText, [fileList.length]) : getI18n(isMoreMax && isMiniMore ? "vxe.upload.moreImgBtnText" : "vxe.upload.moreBtnText", [fileList.length]),
|
|
1893
|
-
status: "primary",
|
|
1894
|
-
onClick: handleMoreEvent
|
|
1895
|
-
})
|
|
1896
|
-
]
|
|
1897
|
-
) : renderEmptyElement($xeUpload),
|
|
1898
|
-
renderImageAction(false)
|
|
1899
|
-
])
|
|
1900
|
-
)
|
|
1901
|
-
] : [
|
|
1902
|
-
h(
|
|
1903
|
-
"div",
|
|
1904
|
-
{
|
|
1905
|
-
class: "vxe-upload--image-list"
|
|
1906
|
-
},
|
|
1907
|
-
[renderImageAction(false)]
|
|
1908
|
-
)
|
|
1909
|
-
]
|
|
1910
|
-
);
|
|
1911
|
-
};
|
|
1912
|
-
const renderVN = () => {
|
|
1913
|
-
const { showErrorStatus, dragToUpload, pasteToUpload, dragSort, dragPlaceholder } = props;
|
|
1914
|
-
const { isDragUploadStatus, showMorePopup, isActivated, dragIndex } = reactData;
|
|
1915
|
-
const vSize = computeSize.value;
|
|
1916
|
-
const isDisabled = computeIsDisabled.value;
|
|
1917
|
-
const formReadonly = computeFormReadonly.value;
|
|
1918
|
-
const isImage = computeIsImage.value;
|
|
1919
|
-
const ons = {
|
|
1920
|
-
onMousedown: handleItemMousedownEvent
|
|
1902
|
+
)
|
|
1903
|
+
] : [
|
|
1904
|
+
h(
|
|
1905
|
+
"div",
|
|
1906
|
+
{
|
|
1907
|
+
class: "vxe-upload--image-list"
|
|
1908
|
+
},
|
|
1909
|
+
[renderImageAction(false)]
|
|
1910
|
+
)
|
|
1911
|
+
]
|
|
1912
|
+
);
|
|
1921
1913
|
};
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
{
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1914
|
+
const renderVN = () => {
|
|
1915
|
+
const { showErrorStatus, dragToUpload, pasteToUpload, dragSort, dragPlaceholder } = props;
|
|
1916
|
+
const { isDragUploadStatus, showMorePopup, isActivated, dragIndex } = reactData;
|
|
1917
|
+
const vSize = computeSize.value;
|
|
1918
|
+
const isDisabled = computeIsDisabled.value;
|
|
1919
|
+
const formReadonly = computeFormReadonly.value;
|
|
1920
|
+
const isImage = computeIsImage.value;
|
|
1921
|
+
const ons = {
|
|
1922
|
+
onMousedown: handleItemMousedownEvent
|
|
1923
|
+
};
|
|
1924
|
+
if (dragToUpload && dragIndex === -1) {
|
|
1925
|
+
ons.onDragover = handleUploadDragoverEvent;
|
|
1926
|
+
ons.onDragleave = handleUploadDragleaveEvent;
|
|
1927
|
+
ons.onDrop = handleUploadDropEvent;
|
|
1928
|
+
}
|
|
1929
|
+
return h(
|
|
1930
|
+
"div",
|
|
1931
|
+
{
|
|
1932
|
+
ref: refElem,
|
|
1933
|
+
class: [
|
|
1934
|
+
"vxe-upload",
|
|
1935
|
+
{
|
|
1936
|
+
[`size--${vSize}`]: vSize,
|
|
1937
|
+
"is--active": isActivated,
|
|
1938
|
+
"is--readonly": formReadonly,
|
|
1939
|
+
"is--disabled": isDisabled,
|
|
1940
|
+
"is--paste": pasteToUpload,
|
|
1941
|
+
"show--error": showErrorStatus,
|
|
1942
|
+
"is--drag": isDragUploadStatus
|
|
1943
|
+
}
|
|
1944
|
+
],
|
|
1945
|
+
...ons
|
|
1946
|
+
},
|
|
1947
|
+
[
|
|
1948
|
+
isImage ? renderImageMode() : rendeFileMode(),
|
|
1949
|
+
dragSort ? h("div", {
|
|
1950
|
+
ref: refDragLineElem,
|
|
1951
|
+
class: "vxe-upload--drag-line"
|
|
1952
|
+
}) : renderEmptyElement($xeUpload),
|
|
1953
|
+
isDragUploadStatus && !showMorePopup ? h(
|
|
1954
|
+
"div",
|
|
1955
|
+
{
|
|
1956
|
+
class: "vxe-upload--drag-placeholder"
|
|
1957
|
+
},
|
|
1958
|
+
dragPlaceholder || getI18n("vxe.upload.dragPlaceholder")
|
|
1959
|
+
) : renderEmptyElement($xeUpload)
|
|
1960
|
+
]
|
|
1961
|
+
);
|
|
1962
|
+
};
|
|
1963
|
+
const listFlag = ref(0);
|
|
1964
|
+
watch(
|
|
1965
|
+
() => props.modelValue ? props.modelValue.length : 0,
|
|
1966
|
+
() => {
|
|
1967
|
+
listFlag.value++;
|
|
1968
|
+
}
|
|
1959
1969
|
);
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
() =>
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1970
|
+
watch(
|
|
1971
|
+
() => props.modelValue,
|
|
1972
|
+
() => {
|
|
1973
|
+
listFlag.value++;
|
|
1974
|
+
}
|
|
1975
|
+
);
|
|
1976
|
+
watch(listFlag, () => {
|
|
1977
|
+
updateFileList();
|
|
1978
|
+
});
|
|
1979
|
+
onMounted(() => {
|
|
1980
|
+
if (props.multiple && props.singleMode) {
|
|
1981
|
+
errLog("vxe.error.errConflicts", ["multiple", "single-mode"]);
|
|
1982
|
+
}
|
|
1983
|
+
if (props.imageStyle) {
|
|
1984
|
+
warnLog("vxe.error.delProp", ["image-style", "image-config"]);
|
|
1985
|
+
}
|
|
1986
|
+
if (props.dragSort) {
|
|
1987
|
+
initTpImg();
|
|
1988
|
+
}
|
|
1989
|
+
globalEvents.on($xeUpload, "paste", handleGlobalPasteEvent);
|
|
1990
|
+
globalEvents.on($xeUpload, "click", handleGlobalClickEvent);
|
|
1991
|
+
globalEvents.on($xeUpload, "blur", handleGlobalBlurEvent);
|
|
1992
|
+
});
|
|
1993
|
+
onBeforeUnmount(() => {
|
|
1994
|
+
reactData.isDragUploadStatus = false;
|
|
1995
|
+
globalEvents.off($xeUpload, "paste");
|
|
1996
|
+
globalEvents.off($xeUpload, "click");
|
|
1997
|
+
globalEvents.off($xeUpload, "blur");
|
|
1998
|
+
XEUtils.assign(reactData, createReactData());
|
|
1999
|
+
XEUtils.assign(internalData, createInternalData());
|
|
2000
|
+
});
|
|
1975
2001
|
updateFileList();
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
if (props.dragSort) {
|
|
1985
|
-
initTpImg();
|
|
1986
|
-
}
|
|
1987
|
-
globalEvents.on($xeUpload, "paste", handleGlobalPasteEvent);
|
|
1988
|
-
globalEvents.on($xeUpload, "click", handleGlobalClickEvent);
|
|
1989
|
-
globalEvents.on($xeUpload, "blur", handleGlobalBlurEvent);
|
|
1990
|
-
});
|
|
1991
|
-
onBeforeUnmount(() => {
|
|
1992
|
-
reactData.isDragUploadStatus = false;
|
|
1993
|
-
globalEvents.off($xeUpload, "paste");
|
|
1994
|
-
globalEvents.off($xeUpload, "click");
|
|
1995
|
-
globalEvents.off($xeUpload, "blur");
|
|
1996
|
-
XEUtils.assign(reactData, createReactData());
|
|
1997
|
-
XEUtils.assign(internalData, createInternalData());
|
|
1998
|
-
});
|
|
1999
|
-
updateFileList();
|
|
2000
|
-
$xeUpload.renderVN = renderVN;
|
|
2001
|
-
return $xeUpload;
|
|
2002
|
-
},
|
|
2003
|
-
render() {
|
|
2004
|
-
return this.renderVN();
|
|
2005
|
-
}
|
|
2006
|
-
});
|
|
2002
|
+
$xeUpload.renderVN = renderVN;
|
|
2003
|
+
return $xeUpload;
|
|
2004
|
+
},
|
|
2005
|
+
render() {
|
|
2006
|
+
return this.renderVN();
|
|
2007
|
+
}
|
|
2008
|
+
})
|
|
2009
|
+
);
|
|
2007
2010
|
export {
|
|
2008
2011
|
upload_default as default
|
|
2009
2012
|
};
|