@opentiny/vue-renderless 3.6.0 → 3.6.1-alpha.2
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/README.md +7 -26
- package/action-menu/index.js +15 -15
- package/action-menu/vue.js +17 -22
- package/action-sheet/index.js +53 -68
- package/action-sheet/vue.js +28 -54
- package/alert/index.js +10 -21
- package/alert/vue.js +19 -33
- package/amount/index.js +205 -308
- package/amount/vue.js +113 -187
- package/anchor/index.js +102 -173
- package/anchor/vue.js +26 -47
- package/area/index.js +93 -153
- package/area/vue.js +26 -62
- package/autocomplete/index.js +115 -157
- package/autocomplete/vue.js +84 -159
- package/autonavi-map/index.js +12 -22
- package/avatar/index.js +28 -31
- package/avatar/vue.js +16 -19
- package/badge/index.js +11 -15
- package/badge/vue.js +19 -27
- package/baidu-map/index.js +12 -22
- package/breadcrumb/index.js +8 -7
- package/breadcrumb/vue.js +15 -22
- package/breadcrumb-item/index.js +14 -26
- package/breadcrumb-item/vue.js +20 -28
- package/bulletin-board/index.js +19 -22
- package/bulletin-board/vue.js +26 -33
- package/button/index.js +14 -18
- package/button/vue.js +26 -38
- package/button-group/index.js +19 -24
- package/button-group/vue.js +32 -45
- package/calendar/index.js +168 -203
- package/calendar/vue.js +89 -100
- package/card-template/index.js +29 -37
- package/card-template/vue.js +18 -30
- package/carousel/index.js +125 -198
- package/carousel/vue.js +132 -188
- package/carousel-item/index.js +55 -80
- package/carousel-item/vue.js +42 -42
- package/cascader/index.js +329 -460
- package/cascader/vue.js +159 -319
- package/cascader-menu/index.js +32 -39
- package/cascader-menu/vue.js +21 -30
- package/cascader-node/index.js +41 -60
- package/cascader-node/vue.js +27 -59
- package/cascader-panel/index.js +229 -311
- package/cascader-panel/node.js +118 -190
- package/cascader-panel/store.js +49 -76
- package/cascader-panel/vue.js +125 -197
- package/chart-bar/index.js +129 -439
- package/chart-boxplot/index.js +78 -219
- package/chart-candle/index.js +134 -379
- package/chart-core/deps/constants.js +70 -49
- package/chart-core/deps/numerify.js +106 -147
- package/chart-core/deps/utils.js +118 -121
- package/chart-core/index.js +302 -469
- package/chart-core/modules/animation.js +7 -5
- package/chart-core/modules/extend.js +18 -19
- package/chart-core/modules/mark.js +7 -3
- package/chart-core/vue.js +81 -120
- package/chart-funnel/index.js +47 -126
- package/chart-gauge/index.js +54 -128
- package/chart-graph/index.js +22 -35
- package/chart-heatmap/index.js +116 -362
- package/chart-line/index.js +98 -289
- package/chart-liquidfill/index.js +35 -100
- package/chart-map/index.js +64 -217
- package/chart-pie/index.js +93 -274
- package/chart-radar/index.js +59 -135
- package/chart-sankey/index.js +51 -137
- package/chart-scatter/index.js +118 -313
- package/chart-sunburst/index.js +25 -33
- package/chart-tree/index.js +43 -85
- package/chart-waterfall/index.js +77 -210
- package/chart-wordcloud/index.js +36 -85
- package/checkbox/index.js +82 -133
- package/checkbox/vue.js +62 -132
- package/checkbox-button/index.js +60 -96
- package/checkbox-button/vue.js +53 -135
- package/checkbox-group/index.js +6 -11
- package/checkbox-group/vue.js +22 -27
- package/chunk-PKUHTIDK.js +37 -0
- package/col/index.js +89 -119
- package/col/vue.js +21 -31
- package/collapse/index.js +31 -40
- package/collapse/vue.js +24 -32
- package/collapse-item/index.js +22 -36
- package/collapse-item/vue.js +22 -42
- package/common/array.js +51 -56
- package/common/bigInt.js +187 -243
- package/common/browser.js +35 -31
- package/common/dataset/index.js +74 -110
- package/common/date.js +199 -201
- package/common/decimal.js +94 -142
- package/common/deps/ResizeObserver.js +188 -208
- package/common/deps/after-leave.js +12 -10
- package/common/deps/clickoutside.js +32 -36
- package/common/deps/date-util.js +139 -166
- package/common/deps/date.js +206 -241
- package/common/deps/debounce.js +8 -4
- package/common/deps/dom.js +75 -68
- package/common/deps/eSpaceCtrl.js +170 -153
- package/common/deps/fullscreen/apis.js +51 -65
- package/common/deps/fullscreen/screenfull.js +61 -45
- package/common/deps/letter-only.js +12 -8
- package/common/deps/memorize.js +100 -125
- package/common/deps/modal-queue.js +6 -2
- package/common/deps/number-only.js +13 -9
- package/common/deps/popper.js +280 -372
- package/common/deps/popup-manager.js +71 -75
- package/common/deps/repeat-click.js +14 -10
- package/common/deps/requestAnimationFrame.js +13 -13
- package/common/deps/resize-event.js +15 -10
- package/common/deps/scroll-into-view.js +13 -13
- package/common/deps/scrollbar-width.js +22 -18
- package/common/deps/throttle.js +15 -11
- package/common/deps/touch.js +24 -22
- package/common/deps/tree-model/node.js +374 -524
- package/common/deps/tree-model/tree-store.js +251 -352
- package/common/deps/tree-model/util.js +10 -4
- package/common/deps/upload-ajax.js +28 -24
- package/common/deps/vue-emitter.js +15 -11
- package/common/deps/vue-popper.js +181 -214
- package/common/deps/vue-popup.js +118 -168
- package/common/event.js +10 -9
- package/common/index.js +180 -194
- package/common/object.js +92 -91
- package/common/runtime.js +78 -51
- package/common/string.js +194 -266
- package/common/type.js +49 -51
- package/common/validate/index.js +8 -4
- package/common/validate/messages.js +64 -67
- package/common/validate/rules/enum.js +10 -6
- package/common/validate/rules/index.js +18 -14
- package/common/validate/rules/pattern.js +9 -5
- package/common/validate/rules/range.js +26 -39
- package/common/validate/rules/required.js +8 -10
- package/common/validate/rules/type.js +67 -79
- package/common/validate/rules/whitespace.js +8 -4
- package/common/validate/schema.js +159 -199
- package/common/validate/util.js +95 -82
- package/common/validate/validations/array.js +14 -17
- package/common/validate/validations/date.js +16 -20
- package/common/validate/validations/enum.js +14 -16
- package/common/validate/validations/float.js +13 -15
- package/common/validate/validations/index.js +28 -24
- package/common/validate/validations/integer.js +13 -15
- package/common/validate/validations/method.js +13 -15
- package/common/validate/validations/number.js +15 -17
- package/common/validate/validations/pattern.js +14 -16
- package/common/validate/validations/required.js +10 -14
- package/common/validate/validations/string.js +19 -15
- package/common/validate/validations/type.js +17 -13
- package/common/xss.js +202 -184
- package/company/index.js +34 -49
- package/company/vue.js +23 -29
- package/container/index.js +72 -98
- package/container/vue.js +36 -61
- package/country/index.js +33 -47
- package/country/vue.js +24 -29
- package/credit-card/index.js +72 -86
- package/credit-card/vue.js +49 -104
- package/credit-card-form/index.js +97 -129
- package/credit-card-form/vue.js +102 -133
- package/crop/index.js +175 -294
- package/crop/vue.js +132 -144
- package/currency/index.js +49 -67
- package/currency/vue.js +25 -34
- package/date-panel/index.js +384 -524
- package/date-panel/vue.js +178 -289
- package/date-picker/index.js +198 -260
- package/date-picker/vue.js +97 -155
- package/date-range/index.js +324 -435
- package/date-range/vue.js +154 -273
- package/date-table/index.js +279 -391
- package/date-table/vue.js +63 -139
- package/dept/index.js +196 -291
- package/dept/vue.js +74 -144
- package/detail-page/index.js +72 -131
- package/detail-page/vue.js +53 -128
- package/dialog-box/index.js +178 -248
- package/dialog-box/vue.js +111 -201
- package/drop-roles/index.js +44 -65
- package/drop-roles/vue.js +23 -31
- package/drop-times/index.js +21 -22
- package/drop-times/vue.js +19 -23
- package/dropdown/index.js +182 -253
- package/dropdown/vue.js +55 -101
- package/dropdown-item/index.js +113 -167
- package/dropdown-item/vue.js +73 -121
- package/dropdown-menu/index.js +85 -111
- package/dropdown-menu/vue.js +23 -36
- package/espace/index.js +86 -106
- package/espace/vue.js +26 -48
- package/exception/index.js +9 -12
- package/exception/vue.js +15 -22
- package/fall-menu/index.js +81 -110
- package/fall-menu/vue.js +32 -78
- package/file-upload/index.js +1081 -1713
- package/file-upload/vue.js +175 -417
- package/floatbar/index.js +8 -5
- package/floatbar/vue.js +13 -16
- package/form/index.js +124 -165
- package/form/vue.js +54 -66
- package/form-item/index.js +255 -328
- package/form-item/vue.js +97 -198
- package/fullscreen/index.js +95 -127
- package/fullscreen/vue.js +36 -72
- package/grid/core/index.js +7 -3
- package/grid/core/interceptor.js +28 -20
- package/grid/core/storeMap.js +11 -7
- package/grid/plugins/export.js +72 -95
- package/grid/plugins/exportExcel.js +244 -561
- package/grid/plugins/header.js +22 -21
- package/grid/plugins/resize.js +45 -62
- package/grid/static/array/arrayEach.js +7 -3
- package/grid/static/array/arrayIndexOf.js +7 -3
- package/grid/static/array/eachTree.js +17 -21
- package/grid/static/array/every.js +6 -2
- package/grid/static/array/filterTree.js +17 -12
- package/grid/static/array/find.js +7 -3
- package/grid/static/array/findTree.js +19 -30
- package/grid/static/array/helperCreateIterateHandle.js +31 -39
- package/grid/static/array/helperCreateTreeFunc.js +18 -16
- package/grid/static/array/includes.js +6 -4
- package/grid/static/array/lastArrayEach.js +7 -3
- package/grid/static/array/map.js +11 -10
- package/grid/static/array/mapTree.js +19 -23
- package/grid/static/array/slice.js +7 -3
- package/grid/static/array/sortBy.js +32 -34
- package/grid/static/array/sum.js +14 -13
- package/grid/static/array/toArray.js +6 -6
- package/grid/static/array/toTreeArray.js +13 -15
- package/grid/static/base/clear.js +18 -14
- package/grid/static/base/clone.js +11 -17
- package/grid/static/base/destructuring.js +14 -10
- package/grid/static/base/each.js +8 -4
- package/grid/static/base/eqNull.js +7 -5
- package/grid/static/base/findIndexOf.js +8 -4
- package/grid/static/base/get.js +21 -17
- package/grid/static/base/has.js +21 -20
- package/grid/static/base/hasOwnProp.js +5 -3
- package/grid/static/base/helperCreateGetObjects.js +13 -9
- package/grid/static/base/helperCreateInInObjectString.js +8 -4
- package/grid/static/base/helperCreateInTypeof.js +8 -5
- package/grid/static/base/helperCreateIndexOf.js +19 -18
- package/grid/static/base/helperCreateiterateIndexOf.js +20 -19
- package/grid/static/base/helperDefaultCompare.js +5 -1
- package/grid/static/base/helperDeleteProperty.js +7 -3
- package/grid/static/base/helperEqualCompare.js +27 -29
- package/grid/static/base/helperGetHGSKeys.js +5 -3
- package/grid/static/base/indexOf.js +7 -3
- package/grid/static/base/isArray.js +7 -3
- package/grid/static/base/isBoolean.js +5 -3
- package/grid/static/base/isDate.js +7 -3
- package/grid/static/base/isEmpty.js +7 -3
- package/grid/static/base/isEqual.js +10 -10
- package/grid/static/base/isFunction.js +5 -3
- package/grid/static/base/isNaN.js +6 -4
- package/grid/static/base/isNull.js +5 -3
- package/grid/static/base/isNumber.js +5 -3
- package/grid/static/base/isObject.js +5 -4
- package/grid/static/base/isPlainObject.js +6 -2
- package/grid/static/base/isRegExp.js +7 -3
- package/grid/static/base/isSet.js +6 -4
- package/grid/static/base/isString.js +5 -3
- package/grid/static/base/isUndefined.js +5 -3
- package/grid/static/base/keys.js +7 -3
- package/grid/static/base/lastEach.js +8 -4
- package/grid/static/base/remove.js +20 -20
- package/grid/static/base/set.js +22 -18
- package/grid/static/base/toJSONString.js +5 -3
- package/grid/static/base/toStringJSON.js +10 -5
- package/grid/static/base/uniqueId.js +6 -4
- package/grid/static/browse/browse.js +25 -22
- package/grid/static/function/property.js +6 -6
- package/grid/static/function/throttle.js +18 -14
- package/grid/static/index.js +111 -55
- package/grid/static/number/helperCreateToNumber.js +12 -10
- package/grid/static/number/toNumber.js +7 -3
- package/grid/static/object/assign.js +20 -20
- package/grid/static/object/extend.js +7 -3
- package/grid/static/object/lastObjectEach.js +9 -5
- package/grid/static/object/objectEach.js +8 -4
- package/grid/static/object/objectMap.js +11 -7
- package/grid/static/object/values.js +15 -7
- package/grid/static/static/staticDocument.js +7 -4
- package/grid/static/static/staticHGKeyRE.js +6 -2
- package/grid/static/static/staticParseInt.js +6 -2
- package/grid/static/static/staticStrUndefined.js +6 -2
- package/grid/static/static/staticWindow.js +7 -4
- package/grid/static/string/template.js +10 -8
- package/grid/static/string/toString.js +12 -8
- package/grid/utils/column.js +11 -14
- package/grid/utils/common.js +84 -102
- package/grid/utils/dom.js +104 -117
- package/grid/utils/event.js +23 -28
- package/grid/utils/index.js +8 -5
- package/hrapprover/index.js +80 -105
- package/hrapprover/vue.js +45 -90
- package/image/index.js +107 -175
- package/image/vue.js +56 -126
- package/image-viewer/index.js +328 -416
- package/image-viewer/vue.js +131 -206
- package/index-bar/index.js +42 -51
- package/index-bar/vue.js +53 -74
- package/index-bar-anchor/vue.js +14 -18
- package/input/index.js +232 -302
- package/input/vue.js +181 -284
- package/ip-address/index.js +168 -335
- package/ip-address/vue.js +95 -160
- package/layout/vue.js +7 -4
- package/link/index.js +9 -10
- package/link/vue.js +15 -23
- package/link-menu/index.js +86 -128
- package/link-menu/vue.js +55 -118
- package/list/index.js +12 -12
- package/list/vue.js +15 -15
- package/loading/index.js +22 -21
- package/loading/vue.js +15 -18
- package/locales/index.js +72 -104
- package/locales/vue.js +23 -41
- package/logon-user/index.js +14 -19
- package/logon-user/vue.js +17 -20
- package/logout/index.js +58 -96
- package/logout/vue.js +15 -19
- package/milestone/index.js +53 -76
- package/milestone/vue.js +28 -26
- package/mini-picker/index.js +155 -219
- package/mini-picker/vue.js +98 -118
- package/modal/index.js +386 -735
- package/modal/vue.js +81 -117
- package/month-range/index.js +108 -143
- package/month-range/vue.js +57 -85
- package/month-table/index.js +157 -202
- package/month-table/vue.js +42 -64
- package/multi-select/index.js +150 -214
- package/multi-select/vue.js +58 -102
- package/nav-menu/index.js +276 -410
- package/nav-menu/vue.js +110 -174
- package/notify/index.js +59 -81
- package/notify/vue.js +42 -57
- package/numeric/index.js +231 -363
- package/numeric/vue.js +78 -202
- package/option/index.js +44 -72
- package/option/vue.js +66 -179
- package/option-group/index.js +12 -17
- package/option-group/vue.js +25 -30
- package/package.json +32 -84
- package/pager-item/index.js +91 -103
- package/pager-item/vue.js +36 -48
- package/panel/index.js +22 -28
- package/panel/vue.js +17 -23
- package/picker/index.js +689 -963
- package/picker/timezone.js +1174 -974
- package/picker/vue.js +187 -389
- package/picker-column/index.js +182 -232
- package/picker-column/vue.js +71 -130
- package/pop-upload/index.js +162 -321
- package/pop-upload/vue.js +143 -273
- package/popeditor/index.js +528 -807
- package/popeditor/vue.js +165 -334
- package/popover/index.js +160 -219
- package/popover/vue.js +76 -162
- package/popup/index.js +90 -128
- package/popup/vue.js +39 -112
- package/progress/index.js +108 -171
- package/progress/vue.js +65 -115
- package/pull-refresh/index.js +118 -132
- package/pull-refresh/vue.js +38 -66
- package/radio/index.js +41 -77
- package/radio/vue.js +35 -92
- package/radio-button/index.js +35 -54
- package/radio-button/vue.js +28 -61
- package/radio-group/index.js +46 -48
- package/radio-group/vue.js +26 -30
- package/rate/index.js +158 -197
- package/rate/vue.js +90 -138
- package/roles/index.js +48 -77
- package/roles/vue.js +20 -32
- package/row/index.js +15 -16
- package/row/vue.js +20 -19
- package/scroll-text/index.js +17 -22
- package/scroll-text/vue.js +18 -27
- package/scrollbar/index.js +87 -115
- package/scrollbar/vue-bar.js +23 -46
- package/scrollbar/vue.js +25 -33
- package/search/index.js +67 -95
- package/search/vue.js +80 -100
- package/select/index.js +1094 -1584
- package/select/vue.js +342 -672
- package/select-dropdown/index.js +18 -23
- package/select-dropdown/vue.js +56 -112
- package/slide-bar/index.js +58 -85
- package/slide-bar/vue.js +21 -47
- package/slider/index.js +276 -373
- package/slider/vue.js +94 -144
- package/split/index.js +74 -123
- package/split/vue.js +63 -116
- package/steps/vue.js +8 -3
- package/switch/index.js +35 -43
- package/switch/vue.js +32 -58
- package/tab-bar/index.js +48 -46
- package/tab-bar/vue.js +14 -12
- package/tab-dropdown/index.js +11 -10
- package/tab-dropdown/vue.js +14 -11
- package/tab-item/index.js +20 -35
- package/tab-item/vue.js +22 -42
- package/tab-nav/index.js +194 -227
- package/tab-nav/vue.js +62 -83
- package/tabbar/index.js +23 -30
- package/tabbar/vue.js +22 -45
- package/tabbar-item/index.js +39 -51
- package/tabbar-item/vue.js +23 -48
- package/table/index.js +69 -103
- package/table/vue.js +37 -61
- package/tabs/index.js +125 -174
- package/tabs/vue.js +98 -143
- package/tag/index.js +13 -18
- package/tag/vue.js +11 -16
- package/tall-storage/index.js +87 -106
- package/tall-storage/vue-storage-box.js +14 -20
- package/tall-storage/vue.js +27 -35
- package/text-popup/index.js +48 -70
- package/text-popup/vue.js +27 -60
- package/time/index.js +71 -113
- package/time/vue.js +65 -108
- package/time-line/index.js +30 -56
- package/time-line/vue.js +23 -46
- package/time-panel/index.js +112 -175
- package/time-panel/scrollIntoView.js +12 -10
- package/time-panel/vue.js +64 -94
- package/time-range/index.js +123 -184
- package/time-range/vue.js +63 -115
- package/time-spinner/index.js +139 -179
- package/time-spinner/vue.js +72 -110
- package/toggle-menu/index.js +68 -98
- package/toggle-menu/vue.js +64 -54
- package/tooltip/index.js +127 -168
- package/tooltip/vue.js +81 -134
- package/top-box/index.js +46 -79
- package/top-box/vue.js +34 -62
- package/transfer/index.js +184 -263
- package/transfer/vue.js +65 -134
- package/transfer-panel/index.js +240 -329
- package/transfer-panel/vue.js +127 -232
- package/tree/index.js +422 -591
- package/tree/vue.js +163 -249
- package/tree-menu/index.js +97 -122
- package/tree-menu/vue.js +57 -39
- package/tree-node/index.js +180 -248
- package/tree-node/vue.js +107 -202
- package/upload/index.js +201 -276
- package/upload/vue.js +51 -82
- package/upload-dragger/index.js +38 -49
- package/upload-dragger/vue.js +16 -24
- package/upload-list/index.js +41 -50
- package/upload-list/vue.js +21 -27
- package/user/index.js +356 -510
- package/user/vue.js +50 -97
- package/user-account/index.js +16 -21
- package/user-account/vue.js +20 -23
- package/user-contact/index.js +11 -10
- package/user-contact/vue.js +15 -15
- package/user-head/index.js +69 -84
- package/user-head/vue.js +24 -45
- package/user-link/index.js +31 -41
- package/user-link/vue.js +23 -46
- package/wheel/index.js +136 -161
- package/wheel/vue.js +64 -95
- package/wizard/index.js +83 -102
- package/wizard/vue.js +19 -34
- package/year-table/index.js +31 -37
- package/year-table/vue.js +17 -21
- package/rich-text/clipboard.js +0 -77
- package/rich-text/index.js +0 -176
- package/rich-text/module/file-upload.js +0 -118
- package/rich-text/module/image-drop.js +0 -54
- package/rich-text/module/image-upload.js +0 -84
- package/rich-text/options.js +0 -187
- package/rich-text/table-module.js +0 -557
- package/rich-text/vue.js +0 -149
package/file-upload/index.js
CHANGED
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
sHA256: 'SHA256'
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues
|
|
3
|
+
} from "../chunk-PKUHTIDK.js";
|
|
4
|
+
import { extend } from "@opentiny/vue-renderless/common/object";
|
|
5
|
+
import { xss, log } from "@opentiny/vue-renderless/common/xss";
|
|
6
|
+
import uploadAjax from "@opentiny/vue-renderless/common/deps/upload-ajax";
|
|
7
|
+
let initTokenPromise = null;
|
|
8
|
+
const shaMap = {
|
|
9
|
+
sHA256: "SHA256"
|
|
11
10
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} else {
|
|
20
|
-
return Promise.reject(new Error('[TINY Error][FileUpload] This component depends on @opentiny/vue-service'));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
11
|
+
const initService = ({ props, service }) => {
|
|
12
|
+
const noopFnCreator = (propName) => () => {
|
|
13
|
+
if (propName) {
|
|
14
|
+
return Promise.reject(new Error(`[TINY Error][FileUpload] Prop ${propName} is not configured`));
|
|
15
|
+
} else {
|
|
16
|
+
return Promise.reject(new Error("[TINY Error][FileUpload] This component depends on @opentiny/vue-service"));
|
|
17
|
+
}
|
|
23
18
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_ref2$common = _ref2.common,
|
|
28
|
-
common = _ref2$common === void 0 ? {} : _ref2$common;
|
|
29
|
-
var request = network.request,
|
|
30
|
-
get = network.get,
|
|
31
|
-
post = network.post,
|
|
32
|
-
all = network.all,
|
|
33
|
-
spread = network.spread,
|
|
34
|
-
_network$CancelToken = network.CancelToken,
|
|
35
|
-
CancelToken = _network$CancelToken === void 0 ? {} : _network$CancelToken;
|
|
36
|
-
var noopFn = noopFnCreator();
|
|
19
|
+
const { network = {}, common = {} } = service || {};
|
|
20
|
+
const { request, get, post, all, spread, CancelToken = {} } = network;
|
|
21
|
+
const noopFn = noopFnCreator();
|
|
37
22
|
return {
|
|
38
23
|
get: get || noopFn,
|
|
39
24
|
post: post || noopFn,
|
|
@@ -53,726 +38,487 @@ export var initService = function initService(_ref) {
|
|
|
53
38
|
httpRequest: props.httpRequest || request || uploadAjax
|
|
54
39
|
};
|
|
55
40
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return state.uploadingFiles.reduce(function (total, file) {
|
|
66
|
-
return total + file.size;
|
|
67
|
-
}, 0);
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
export var watchListType = function watchListType(_ref4) {
|
|
71
|
-
var constants = _ref4.constants,
|
|
72
|
-
state = _ref4.state;
|
|
73
|
-
return function (type) {
|
|
74
|
-
if (type === constants.LIST_TYPE.PICTURE_CARD || type === constants.LIST_TYPE.PICTURE) {
|
|
75
|
-
state.uploadFiles = state.uploadFiles.map(function (file) {
|
|
76
|
-
if (!file.url && file.raw) {
|
|
77
|
-
try {
|
|
78
|
-
file.url = URL.createObjectURL(file.raw);
|
|
79
|
-
} catch (err) {}
|
|
41
|
+
const computedUploadDisabled = ({ props, state }) => () => props.disabled || (state.elForm || {}).disabled;
|
|
42
|
+
const computedUploadingSize = (state) => () => state.uploadingFiles.reduce((total, file) => total + file.size, 0);
|
|
43
|
+
const watchListType = ({ constants, state }) => (type) => {
|
|
44
|
+
if (type === constants.LIST_TYPE.PICTURE_CARD || type === constants.LIST_TYPE.PICTURE) {
|
|
45
|
+
state.uploadFiles = state.uploadFiles.map((file) => {
|
|
46
|
+
if (!file.url && file.raw) {
|
|
47
|
+
try {
|
|
48
|
+
file.url = URL.createObjectURL(file.raw);
|
|
49
|
+
} catch (err) {
|
|
80
50
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export var watchFileList = function watchFileList(_ref5) {
|
|
87
|
-
var constants = _ref5.constants,
|
|
88
|
-
state = _ref5.state;
|
|
89
|
-
return function (fileList) {
|
|
90
|
-
state.uploadFiles = fileList && fileList.map(function (item) {
|
|
91
|
-
item.uid = item.uid || Date.now() + state.tempIndex++;
|
|
92
|
-
item.status = item.status || constants.FILE_STATUS.SUCESS;
|
|
93
|
-
return item;
|
|
51
|
+
}
|
|
52
|
+
return file;
|
|
94
53
|
});
|
|
95
|
-
}
|
|
54
|
+
}
|
|
96
55
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
56
|
+
const watchFileList = ({ constants, state }) => (fileList) => {
|
|
57
|
+
state.uploadFiles = fileList && fileList.map((item) => {
|
|
58
|
+
item.uid = item.uid || Date.now() + state.tempIndex++;
|
|
59
|
+
item.status = item.status || constants.FILE_STATUS.SUCESS;
|
|
60
|
+
return item;
|
|
61
|
+
});
|
|
102
62
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
63
|
+
const isNonFuncPropBeforeUpload = ({ flag, doUpload, file }) => !flag && doUpload(file);
|
|
64
|
+
const onBeforeIsPromise = ({ before, rawFile, file, doUpload, autoRemove, api }) => {
|
|
65
|
+
before.then(
|
|
66
|
+
(processedFile) => {
|
|
67
|
+
const fileType = Object.prototype.toString.call(processedFile);
|
|
68
|
+
if (fileType === "[object File]" || fileType === "[object Blob]") {
|
|
69
|
+
if (fileType === "[object Blob]") {
|
|
70
|
+
processedFile = new File([processedFile], rawFile.name, { type: rawFile.type });
|
|
71
|
+
}
|
|
72
|
+
for (const p in rawFile) {
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(rawFile, p)) {
|
|
74
|
+
processedFile[p] = rawFile[p];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
file.raw = processedFile;
|
|
117
78
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
79
|
+
doUpload(file);
|
|
80
|
+
},
|
|
81
|
+
() => {
|
|
82
|
+
if (autoRemove) {
|
|
83
|
+
if (!Array.isArray(rawFile)) {
|
|
84
|
+
api.handleRemove(null, rawFile);
|
|
85
|
+
} else {
|
|
86
|
+
rawFile.forEach((raw) => api.handleRemove(null, raw));
|
|
121
87
|
}
|
|
122
88
|
}
|
|
123
|
-
file.raw = processedFile;
|
|
124
89
|
}
|
|
125
|
-
|
|
126
|
-
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
const beforeUpload = ({ props, api, Modal, constants, t, state }) => (file, autoRemove, doUpload) => {
|
|
93
|
+
if (state.isEdm && file.name.length > 255) {
|
|
127
94
|
if (autoRemove) {
|
|
128
|
-
|
|
129
|
-
|
|
95
|
+
const rawFile = file.raw;
|
|
96
|
+
if (Array.isArray(rawFile)) {
|
|
97
|
+
rawFile.forEach((raw) => api.handleRemove(null, raw));
|
|
130
98
|
} else {
|
|
131
|
-
|
|
132
|
-
return api.handleRemove(null, raw);
|
|
133
|
-
});
|
|
99
|
+
api.handleRemove(null, rawFile);
|
|
134
100
|
}
|
|
135
101
|
}
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
102
|
+
return Modal.message({
|
|
103
|
+
message: `${t(constants.EDM.THEFILENAME)}"${file.name}"${t(constants.EDM.FILENAMEEXCEEDS)}`,
|
|
104
|
+
status: "warning"
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
let flag = typeof props.beforeUpload === "function";
|
|
108
|
+
isNonFuncPropBeforeUpload({ flag, doUpload, file });
|
|
109
|
+
if (flag) {
|
|
110
|
+
const { rawFile = file.raw, before = props.beforeUpload(rawFile) } = {};
|
|
111
|
+
if (before && before.then) {
|
|
112
|
+
onBeforeIsPromise({ before, rawFile, file, doUpload, autoRemove, api });
|
|
113
|
+
} else if (before !== false) {
|
|
114
|
+
doUpload(file);
|
|
115
|
+
} else {
|
|
147
116
|
if (autoRemove) {
|
|
148
|
-
var rawFile = file.raw;
|
|
149
117
|
if (Array.isArray(rawFile)) {
|
|
150
|
-
rawFile.forEach(
|
|
151
|
-
return api.handleRemove(null, raw);
|
|
152
|
-
});
|
|
118
|
+
rawFile.forEach((raw) => api.handleRemove(null, raw));
|
|
153
119
|
} else {
|
|
154
120
|
api.handleRemove(null, rawFile);
|
|
155
121
|
}
|
|
156
122
|
}
|
|
157
|
-
return Modal.message({
|
|
158
|
-
message: "".concat(t(constants.EDM.THEFILENAME), "\"").concat(file.name, "\"").concat(t(constants.EDM.FILENAMEEXCEEDS)),
|
|
159
|
-
status: 'warning'
|
|
160
|
-
});
|
|
161
123
|
}
|
|
162
|
-
|
|
163
|
-
isNonFuncPropBeforeUpload({
|
|
164
|
-
flag: flag,
|
|
165
|
-
doUpload: doUpload,
|
|
166
|
-
file: file
|
|
167
|
-
});
|
|
168
|
-
if (flag) {
|
|
169
|
-
var _ref9 = {},
|
|
170
|
-
_ref9$rawFile = _ref9.rawFile,
|
|
171
|
-
_rawFile = _ref9$rawFile === void 0 ? file.raw : _ref9$rawFile,
|
|
172
|
-
_ref9$before = _ref9.before,
|
|
173
|
-
before = _ref9$before === void 0 ? props.beforeUpload(_rawFile) : _ref9$before;
|
|
174
|
-
if (before && before.then) {
|
|
175
|
-
onBeforeIsPromise({
|
|
176
|
-
before: before,
|
|
177
|
-
rawFile: _rawFile,
|
|
178
|
-
file: file,
|
|
179
|
-
doUpload: doUpload,
|
|
180
|
-
autoRemove: autoRemove,
|
|
181
|
-
api: api
|
|
182
|
-
});
|
|
183
|
-
} else if (before !== false) {
|
|
184
|
-
doUpload(file);
|
|
185
|
-
} else {
|
|
186
|
-
if (autoRemove) {
|
|
187
|
-
if (Array.isArray(_rawFile)) {
|
|
188
|
-
_rawFile.forEach(function (raw) {
|
|
189
|
-
return api.handleRemove(null, raw);
|
|
190
|
-
});
|
|
191
|
-
} else {
|
|
192
|
-
api.handleRemove(null, _rawFile);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
124
|
+
}
|
|
198
125
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
Modal.message({
|
|
216
|
-
message: "".concat(file.name).concat(t(constants.EDM.LARGEFILEKEY)),
|
|
217
|
-
status: 'warning'
|
|
218
|
-
});
|
|
219
|
-
} else {
|
|
220
|
-
refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
221
|
-
}
|
|
222
|
-
};
|
|
126
|
+
const startUpload = ({ state, constants, refs, Modal, api, t }) => (file, isList) => {
|
|
127
|
+
if (file.size > state.docSize && file.size > state.chunkSize) {
|
|
128
|
+
file.isLargeFile = true;
|
|
129
|
+
isList && state.uploadFiles.forEach((f) => {
|
|
130
|
+
if (f.cacheSign === file.cacheSign) {
|
|
131
|
+
f.percentage = 0;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
api.largeDocumentUpload(file);
|
|
135
|
+
Modal.message({
|
|
136
|
+
message: `${file.name}${t(constants.EDM.LARGEFILEKEY)}`,
|
|
137
|
+
status: "warning"
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
141
|
+
}
|
|
223
142
|
};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
143
|
+
const calcFileForMobile = (rawFile, file) => {
|
|
144
|
+
const fileName = rawFile.name.lastIndexOf(".");
|
|
145
|
+
const fileNameLen = rawFile.name.length;
|
|
227
146
|
file.fileType = rawFile.name.substring(fileName + 1, fileNameLen);
|
|
228
|
-
|
|
147
|
+
const size = rawFile.size / 1024;
|
|
229
148
|
if (size < 1024) {
|
|
230
|
-
file.size = Math.round(size *
|
|
149
|
+
file.size = Math.round(size * 10 ** 1) / 10 ** 1 + "KB";
|
|
231
150
|
} else {
|
|
232
|
-
|
|
233
|
-
file.size = Math.round(fileSize *
|
|
151
|
+
const fileSize = size / 1024;
|
|
152
|
+
file.size = Math.round(fileSize * 10 ** 1) / 10 ** 1 + "MB";
|
|
234
153
|
}
|
|
235
154
|
};
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
maxSize = Math.min(state.singleMaxSize);
|
|
248
|
-
}
|
|
249
|
-
if (file.size > maxSize * 1024 * 1024) {
|
|
250
|
-
Modal.message({
|
|
251
|
-
message: "".concat(file.name, " ").concat(t(constants.EDM.EXCEED), " ").concat(maxSize, " MB"),
|
|
252
|
-
status: 'warning'
|
|
253
|
-
});
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
if (file.size <= 0) {
|
|
257
|
-
Modal.message({
|
|
258
|
-
message: "".concat(file.name, " ").concat(t(constants.EDM.FILEEMPTY)),
|
|
259
|
-
status: 'warning'
|
|
260
|
-
});
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
var userMin = props.fileSize && (props.fileSize[0] || props.fileSize) || 0;
|
|
264
|
-
if (file.size <= userMin * 1024) {
|
|
265
|
-
Modal.message({
|
|
266
|
-
message: "".concat(t(constants.EDM.SIZE).replace(/{name}/, file.name), " ").concat(userMin, " KB"),
|
|
267
|
-
status: 'warning'
|
|
268
|
-
});
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
return true;
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
export var addFileToList = function addFileToList(_ref12) {
|
|
275
|
-
var api = _ref12.api,
|
|
276
|
-
constants = _ref12.constants,
|
|
277
|
-
emit = _ref12.emit,
|
|
278
|
-
props = _ref12.props,
|
|
279
|
-
state = _ref12.state,
|
|
280
|
-
mode = _ref12.mode;
|
|
281
|
-
return function (rawFile, updateId) {
|
|
282
|
-
rawFile.uid = Date.now() + state.tempIndex++;
|
|
283
|
-
var file = {
|
|
284
|
-
status: constants.FILE_STATUS.READY,
|
|
285
|
-
name: rawFile.name,
|
|
286
|
-
size: rawFile.size
|
|
287
|
-
};
|
|
288
|
-
Object.assign(file, {
|
|
289
|
-
percentage: 0,
|
|
290
|
-
uid: rawFile.uid,
|
|
291
|
-
raw: rawFile,
|
|
292
|
-
response: {}
|
|
155
|
+
const properFileSize = ({ props, state, constants, Modal, t }) => (file) => {
|
|
156
|
+
let maxSize = 0;
|
|
157
|
+
if (Array.isArray(props.fileSize) && props.fileSize[1]) {
|
|
158
|
+
maxSize = Math.min(state.singleMaxSize, props.fileSize[1] / 1024).toFixed(2);
|
|
159
|
+
} else {
|
|
160
|
+
maxSize = Math.min(state.singleMaxSize);
|
|
161
|
+
}
|
|
162
|
+
if (file.size > maxSize * 1024 * 1024) {
|
|
163
|
+
Modal.message({
|
|
164
|
+
message: `${file.name} ${t(constants.EDM.EXCEED)} ${maxSize} MB`,
|
|
165
|
+
status: "warning"
|
|
293
166
|
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
if (file.size <= 0) {
|
|
170
|
+
Modal.message({
|
|
171
|
+
message: `${file.name} ${t(constants.EDM.FILEEMPTY)}`,
|
|
172
|
+
status: "warning"
|
|
173
|
+
});
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
const userMin = props.fileSize && (props.fileSize[0] || props.fileSize) || 0;
|
|
177
|
+
if (file.size <= userMin * 1024) {
|
|
178
|
+
Modal.message({
|
|
179
|
+
message: `${t(constants.EDM.SIZE).replace(/{name}/, file.name)} ${userMin} KB`,
|
|
180
|
+
status: "warning"
|
|
181
|
+
});
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
};
|
|
186
|
+
const addFileToList = ({ api, constants, emit, props, state, mode }) => (rawFile, updateId) => {
|
|
187
|
+
rawFile.uid = Date.now() + state.tempIndex++;
|
|
188
|
+
let file = { status: constants.FILE_STATUS.READY, name: rawFile.name, size: rawFile.size };
|
|
189
|
+
Object.assign(file, { percentage: 0, uid: rawFile.uid, raw: rawFile, response: {} });
|
|
190
|
+
if (state.isEdm) {
|
|
191
|
+
let fileBase = { serverName: "", docRelativePath: "", docId: "", docVersion: "", cacheSign: rawFile.uid };
|
|
192
|
+
file = Object.assign(file, fileBase);
|
|
193
|
+
props.edm.upload.isFolder && (file.path = rawFile.webkitRelativePath.match(/.*\//g)[0]);
|
|
194
|
+
}
|
|
195
|
+
state.cacheDocuments[file.uid] = file;
|
|
196
|
+
mode === "mobile" && calcFileForMobile(rawFile, file);
|
|
197
|
+
if (~[constants.LIST_TYPE.PICTURE_CARD, constants.LIST_TYPE.PICTURE].indexOf(props.listType)) {
|
|
198
|
+
try {
|
|
199
|
+
file.url = URL.createObjectURL(rawFile);
|
|
200
|
+
} catch (err) {
|
|
201
|
+
return;
|
|
304
202
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
} catch (err) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
203
|
+
}
|
|
204
|
+
if (state.isEdm && state.isSuccess) {
|
|
205
|
+
const proper = api.properFileSize(file);
|
|
206
|
+
if (!proper) {
|
|
207
|
+
return;
|
|
313
208
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (state.updateId) {
|
|
321
|
-
var index = state.uploadFiles.findIndex(function (item) {
|
|
322
|
-
return item.docId === updateId;
|
|
323
|
-
});
|
|
324
|
-
state.uploadFiles.splice(index, 1, file);
|
|
325
|
-
emit('change', file, state.uploadFiles);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
209
|
+
state.updateId = updateId || props.edm.updateId || "";
|
|
210
|
+
if (state.updateId) {
|
|
211
|
+
const index = state.uploadFiles.findIndex((item) => item.docId === updateId);
|
|
212
|
+
state.uploadFiles.splice(index, 1, file);
|
|
213
|
+
emit("change", file, state.uploadFiles);
|
|
214
|
+
return;
|
|
328
215
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
216
|
+
}
|
|
217
|
+
state.uploadFiles.push(file);
|
|
218
|
+
state.currentUploadingFileUids.push(file.uid);
|
|
219
|
+
emit("change", file, state.uploadFiles);
|
|
333
220
|
};
|
|
334
|
-
|
|
335
|
-
var state = _ref13.state,
|
|
336
|
-
props = _ref13.props,
|
|
337
|
-
refs = _ref13.refs,
|
|
338
|
-
constants = _ref13.constants,
|
|
339
|
-
rawFiles = _ref13.rawFiles,
|
|
340
|
-
api = _ref13.api;
|
|
221
|
+
const rawfileUpload = ({ state, props, refs, constants, rawFiles, api }) => {
|
|
341
222
|
if (!state.isEdm && props.autoUpload) {
|
|
342
223
|
if (props.multiple && props.mergeService) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
};
|
|
346
|
-
rawFiles.length && api.beforeUpload({
|
|
347
|
-
raw: rawFiles
|
|
348
|
-
}, true, handler);
|
|
224
|
+
const handler = (file) => refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
225
|
+
rawFiles.length && api.beforeUpload({ raw: rawFiles }, true, handler);
|
|
349
226
|
} else {
|
|
350
|
-
rawFiles.forEach(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
354
|
-
};
|
|
227
|
+
rawFiles.forEach((rawFile) => {
|
|
228
|
+
const file = api.getFile(rawFile);
|
|
229
|
+
const handler = (file2) => refs[constants.UPLOAD_INNER].upload(file2.raw);
|
|
355
230
|
api.beforeUpload(file, true, handler);
|
|
356
231
|
});
|
|
357
232
|
}
|
|
358
233
|
}
|
|
359
234
|
};
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
resolve(hash);
|
|
400
|
-
};
|
|
401
|
-
}).then(function () {
|
|
402
|
-
if (props.autoUpload) {
|
|
403
|
-
var tokenParams = {
|
|
404
|
-
token: props.edm.upload.token,
|
|
405
|
-
file: file,
|
|
406
|
-
type: 'upload'
|
|
407
|
-
};
|
|
408
|
-
api.getToken(tokenParams).then(function (data) {
|
|
409
|
-
if (data) {
|
|
410
|
-
file.status = constants.FILE_STATUS.UPLOADING;
|
|
411
|
-
api.startUpload(file, true);
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
});
|
|
235
|
+
const handleStart = ({ api, constants, props, state, refs }) => (rawFiles, updateId) => {
|
|
236
|
+
state.currentUploadingFileUids = [];
|
|
237
|
+
rawFiles.forEach((rawFile) => api.addFileToList(rawFile, updateId));
|
|
238
|
+
const { UPLOADING, READY } = constants.FILE_STATUS;
|
|
239
|
+
state.uploadingFiles = state.uploadFiles.filter((file) => [UPLOADING, READY].includes(file.status));
|
|
240
|
+
if (state.isEdm && state.isSuccess) {
|
|
241
|
+
rawFiles.forEach((rawFile) => {
|
|
242
|
+
const file = api.getFile(rawFile);
|
|
243
|
+
if (!file) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
api.beforeUpload(file, true, (file2) => {
|
|
247
|
+
typeof props.edm.upload.loading === "function" && props.edm.upload.loading(file2);
|
|
248
|
+
new Promise((resolve) => {
|
|
249
|
+
if (props.edm.isCheckCode !== true) {
|
|
250
|
+
return resolve();
|
|
251
|
+
}
|
|
252
|
+
if (file2.size > state.docSize && file2.size > state.chunkSize && !state.isEntireCheckCode) {
|
|
253
|
+
return resolve();
|
|
254
|
+
}
|
|
255
|
+
const reader = new FileReader();
|
|
256
|
+
reader.readAsArrayBuffer(file2.raw);
|
|
257
|
+
reader.onload = (e) => {
|
|
258
|
+
const cryptoJS = props.edm.upload.plugin();
|
|
259
|
+
const wordArray = cryptoJS.lib.WordArray.create(e.target.result);
|
|
260
|
+
const hash = cryptoJS[shaMap.shaMap](wordArray).toString();
|
|
261
|
+
file2.hash = file2.raw.hash = hash;
|
|
262
|
+
resolve(hash);
|
|
263
|
+
};
|
|
264
|
+
}).then(() => {
|
|
265
|
+
if (props.autoUpload) {
|
|
266
|
+
const tokenParams = { token: props.edm.upload.token, file: file2, type: "upload" };
|
|
267
|
+
api.getToken(tokenParams).then((data) => {
|
|
268
|
+
if (data) {
|
|
269
|
+
file2.status = constants.FILE_STATUS.UPLOADING;
|
|
270
|
+
api.startUpload(file2, true);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
416
274
|
});
|
|
417
275
|
});
|
|
418
|
-
}
|
|
419
|
-
rawfileUpload({
|
|
420
|
-
state: state,
|
|
421
|
-
props: props,
|
|
422
|
-
refs: refs,
|
|
423
|
-
constants: constants,
|
|
424
|
-
rawFiles: rawFiles,
|
|
425
|
-
api: api
|
|
426
276
|
});
|
|
427
|
-
}
|
|
277
|
+
}
|
|
278
|
+
rawfileUpload({ state, props, refs, constants, rawFiles, api });
|
|
428
279
|
};
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return {
|
|
442
|
-
percentage: percentage,
|
|
443
|
-
uploadList: state.uploadingFiles,
|
|
444
|
-
uploadedCount: uploadedFiles.length
|
|
445
|
-
};
|
|
280
|
+
const calcUploadingFilesInfo = ({ state }) => () => {
|
|
281
|
+
const totalLoadedSize = state.uploadingFiles.reduce((loadedSize, file) => {
|
|
282
|
+
const loaded = file.size * file.percentage / 100;
|
|
283
|
+
return loadedSize + loaded;
|
|
284
|
+
}, 0);
|
|
285
|
+
const uploadedFiles = state.uploadingFiles.filter((file) => file.percentage === 100);
|
|
286
|
+
let percentage = Math.floor(totalLoadedSize / state.uploadingSize * 100);
|
|
287
|
+
percentage = Math.min(percentage, 100);
|
|
288
|
+
return {
|
|
289
|
+
percentage,
|
|
290
|
+
uploadList: state.uploadingFiles,
|
|
291
|
+
uploadedCount: uploadedFiles.length
|
|
446
292
|
};
|
|
447
293
|
};
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
state = _ref16.state;
|
|
453
|
-
return function (event, rawFile) {
|
|
454
|
-
if (Array.isArray(rawFile)) {
|
|
455
|
-
state.uploadFiles.forEach(function (file) {
|
|
456
|
-
if (rawFile.some(function (raw) {
|
|
457
|
-
return file.uid === raw.uid;
|
|
458
|
-
})) {
|
|
459
|
-
file.status = constants.FILE_STATUS.UPLOADING;
|
|
460
|
-
if (event.lengthComputable) {
|
|
461
|
-
file.percentage = Math.floor(event.loaded * 100 / event.total) || 0;
|
|
462
|
-
}
|
|
463
|
-
emit('progress', file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
} else {
|
|
467
|
-
var file = api.getFile(rawFile);
|
|
468
|
-
if (file) {
|
|
294
|
+
const handleProgress = ({ api, constants, emit, state }) => (event, rawFile) => {
|
|
295
|
+
if (Array.isArray(rawFile)) {
|
|
296
|
+
state.uploadFiles.forEach((file) => {
|
|
297
|
+
if (rawFile.some((raw) => file.uid === raw.uid)) {
|
|
469
298
|
file.status = constants.FILE_STATUS.UPLOADING;
|
|
470
|
-
if (event.lengthComputable
|
|
299
|
+
if (event.lengthComputable) {
|
|
471
300
|
file.percentage = Math.floor(event.loaded * 100 / event.total) || 0;
|
|
472
|
-
if (file.percentage >= 100) {
|
|
473
|
-
file.isFinished = true;
|
|
474
|
-
}
|
|
475
|
-
emit('progress', file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
476
301
|
}
|
|
302
|
+
emit("progress", file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
477
303
|
}
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
};
|
|
481
|
-
export var handleSuccess = function handleSuccess(_ref17) {
|
|
482
|
-
var api = _ref17.api,
|
|
483
|
-
constants = _ref17.constants,
|
|
484
|
-
emit = _ref17.emit,
|
|
485
|
-
state = _ref17.state,
|
|
486
|
-
props = _ref17.props;
|
|
487
|
-
return function (res, rawFile) {
|
|
488
|
-
var currentUploadFiles = state.uploadFiles.filter(function (file) {
|
|
489
|
-
return state.currentUploadingFileUids.includes(file.uid);
|
|
490
304
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
file.
|
|
499
|
-
emit('success', res, file, currentUploadFiles);
|
|
500
|
-
emit('change', file, state.uploadFiles);
|
|
501
|
-
delete file.cancelToken;
|
|
305
|
+
} else {
|
|
306
|
+
const file = api.getFile(rawFile);
|
|
307
|
+
if (file) {
|
|
308
|
+
file.status = constants.FILE_STATUS.UPLOADING;
|
|
309
|
+
if (event.lengthComputable && !file.isLargeFile) {
|
|
310
|
+
file.percentage = Math.floor(event.loaded * 100 / event.total) || 0;
|
|
311
|
+
if (file.percentage >= 100) {
|
|
312
|
+
file.isFinished = true;
|
|
502
313
|
}
|
|
503
|
-
|
|
504
|
-
} else {
|
|
505
|
-
var file = api.getFile(rawFile);
|
|
506
|
-
delete file.cancelToken;
|
|
507
|
-
if (props.edm.upload && file && res.data && res.data.status !== 200) {
|
|
508
|
-
file.status = constants.FILE_STATUS.FAIL;
|
|
509
|
-
emit('error', res, file, state.uploadFiles);
|
|
510
|
-
return;
|
|
314
|
+
emit("progress", file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
511
315
|
}
|
|
512
|
-
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
const handleSuccess = ({ api, constants, emit, state, props }) => (res, rawFile) => {
|
|
320
|
+
const currentUploadFiles = state.uploadFiles.filter((file) => state.currentUploadingFileUids.includes(file.uid));
|
|
321
|
+
if (Array.isArray(rawFile)) {
|
|
322
|
+
state.uploadFiles.forEach((file) => {
|
|
323
|
+
if (rawFile.some((raw) => file.uid === raw.uid)) {
|
|
513
324
|
file.status = constants.FILE_STATUS.SUCESS;
|
|
514
325
|
file.percentage = 100;
|
|
515
|
-
if (!file.isFinished) {
|
|
516
|
-
emit('progress', file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
517
|
-
}
|
|
518
|
-
file.isLargeFile && delete res.config;
|
|
519
326
|
file.response = res;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
file.docId = res.data.result.docId;
|
|
524
|
-
file.docVersion = res.data.result.version;
|
|
525
|
-
file.docSize = res.data.result.docSize;
|
|
526
|
-
file.isLargeFile && delete file.raw;
|
|
527
|
-
Object.assign(file, res.data.result);
|
|
528
|
-
}
|
|
529
|
-
emit('success', res, file, currentUploadFiles);
|
|
530
|
-
emit('change', file, state.uploadFiles);
|
|
327
|
+
emit("success", res, file, currentUploadFiles);
|
|
328
|
+
emit("change", file, state.uploadFiles);
|
|
329
|
+
delete file.cancelToken;
|
|
531
330
|
}
|
|
331
|
+
});
|
|
332
|
+
} else {
|
|
333
|
+
const file = api.getFile(rawFile);
|
|
334
|
+
delete file.cancelToken;
|
|
335
|
+
if (props.edm.upload && file && res.data && res.data.status !== 200) {
|
|
336
|
+
file.status = constants.FILE_STATUS.FAIL;
|
|
337
|
+
emit("error", res, file, state.uploadFiles);
|
|
338
|
+
return;
|
|
532
339
|
}
|
|
533
|
-
api.clearUploadingFiles();
|
|
534
|
-
};
|
|
535
|
-
};
|
|
536
|
-
export var handleError = function handleError(_ref18) {
|
|
537
|
-
var api = _ref18.api,
|
|
538
|
-
constants = _ref18.constants,
|
|
539
|
-
emit = _ref18.emit,
|
|
540
|
-
state = _ref18.state;
|
|
541
|
-
return function (err, rawFile) {
|
|
542
|
-
var file = api.getFile(rawFile);
|
|
543
340
|
if (file) {
|
|
544
|
-
file.status = constants.FILE_STATUS.
|
|
341
|
+
file.status = constants.FILE_STATUS.SUCESS;
|
|
545
342
|
file.percentage = 100;
|
|
546
|
-
if (!
|
|
547
|
-
|
|
343
|
+
if (!file.isFinished) {
|
|
344
|
+
emit("progress", file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
548
345
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
state = _ref19.state;
|
|
560
|
-
return function (file, raw) {
|
|
561
|
-
if (raw) {
|
|
562
|
-
file = api.getFile(raw);
|
|
563
|
-
}
|
|
564
|
-
var doRemove = function doRemove() {
|
|
565
|
-
api.abort(file);
|
|
566
|
-
var fileList = state.uploadFiles;
|
|
567
|
-
fileList.splice(fileList.indexOf(file), 1);
|
|
568
|
-
emit('remove', file, fileList);
|
|
569
|
-
};
|
|
570
|
-
if (!props.beforeRemove) {
|
|
571
|
-
doRemove();
|
|
572
|
-
} else if (typeof props.beforeRemove === 'function') {
|
|
573
|
-
var before = props.beforeRemove(file, state.uploadFiles);
|
|
574
|
-
if (before && before.then) {
|
|
575
|
-
before.then(function () {
|
|
576
|
-
doRemove();
|
|
577
|
-
}, function () {
|
|
578
|
-
return undefined;
|
|
579
|
-
});
|
|
580
|
-
} else if (before !== false) {
|
|
581
|
-
doRemove();
|
|
346
|
+
file.isLargeFile && delete res.config;
|
|
347
|
+
file.response = res;
|
|
348
|
+
if (state.isEdm && res.data.result) {
|
|
349
|
+
file.serverName = res.data.result.serverName;
|
|
350
|
+
file.docRelativePath = res.data.result.docRelativePath;
|
|
351
|
+
file.docId = res.data.result.docId;
|
|
352
|
+
file.docVersion = res.data.result.version;
|
|
353
|
+
file.docSize = res.data.result.docSize;
|
|
354
|
+
file.isLargeFile && delete file.raw;
|
|
355
|
+
Object.assign(file, res.data.result);
|
|
582
356
|
}
|
|
357
|
+
emit("success", res, file, currentUploadFiles);
|
|
358
|
+
emit("change", file, state.uploadFiles);
|
|
583
359
|
}
|
|
584
|
-
}
|
|
360
|
+
}
|
|
361
|
+
api.clearUploadingFiles();
|
|
585
362
|
};
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
var isUploadComplete = state.uploadingFiles.every(function (file) {
|
|
594
|
-
return [SUCESS, FAIL].indexOf(file.status) > -1;
|
|
595
|
-
});
|
|
596
|
-
if (isUploadComplete) {
|
|
597
|
-
state.uploadingFiles = [];
|
|
363
|
+
const handleError = ({ api, constants, emit, state }) => (err, rawFile) => {
|
|
364
|
+
const file = api.getFile(rawFile);
|
|
365
|
+
if (file) {
|
|
366
|
+
file.status = constants.FILE_STATUS.FAIL;
|
|
367
|
+
file.percentage = 100;
|
|
368
|
+
if (!state.isEdm) {
|
|
369
|
+
state.uploadFiles.splice(state.uploadFiles.indexOf(file), 1);
|
|
598
370
|
}
|
|
599
|
-
|
|
371
|
+
api.clearUploadingFiles();
|
|
372
|
+
emit("error", err, file, state.uploadFiles);
|
|
373
|
+
emit("change", file, state.uploadFiles);
|
|
374
|
+
}
|
|
600
375
|
};
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
376
|
+
const handleRemove = ({ api, emit, props, state }) => (file, raw) => {
|
|
377
|
+
if (raw) {
|
|
378
|
+
file = api.getFile(raw);
|
|
379
|
+
}
|
|
380
|
+
let doRemove = () => {
|
|
381
|
+
api.abort(file);
|
|
382
|
+
let fileList = state.uploadFiles;
|
|
383
|
+
fileList.splice(fileList.indexOf(file), 1);
|
|
384
|
+
emit("remove", file, fileList);
|
|
610
385
|
};
|
|
386
|
+
if (!props.beforeRemove) {
|
|
387
|
+
doRemove();
|
|
388
|
+
} else if (typeof props.beforeRemove === "function") {
|
|
389
|
+
const before = props.beforeRemove(file, state.uploadFiles);
|
|
390
|
+
if (before && before.then) {
|
|
391
|
+
before.then(
|
|
392
|
+
() => {
|
|
393
|
+
doRemove();
|
|
394
|
+
},
|
|
395
|
+
() => void 0
|
|
396
|
+
);
|
|
397
|
+
} else if (before !== false) {
|
|
398
|
+
doRemove();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
611
401
|
};
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
402
|
+
const clearUploadingFiles = ({ constants, state }) => () => {
|
|
403
|
+
const { SUCESS, FAIL } = constants.FILE_STATUS;
|
|
404
|
+
const isUploadComplete = state.uploadingFiles.every((file) => [SUCESS, FAIL].includes(file.status));
|
|
405
|
+
if (isUploadComplete) {
|
|
406
|
+
state.uploadingFiles = [];
|
|
407
|
+
}
|
|
618
408
|
};
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
409
|
+
const getFile = (state) => (rawFile) => {
|
|
410
|
+
let fileList = state.uploadFiles;
|
|
411
|
+
let target;
|
|
412
|
+
fileList.every((item) => {
|
|
413
|
+
target = rawFile.uid === item.uid ? item : null;
|
|
414
|
+
return !target;
|
|
415
|
+
});
|
|
416
|
+
return target;
|
|
417
|
+
};
|
|
418
|
+
const abort = ({ constants, refs }) => (file) => refs[constants.UPLOAD_INNER].abort(file);
|
|
419
|
+
const clearFiles = (state) => () => {
|
|
420
|
+
state.uploadFiles = [];
|
|
623
421
|
};
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
422
|
+
const submit = ({ api, constants, refs, state, props }) => () => {
|
|
423
|
+
const files = state.uploadFiles.filter((file) => file.status === constants.FILE_STATUS.READY);
|
|
424
|
+
if (state.isEdm && state.isSuccess) {
|
|
425
|
+
files.forEach((file) => {
|
|
426
|
+
api.getToken({
|
|
427
|
+
token: props.edm.upload.token,
|
|
428
|
+
file,
|
|
429
|
+
type: "upload"
|
|
430
|
+
}).then((data) => {
|
|
431
|
+
if (data) {
|
|
432
|
+
api.beforeUpload(file, false, (file2) => {
|
|
433
|
+
api.startUpload(file2);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
});
|
|
633
437
|
});
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
type: 'upload'
|
|
640
|
-
}).then(function (data) {
|
|
641
|
-
if (data) {
|
|
642
|
-
api.beforeUpload(file, false, function (file) {
|
|
643
|
-
api.startUpload(file);
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
});
|
|
438
|
+
} else {
|
|
439
|
+
if (props.multiple && props.mergeService) {
|
|
440
|
+
const rawFiles = files.map((file) => file.raw);
|
|
441
|
+
rawFiles.length && api.beforeUpload({ raw: rawFiles }, false, (file) => {
|
|
442
|
+
refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
647
443
|
});
|
|
648
444
|
} else {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
});
|
|
653
|
-
rawFiles.length && api.beforeUpload({
|
|
654
|
-
raw: rawFiles
|
|
655
|
-
}, false, function (file) {
|
|
656
|
-
refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
657
|
-
});
|
|
658
|
-
} else {
|
|
659
|
-
files.forEach(function (file) {
|
|
660
|
-
api.beforeUpload(file, false, function (file) {
|
|
661
|
-
refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
662
|
-
});
|
|
445
|
+
files.forEach((file) => {
|
|
446
|
+
api.beforeUpload(file, false, (file2) => {
|
|
447
|
+
refs[constants.UPLOAD_INNER].upload(file2.raw);
|
|
663
448
|
});
|
|
664
|
-
}
|
|
449
|
+
});
|
|
665
450
|
}
|
|
666
|
-
}
|
|
667
|
-
};
|
|
668
|
-
export var handleClick = function handleClick(_ref23) {
|
|
669
|
-
var constants = _ref23.constants,
|
|
670
|
-
refs = _ref23.refs;
|
|
671
|
-
return function () {
|
|
672
|
-
return refs[constants.UPLOAD_INNER].handleClick();
|
|
673
|
-
};
|
|
451
|
+
}
|
|
674
452
|
};
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
453
|
+
const handleClick = ({ constants, refs }) => () => refs[constants.UPLOAD_INNER].handleClick();
|
|
454
|
+
const getFileUploadUrl = (service) => () => service.getFileUploadUrl();
|
|
455
|
+
const updateUrl = ({ api, props, state }) => () => {
|
|
456
|
+
if (props.action) {
|
|
457
|
+
state.url = props.action;
|
|
458
|
+
} else {
|
|
459
|
+
api.getFileUploadUrl().then((url) => state.url = url);
|
|
460
|
+
}
|
|
679
461
|
};
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
return function () {
|
|
685
|
-
if (props.action) {
|
|
686
|
-
state.url = props.action;
|
|
687
|
-
} else {
|
|
688
|
-
api.getFileUploadUrl().then(function (url) {
|
|
689
|
-
return state.url = url;
|
|
690
|
-
});
|
|
462
|
+
const getTranslateFile = ({ api, isChunk }) => (data, type, index) => {
|
|
463
|
+
if (isChunk) {
|
|
464
|
+
if (index === 0) {
|
|
465
|
+
api.setWriterFile({ data, index });
|
|
691
466
|
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
if (index === 0) {
|
|
700
|
-
api.setWriterFile({
|
|
701
|
-
data: data,
|
|
702
|
-
index: index
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
} else {
|
|
706
|
-
var content = data.headers['content-disposition'];
|
|
707
|
-
var name = content.match(/fileName.?=(.*)/)[1] || content.match(/fileName=(.*)/)[1];
|
|
708
|
-
var blob = new Blob([data.data], {
|
|
709
|
-
type: type !== 'zip' ? 'application / x - xls' : 'application/zip'
|
|
710
|
-
});
|
|
711
|
-
if (window && window.navigator.msSaveOrOpenBlob) {
|
|
712
|
-
window.navigator.msSaveOrOpenBlob(blob, decodeURIComponent(name));
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
var url = window.URL || window.webkitURL || window.moxURL;
|
|
716
|
-
var downloadHref = xss.filterUrl(url.createObjectURL(blob));
|
|
717
|
-
var downloadLink = document.createElement('a');
|
|
718
|
-
downloadLink.href = downloadHref;
|
|
719
|
-
downloadLink.download = decodeURIComponent(name);
|
|
720
|
-
downloadLink.click();
|
|
467
|
+
} else {
|
|
468
|
+
const content = data.headers["content-disposition"];
|
|
469
|
+
const name = content.match(/fileName.?=(.*)/)[1] || content.match(/fileName=(.*)/)[1];
|
|
470
|
+
const blob = new Blob([data.data], { type: type !== "zip" ? "application / x - xls" : "application/zip" });
|
|
471
|
+
if (window && window.navigator.msSaveOrOpenBlob) {
|
|
472
|
+
window.navigator.msSaveOrOpenBlob(blob, decodeURIComponent(name));
|
|
473
|
+
return;
|
|
721
474
|
}
|
|
722
|
-
|
|
475
|
+
const url = window.URL || window.webkitURL || window.moxURL;
|
|
476
|
+
const downloadHref = xss.filterUrl(url.createObjectURL(blob));
|
|
477
|
+
let downloadLink = document.createElement("a");
|
|
478
|
+
downloadLink.href = downloadHref;
|
|
479
|
+
downloadLink.download = decodeURIComponent(name);
|
|
480
|
+
downloadLink.click();
|
|
481
|
+
}
|
|
723
482
|
};
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
translateFile
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
483
|
+
const getHandleSuccess = ({ downloadOps, file, translateFile, isChunk, state }) => (data, type, index) => {
|
|
484
|
+
if (isChunk) {
|
|
485
|
+
state.dowuloadChunkFile.set(index, new Uint8Array(data.data));
|
|
486
|
+
translateFile(data, type, index);
|
|
487
|
+
} else {
|
|
488
|
+
if (data.data.type.includes("application/json")) {
|
|
489
|
+
const reader = new FileReader();
|
|
490
|
+
reader.onload = (e) => {
|
|
491
|
+
if (typeof downloadOps.fail === "function") {
|
|
492
|
+
downloadOps.fail(JSON.parse(e.target.result), file);
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
reader.readAsText(data.data);
|
|
734
496
|
} else {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
reader.onload = function (e) {
|
|
738
|
-
if (typeof downloadOps.fail === 'function') {
|
|
739
|
-
downloadOps.fail(JSON.parse(e.target.result), file);
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
reader.readAsText(data.data);
|
|
743
|
-
} else {
|
|
744
|
-
typeof downloadOps.loading === 'function' && downloadOps.loading(file);
|
|
745
|
-
translateFile(data, type);
|
|
746
|
-
}
|
|
497
|
+
typeof downloadOps.loading === "function" && downloadOps.loading(file);
|
|
498
|
+
translateFile(data, type);
|
|
747
499
|
}
|
|
748
|
-
}
|
|
500
|
+
}
|
|
749
501
|
};
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
return progress;
|
|
758
|
-
};
|
|
502
|
+
const getCalcProgress = () => (evt) => {
|
|
503
|
+
let total = Number(evt.target.getResponseHeader("Content-Size"));
|
|
504
|
+
total = Math.max(total, evt.loaded);
|
|
505
|
+
let progress = Math.ceil(evt.loaded / total * 100) || 0;
|
|
506
|
+
progress = Math.max(progress, 0);
|
|
507
|
+
progress = Math.min(progress, 100);
|
|
508
|
+
return progress;
|
|
759
509
|
};
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
range = _ref27.range,
|
|
764
|
-
constants = _ref27.constants;
|
|
765
|
-
if (_typeof(file) === 'object') {
|
|
766
|
-
var tempFile = _objectSpread(_objectSpread({}, file), range);
|
|
510
|
+
const modifyServiceUrlSingle = ({ file, serviceUrl, range, constants }) => {
|
|
511
|
+
if (typeof file === "object") {
|
|
512
|
+
let tempFile = __spreadValues(__spreadValues({}, file), range);
|
|
767
513
|
delete tempFile.docId;
|
|
768
514
|
delete tempFile.docVersion;
|
|
769
|
-
delete tempFile[
|
|
770
|
-
for (
|
|
515
|
+
delete tempFile["x-download-sign"];
|
|
516
|
+
for (let key in tempFile) {
|
|
771
517
|
if (Object.prototype.hasOwnProperty.call(tempFile, key)) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
if (!~[
|
|
775
|
-
serviceUrl +=
|
|
518
|
+
const value = tempFile[key];
|
|
519
|
+
const dataType = typeof value;
|
|
520
|
+
if (!~["undefined", "object", "function"].indexOf(dataType)) {
|
|
521
|
+
serviceUrl += `&${key}=${value}`;
|
|
776
522
|
}
|
|
777
523
|
}
|
|
778
524
|
}
|
|
@@ -781,657 +527,383 @@ var modifyServiceUrlSingle = function modifyServiceUrlSingle(_ref27) {
|
|
|
781
527
|
}
|
|
782
528
|
return serviceUrl;
|
|
783
529
|
};
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
t = _ref28.t,
|
|
787
|
-
Modal = _ref28.Modal,
|
|
788
|
-
constants = _ref28.constants;
|
|
789
|
-
if (data.status === '12079') {
|
|
530
|
+
const getKiaScanTip = ({ data, t, Modal, constants }) => {
|
|
531
|
+
if (data.status === "12079") {
|
|
790
532
|
return Modal.message({
|
|
791
|
-
message:
|
|
792
|
-
status:
|
|
533
|
+
message: `${t(constants.EDM.KIASCANTIP)}`,
|
|
534
|
+
status: "warning"
|
|
793
535
|
});
|
|
794
536
|
}
|
|
795
537
|
};
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
service = args.service,
|
|
804
|
-
constants = args.constants,
|
|
805
|
-
props = args.props,
|
|
806
|
-
state = args.state,
|
|
807
|
-
batchIndex = args.batchIndex,
|
|
808
|
-
isChunk = args.isChunk,
|
|
809
|
-
api = args.api;
|
|
810
|
-
var calcProgress = args.calcProgress,
|
|
811
|
-
emit = args.emit,
|
|
812
|
-
handleSuccess = args.handleSuccess,
|
|
813
|
-
t = args.t,
|
|
814
|
-
Modal = args.Modal,
|
|
815
|
-
_args$range = args.range,
|
|
816
|
-
range = _args$range === void 0 ? {} : _args$range,
|
|
817
|
-
isBatch = args.isBatch;
|
|
818
|
-
var sdResolver = function sdResolver(url) {
|
|
819
|
-
var serviceUrl = getServiceUrl({
|
|
820
|
-
url: url,
|
|
821
|
-
file: file
|
|
822
|
-
});
|
|
823
|
-
serviceUrl = modifyServiceUrlSingle({
|
|
824
|
-
file: file,
|
|
825
|
-
serviceUrl: serviceUrl,
|
|
826
|
-
range: range,
|
|
827
|
-
constants: constants
|
|
828
|
-
});
|
|
538
|
+
const getServiceUrl = ({ url, file }) => url.replace(/{docId}/, file.docId || file) + `${~url.indexOf("?") ? "&" : "?"}x-download-sign=true&docVersion=${file.docVersion || ""}`;
|
|
539
|
+
const downloadFileSingle = (args) => {
|
|
540
|
+
let { file, service, constants, props, state, batchIndex, isChunk, api } = args;
|
|
541
|
+
let { calcProgress, emit, handleSuccess: handleSuccess2, t, Modal, range = {}, isBatch } = args;
|
|
542
|
+
let sdResolver = (url) => {
|
|
543
|
+
let serviceUrl = getServiceUrl({ url, file });
|
|
544
|
+
serviceUrl = modifyServiceUrlSingle({ file, serviceUrl, range, constants });
|
|
829
545
|
serviceUrl = xss.filterUrl(serviceUrl);
|
|
830
|
-
|
|
546
|
+
let params = {
|
|
831
547
|
withCredentials: props.withCredentials,
|
|
832
548
|
headers: Object.assign(props.headers, state.headers),
|
|
833
|
-
responseType: isChunk ?
|
|
549
|
+
responseType: isChunk ? "arraybuffer" : "blob",
|
|
834
550
|
hideErr: true,
|
|
835
|
-
onDownloadProgress
|
|
836
|
-
|
|
551
|
+
onDownloadProgress(evt) {
|
|
552
|
+
let progress = calcProgress(evt, isChunk);
|
|
837
553
|
if (progress !== 100) {
|
|
838
|
-
!isChunk && emit(
|
|
554
|
+
!isChunk && emit("download", progress, evt);
|
|
839
555
|
}
|
|
840
|
-
if (
|
|
556
|
+
if (typeof file === "object") {
|
|
841
557
|
file.percentage = progress;
|
|
842
558
|
}
|
|
843
559
|
}
|
|
844
560
|
};
|
|
845
|
-
service.get(serviceUrl, params).then(
|
|
846
|
-
if (getKiaScanTip({
|
|
847
|
-
data: data,
|
|
848
|
-
t: t,
|
|
849
|
-
Modal: Modal,
|
|
850
|
-
constants: constants
|
|
851
|
-
})) {
|
|
561
|
+
service.get(serviceUrl, params).then((data) => {
|
|
562
|
+
if (getKiaScanTip({ data, t, Modal, constants })) {
|
|
852
563
|
return;
|
|
853
564
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
checkcode: checkcode,
|
|
859
|
-
fileSize: fileSize
|
|
860
|
-
});
|
|
861
|
-
handleSuccess(data, '', range.index);
|
|
862
|
-
if (_typeof(file) === 'object') {
|
|
565
|
+
const { checkcode, "content-size": fileSize } = data.headers;
|
|
566
|
+
!isChunk && emit("download", 100, { checkcode, fileSize });
|
|
567
|
+
handleSuccess2(data, "", range.index);
|
|
568
|
+
if (typeof file === "object") {
|
|
863
569
|
file.percentage = 100;
|
|
864
|
-
setTimeout(
|
|
865
|
-
return file.status = constants.FILE_STATUS.SUCESS;
|
|
866
|
-
}, 1000);
|
|
570
|
+
setTimeout(() => file.status = constants.FILE_STATUS.SUCESS, 1e3);
|
|
867
571
|
}
|
|
868
|
-
api.afterDownload({
|
|
869
|
-
|
|
870
|
-
data: data,
|
|
871
|
-
file: file
|
|
872
|
-
});
|
|
873
|
-
})["catch"](function (data) {
|
|
572
|
+
api.afterDownload({ batchIndex, data, file });
|
|
573
|
+
}).catch((data) => {
|
|
874
574
|
if (data.response && data.response.status === 401) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
type: 'download'
|
|
880
|
-
};
|
|
881
|
-
api.getToken(tokenParams).then(function (data) {
|
|
882
|
-
api.afterDownload({
|
|
883
|
-
batchIndex: batchIndex,
|
|
884
|
-
data: data,
|
|
885
|
-
file: file,
|
|
886
|
-
range: range,
|
|
887
|
-
isChunk: isChunk,
|
|
888
|
-
isBatch: isBatch
|
|
889
|
-
});
|
|
575
|
+
const downloadOps = props.edm.download || {};
|
|
576
|
+
const tokenParams = { token: downloadOps.token, file, type: "download" };
|
|
577
|
+
api.getToken(tokenParams).then((data2) => {
|
|
578
|
+
api.afterDownload({ batchIndex, data: data2, file, range, isChunk, isBatch });
|
|
890
579
|
});
|
|
891
580
|
}
|
|
892
581
|
});
|
|
893
582
|
};
|
|
894
583
|
service.getSingleDownloadUrl().then(sdResolver);
|
|
895
584
|
};
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
props = args.props,
|
|
902
|
-
state = args.state,
|
|
903
|
-
calcProgress = args.calcProgress,
|
|
904
|
-
emit = args.emit,
|
|
905
|
-
handleSuccess = args.handleSuccess;
|
|
906
|
-
var t = args.t,
|
|
907
|
-
Modal = args.Modal,
|
|
908
|
-
constants = args.constants,
|
|
909
|
-
_args$range2 = args.range,
|
|
910
|
-
range = _args$range2 === void 0 ? {} : _args$range2;
|
|
911
|
-
var tokenParams = {
|
|
912
|
-
token: downloadOps.packageToken,
|
|
913
|
-
file: file,
|
|
914
|
-
type: 'download'
|
|
915
|
-
};
|
|
916
|
-
api.getToken(tokenParams).then(function (data) {
|
|
585
|
+
const downloadFileBatch = (args) => {
|
|
586
|
+
let { api, downloadOps, file, service, props, state, calcProgress, emit, handleSuccess: handleSuccess2 } = args;
|
|
587
|
+
let { t, Modal, constants, range = {} } = args;
|
|
588
|
+
let tokenParams = { token: downloadOps.packageToken, file, type: "download" };
|
|
589
|
+
api.getToken(tokenParams).then((data) => {
|
|
917
590
|
if (!data) {
|
|
918
591
|
return;
|
|
919
592
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
attachdownloadTOs: [],
|
|
923
|
-
isZip: 'true',
|
|
924
|
-
transformType: 'sync',
|
|
925
|
-
type: 'package'
|
|
926
|
-
};
|
|
927
|
-
var hasWmType = file.some(function (item) {
|
|
928
|
-
return Boolean(item.wmType);
|
|
929
|
-
});
|
|
593
|
+
const params = { downloadTOs: [], attachdownloadTOs: [], isZip: "true", transformType: "sync", type: "package" };
|
|
594
|
+
const hasWmType = file.some((item) => Boolean(item.wmType));
|
|
930
595
|
if (hasWmType) {
|
|
931
596
|
params.attachdownloadTOs = file;
|
|
932
597
|
} else {
|
|
933
598
|
params.downloadTOs = file;
|
|
934
599
|
}
|
|
935
|
-
service.getPackageDownloadUrl().then(
|
|
936
|
-
url +=
|
|
600
|
+
service.getPackageDownloadUrl().then((url) => {
|
|
601
|
+
url += `${~url.indexOf("?") ? "&" : "?"}x-download-sign=true`;
|
|
937
602
|
url = xss.filterUrl(url);
|
|
938
|
-
service.post(
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
603
|
+
service.post(
|
|
604
|
+
url,
|
|
605
|
+
__spreadValues(__spreadValues({}, params), range),
|
|
606
|
+
{
|
|
607
|
+
withCredentials: props.withCredentials,
|
|
608
|
+
headers: Object.assign(props.headers, state.headers),
|
|
609
|
+
responseType: "blob",
|
|
610
|
+
onDownloadProgress(evt) {
|
|
611
|
+
let progress = calcProgress(evt);
|
|
612
|
+
if (progress !== 100) {
|
|
613
|
+
emit("download", progress, evt);
|
|
614
|
+
}
|
|
946
615
|
}
|
|
947
616
|
}
|
|
948
|
-
|
|
949
|
-
if (getKiaScanTip({
|
|
950
|
-
data: data,
|
|
951
|
-
t: t,
|
|
952
|
-
Modal: Modal,
|
|
953
|
-
constants: constants
|
|
954
|
-
})) {
|
|
617
|
+
).then((data2) => {
|
|
618
|
+
if (getKiaScanTip({ data: data2, t, Modal, constants })) {
|
|
955
619
|
return;
|
|
956
620
|
}
|
|
957
|
-
|
|
958
|
-
emit(
|
|
959
|
-
|
|
960
|
-
});
|
|
961
|
-
handleSuccess(data, 'zip');
|
|
621
|
+
const { "content-size": fileSize } = data2.headers;
|
|
622
|
+
emit("download", 100, { fileSize });
|
|
623
|
+
handleSuccess2(data2, "zip");
|
|
962
624
|
});
|
|
963
625
|
});
|
|
964
626
|
});
|
|
965
627
|
};
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
628
|
+
const downloadFile = ({ api, state, props }) => (file) => {
|
|
629
|
+
if (!state.isEdm) {
|
|
630
|
+
api.ordinaryDownload(file);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
const isBatch = Array.isArray(file);
|
|
634
|
+
if (isBatch) {
|
|
635
|
+
return api.downloadFileInner({ file, isBatch });
|
|
636
|
+
}
|
|
637
|
+
const downloadOps = props.edm.download || {};
|
|
638
|
+
let tokenParams = { token: downloadOps.token, file, type: "download" };
|
|
639
|
+
api.getToken(tokenParams).then((data) => {
|
|
640
|
+
if (!data) {
|
|
973
641
|
return;
|
|
974
642
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
type: 'download'
|
|
987
|
-
};
|
|
988
|
-
api.getToken(tokenParams).then(function (data) {
|
|
989
|
-
if (!data) {
|
|
990
|
-
return;
|
|
643
|
+
api.getDownloadFileInfo({ docId: file.docId }).then((res) => {
|
|
644
|
+
let fileInfo;
|
|
645
|
+
if (res && res.outDocQueryList[0].verInfo[0]) {
|
|
646
|
+
fileInfo = res.outDocQueryList[0].verInfo[0].docInfo[0];
|
|
647
|
+
}
|
|
648
|
+
const { fileSize } = fileInfo;
|
|
649
|
+
const isLargeFile = fileSize > state.docSize && fileSize > state.chunkSize && fileSize > 10 * 1024 * 1024 * 1024;
|
|
650
|
+
if (isLargeFile) {
|
|
651
|
+
api.largeDocumentDownload({ file: fileInfo, isBatch });
|
|
652
|
+
} else {
|
|
653
|
+
api.downloadFileInner({ file, isBatch });
|
|
991
654
|
}
|
|
992
|
-
api.getDownloadFileInfo({
|
|
993
|
-
docId: file.docId
|
|
994
|
-
}).then(function (res) {
|
|
995
|
-
var fileInfo;
|
|
996
|
-
if (res && res.outDocQueryList[0].verInfo[0]) {
|
|
997
|
-
fileInfo = res.outDocQueryList[0].verInfo[0].docInfo[0];
|
|
998
|
-
}
|
|
999
|
-
var _fileInfo = fileInfo,
|
|
1000
|
-
fileSize = _fileInfo.fileSize;
|
|
1001
|
-
var isLargeFile = fileSize > state.docSize && fileSize > state.chunkSize && fileSize > 10 * 1024 * 1024 * 1024;
|
|
1002
|
-
if (isLargeFile) {
|
|
1003
|
-
api.largeDocumentDownload({
|
|
1004
|
-
file: fileInfo,
|
|
1005
|
-
isBatch: isBatch
|
|
1006
|
-
});
|
|
1007
|
-
} else {
|
|
1008
|
-
api.downloadFileInner({
|
|
1009
|
-
file: file,
|
|
1010
|
-
isBatch: isBatch
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
});
|
|
1014
|
-
});
|
|
1015
|
-
};
|
|
1016
|
-
};
|
|
1017
|
-
export var getDownloadFileInfo = function getDownloadFileInfo(_ref31) {
|
|
1018
|
-
var state = _ref31.state,
|
|
1019
|
-
props = _ref31.props,
|
|
1020
|
-
service = _ref31.service;
|
|
1021
|
-
return function (_ref32) {
|
|
1022
|
-
var docId = _ref32.docId;
|
|
1023
|
-
return service.getDocumentInfoUrl().then(function (url) {
|
|
1024
|
-
return new Promise(function (resolve, reject) {
|
|
1025
|
-
service.request({
|
|
1026
|
-
method: 'post',
|
|
1027
|
-
url: xss.filterUrl(url),
|
|
1028
|
-
withCredentials: props.withCredentials,
|
|
1029
|
-
headers: Object.assign(props.headers, state.headers),
|
|
1030
|
-
data: {
|
|
1031
|
-
docInfoVO: {
|
|
1032
|
-
ids: [docId],
|
|
1033
|
-
docType: '',
|
|
1034
|
-
docVersion: ''
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
}).then(function (res) {
|
|
1038
|
-
if (res.data.status === 200) {
|
|
1039
|
-
resolve(res.data.result);
|
|
1040
|
-
} else {
|
|
1041
|
-
reject(res);
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
});
|
|
1045
|
-
});
|
|
1046
|
-
};
|
|
1047
|
-
};
|
|
1048
|
-
export var largeDocumentDownload = function largeDocumentDownload(_ref33) {
|
|
1049
|
-
var api = _ref33.api,
|
|
1050
|
-
state = _ref33.state;
|
|
1051
|
-
return function (_ref34) {
|
|
1052
|
-
var file = _ref34.file,
|
|
1053
|
-
isBatch = _ref34.isBatch;
|
|
1054
|
-
var chunkSize = Math.ceil(file.fileSize / state.chunkSize);
|
|
1055
|
-
state.dowuloadChunkFile.set('chunkSize', chunkSize);
|
|
1056
|
-
state.dowuloadChunkFile.set('fileSize', file.fileSize);
|
|
1057
|
-
state.dowuloadChunkFile.set('docName', file.docName);
|
|
1058
|
-
file.chunkSize = chunkSize;
|
|
1059
|
-
var batches = api.sliceDownloadChunk(file);
|
|
1060
|
-
api.batchSegmentDownload({
|
|
1061
|
-
batchIndex: 0,
|
|
1062
|
-
batches: batches,
|
|
1063
|
-
docId: file.docId,
|
|
1064
|
-
isBatch: isBatch
|
|
1065
655
|
});
|
|
1066
|
-
};
|
|
656
|
+
});
|
|
1067
657
|
};
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
if (downloadChunkArray[lastIndex].length < state.downloadChunkLimit) {
|
|
1080
|
-
downloadChunkArray[lastIndex].push({
|
|
1081
|
-
startRange: startRange,
|
|
1082
|
-
endRange: endRange,
|
|
1083
|
-
index: i
|
|
1084
|
-
});
|
|
658
|
+
const getDownloadFileInfo = ({ state, props, service }) => ({ docId }) => service.getDocumentInfoUrl().then(
|
|
659
|
+
(url) => new Promise((resolve, reject) => {
|
|
660
|
+
service.request({
|
|
661
|
+
method: "post",
|
|
662
|
+
url: xss.filterUrl(url),
|
|
663
|
+
withCredentials: props.withCredentials,
|
|
664
|
+
headers: Object.assign(props.headers, state.headers),
|
|
665
|
+
data: { docInfoVO: { ids: [docId], docType: "", docVersion: "" } }
|
|
666
|
+
}).then((res) => {
|
|
667
|
+
if (res.data.status === 200) {
|
|
668
|
+
resolve(res.data.result);
|
|
1085
669
|
} else {
|
|
1086
|
-
|
|
1087
|
-
state.downloadBatchQueueListen[file.docId + '-' + downloadChunkArray.length] = 0;
|
|
1088
|
-
downloadChunkArray.push([]);
|
|
1089
|
-
downloadChunkArray[lastIndex + 1].push({
|
|
1090
|
-
startRange: startRange,
|
|
1091
|
-
endRange: endRange,
|
|
1092
|
-
index: i
|
|
1093
|
-
});
|
|
670
|
+
reject(res);
|
|
1094
671
|
}
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
672
|
+
});
|
|
673
|
+
})
|
|
674
|
+
);
|
|
675
|
+
const largeDocumentDownload = ({ api, state }) => ({ file, isBatch }) => {
|
|
676
|
+
const chunkSize = Math.ceil(file.fileSize / state.chunkSize);
|
|
677
|
+
state.dowuloadChunkFile.set("chunkSize", chunkSize);
|
|
678
|
+
state.dowuloadChunkFile.set("fileSize", file.fileSize);
|
|
679
|
+
state.dowuloadChunkFile.set("docName", file.docName);
|
|
680
|
+
file.chunkSize = chunkSize;
|
|
681
|
+
const batches = api.sliceDownloadChunk(file);
|
|
682
|
+
api.batchSegmentDownload({ batchIndex: 0, batches, docId: file.docId, isBatch });
|
|
1098
683
|
};
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
docId: docId,
|
|
1119
|
-
batchIndex: ++batchIndex,
|
|
1120
|
-
batches: batches,
|
|
1121
|
-
isBatch: isBatch
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
684
|
+
const sliceDownloadChunk = ({ state }) => (file) => {
|
|
685
|
+
const chunkSize = file.chunkSize;
|
|
686
|
+
const downloadChunkArray = [[]];
|
|
687
|
+
state.downloadBatchQueue[file.docId + "-0"] = 0;
|
|
688
|
+
state.downloadBatchQueueListen[file.docId + "-0"] = 0;
|
|
689
|
+
for (let i = 0; i < chunkSize; i++) {
|
|
690
|
+
const startRange = i * state.chunkSize;
|
|
691
|
+
const endRange = Math.min(file.fileSize, startRange + state.chunkSize);
|
|
692
|
+
const lastIndex = downloadChunkArray.length - 1;
|
|
693
|
+
if (downloadChunkArray[lastIndex].length < state.downloadChunkLimit) {
|
|
694
|
+
downloadChunkArray[lastIndex].push({ startRange, endRange, index: i });
|
|
695
|
+
} else {
|
|
696
|
+
state.downloadBatchQueue[file.docId + "-" + downloadChunkArray.length] = 0;
|
|
697
|
+
state.downloadBatchQueueListen[file.docId + "-" + downloadChunkArray.length] = 0;
|
|
698
|
+
downloadChunkArray.push([]);
|
|
699
|
+
downloadChunkArray[lastIndex + 1].push({
|
|
700
|
+
startRange,
|
|
701
|
+
endRange,
|
|
702
|
+
index: i
|
|
1125
703
|
});
|
|
1126
|
-
var index = 0;
|
|
1127
|
-
while (batch.length - index > 0) {
|
|
1128
|
-
api.downloadFileInner({
|
|
1129
|
-
batchIndex: batchIndex,
|
|
1130
|
-
range: batch[index++],
|
|
1131
|
-
file: {
|
|
1132
|
-
docId: docId
|
|
1133
|
-
},
|
|
1134
|
-
isBatch: isBatch,
|
|
1135
|
-
isChunk: true
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
704
|
}
|
|
1139
|
-
}
|
|
705
|
+
}
|
|
706
|
+
return downloadChunkArray;
|
|
1140
707
|
};
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
state
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
});
|
|
1161
|
-
var handleSuccess = getHandleSuccess({
|
|
1162
|
-
downloadOps: downloadOps,
|
|
1163
|
-
file: file,
|
|
1164
|
-
translateFile: translateFile,
|
|
1165
|
-
isChunk: isChunk,
|
|
1166
|
-
state: state
|
|
708
|
+
const batchSegmentDownload = ({ state, api }) => ({ batchIndex, batches, docId, isBatch }) => {
|
|
709
|
+
if (batchIndex < batches.length) {
|
|
710
|
+
const batch = batches[batchIndex];
|
|
711
|
+
const key = docId + "-" + batchIndex;
|
|
712
|
+
Object.defineProperty(state.downloadBatchQueue, key, {
|
|
713
|
+
get() {
|
|
714
|
+
return state.downloadBatchQueueListen[key];
|
|
715
|
+
},
|
|
716
|
+
set(value) {
|
|
717
|
+
state.downloadBatchQueueListen[key] = value;
|
|
718
|
+
if (value >= batch.length) {
|
|
719
|
+
api.batchSegmentDownload({
|
|
720
|
+
docId,
|
|
721
|
+
batchIndex: ++batchIndex,
|
|
722
|
+
batches,
|
|
723
|
+
isBatch
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
}
|
|
1167
727
|
});
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
isFinished = _ref40$isFinished === void 0 ? false : _ref40$isFinished;
|
|
1172
|
-
if (!isBatch) {
|
|
1173
|
-
var args = {
|
|
1174
|
-
api: api,
|
|
1175
|
-
downloadOps: downloadOps,
|
|
1176
|
-
file: file,
|
|
1177
|
-
service: service,
|
|
1178
|
-
constants: constants,
|
|
1179
|
-
props: props,
|
|
1180
|
-
state: state,
|
|
1181
|
-
t: t,
|
|
1182
|
-
Modal: Modal,
|
|
1183
|
-
isChunk: isChunk
|
|
1184
|
-
};
|
|
1185
|
-
Object.assign(args, {
|
|
1186
|
-
calcProgress: calcProgress,
|
|
1187
|
-
isFinished: isFinished,
|
|
1188
|
-
emit: emit,
|
|
1189
|
-
handleSuccess: handleSuccess,
|
|
1190
|
-
range: range,
|
|
1191
|
-
batchIndex: batchIndex,
|
|
1192
|
-
isBatch: isBatch
|
|
1193
|
-
});
|
|
1194
|
-
downloadFileSingle(args);
|
|
1195
|
-
return;
|
|
728
|
+
let index = 0;
|
|
729
|
+
while (batch.length - index > 0) {
|
|
730
|
+
api.downloadFileInner({ batchIndex, range: batch[index++], file: { docId }, isBatch, isChunk: true });
|
|
1196
731
|
}
|
|
1197
|
-
|
|
1198
|
-
api: api,
|
|
1199
|
-
downloadOps: downloadOps,
|
|
1200
|
-
file: file,
|
|
1201
|
-
service: service,
|
|
1202
|
-
props: props,
|
|
1203
|
-
state: state,
|
|
1204
|
-
calcProgress: calcProgress,
|
|
1205
|
-
emit: emit,
|
|
1206
|
-
handleSuccess: handleSuccess,
|
|
1207
|
-
t: t,
|
|
1208
|
-
Modal: Modal,
|
|
1209
|
-
range: range
|
|
1210
|
-
};
|
|
1211
|
-
isBatch && downloadFileBatch(params);
|
|
1212
|
-
};
|
|
732
|
+
}
|
|
1213
733
|
};
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
734
|
+
const downloadFileInner = ({ api, props, service, state, emit, constants, t, Modal }) => ({ batchIndex, file, range, isBatch, isChunk }) => {
|
|
735
|
+
const downloadOps = props.edm.download || {};
|
|
736
|
+
const translateFile = getTranslateFile({ api, isChunk });
|
|
737
|
+
const handleSuccess2 = getHandleSuccess({ downloadOps, file, translateFile, isChunk, state });
|
|
738
|
+
const calcProgress = getCalcProgress();
|
|
739
|
+
let { isFinished = false } = {};
|
|
740
|
+
if (!isBatch) {
|
|
741
|
+
let args = { api, downloadOps, file, service, constants, props, state, t, Modal, isChunk };
|
|
742
|
+
Object.assign(args, { calcProgress, isFinished, emit, handleSuccess: handleSuccess2, range, batchIndex, isBatch });
|
|
743
|
+
downloadFileSingle(args);
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
const params = { api, downloadOps, file, service, props, state, calcProgress, emit, handleSuccess: handleSuccess2, t, Modal, range };
|
|
747
|
+
isBatch && downloadFileBatch(params);
|
|
748
|
+
};
|
|
749
|
+
const afterDownload = ({ api, state }) => ({ batchIndex, range, data, file, isBatch, isChunk }) => {
|
|
750
|
+
if (data.status === 200) {
|
|
751
|
+
const key = file.docId + "-" + batchIndex;
|
|
752
|
+
const count = state.downloadBatchQueue[key];
|
|
753
|
+
state.downloadBatchQueue[key] = count + 1;
|
|
754
|
+
} else {
|
|
755
|
+
const countDownloadReplay = state.downloadReplayAtoms[file.docId + "-" + range.index];
|
|
756
|
+
if (countDownloadReplay && countDownloadReplay >= 2) {
|
|
757
|
+
const msgArray = ["The number of retry times exceeds the threshold! [docId:", file.docId, ", chunk:", range.index, "]"];
|
|
758
|
+
log.logger.warn(msgArray.join(""));
|
|
759
|
+
delete state.downloadReplayAtoms[file.docId + "-" + range.index];
|
|
1228
760
|
} else {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
delete state.downloadReplayAtoms[file.docId + '-' + range.index];
|
|
1234
|
-
} else {
|
|
1235
|
-
var _msgArray = ['replay ', countDownloadReplay, '! [docId:', file.docId, ', chunk:', range.index, ']'];
|
|
1236
|
-
log.logger.warn(_msgArray.join(''));
|
|
1237
|
-
state.downloadReplayAtoms[file.docId + '-' + range.index] = countDownloadReplay + 1;
|
|
1238
|
-
api.downloadFileInner({
|
|
1239
|
-
batchIndex: batchIndex,
|
|
1240
|
-
range: range,
|
|
1241
|
-
file: file,
|
|
1242
|
-
isBatch: isBatch,
|
|
1243
|
-
isChunk: isChunk
|
|
1244
|
-
});
|
|
1245
|
-
}
|
|
761
|
+
const msgArray = ["replay ", countDownloadReplay, "! [docId:", file.docId, ", chunk:", range.index, "]"];
|
|
762
|
+
log.logger.warn(msgArray.join(""));
|
|
763
|
+
state.downloadReplayAtoms[file.docId + "-" + range.index] = countDownloadReplay + 1;
|
|
764
|
+
api.downloadFileInner({ batchIndex, range, file, isBatch, isChunk });
|
|
1246
765
|
}
|
|
1247
|
-
}
|
|
766
|
+
}
|
|
1248
767
|
};
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
downloaded
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
emit('download', 100);
|
|
1270
|
-
writer.close();
|
|
1271
|
-
} else {
|
|
1272
|
-
var progress = Math.ceil(downloaded / fileSize * 100) || 0;
|
|
1273
|
-
if (progress !== 100) {
|
|
1274
|
-
emit('download', progress);
|
|
1275
|
-
}
|
|
1276
|
-
index++;
|
|
1277
|
-
writerStreamSaver();
|
|
768
|
+
const setWriterFile = ({ state, emit, props }) => ({ data, index }) => {
|
|
769
|
+
const fileStream = props.plugin && props.plugin.createWriteStream(state.dowuloadChunkFile.get("docName"), {
|
|
770
|
+
size: data.byteLength
|
|
771
|
+
});
|
|
772
|
+
const writer = fileStream.getWriter();
|
|
773
|
+
let downloaded = 0;
|
|
774
|
+
const fileSize = state.dowuloadChunkFile.get("fileSize");
|
|
775
|
+
const writerStreamSaver = () => {
|
|
776
|
+
let chunk = state.dowuloadChunkFile.get(index);
|
|
777
|
+
if (chunk) {
|
|
778
|
+
writer.write(chunk).then(() => {
|
|
779
|
+
downloaded += chunk.byteLength;
|
|
780
|
+
state.dowuloadChunkFile.delete(index);
|
|
781
|
+
if (index + 1 === state.dowuloadChunkFile.get("chunkSize")) {
|
|
782
|
+
emit("download", 100);
|
|
783
|
+
writer.close();
|
|
784
|
+
} else {
|
|
785
|
+
const progress = Math.ceil(downloaded / fileSize * 100) || 0;
|
|
786
|
+
if (progress !== 100) {
|
|
787
|
+
emit("download", progress);
|
|
1278
788
|
}
|
|
1279
|
-
|
|
1280
|
-
});
|
|
1281
|
-
} else {
|
|
1282
|
-
setTimeout(function () {
|
|
789
|
+
index++;
|
|
1283
790
|
writerStreamSaver();
|
|
1284
|
-
}, 1000);
|
|
1285
|
-
}
|
|
1286
|
-
};
|
|
1287
|
-
writerStreamSaver();
|
|
1288
|
-
};
|
|
1289
|
-
};
|
|
1290
|
-
export var getFormData = function getFormData(_ref45) {
|
|
1291
|
-
var constants = _ref45.constants,
|
|
1292
|
-
props = _ref45.props,
|
|
1293
|
-
state = _ref45.state;
|
|
1294
|
-
return function (_ref46) {
|
|
1295
|
-
var formData = _ref46.formData,
|
|
1296
|
-
file = _ref46.file,
|
|
1297
|
-
type = _ref46.type;
|
|
1298
|
-
if (state.isEdm && props.edm.upload) {
|
|
1299
|
-
var propData = props.data || {};
|
|
1300
|
-
var edmData = props.edm.upload.params || {};
|
|
1301
|
-
var params = _objectSpread(_objectSpread({}, propData), edmData);
|
|
1302
|
-
for (var key in params) {
|
|
1303
|
-
if (Object.prototype.hasOwnProperty.call(params, key)) {
|
|
1304
|
-
formData.set(key, params[key] || '');
|
|
1305
791
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
if (props.edm.isCheckCode === true) {
|
|
1309
|
-
formData.append(constants.EDM.ISCHECKCODE, 'Y');
|
|
1310
|
-
file.hash && formData.append(constants.EDM.CHECKCODE, file.hash);
|
|
1311
|
-
} else {
|
|
1312
|
-
formData.append(constants.EDM.ISCHECKCODE, 'N');
|
|
1313
|
-
}
|
|
1314
|
-
var updateId = state.updateId || props.edm.updateId;
|
|
1315
|
-
if (type === constants.EDM.CHUNKINIT) {
|
|
1316
|
-
formData.append(constants.EDM.FILESIZE, file.size);
|
|
1317
|
-
formData.append(constants.EDM.CHUNKS, file.chunkSize);
|
|
1318
|
-
formData.append(constants.EDM.FILENAME, file.name);
|
|
1319
|
-
updateId && formData.append(constants.EDM.DOCID, updateId);
|
|
792
|
+
chunk = null;
|
|
793
|
+
});
|
|
1320
794
|
} else {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
var docId = updateId || file.docId;
|
|
1325
|
-
formData.append(constants.EDM.DOCID, docId);
|
|
795
|
+
setTimeout(() => {
|
|
796
|
+
writerStreamSaver();
|
|
797
|
+
}, 1e3);
|
|
1326
798
|
}
|
|
1327
|
-
updateId && formData.append('updateFile', true);
|
|
1328
|
-
return formData;
|
|
1329
799
|
};
|
|
800
|
+
writerStreamSaver();
|
|
1330
801
|
};
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
var chunkSize = Math.ceil(file.size / state.chunkSize);
|
|
1340
|
-
file.chunkSize = chunkSize;
|
|
1341
|
-
file.cancelToken = [];
|
|
1342
|
-
api.segmentUploadInit(file).then(function (data) {
|
|
1343
|
-
if (data) {
|
|
1344
|
-
file.records = data.chunks;
|
|
1345
|
-
file.docId = data.docId;
|
|
1346
|
-
state.largeFileInfo[data.docId] = file;
|
|
1347
|
-
var batches = api.sliceChunk(file);
|
|
1348
|
-
api.batchSegmentUpload({
|
|
1349
|
-
docId: data.docId,
|
|
1350
|
-
batchIndex: 0,
|
|
1351
|
-
batches: batches,
|
|
1352
|
-
progress: {
|
|
1353
|
-
size: file.size,
|
|
1354
|
-
trunks: [],
|
|
1355
|
-
file: file
|
|
1356
|
-
}
|
|
1357
|
-
});
|
|
1358
|
-
} else {
|
|
1359
|
-
Modal.message({
|
|
1360
|
-
message: t('ui.fileUpload.init'),
|
|
1361
|
-
status: 'warning',
|
|
1362
|
-
duration: '1000'
|
|
1363
|
-
});
|
|
1364
|
-
var fileData = api.getFile(file);
|
|
1365
|
-
state.uploadFiles.splice(state.uploadFiles.indexOf(fileData), 1);
|
|
802
|
+
const getFormData = ({ constants, props, state }) => ({ formData, file, type }) => {
|
|
803
|
+
if (state.isEdm && props.edm.upload) {
|
|
804
|
+
const propData = props.data || {};
|
|
805
|
+
const edmData = props.edm.upload.params || {};
|
|
806
|
+
const params = __spreadValues(__spreadValues({}, propData), edmData);
|
|
807
|
+
for (let key in params) {
|
|
808
|
+
if (Object.prototype.hasOwnProperty.call(params, key)) {
|
|
809
|
+
formData.set(key, params[key] || "");
|
|
1366
810
|
}
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (props.edm.isCheckCode === true) {
|
|
814
|
+
formData.append(constants.EDM.ISCHECKCODE, "Y");
|
|
815
|
+
file.hash && formData.append(constants.EDM.CHECKCODE, file.hash);
|
|
816
|
+
} else {
|
|
817
|
+
formData.append(constants.EDM.ISCHECKCODE, "N");
|
|
818
|
+
}
|
|
819
|
+
const updateId = state.updateId || props.edm.updateId;
|
|
820
|
+
if (type === constants.EDM.CHUNKINIT) {
|
|
821
|
+
formData.append(constants.EDM.FILESIZE, file.size);
|
|
822
|
+
formData.append(constants.EDM.CHUNKS, file.chunkSize);
|
|
823
|
+
formData.append(constants.EDM.FILENAME, file.name);
|
|
824
|
+
updateId && formData.append(constants.EDM.DOCID, updateId);
|
|
825
|
+
} else {
|
|
826
|
+
formData.append(constants.EDM.MULTIPART, file, file.filename);
|
|
827
|
+
formData.append(constants.EDM.CHUNK, file.chunk);
|
|
828
|
+
formData.append(constants.EDM.LOWERNAME, file.filename);
|
|
829
|
+
const docId = updateId || file.docId;
|
|
830
|
+
formData.append(constants.EDM.DOCID, docId);
|
|
831
|
+
}
|
|
832
|
+
updateId && formData.append("updateFile", true);
|
|
833
|
+
return formData;
|
|
1372
834
|
};
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
835
|
+
const largeDocumentUpload = ({ api, Modal, state, t, emit, constants }) => (file) => {
|
|
836
|
+
const chunkSize = Math.ceil(file.size / state.chunkSize);
|
|
837
|
+
file.chunkSize = chunkSize;
|
|
838
|
+
file.cancelToken = [];
|
|
839
|
+
api.segmentUploadInit(file).then((data) => {
|
|
840
|
+
if (data) {
|
|
841
|
+
file.records = data.chunks;
|
|
842
|
+
file.docId = data.docId;
|
|
843
|
+
state.largeFileInfo[data.docId] = file;
|
|
844
|
+
const batches = api.sliceChunk(file);
|
|
845
|
+
api.batchSegmentUpload({
|
|
846
|
+
docId: data.docId,
|
|
847
|
+
batchIndex: 0,
|
|
848
|
+
batches,
|
|
849
|
+
progress: { size: file.size, trunks: [], file }
|
|
850
|
+
});
|
|
851
|
+
} else {
|
|
852
|
+
Modal.message({
|
|
853
|
+
message: t("ui.fileUpload.init"),
|
|
854
|
+
status: "warning",
|
|
855
|
+
duration: "1000"
|
|
856
|
+
});
|
|
857
|
+
const fileData = api.getFile(file);
|
|
858
|
+
state.uploadFiles.splice(state.uploadFiles.indexOf(fileData), 1);
|
|
859
|
+
}
|
|
860
|
+
}).catch((err) => {
|
|
861
|
+
file.status = constants.FILE_STATUS.FAIL;
|
|
862
|
+
emit("error", err, file, state.uploadFiles);
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
const segmentUploadInit = ({ api, props, service, state, constants }) => (file) => {
|
|
866
|
+
const formData = new FormData();
|
|
867
|
+
return new Promise((resolve, reject) => {
|
|
868
|
+
service.getLargeFileInitUrl().then((data) => {
|
|
869
|
+
service.request({
|
|
870
|
+
method: "post",
|
|
871
|
+
url: xss.filterUrl(data),
|
|
872
|
+
data: api.getFormData({ formData, file, type: constants.EDM.CHUNKINIT }),
|
|
873
|
+
withCredentials: props.withCredentials,
|
|
874
|
+
headers: Object.assign(props.headers, state.headers)
|
|
875
|
+
}).then((data2) => {
|
|
876
|
+
if (data2.data.status === 200) {
|
|
877
|
+
resolve(data2.data.result);
|
|
878
|
+
} else {
|
|
879
|
+
reject(data2);
|
|
880
|
+
}
|
|
1400
881
|
});
|
|
1401
882
|
});
|
|
1402
|
-
};
|
|
883
|
+
});
|
|
1403
884
|
};
|
|
1404
|
-
|
|
1405
|
-
var data = _ref49.data,
|
|
1406
|
-
file = _ref49.file,
|
|
1407
|
-
batchIndex = _ref49.batchIndex,
|
|
1408
|
-
state = _ref49.state,
|
|
1409
|
-
api = _ref49.api,
|
|
1410
|
-
progress = _ref49.progress;
|
|
885
|
+
const afterUpload = ({ data, file, batchIndex, state, api, progress }) => {
|
|
1411
886
|
if (data.status === 200) {
|
|
1412
|
-
|
|
1413
|
-
|
|
887
|
+
const key = file.docId + "-" + batchIndex;
|
|
888
|
+
const count = state.batchQueue[key];
|
|
1414
889
|
state.batchQueue[key] = count + 1;
|
|
1415
890
|
} else {
|
|
1416
|
-
|
|
891
|
+
const countReplay = state.replayAtoms[file.docId + "-" + file.chunk];
|
|
1417
892
|
if (countReplay && countReplay >= 2) {
|
|
1418
|
-
|
|
1419
|
-
log.logger.warn(msgArray.join(
|
|
1420
|
-
delete state.replayAtoms[file.docId +
|
|
893
|
+
const msgArray = ["The number of retry times exceeds the threshold! [docId:", file.docId, ", chunk:", file.chunk, "]"];
|
|
894
|
+
log.logger.warn(msgArray.join(""));
|
|
895
|
+
delete state.replayAtoms[file.docId + "-" + file.chunk];
|
|
1421
896
|
} else {
|
|
1422
|
-
|
|
1423
|
-
log.logger.warn(
|
|
1424
|
-
state.replayAtoms[file.docId +
|
|
897
|
+
const msgArray = ["replay ", countReplay, "! [docId:", file.docId, ", chunk:", file.chunk, "]"];
|
|
898
|
+
log.logger.warn(msgArray.join(""));
|
|
899
|
+
state.replayAtoms[file.docId + "-" + file.chunk] = countReplay + 1;
|
|
1425
900
|
api.segmentUpload(batchIndex, file, progress);
|
|
1426
901
|
}
|
|
1427
902
|
}
|
|
1428
903
|
};
|
|
1429
|
-
|
|
1430
|
-
var state = _ref50.state,
|
|
1431
|
-
service = _ref50.service,
|
|
1432
|
-
postChunk = _ref50.postChunk;
|
|
904
|
+
const chunkUpload = ({ state, service, postChunk }) => {
|
|
1433
905
|
if (!state.chunkUploadUrl) {
|
|
1434
|
-
service.getChunkUploadUrl().then(
|
|
906
|
+
service.getChunkUploadUrl().then((data) => {
|
|
1435
907
|
state.chunkUploadUrl = data;
|
|
1436
908
|
postChunk(data);
|
|
1437
909
|
});
|
|
@@ -1439,74 +911,41 @@ var chunkUpload = function chunkUpload(_ref50) {
|
|
|
1439
911
|
postChunk(state.chunkUploadUrl);
|
|
1440
912
|
}
|
|
1441
913
|
};
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
state = _ref51.state,
|
|
1447
|
-
emit = _ref51.emit,
|
|
1448
|
-
constants = _ref51.constants,
|
|
1449
|
-
batchIndex = _ref51.batchIndex,
|
|
1450
|
-
file = _ref51.file,
|
|
1451
|
-
progress = _ref51.progress;
|
|
1452
|
-
var formData = new FormData();
|
|
1453
|
-
var postChunk = function postChunk(url) {
|
|
1454
|
-
var source = service.cancelToken();
|
|
914
|
+
const segmentUploadInner = ({ api, props, service, state, emit, constants, batchIndex, file, progress }) => {
|
|
915
|
+
const formData = new FormData();
|
|
916
|
+
const postChunk = (url) => {
|
|
917
|
+
const source = service.cancelToken();
|
|
1455
918
|
if (progress.file.cancelToken) {
|
|
1456
919
|
progress.file.cancelToken.push(source.cancel);
|
|
1457
920
|
service.request({
|
|
1458
|
-
method:
|
|
921
|
+
method: "post",
|
|
1459
922
|
url: xss.filterUrl(url),
|
|
1460
|
-
data: api.getFormData({
|
|
1461
|
-
formData: formData,
|
|
1462
|
-
file: file,
|
|
1463
|
-
type: ''
|
|
1464
|
-
}),
|
|
923
|
+
data: api.getFormData({ formData, file, type: "" }),
|
|
1465
924
|
withCredentials: props.withCredentials,
|
|
1466
925
|
headers: Object.assign(props.headers, state.headers),
|
|
1467
926
|
cancelToken: source.token,
|
|
1468
927
|
hideErr: true,
|
|
1469
|
-
onUploadProgress
|
|
928
|
+
onUploadProgress(event) {
|
|
1470
929
|
progress.trunks[file.chunk] = event.loaded;
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
});
|
|
1474
|
-
var percentage = Math.floor(count / progress.size * 100) || 0;
|
|
930
|
+
const count = progress.trunks.reduce((a, b) => a + b);
|
|
931
|
+
let percentage = Math.floor(count / progress.size * 100) || 0;
|
|
1475
932
|
file.percentage = Math.floor(event.loaded / event.total * 100);
|
|
1476
933
|
event.percentage = progress.file.percentage = percentage > 100 ? 100 : percentage;
|
|
1477
934
|
if (percentage >= 100) {
|
|
1478
935
|
progress.file.isFinished = true;
|
|
1479
936
|
}
|
|
1480
|
-
emit(
|
|
937
|
+
emit("progress", progress.file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
1481
938
|
}
|
|
1482
|
-
}).then(
|
|
1483
|
-
afterUpload({
|
|
1484
|
-
data: data,
|
|
1485
|
-
file: file,
|
|
1486
|
-
batchIndex: batchIndex,
|
|
1487
|
-
state: state,
|
|
1488
|
-
api: api,
|
|
1489
|
-
progress: progress
|
|
1490
|
-
});
|
|
939
|
+
}).then((data) => {
|
|
940
|
+
afterUpload({ data, file, batchIndex, state, api, progress });
|
|
1491
941
|
if (progress.file.percentage === 100) {
|
|
1492
942
|
progress.file.status = constants.FILE_STATUS.SUCESS;
|
|
1493
943
|
}
|
|
1494
|
-
})
|
|
944
|
+
}).catch((data) => {
|
|
1495
945
|
if (data.response && data.response.status === 401) {
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
type: 'upload'
|
|
1500
|
-
};
|
|
1501
|
-
api.getToken(tokenParams).then(function (data) {
|
|
1502
|
-
afterUpload({
|
|
1503
|
-
data: data,
|
|
1504
|
-
file: file,
|
|
1505
|
-
batchIndex: batchIndex,
|
|
1506
|
-
state: state,
|
|
1507
|
-
api: api,
|
|
1508
|
-
progress: progress
|
|
1509
|
-
});
|
|
946
|
+
const tokenParams = { token: props.edm.upload.token, file, type: "upload" };
|
|
947
|
+
api.getToken(tokenParams).then((data2) => {
|
|
948
|
+
afterUpload({ data: data2, file, batchIndex, state, api, progress });
|
|
1510
949
|
});
|
|
1511
950
|
} else {
|
|
1512
951
|
file.state = constants.FILE_STATUS.FAIL;
|
|
@@ -1514,234 +953,180 @@ var segmentUploadInner = function segmentUploadInner(_ref51) {
|
|
|
1514
953
|
});
|
|
1515
954
|
}
|
|
1516
955
|
};
|
|
1517
|
-
chunkUpload({
|
|
1518
|
-
state: state,
|
|
1519
|
-
service: service,
|
|
1520
|
-
postChunk: postChunk
|
|
1521
|
-
});
|
|
956
|
+
chunkUpload({ state, service, postChunk });
|
|
1522
957
|
};
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
service = _ref52.service,
|
|
1527
|
-
state = _ref52.state,
|
|
1528
|
-
emit = _ref52.emit,
|
|
1529
|
-
constants = _ref52.constants;
|
|
1530
|
-
return function (batchIndex, file, progress) {
|
|
1531
|
-
if (typeof file.then === 'function') {
|
|
1532
|
-
file.then(function (file) {
|
|
1533
|
-
segmentUploadInner({
|
|
1534
|
-
batchIndex: batchIndex,
|
|
1535
|
-
api: api,
|
|
1536
|
-
service: service,
|
|
1537
|
-
state: state,
|
|
1538
|
-
emit: emit,
|
|
1539
|
-
props: props,
|
|
1540
|
-
file: file,
|
|
1541
|
-
constants: constants,
|
|
1542
|
-
progress: progress
|
|
1543
|
-
});
|
|
1544
|
-
});
|
|
1545
|
-
} else {
|
|
958
|
+
const segmentUpload = ({ api, props, service, state, emit, constants }) => (batchIndex, file, progress) => {
|
|
959
|
+
if (typeof file.then === "function") {
|
|
960
|
+
file.then((file2) => {
|
|
1546
961
|
segmentUploadInner({
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
service
|
|
1550
|
-
state
|
|
1551
|
-
emit
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
progress
|
|
962
|
+
batchIndex,
|
|
963
|
+
api,
|
|
964
|
+
service,
|
|
965
|
+
state,
|
|
966
|
+
emit,
|
|
967
|
+
props,
|
|
968
|
+
file: file2,
|
|
969
|
+
constants,
|
|
970
|
+
progress
|
|
1556
971
|
});
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
972
|
+
});
|
|
973
|
+
} else {
|
|
974
|
+
segmentUploadInner({
|
|
975
|
+
api,
|
|
976
|
+
props,
|
|
977
|
+
service,
|
|
978
|
+
state,
|
|
979
|
+
emit,
|
|
980
|
+
constants,
|
|
981
|
+
batchIndex,
|
|
982
|
+
file,
|
|
983
|
+
progress
|
|
984
|
+
});
|
|
985
|
+
}
|
|
1559
986
|
};
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
},
|
|
1578
|
-
set: function set(value) {
|
|
1579
|
-
state.batchQueueListen[key] = value;
|
|
1580
|
-
if (value >= batch.length) {
|
|
1581
|
-
api.batchSegmentUpload({
|
|
1582
|
-
docId: docId,
|
|
1583
|
-
batchIndex: ++batchIndex,
|
|
1584
|
-
batches: batches,
|
|
1585
|
-
progress: progress
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
987
|
+
const batchSegmentUpload = ({ api, constants, props, refs, state }) => ({ docId, batchIndex, batches, progress }) => {
|
|
988
|
+
if (batchIndex < batches.length && progress.file.cancelToken) {
|
|
989
|
+
const key = docId + "-" + batchIndex;
|
|
990
|
+
const batch = batches[batchIndex];
|
|
991
|
+
Object.defineProperty(state.batchQueue, key, {
|
|
992
|
+
get() {
|
|
993
|
+
return state.batchQueueListen[key];
|
|
994
|
+
},
|
|
995
|
+
set(value) {
|
|
996
|
+
state.batchQueueListen[key] = value;
|
|
997
|
+
if (value >= batch.length) {
|
|
998
|
+
api.batchSegmentUpload({
|
|
999
|
+
docId,
|
|
1000
|
+
batchIndex: ++batchIndex,
|
|
1001
|
+
batches,
|
|
1002
|
+
progress
|
|
1003
|
+
});
|
|
1588
1004
|
}
|
|
1589
|
-
});
|
|
1590
|
-
var index = 0;
|
|
1591
|
-
while (batch.length - index > 0) {
|
|
1592
|
-
api.segmentUpload(batchIndex, batch[index++], progress);
|
|
1593
1005
|
}
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1006
|
+
});
|
|
1007
|
+
let index = 0;
|
|
1008
|
+
while (batch.length - index > 0) {
|
|
1009
|
+
api.segmentUpload(batchIndex, batch[index++], progress);
|
|
1597
1010
|
}
|
|
1598
|
-
}
|
|
1011
|
+
} else {
|
|
1012
|
+
typeof props.edm.upload.closeloading === "function" && props.edm.upload.closeloading();
|
|
1013
|
+
refs[constants.UPLOAD_INNER].upload(state.largeFileInfo[docId]);
|
|
1014
|
+
}
|
|
1599
1015
|
};
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1016
|
+
const sliceChunk = ({ state, props }) => (file) => {
|
|
1017
|
+
const chunkSize = file.chunkSize;
|
|
1018
|
+
const chunkBatchArray = [[]];
|
|
1019
|
+
state.batchQueue[file.docId + "-0"] = 0;
|
|
1020
|
+
state.batchQueueListen[file.docId + "-0"] = 0;
|
|
1021
|
+
for (let i = 0; i < chunkSize; i++) {
|
|
1022
|
+
if (file.records.includes(i.toString())) {
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
const start = i * state.chunkSize;
|
|
1026
|
+
const end = Math.min(file.size, start + state.chunkSize);
|
|
1027
|
+
const atom = file.raw.slice(start, end);
|
|
1028
|
+
atom.chunk = i + 1;
|
|
1029
|
+
atom.filename = file.name;
|
|
1030
|
+
atom.docId = file.docId;
|
|
1031
|
+
atom.chunkSize = chunkSize;
|
|
1032
|
+
atom.cacheSign = file.cacheSign;
|
|
1033
|
+
atom.records = file.records;
|
|
1034
|
+
atom.percentage = file.percentage;
|
|
1035
|
+
const promise = new Promise((resolve) => {
|
|
1036
|
+
if (props.edm.isCheckCode !== true) {
|
|
1037
|
+
return resolve(atom);
|
|
1611
1038
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
atom.records = file.records;
|
|
1621
|
-
atom.percentage = file.percentage;
|
|
1622
|
-
var promise = new Promise(function (resolve) {
|
|
1623
|
-
if (props.edm.isCheckCode !== true) {
|
|
1624
|
-
return resolve(atom);
|
|
1039
|
+
const reader = new FileReader();
|
|
1040
|
+
reader.readAsArrayBuffer(atom);
|
|
1041
|
+
reader.onload = (e) => {
|
|
1042
|
+
if (props.edm.isCheckCode === true) {
|
|
1043
|
+
const cryptoJS = props.edm.upload.plugin();
|
|
1044
|
+
const wordArray = cryptoJS.lib.WordArray.create(e.target.result);
|
|
1045
|
+
const hash = cryptoJS[shaMap.shaMap](wordArray).toString();
|
|
1046
|
+
atom.hash = hash;
|
|
1625
1047
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
});
|
|
1638
|
-
var lastIndex = chunkBatchArray.length - 1;
|
|
1639
|
-
if (chunkBatchArray[lastIndex].length < state.chunkBatchLimit) {
|
|
1640
|
-
chunkBatchArray[lastIndex].push(promise);
|
|
1641
|
-
} else {
|
|
1642
|
-
state.batchQueue[file.docId + '-' + chunkBatchArray.length] = 0;
|
|
1643
|
-
state.batchQueueListen[file.docId + '-' + chunkBatchArray.length] = 0;
|
|
1644
|
-
chunkBatchArray.push([]);
|
|
1645
|
-
chunkBatchArray[lastIndex + 1].push(promise);
|
|
1646
|
-
}
|
|
1647
|
-
};
|
|
1648
|
-
for (var i = 0; i < chunkSize; i++) {
|
|
1649
|
-
var _ret = _loop();
|
|
1650
|
-
if (_ret === "continue") continue;
|
|
1048
|
+
resolve(atom);
|
|
1049
|
+
};
|
|
1050
|
+
});
|
|
1051
|
+
const lastIndex = chunkBatchArray.length - 1;
|
|
1052
|
+
if (chunkBatchArray[lastIndex].length < state.chunkBatchLimit) {
|
|
1053
|
+
chunkBatchArray[lastIndex].push(promise);
|
|
1054
|
+
} else {
|
|
1055
|
+
state.batchQueue[file.docId + "-" + chunkBatchArray.length] = 0;
|
|
1056
|
+
state.batchQueueListen[file.docId + "-" + chunkBatchArray.length] = 0;
|
|
1057
|
+
chunkBatchArray.push([]);
|
|
1058
|
+
chunkBatchArray[lastIndex + 1].push(promise);
|
|
1651
1059
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1060
|
+
}
|
|
1061
|
+
return chunkBatchArray;
|
|
1654
1062
|
};
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
state =
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1063
|
+
const getToken = ({ constants, props, state, t, Modal }) => ({ token, file, isOnlinePreview = false, type = "", isinit = false }) => {
|
|
1064
|
+
if (props.edm.isExtranet && !isOnlinePreview) {
|
|
1065
|
+
state.isSuccess = true;
|
|
1066
|
+
state.accept = props.accept;
|
|
1067
|
+
state.singleMaxSize = props.edm.singleFileMaxSize || 200;
|
|
1068
|
+
return Promise.resolve(true);
|
|
1069
|
+
}
|
|
1070
|
+
if (state.isEdm && !token || typeof token !== "function") {
|
|
1071
|
+
Modal.message({
|
|
1072
|
+
message: t(constants.EDM.I18NKEY),
|
|
1073
|
+
status: "warning",
|
|
1074
|
+
duration: "2000"
|
|
1075
|
+
});
|
|
1076
|
+
return new Promise((resolve) => {
|
|
1077
|
+
resolve(false);
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
return new Promise((resolve, reject) => {
|
|
1081
|
+
try {
|
|
1082
|
+
let promise;
|
|
1083
|
+
if (isinit) {
|
|
1084
|
+
!initTokenPromise && (initTokenPromise = token(file));
|
|
1085
|
+
promise = initTokenPromise;
|
|
1086
|
+
} else {
|
|
1087
|
+
promise = token(file);
|
|
1088
|
+
}
|
|
1089
|
+
promise.then((data) => {
|
|
1090
|
+
const result = data || {};
|
|
1091
|
+
const whitelist = result.config && result.config.fileWhiteList || "";
|
|
1092
|
+
state.isSuccess = true;
|
|
1093
|
+
state.accept = type === "download" || type === "preview" ? props.accept : `${whitelist},${props.accept}`;
|
|
1094
|
+
state.headers[constants.EDM.EDMTOKEN] = result.edmToken || "";
|
|
1095
|
+
state.headers[constants.EDM.TRACEID] = result.traceId || "";
|
|
1096
|
+
if (result.config) {
|
|
1097
|
+
state.singleMaxSize = result.config.singleFileMaxSize;
|
|
1098
|
+
}
|
|
1099
|
+
state.edmToken = result;
|
|
1100
|
+
resolve(true);
|
|
1684
1101
|
});
|
|
1102
|
+
} catch (error) {
|
|
1103
|
+
reject(new Error(error));
|
|
1685
1104
|
}
|
|
1686
|
-
|
|
1687
|
-
try {
|
|
1688
|
-
var promise;
|
|
1689
|
-
if (isinit) {
|
|
1690
|
-
!initTokenPromise && (initTokenPromise = token(file));
|
|
1691
|
-
promise = initTokenPromise;
|
|
1692
|
-
} else {
|
|
1693
|
-
promise = token(file);
|
|
1694
|
-
}
|
|
1695
|
-
promise.then(function (data) {
|
|
1696
|
-
var result = data || {};
|
|
1697
|
-
var whitelist = result.config && result.config.fileWhiteList || '';
|
|
1698
|
-
state.isSuccess = true;
|
|
1699
|
-
state.accept = type === 'download' || type === 'preview' ? props.accept : "".concat(whitelist, ",").concat(props.accept);
|
|
1700
|
-
state.headers[constants.EDM.EDMTOKEN] = result.edmToken || '';
|
|
1701
|
-
state.headers[constants.EDM.TRACEID] = result.traceId || '';
|
|
1702
|
-
if (result.config) {
|
|
1703
|
-
state.singleMaxSize = result.config.singleFileMaxSize;
|
|
1704
|
-
}
|
|
1705
|
-
state.edmToken = result;
|
|
1706
|
-
resolve(true);
|
|
1707
|
-
});
|
|
1708
|
-
} catch (error) {
|
|
1709
|
-
reject(new Error(error));
|
|
1710
|
-
}
|
|
1711
|
-
});
|
|
1712
|
-
};
|
|
1105
|
+
});
|
|
1713
1106
|
};
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
var params = state.fileWater ? constants.EDM.FORMAT : '';
|
|
1738
|
-
var downParams = state.fileWater ? constants.EDM.WATER : constants.EDM.SOURCE;
|
|
1739
|
-
var tools = props.edm.preview.plugin;
|
|
1740
|
-
service.all([service.getPreviewUrl(), service.getSingleDownloadUrl()]).then(service.spread(function (previewUrl, downloadurl) {
|
|
1741
|
-
var serviceUrl = props.edm.preview.serviceUrl;
|
|
1742
|
-
var infoUrl = serviceUrl || previewUrl.replace(/{docId}/, file.docId) + "?".concat(params, "docVersion=").concat(file.docVersion);
|
|
1743
|
-
var pageUrl = serviceUrl || previewUrl.replace(/{docId}/, file.docId) + "?type=doc&pageNum=1&".concat(params, "docVersion=").concat(file.docVersion);
|
|
1744
|
-
var downloadUrl = serviceUrl + downloadurl.replace(/{docId}/, file.docId) + "?docId=".concat(file.docId, "&docVersion=").concat(file.docVersion, "&").concat(downParams, "from=Experience&");
|
|
1107
|
+
const getTokenResolver = ({ reject, api, file, state, resolve, props, constants, service }) => (data) => {
|
|
1108
|
+
if (!data) {
|
|
1109
|
+
const message = "[TINY Error][FileUpload] No edm token";
|
|
1110
|
+
reject(new Error(message));
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
const iframeUrl = api.getPreviewUrlSync(file);
|
|
1114
|
+
if (iframeUrl) {
|
|
1115
|
+
state.showPreview = true;
|
|
1116
|
+
state.iframeUrl = iframeUrl;
|
|
1117
|
+
resolve(state.iframeUrl);
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
const watermark = props.edm.preview.watermark || {};
|
|
1121
|
+
const params = state.fileWater ? constants.EDM.FORMAT : "";
|
|
1122
|
+
const downParams = state.fileWater ? constants.EDM.WATER : constants.EDM.SOURCE;
|
|
1123
|
+
const tools = props.edm.preview.plugin;
|
|
1124
|
+
service.all([service.getPreviewUrl(), service.getSingleDownloadUrl()]).then(
|
|
1125
|
+
service.spread((previewUrl, downloadurl) => {
|
|
1126
|
+
const serviceUrl = props.edm.preview.serviceUrl;
|
|
1127
|
+
const infoUrl = serviceUrl || previewUrl.replace(/{docId}/, file.docId) + `?${params}docVersion=${file.docVersion}`;
|
|
1128
|
+
const pageUrl = serviceUrl || previewUrl.replace(/{docId}/, file.docId) + `?type=doc&pageNum=1&${params}docVersion=${file.docVersion}`;
|
|
1129
|
+
const downloadUrl = serviceUrl + downloadurl.replace(/{docId}/, file.docId) + `?docId=${file.docId}&docVersion=${file.docVersion}&${downParams}from=Experience&`;
|
|
1745
1130
|
tools.setIsEDM3(true);
|
|
1746
1131
|
tools.setDocumentInfoUrl(infoUrl);
|
|
1747
1132
|
tools.setDownloadUrl(downloadUrl, true);
|
|
@@ -1749,237 +1134,220 @@ var getTokenResolver = function getTokenResolver(_ref58) {
|
|
|
1749
1134
|
tools.setWatermarkParameters({
|
|
1750
1135
|
showWatermark: watermark.showWatermark || 1,
|
|
1751
1136
|
rotation: watermark.rotation || 30,
|
|
1752
|
-
text: watermark.text ||
|
|
1137
|
+
text: watermark.text || ""
|
|
1753
1138
|
});
|
|
1754
1139
|
tools.setPdfjsPaht(props.edm.preview.packageName || constants.EDM.JSLIB);
|
|
1755
1140
|
tools.setAuthToken(state.headers[constants.EDM.EDMTOKEN]);
|
|
1756
1141
|
state.showPreview = true;
|
|
1757
|
-
state.iframeUrl = props.edm.preview.previewUrl +
|
|
1142
|
+
state.iframeUrl = props.edm.preview.previewUrl + `${constants.EDM.URLCONTS}${file.docVersion}&docId=${file.docId}`;
|
|
1758
1143
|
resolve(state.iframeUrl);
|
|
1759
|
-
})
|
|
1760
|
-
|
|
1761
|
-
};
|
|
1762
|
-
export var previewFile = function previewFile(_ref59) {
|
|
1763
|
-
var api = _ref59.api,
|
|
1764
|
-
constants = _ref59.constants,
|
|
1765
|
-
props = _ref59.props,
|
|
1766
|
-
service = _ref59.service,
|
|
1767
|
-
state = _ref59.state;
|
|
1768
|
-
return function (file) {
|
|
1769
|
-
return new Promise(function (resolve, reject) {
|
|
1770
|
-
try {
|
|
1771
|
-
var tokenParams = {
|
|
1772
|
-
isOnlinePreview: true,
|
|
1773
|
-
file: file,
|
|
1774
|
-
type: 'preview',
|
|
1775
|
-
token: props.edm.preview.token
|
|
1776
|
-
};
|
|
1777
|
-
var tokenCatcher = function tokenCatcher(e) {
|
|
1778
|
-
reject(new Error(e));
|
|
1779
|
-
};
|
|
1780
|
-
var tokenResolver = getTokenResolver({
|
|
1781
|
-
reject: reject,
|
|
1782
|
-
api: api,
|
|
1783
|
-
file: file,
|
|
1784
|
-
state: state,
|
|
1785
|
-
resolve: resolve,
|
|
1786
|
-
props: props,
|
|
1787
|
-
constants: constants,
|
|
1788
|
-
service: service
|
|
1789
|
-
});
|
|
1790
|
-
api.getToken(tokenParams).then(tokenResolver)["catch"](tokenCatcher);
|
|
1791
|
-
} catch (e) {
|
|
1792
|
-
reject(new Error(e));
|
|
1793
|
-
}
|
|
1794
|
-
});
|
|
1795
|
-
};
|
|
1144
|
+
})
|
|
1145
|
+
);
|
|
1796
1146
|
};
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
})["catch"](function (e) {
|
|
1819
|
-
reject(new Error(e));
|
|
1820
|
-
});
|
|
1821
|
-
});
|
|
1822
|
-
};
|
|
1823
|
-
};
|
|
1824
|
-
export var getPreviewUrlSync = function getPreviewUrlSync(_ref61) {
|
|
1825
|
-
var constants = _ref61.constants,
|
|
1826
|
-
props = _ref61.props,
|
|
1827
|
-
state = _ref61.state;
|
|
1828
|
-
return function (file) {
|
|
1829
|
-
var edm = props.edm || {};
|
|
1830
|
-
var preview = edm.preview || {};
|
|
1831
|
-
var online = preview.online;
|
|
1832
|
-
if (!online) {
|
|
1147
|
+
const previewFile = ({ api, constants, props, service, state }) => (file) => new Promise((resolve, reject) => {
|
|
1148
|
+
try {
|
|
1149
|
+
const tokenParams = { isOnlinePreview: true, file, type: "preview", token: props.edm.preview.token };
|
|
1150
|
+
const tokenCatcher = (e) => {
|
|
1151
|
+
reject(new Error(e));
|
|
1152
|
+
};
|
|
1153
|
+
const tokenResolver = getTokenResolver({ reject, api, file, state, resolve, props, constants, service });
|
|
1154
|
+
api.getToken(tokenParams).then(tokenResolver).catch(tokenCatcher);
|
|
1155
|
+
} catch (e) {
|
|
1156
|
+
reject(new Error(e));
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
const getNewTabPreviewUrl = ({ api, props }) => (file) => new Promise((resolve, reject) => {
|
|
1160
|
+
api.getToken({
|
|
1161
|
+
token: props.edm.preview.token,
|
|
1162
|
+
file,
|
|
1163
|
+
isOnlinePreview: true,
|
|
1164
|
+
type: "preview"
|
|
1165
|
+
}).then((data) => {
|
|
1166
|
+
if (!data) {
|
|
1167
|
+
reject(new Error("[TINY Error][FileUpload] No edm token"));
|
|
1833
1168
|
return;
|
|
1834
1169
|
}
|
|
1835
|
-
|
|
1836
|
-
if (!
|
|
1837
|
-
|
|
1170
|
+
const iframeUrl = api.getPreviewUrlSync(file);
|
|
1171
|
+
if (!iframeUrl) {
|
|
1172
|
+
reject(new Error(new Error("[TINY Error][FileUpload] No preview url")));
|
|
1173
|
+
} else {
|
|
1174
|
+
resolve(iframeUrl);
|
|
1838
1175
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1176
|
+
}).catch((e) => {
|
|
1177
|
+
reject(new Error(e));
|
|
1178
|
+
});
|
|
1179
|
+
});
|
|
1180
|
+
const getPreviewUrlSync = ({ constants, props, state }) => (file) => {
|
|
1181
|
+
const edm = props.edm || {};
|
|
1182
|
+
const preview = edm.preview || {};
|
|
1183
|
+
const online = preview.online;
|
|
1184
|
+
if (!online) {
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
const html = online.jslibhtml.split("?").shift();
|
|
1188
|
+
if (!html) {
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
const watermark = preview.watermark || {};
|
|
1192
|
+
const paramsData = __spreadValues(__spreadValues(__spreadValues({}, online), watermark), {
|
|
1193
|
+
jslibhtml: html,
|
|
1194
|
+
authToken: state.headers[constants.EDM.EDMTOKEN],
|
|
1195
|
+
docId: file.docId,
|
|
1196
|
+
docVersion: file.docVersion || file.version || "V1",
|
|
1197
|
+
type: "doc",
|
|
1198
|
+
pageNum: "1"
|
|
1199
|
+
});
|
|
1200
|
+
const params = [];
|
|
1201
|
+
for (let key in paramsData) {
|
|
1202
|
+
if (Object.prototype.hasOwnProperty.call(paramsData, key)) {
|
|
1203
|
+
params.push(`${key}=${paramsData[key]}`);
|
|
1853
1204
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1205
|
+
}
|
|
1206
|
+
const iframeUrl = html + "?" + params.join("&");
|
|
1207
|
+
return iframeUrl;
|
|
1857
1208
|
};
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
file: file,
|
|
1869
|
-
type: 'preview'
|
|
1870
|
-
}).then(function (data) {
|
|
1871
|
-
if (!data) {
|
|
1872
|
-
reject(new Error('[TINY Error][FileUpload] No edm token'));
|
|
1873
|
-
return;
|
|
1874
|
-
}
|
|
1875
|
-
service.getPreviewUrl().then(function (url) {
|
|
1876
|
-
var imgParam = Object.assign(file, {
|
|
1877
|
-
type: 'image',
|
|
1878
|
-
imageType: 'image'
|
|
1879
|
-
});
|
|
1880
|
-
url = url.replace(/{docId}/, file.docId);
|
|
1881
|
-
service.post(xss.filterUrl(url), imgParam, {
|
|
1882
|
-
withCredentials: props.withCredentials,
|
|
1883
|
-
headers: Object.assign(props.headers, state.headers),
|
|
1884
|
-
responseType: 'blob'
|
|
1885
|
-
}).then(function (data) {
|
|
1886
|
-
var blob = new Blob([data.data]);
|
|
1887
|
-
var URL = window.URL || window.webkitURL;
|
|
1888
|
-
var link = URL.createObjectURL(blob);
|
|
1889
|
-
resolve(link);
|
|
1890
|
-
});
|
|
1891
|
-
});
|
|
1892
|
-
});
|
|
1893
|
-
} catch (e) {
|
|
1894
|
-
reject(new Error(e));
|
|
1209
|
+
const previewImage = ({ api, props, service, state }) => (file) => new Promise((resolve, reject) => {
|
|
1210
|
+
try {
|
|
1211
|
+
api.getToken({
|
|
1212
|
+
token: props.edm.preview.token,
|
|
1213
|
+
file,
|
|
1214
|
+
type: "preview"
|
|
1215
|
+
}).then((data) => {
|
|
1216
|
+
if (!data) {
|
|
1217
|
+
reject(new Error("[TINY Error][FileUpload] No edm token"));
|
|
1218
|
+
return;
|
|
1895
1219
|
}
|
|
1220
|
+
service.getPreviewUrl().then((url) => {
|
|
1221
|
+
const imgParam = Object.assign(file, {
|
|
1222
|
+
type: "image",
|
|
1223
|
+
imageType: "image"
|
|
1224
|
+
});
|
|
1225
|
+
url = url.replace(/{docId}/, file.docId);
|
|
1226
|
+
service.post(xss.filterUrl(url), imgParam, {
|
|
1227
|
+
withCredentials: props.withCredentials,
|
|
1228
|
+
headers: Object.assign(props.headers, state.headers),
|
|
1229
|
+
responseType: "blob"
|
|
1230
|
+
}).then((data2) => {
|
|
1231
|
+
const blob = new Blob([data2.data]);
|
|
1232
|
+
const URL2 = window.URL || window.webkitURL;
|
|
1233
|
+
const link = URL2.createObjectURL(blob);
|
|
1234
|
+
resolve(link);
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1896
1237
|
});
|
|
1238
|
+
} catch (e) {
|
|
1239
|
+
reject(new Error(e));
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
const getDialogConfigObj = ({ props, state }) => () => {
|
|
1243
|
+
const dialogConfigDefault = {
|
|
1244
|
+
class: "single-download-modal single-download-modal1",
|
|
1245
|
+
style: "",
|
|
1246
|
+
props: {
|
|
1247
|
+
lockScroll: true,
|
|
1248
|
+
visible: state.showPreview,
|
|
1249
|
+
dragable: true,
|
|
1250
|
+
title: "\u6587\u6863\u9884\u89C8",
|
|
1251
|
+
width: "60%"
|
|
1252
|
+
},
|
|
1253
|
+
on: {
|
|
1254
|
+
"update:visible": (value) => state.showPreview = value
|
|
1255
|
+
}
|
|
1897
1256
|
};
|
|
1257
|
+
let dialogConfig = {};
|
|
1258
|
+
if (props.edm && props.edm.preview && typeof props.edm.preview.dialogConfig === "object") {
|
|
1259
|
+
dialogConfig = props.edm.preview.dialogConfig || {};
|
|
1260
|
+
}
|
|
1261
|
+
const dialogConfigCopy = extend(true, {}, dialogConfig);
|
|
1262
|
+
const events = dialogConfigCopy.events || {};
|
|
1263
|
+
const clazz = dialogConfigCopy.class || "";
|
|
1264
|
+
const style = dialogConfigCopy.style || "";
|
|
1265
|
+
delete dialogConfigCopy.events;
|
|
1266
|
+
delete dialogConfigCopy.class;
|
|
1267
|
+
delete dialogConfigCopy.style;
|
|
1268
|
+
return extend(true, {}, dialogConfigDefault, {
|
|
1269
|
+
class: `${dialogConfigDefault.class} ${clazz}`,
|
|
1270
|
+
style: `${style}`,
|
|
1271
|
+
props: __spreadValues({}, dialogConfigCopy),
|
|
1272
|
+
on: __spreadValues({}, events)
|
|
1273
|
+
});
|
|
1898
1274
|
};
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
on: {
|
|
1914
|
-
'update:visible': function updateVisible(value) {
|
|
1915
|
-
return state.showPreview = value;
|
|
1916
|
-
}
|
|
1275
|
+
const computeDocChunkSize = ({ props, state, SIZE_2G, SIZE_20M, SIZE_8M }) => () => {
|
|
1276
|
+
const isDefaultChunkSize = !(props.edm && props.edm.chunkSize);
|
|
1277
|
+
let { docSize = SIZE_20M, chunkSize = SIZE_8M } = props.edm || {};
|
|
1278
|
+
docSize = docSize < 0 ? 0 : docSize;
|
|
1279
|
+
docSize = docSize > SIZE_2G ? SIZE_2G : docSize;
|
|
1280
|
+
if (docSize) {
|
|
1281
|
+
chunkSize = chunkSize < 0 ? 0 : chunkSize;
|
|
1282
|
+
}
|
|
1283
|
+
if (!isDefaultChunkSize) {
|
|
1284
|
+
const chunkSizes = [64 * 1024, 32 * 1024, 16 * 1024, 8 * 1024, 4 * 1024, 2 * 1024, 0 * 1024];
|
|
1285
|
+
chunkSizes.some((size) => {
|
|
1286
|
+
if (chunkSize >= size) {
|
|
1287
|
+
chunkSize = Math.max(size, 2 * 1024);
|
|
1288
|
+
return true;
|
|
1917
1289
|
}
|
|
1918
|
-
|
|
1919
|
-
var dialogConfig = {};
|
|
1920
|
-
if (props.edm && props.edm.preview && _typeof(props.edm.preview.dialogConfig) === 'object') {
|
|
1921
|
-
dialogConfig = props.edm.preview.dialogConfig || {};
|
|
1922
|
-
}
|
|
1923
|
-
var dialogConfigCopy = extend(true, {}, dialogConfig);
|
|
1924
|
-
var events = dialogConfigCopy.events || {};
|
|
1925
|
-
var clazz = dialogConfigCopy["class"] || '';
|
|
1926
|
-
var style = dialogConfigCopy.style || '';
|
|
1927
|
-
delete dialogConfigCopy.events;
|
|
1928
|
-
delete dialogConfigCopy["class"];
|
|
1929
|
-
delete dialogConfigCopy.style;
|
|
1930
|
-
return extend(true, {}, dialogConfigDefault, {
|
|
1931
|
-
"class": "".concat(dialogConfigDefault["class"], " ").concat(clazz),
|
|
1932
|
-
style: "".concat(style),
|
|
1933
|
-
props: _objectSpread({}, dialogConfigCopy),
|
|
1934
|
-
on: _objectSpread({}, events)
|
|
1290
|
+
return false;
|
|
1935
1291
|
});
|
|
1936
|
-
}
|
|
1292
|
+
}
|
|
1293
|
+
state.docSize = docSize * 1024;
|
|
1294
|
+
state.chunkSize = chunkSize * 1024;
|
|
1937
1295
|
};
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
var isDefaultChunkSize = !(props.edm && props.edm.chunkSize);
|
|
1946
|
-
var _ref65 = props.edm || {},
|
|
1947
|
-
_ref65$docSize = _ref65.docSize,
|
|
1948
|
-
docSize = _ref65$docSize === void 0 ? SIZE_20M : _ref65$docSize,
|
|
1949
|
-
_ref65$chunkSize = _ref65.chunkSize,
|
|
1950
|
-
chunkSize = _ref65$chunkSize === void 0 ? SIZE_8M : _ref65$chunkSize;
|
|
1951
|
-
docSize = docSize < 0 ? 0 : docSize;
|
|
1952
|
-
docSize = docSize > SIZE_2G ? SIZE_2G : docSize;
|
|
1953
|
-
if (docSize) {
|
|
1954
|
-
chunkSize = chunkSize < 0 ? 0 : chunkSize;
|
|
1955
|
-
}
|
|
1956
|
-
if (!isDefaultChunkSize) {
|
|
1957
|
-
var chunkSizes = [64 * 1024, 32 * 1024, 16 * 1024, 8 * 1024, 4 * 1024, 2 * 1024, 0 * 1024];
|
|
1958
|
-
chunkSizes.some(function (size) {
|
|
1959
|
-
if (chunkSize >= size) {
|
|
1960
|
-
chunkSize = Math.max(size, 2 * 1024);
|
|
1961
|
-
return true;
|
|
1962
|
-
}
|
|
1963
|
-
return false;
|
|
1964
|
-
});
|
|
1296
|
+
const updateFile = ({ constants, refs }) => (file) => {
|
|
1297
|
+
refs[constants.UPLOAD_INNER].handleUpdate(file);
|
|
1298
|
+
};
|
|
1299
|
+
const onBeforeDestroy = (state) => () => {
|
|
1300
|
+
state.uploadFiles.forEach((file) => {
|
|
1301
|
+
if (file.url && file.url.indexOf("blob:") === 0) {
|
|
1302
|
+
URL.revokeObjectURL(file.url);
|
|
1965
1303
|
}
|
|
1966
|
-
|
|
1967
|
-
state.chunkSize = chunkSize * 1024;
|
|
1968
|
-
};
|
|
1304
|
+
});
|
|
1969
1305
|
};
|
|
1970
|
-
export
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1306
|
+
export {
|
|
1307
|
+
abort,
|
|
1308
|
+
addFileToList,
|
|
1309
|
+
afterDownload,
|
|
1310
|
+
batchSegmentDownload,
|
|
1311
|
+
batchSegmentUpload,
|
|
1312
|
+
beforeUpload,
|
|
1313
|
+
calcUploadingFilesInfo,
|
|
1314
|
+
clearFiles,
|
|
1315
|
+
clearUploadingFiles,
|
|
1316
|
+
computeDocChunkSize,
|
|
1317
|
+
computedUploadDisabled,
|
|
1318
|
+
computedUploadingSize,
|
|
1319
|
+
downloadFile,
|
|
1320
|
+
downloadFileInner,
|
|
1321
|
+
getDialogConfigObj,
|
|
1322
|
+
getDownloadFileInfo,
|
|
1323
|
+
getFile,
|
|
1324
|
+
getFileUploadUrl,
|
|
1325
|
+
getFormData,
|
|
1326
|
+
getNewTabPreviewUrl,
|
|
1327
|
+
getPreviewUrlSync,
|
|
1328
|
+
getToken,
|
|
1329
|
+
handleClick,
|
|
1330
|
+
handleError,
|
|
1331
|
+
handleProgress,
|
|
1332
|
+
handleRemove,
|
|
1333
|
+
handleStart,
|
|
1334
|
+
handleSuccess,
|
|
1335
|
+
initService,
|
|
1336
|
+
largeDocumentDownload,
|
|
1337
|
+
largeDocumentUpload,
|
|
1338
|
+
onBeforeDestroy,
|
|
1339
|
+
previewFile,
|
|
1340
|
+
previewImage,
|
|
1341
|
+
properFileSize,
|
|
1342
|
+
segmentUpload,
|
|
1343
|
+
segmentUploadInit,
|
|
1344
|
+
setWriterFile,
|
|
1345
|
+
sliceChunk,
|
|
1346
|
+
sliceDownloadChunk,
|
|
1347
|
+
startUpload,
|
|
1348
|
+
submit,
|
|
1349
|
+
updateFile,
|
|
1350
|
+
updateUrl,
|
|
1351
|
+
watchFileList,
|
|
1352
|
+
watchListType
|
|
1976
1353
|
};
|
|
1977
|
-
export var onBeforeDestroy = function onBeforeDestroy(state) {
|
|
1978
|
-
return function () {
|
|
1979
|
-
state.uploadFiles.forEach(function (file) {
|
|
1980
|
-
if (file.url && file.url.indexOf('blob:') === 0) {
|
|
1981
|
-
URL.revokeObjectURL(file.url);
|
|
1982
|
-
}
|
|
1983
|
-
});
|
|
1984
|
-
};
|
|
1985
|
-
};
|