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