@opentiny/vue-renderless 3.6.8 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/index.js +28 -1
- package/action-sheet/vue.js +10 -4
- package/alert/index.js +24 -2
- package/alert/vue.js +15 -11
- package/amount/index.js +4 -4
- package/anchor/index.js +1 -1
- package/autocomplete/vue.js +3 -3
- package/autonavi-map/index.js +1 -1
- package/badge/vue.js +6 -6
- package/baidu-map/index.js +1 -1
- package/bulletin-board/index.js +1 -1
- package/button-group/vue.js +5 -4
- package/calendar/index.js +2 -2
- package/calendar-bar/index.js +268 -0
- package/calendar-bar/vue.js +87 -0
- package/card/index.js +84 -0
- package/card/vue.js +70 -0
- package/card-group/index.js +16 -0
- package/card-group/vue.js +21 -0
- package/card-template/index.js +1 -1
- package/carousel/index.js +89 -2
- package/carousel/vue.js +14 -5
- package/carousel-item/index.js +8 -0
- package/carousel-item/vue.js +7 -3
- package/cascader/index.js +6 -6
- package/cascader/vue.js +3 -3
- package/cascader-menu/vue.js +2 -2
- package/cascader-panel/index.js +4 -4
- package/cascader-panel/node.js +4 -4
- package/cascader-panel/vue.js +2 -2
- package/cascader-select/index.js +179 -0
- package/cascader-select/vue.js +74 -0
- package/cell/vue.js +16 -0
- package/chart-bar/index.js +3 -3
- package/chart-boxplot/index.js +2 -2
- package/chart-candle/index.js +3 -3
- package/chart-core/deps/utils.js +7 -7
- package/chart-core/index.js +2 -2
- package/chart-funnel/index.js +3 -3
- package/chart-gauge/index.js +3 -3
- package/chart-graph/index.js +1 -1
- package/chart-heatmap/index.js +2 -2
- package/chart-line/index.js +3 -3
- package/chart-liquidfill/index.js +2 -2
- package/chart-map/index.js +3 -3
- package/chart-pie/index.js +3 -3
- package/chart-radar/index.js +3 -3
- package/chart-sankey/index.js +3 -3
- package/chart-scatter/index.js +4 -4
- package/chart-sunburst/index.js +1 -1
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +3 -3
- package/chart-wordcloud/index.js +2 -2
- package/checkbox/index.js +21 -0
- package/checkbox/vue.js +16 -3
- package/checkbox-button/vue.js +1 -1
- package/collapse-item/vue.js +1 -1
- package/column-list-group/index.js +0 -0
- package/column-list-group/vue.js +14 -0
- package/column-list-item/index.js +50 -0
- package/column-list-item/vue.js +39 -0
- package/common/array.js +3 -3
- package/common/bigInt.js +5 -2
- package/common/dataset/index.js +3 -3
- package/common/date.js +2 -2
- package/common/deps/ResizeObserver.js +1 -1
- package/common/deps/clickoutside.js +1 -1
- package/common/deps/date-util.js +4 -4
- package/common/deps/date.js +2 -2
- package/common/deps/debounce.js +1 -1
- package/common/deps/dom.js +1 -1
- package/common/deps/fullscreen/apis.js +3 -3
- package/common/deps/fullscreen/screenfull.js +1 -1
- package/common/deps/infinite-scroll.js +176 -0
- package/common/deps/letter-only.js +1 -1
- package/common/deps/number-only.js +1 -1
- package/common/deps/observe-visibility.js +106 -0
- package/common/deps/popper.js +20 -22
- package/common/deps/popup-manager.js +2 -2
- package/common/deps/repeat-click.js +1 -1
- package/common/deps/resize-event.js +1 -1
- package/common/deps/tree-model/node.js +5 -5
- package/common/deps/tree-model/tree-store.js +3 -3
- package/common/deps/upload-ajax.js +2 -2
- package/common/deps/vue-popper.js +6 -6
- package/common/deps/vue-popup.js +4 -4
- package/common/index.js +2 -2
- package/common/object.js +1 -1
- package/common/runtime.js +24 -24
- package/common/string.js +23 -4
- package/common/validate/rules/range.js +2 -2
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +3 -3
- package/common/validate/schema.js +1 -1
- package/common/validate/util.js +1 -1
- package/common/validate/validations/array.js +1 -1
- package/common/validate/validations/date.js +1 -1
- package/common/validate/validations/enum.js +1 -1
- package/common/validate/validations/float.js +1 -1
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/common/validate/validations/number.js +1 -1
- package/common/validate/validations/pattern.js +1 -1
- package/common/validate/validations/string.js +1 -1
- package/common/validate/validations/type.js +1 -1
- package/container/index.js +1 -1
- package/crop/index.js +2 -2
- package/currency/index.js +2 -2
- package/date-panel/index.js +7 -7
- package/date-panel/vue.js +3 -2
- package/date-picker-mobile/index.js +250 -0
- package/date-picker-mobile/vue.js +86 -0
- package/date-range/index.js +1 -1
- package/date-range/vue.js +1 -1
- package/date-table/index.js +3 -3
- package/date-table/vue.js +1 -1
- package/dialog-box/index.js +6 -4
- package/dialog-box/vue.js +1 -1
- package/dialog-select/index.js +345 -0
- package/dialog-select/vue.js +110 -0
- package/drawer/index.js +83 -0
- package/drawer/vue.js +51 -0
- package/drop-times/index.js +1 -1
- package/dropdown/index.js +2 -2
- package/dropdown/vue.js +4 -3
- package/dropdown-item/index.js +5 -1
- package/dropdown-item/mf.js +79 -0
- package/dropdown-item/vue.js +9 -6
- package/dropdown-menu/index.js +30 -1
- package/dropdown-menu/vue.js +17 -7
- package/dynamic-scroller/index.js +117 -0
- package/dynamic-scroller/vue.js +88 -0
- package/dynamic-scroller-item/index.js +147 -0
- package/dynamic-scroller-item/vue.js +92 -0
- package/espace/index.js +1 -1
- package/espace/vue.js +1 -1
- package/exception/vue.js +3 -1
- package/fall-menu/index.js +4 -4
- package/file-upload/index.js +872 -408
- package/file-upload/vue.js +87 -36
- package/filter/index.js +131 -0
- package/filter/tag-group.js +43 -0
- package/filter/vue.js +73 -0
- package/filter-bar/index.js +9 -0
- package/filter-bar/vue.js +16 -0
- package/filter-box/index.js +17 -0
- package/filter-box/vue.js +19 -0
- package/filter-panel/index.js +42 -0
- package/filter-panel/vue.js +33 -0
- package/floatbar/index.js +1 -1
- package/flowchart/index.js +721 -0
- package/flowchart/vue.js +81 -0
- package/form/index.js +15 -1
- package/form/vue.js +10 -4
- package/form-item/index.js +46 -6
- package/form-item/vue.js +27 -3
- package/fullscreen/index.js +1 -1
- package/fullscreen/vue.js +1 -1
- package/grid/plugins/export.js +2 -2
- package/grid/plugins/exportExcel.js +2 -2
- package/grid/plugins/resize.js +1 -1
- package/grid/static/base/helperEqualCompare.js +1 -1
- package/grid/static/base/isPlainObject.js +1 -1
- package/grid/utils/common.js +3 -3
- package/grid/utils/dom.js +3 -3
- package/grid/utils/event.js +2 -2
- package/guide/index.js +168 -0
- package/guide/vue.js +36 -0
- package/hrapprover/index.js +1 -1
- package/image/index.js +8 -4
- package/image/vue.js +12 -6
- package/image-viewer/index.js +3 -3
- package/image-viewer/vue.js +16 -6
- package/input/index.js +34 -1
- package/input/vue.js +22 -6
- package/ip-address/index.js +1 -1
- package/ip-address/vue.js +1 -1
- package/link-menu/index.js +2 -2
- package/link-menu/vue.js +2 -2
- package/loading/index.js +2 -2
- package/loading/vue.js +2 -1
- package/locales/index.js +1 -1
- package/logout/index.js +1 -1
- package/milestone/index.js +5 -1
- package/modal/index.js +68 -39
- package/modal/vue.js +15 -12
- package/month-range/index.js +1 -1
- package/month-range/vue.js +1 -1
- package/month-table/index.js +5 -5
- package/month-table/vue.js +1 -1
- package/multi-select/index.js +5 -2
- package/multi-select/vue.js +4 -5
- package/nav-menu/index.js +6 -6
- package/notify/index.js +3 -3
- package/numeric/index.js +15 -5
- package/numeric/vue.js +15 -6
- package/option/index.js +1 -1
- package/package.json +2 -1
- package/pager/vue.js +10 -0
- package/pager-item/index.js +1 -1
- package/panel/index.js +1 -1
- package/picker/index.js +7 -7
- package/picker/vue.js +1 -1
- package/picker-column/index.js +1 -1
- package/popconfirm/index.js +25 -0
- package/popconfirm/vue.js +22 -0
- package/popeditor/index.js +7 -7
- package/popeditor/vue.js +2 -2
- package/popover/index.js +11 -3
- package/popover/vue.js +33 -10
- package/popup/index.js +4 -4
- package/pull-refresh/index.js +8 -11
- package/pull-refresh/vue.js +7 -7
- package/radio/index.js +17 -0
- package/radio/vue.js +18 -3
- package/radio-button/index.js +8 -0
- package/radio-button/vue.js +19 -4
- package/radio-group/index.js +1 -1
- package/radio-group/vue.js +5 -2
- package/rate/index.js +4 -2
- package/rate/vue.js +1 -1
- package/record/index.js +190 -0
- package/record/vue.js +44 -0
- package/recycle-scroller/index.js +470 -0
- package/recycle-scroller/vue.js +135 -0
- package/river/index.js +371 -0
- package/river/river.js +352 -0
- package/river/vue.js +77 -0
- package/roles/index.js +1 -1
- package/scrollbar/vue-bar.js +1 -1
- package/scrollbar/vue.js +1 -1
- package/search/index.js +3 -3
- package/select/index.js +21 -14
- package/select/vue.js +38 -15
- package/select-dropdown/vue.js +1 -1
- package/select-mobile/index.js +111 -0
- package/select-mobile/vue.js +58 -0
- package/select-view/index.js +170 -0
- package/select-view/vue.js +82 -0
- package/selected-box/index.js +216 -0
- package/selected-box/vue.js +98 -0
- package/slide-bar/index.js +1 -1
- package/slider/index.js +49 -4
- package/slider/vue.js +15 -4
- package/split/vue.js +1 -1
- package/standard-list-item/index.js +18 -0
- package/standard-list-item/vue.js +22 -0
- package/steps/index.js +30 -0
- package/steps/slide-bar.js +122 -0
- package/steps/vue.js +15 -3
- package/switch/index.js +1 -1
- package/switch/vue.js +2 -1
- package/tab-bar/index.js +2 -2
- package/tab-item/index.js +3 -3
- package/tab-item/vue.js +4 -3
- package/tab-item-mf/index.js +0 -0
- package/tab-item-mf/vue.js +16 -0
- package/tab-nav/index.js +78 -4
- package/tab-nav/vue.js +11 -3
- package/tabbar-item/index.js +1 -1
- package/tabbar-item/vue.js +1 -1
- package/tabs/index.js +8 -9
- package/tabs/vue.js +1 -1
- package/tabs-mf/index.js +109 -0
- package/tabs-mf/vue-bar.js +49 -0
- package/tabs-mf/vue-nav-item.js +22 -0
- package/tabs-mf/vue-nav.js +13 -0
- package/tabs-mf/vue.js +45 -0
- package/tabs-mf/wheel.js +71 -0
- package/tag/index.js +8 -2
- package/tag/vue.js +13 -5
- package/tag-group/index.js +24 -0
- package/tag-group/vue.js +29 -0
- package/tall-storage/index.js +1 -1
- package/tall-storage/vue.js +1 -1
- package/time/index.js +1 -1
- package/time/vue.js +2 -2
- package/time-line/index.js +28 -7
- package/time-line/vue.js +9 -4
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +1 -1
- package/time-picker-mobile/index.js +30 -0
- package/time-picker-mobile/vue.js +30 -0
- package/time-range/index.js +1 -1
- package/time-range/vue.js +1 -1
- package/time-spinner/index.js +2 -2
- package/time-spinner/vue.js +1 -1
- package/toggle-menu/index.js +2 -2
- package/toggle-menu/vue.js +1 -1
- package/tooltip/index.js +30 -3
- package/tooltip/vue.js +34 -13
- package/top-box/index.js +3 -3
- package/transfer/index.js +1 -1
- package/transfer-panel/index.js +2 -2
- package/tree/index.js +6 -6
- package/tree/vue.js +1 -1
- package/tree-node/index.js +1 -1
- package/upload/index.js +1 -1
- package/upload/vue.js +2 -2
- package/upload-dragger/index.js +5 -1
- package/upload-dragger/vue.js +9 -3
- package/upload-list/index.js +158 -8
- package/upload-list/vue.js +77 -25
- package/user/index.js +86 -70
- package/user/vue.js +15 -5
- package/user-account/vue.js +1 -1
- package/user-contact/index.js +49 -3
- package/user-contact/vue.js +17 -8
- package/user-head-group/vue.js +17 -0
- package/user-link/index.js +10 -2
- package/user-link/vue.js +11 -6
- package/wheel/index.js +1 -1
- package/wizard/index.js +3 -3
- package/year-range/index.js +125 -0
- package/year-range/vue.js +88 -0
- package/year-table/index.js +175 -11
- package/year-table/vue.js +17 -5
package/file-upload/index.js
CHANGED
|
@@ -1,64 +1,91 @@
|
|
|
1
1
|
import {
|
|
2
|
+
__spreadProps,
|
|
2
3
|
__spreadValues
|
|
3
4
|
} from "../chunk-PKUHTIDK.js";
|
|
4
|
-
import { extend } from "
|
|
5
|
-
import { xss, log } from "
|
|
6
|
-
import uploadAjax from "
|
|
5
|
+
import { extend } from "../common/object";
|
|
6
|
+
import { xss, log } from "../common/xss";
|
|
7
|
+
import uploadAjax from "../common/deps/upload-ajax";
|
|
8
|
+
import { isObject } from "../common/type";
|
|
9
|
+
import { isEmptyObject } from "../common/type";
|
|
7
10
|
let initTokenPromise = null;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
const initService = ({ props, service }) => {
|
|
12
|
-
const noopFnCreator = (propName) => () => {
|
|
11
|
+
const noopFnCreator = (fn, propName) => {
|
|
12
|
+
const noFn = () => {
|
|
13
13
|
if (propName) {
|
|
14
14
|
return Promise.reject(new Error(`[TINY Error][FileUpload] Prop ${propName} is not configured`));
|
|
15
15
|
} else {
|
|
16
|
-
return Promise.reject(
|
|
16
|
+
return Promise.reject(
|
|
17
|
+
new Error(
|
|
18
|
+
"[TINY Error][FileUpload] This component depends on @opentiny/vue-service, Currently unable to generate a default gateway, please set a value for the action"
|
|
19
|
+
)
|
|
20
|
+
);
|
|
17
21
|
}
|
|
18
22
|
};
|
|
23
|
+
return fn || noFn;
|
|
24
|
+
};
|
|
25
|
+
const initService = ({ props, service }) => {
|
|
19
26
|
const { network = {}, common = {} } = service || {};
|
|
20
27
|
const { request, get, post, all, spread, CancelToken = {} } = network;
|
|
21
|
-
|
|
28
|
+
let requestFn;
|
|
29
|
+
if (!isEmptyObject(props.hwh5)) {
|
|
30
|
+
const { HWH5 } = props.hwh5;
|
|
31
|
+
const { uploadToEDM } = HWH5();
|
|
32
|
+
requestFn = props.httpRequest || uploadToEDM;
|
|
33
|
+
} else if (request) {
|
|
34
|
+
requestFn = props.httpRequest || request;
|
|
35
|
+
} else {
|
|
36
|
+
requestFn = props.httpRequest || uploadAjax;
|
|
37
|
+
}
|
|
22
38
|
return {
|
|
23
|
-
get: get
|
|
24
|
-
post: post
|
|
25
|
-
request: request
|
|
26
|
-
all: all
|
|
27
|
-
spread: spread
|
|
28
|
-
cancelToken: CancelToken.source
|
|
29
|
-
getSingleUploadUrl: common.getSingleUploadUrl
|
|
30
|
-
getFileUploadUrl: common.getFileUploadUrl
|
|
31
|
-
getFileDownloadUrl: common.getFileDownloadUrl
|
|
32
|
-
getSingleDownloadUrl: common.getSingleDownloadUrl
|
|
33
|
-
getPackageDownloadUrl: common.getPackageDownloadUrl
|
|
34
|
-
getLargeFileInitUrl: common.getLargeFileInitUrl
|
|
35
|
-
getChunkUploadUrl: common.getChunkUploadUrl
|
|
36
|
-
getPreviewUrl: common.getPreviewUrl
|
|
37
|
-
getDocumentInfoUrl: common.getDocumentInfoUrl
|
|
38
|
-
|
|
39
|
+
get: noopFnCreator(get),
|
|
40
|
+
post: noopFnCreator(post),
|
|
41
|
+
request: noopFnCreator(request),
|
|
42
|
+
all: noopFnCreator(all),
|
|
43
|
+
spread: noopFnCreator(spread),
|
|
44
|
+
cancelToken: noopFnCreator(CancelToken.source),
|
|
45
|
+
getSingleUploadUrl: noopFnCreator(common.getSingleUploadUrl),
|
|
46
|
+
getFileUploadUrl: noopFnCreator(common.getFileUploadUrl),
|
|
47
|
+
getFileDownloadUrl: noopFnCreator(common.getFileDownloadUrl),
|
|
48
|
+
getSingleDownloadUrl: noopFnCreator(common.getSingleDownloadUrl),
|
|
49
|
+
getPackageDownloadUrl: noopFnCreator(common.getPackageDownloadUrl),
|
|
50
|
+
getLargeFileInitUrl: noopFnCreator(common.getLargeFileInitUrl),
|
|
51
|
+
getChunkUploadUrl: noopFnCreator(common.getChunkUploadUrl),
|
|
52
|
+
getPreviewUrl: noopFnCreator(common.getPreviewUrl),
|
|
53
|
+
getDocumentInfoUrl: noopFnCreator(common.getDocumentInfoUrl),
|
|
54
|
+
getPreviewUrlBatch: noopFnCreator(common.getPreviewUrlBatch),
|
|
55
|
+
httpRequest: noopFnCreator(requestFn, "httpRequest")
|
|
39
56
|
};
|
|
40
57
|
};
|
|
41
58
|
const computedUploadDisabled = ({ props, state }) => () => props.disabled || (state.elForm || {}).disabled;
|
|
42
|
-
const computedUploadingSize = (state) => () => state.uploadingFiles.reduce((total, file) => total + file.size, 0);
|
|
59
|
+
const computedUploadingSize = ({ state, constants }) => () => state.uploadingFiles.reduce((total, file) => total + file.status !== constants.FILE_STATUS.FAIL ? file.size : 0, 0);
|
|
43
60
|
const watchListType = ({ constants, state }) => (type) => {
|
|
44
|
-
if (
|
|
61
|
+
if ([
|
|
62
|
+
constants.LIST_TYPE.PICTURE_CARD,
|
|
63
|
+
constants.LIST_TYPE.PICTURE,
|
|
64
|
+
constants.LIST_TYPE.PICTURE_SINGLE,
|
|
65
|
+
constants.LIST_TYPE.DRAG_SINGLE
|
|
66
|
+
].includes(type)) {
|
|
45
67
|
state.uploadFiles = state.uploadFiles.map((file) => {
|
|
46
68
|
if (!file.url && file.raw) {
|
|
47
69
|
try {
|
|
48
70
|
file.url = URL.createObjectURL(file.raw);
|
|
49
71
|
} catch (err) {
|
|
72
|
+
return;
|
|
50
73
|
}
|
|
51
74
|
}
|
|
52
75
|
return file;
|
|
53
76
|
});
|
|
54
77
|
}
|
|
55
78
|
};
|
|
56
|
-
const watchFileList = ({ constants, state }) => (fileList) => {
|
|
57
|
-
|
|
79
|
+
const watchFileList = ({ constants, state, props }) => (fileList) => {
|
|
80
|
+
let uploadFiles = fileList && fileList.map((item) => {
|
|
58
81
|
item.uid = item.uid || Date.now() + state.tempIndex++;
|
|
59
82
|
item.status = item.status || constants.FILE_STATUS.SUCESS;
|
|
60
83
|
return item;
|
|
61
84
|
});
|
|
85
|
+
if ([constants.LIST_TYPE.PICTURE_SINGLE, constants.LIST_TYPE.DRAG_SINGLE].includes(props.listType)) {
|
|
86
|
+
uploadFiles = uploadFiles.slice(0, 1);
|
|
87
|
+
}
|
|
88
|
+
state.uploadFiles = uploadFiles;
|
|
62
89
|
};
|
|
63
90
|
const isNonFuncPropBeforeUpload = ({ flag, doUpload, file }) => !flag && doUpload(file);
|
|
64
91
|
const onBeforeIsPromise = ({ before, rawFile, file, doUpload, autoRemove, api }) => {
|
|
@@ -70,9 +97,7 @@ const onBeforeIsPromise = ({ before, rawFile, file, doUpload, autoRemove, api })
|
|
|
70
97
|
processedFile = new File([processedFile], rawFile.name, { type: rawFile.type });
|
|
71
98
|
}
|
|
72
99
|
for (const p in rawFile) {
|
|
73
|
-
|
|
74
|
-
processedFile[p] = rawFile[p];
|
|
75
|
-
}
|
|
100
|
+
Object.prototype.hasOwnProperty.call(rawFile, p) && (processedFile[p] = rawFile[p]);
|
|
76
101
|
}
|
|
77
102
|
file.raw = processedFile;
|
|
78
103
|
}
|
|
@@ -89,21 +114,42 @@ const onBeforeIsPromise = ({ before, rawFile, file, doUpload, autoRemove, api })
|
|
|
89
114
|
}
|
|
90
115
|
);
|
|
91
116
|
};
|
|
117
|
+
const getFileType = ({ file }) => file.name && file.name.split(".")[file.name.split(".").length - 1].toLowerCase();
|
|
118
|
+
const remove = ({ api, file, autoRemove }) => {
|
|
119
|
+
if (autoRemove) {
|
|
120
|
+
const rawFile = file.raw;
|
|
121
|
+
if (Array.isArray(rawFile)) {
|
|
122
|
+
rawFile.forEach((raw) => api.handleRemove(null, raw));
|
|
123
|
+
} else {
|
|
124
|
+
api.handleRemove(null, rawFile);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
92
128
|
const beforeUpload = ({ props, api, Modal, constants, t, state }) => (file, autoRemove, doUpload) => {
|
|
93
129
|
if (state.isEdm && file.name.length > 255) {
|
|
94
|
-
|
|
95
|
-
const rawFile = file.raw;
|
|
96
|
-
if (Array.isArray(rawFile)) {
|
|
97
|
-
rawFile.forEach((raw) => api.handleRemove(null, raw));
|
|
98
|
-
} else {
|
|
99
|
-
api.handleRemove(null, rawFile);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
130
|
+
remove({ api, file, autoRemove });
|
|
102
131
|
return Modal.message({
|
|
103
132
|
message: `${t(constants.EDM.THEFILENAME)}"${file.name}"${t(constants.EDM.FILENAMEEXCEEDS)}`,
|
|
104
133
|
status: "warning"
|
|
105
134
|
});
|
|
106
135
|
}
|
|
136
|
+
if (file) {
|
|
137
|
+
const accept = state.isEdm ? state.accept : props.accept;
|
|
138
|
+
const fileType = getFileType({ file });
|
|
139
|
+
const isExist = accept && accept.split(",").some((type) => {
|
|
140
|
+
if (type.toLowerCase() === constants.IMAGE_TYPE) {
|
|
141
|
+
return constants.IMAGE_TYPES.includes(fileType.toLowerCase());
|
|
142
|
+
}
|
|
143
|
+
return new RegExp(type.trim(), "i").test(`.${fileType}` || file.raw.type);
|
|
144
|
+
});
|
|
145
|
+
if (accept && !isExist) {
|
|
146
|
+
remove({ api, file, autoRemove });
|
|
147
|
+
return Modal.message({
|
|
148
|
+
message: t("ui.fileUpload.notSupport"),
|
|
149
|
+
status: "warning"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
107
153
|
let flag = typeof props.beforeUpload === "function";
|
|
108
154
|
isNonFuncPropBeforeUpload({ flag, doUpload, file });
|
|
109
155
|
if (flag) {
|
|
@@ -123,7 +169,11 @@ const beforeUpload = ({ props, api, Modal, constants, t, state }) => (file, auto
|
|
|
123
169
|
}
|
|
124
170
|
}
|
|
125
171
|
};
|
|
126
|
-
const startUpload = ({ state, constants,
|
|
172
|
+
const startUpload = ({ state, constants, vm, Modal, api, t }) => (file, isList) => {
|
|
173
|
+
if (state.isHwh5) {
|
|
174
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
127
177
|
if (file.size > state.docSize && file.size > state.chunkSize) {
|
|
128
178
|
file.isLargeFile = true;
|
|
129
179
|
isList && state.uploadFiles.forEach((f) => {
|
|
@@ -137,7 +187,7 @@ const startUpload = ({ state, constants, refs, Modal, api, t }) => (file, isList
|
|
|
137
187
|
status: "warning"
|
|
138
188
|
});
|
|
139
189
|
} else {
|
|
140
|
-
refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
190
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw);
|
|
141
191
|
}
|
|
142
192
|
};
|
|
143
193
|
const calcFileForMobile = (rawFile, file) => {
|
|
@@ -153,18 +203,22 @@ const calcFileForMobile = (rawFile, file) => {
|
|
|
153
203
|
}
|
|
154
204
|
};
|
|
155
205
|
const properFileSize = ({ props, state, constants, Modal, t }) => (file) => {
|
|
206
|
+
if ([void 0, null].includes(file.size))
|
|
207
|
+
return true;
|
|
156
208
|
let maxSize = 0;
|
|
157
209
|
if (Array.isArray(props.fileSize) && props.fileSize[1]) {
|
|
158
210
|
maxSize = Math.min(state.singleMaxSize, props.fileSize[1] / 1024).toFixed(2);
|
|
159
211
|
} else {
|
|
160
212
|
maxSize = Math.min(state.singleMaxSize);
|
|
161
213
|
}
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
message
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
214
|
+
if (state.isEdm || !state.isEdm && Array.isArray(props.fileSize) && props.fileSize[1]) {
|
|
215
|
+
if (file.size > maxSize * 1024 * 1024) {
|
|
216
|
+
Modal.message({
|
|
217
|
+
message: `${file.name} ${t(constants.EDM.EXCEED)} ${maxSize} MB`,
|
|
218
|
+
status: "warning"
|
|
219
|
+
});
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
168
222
|
}
|
|
169
223
|
if (file.size <= 0) {
|
|
170
224
|
Modal.message({
|
|
@@ -183,8 +237,8 @@ const properFileSize = ({ props, state, constants, Modal, t }) => (file) => {
|
|
|
183
237
|
}
|
|
184
238
|
return true;
|
|
185
239
|
};
|
|
186
|
-
const addFileToList = ({ api, constants, emit, props, state, mode }) => (rawFile, updateId) => {
|
|
187
|
-
rawFile.uid = Date.now() + state.tempIndex
|
|
240
|
+
const addFileToList = ({ api, constants, emit, props, state, mode }) => (rawFile, updateId, reUpload) => {
|
|
241
|
+
!reUpload && (rawFile.uid = Date.now() + state.tempIndex++);
|
|
188
242
|
let file = { status: constants.FILE_STATUS.READY, name: rawFile.name, size: rawFile.size };
|
|
189
243
|
Object.assign(file, { percentage: 0, uid: rawFile.uid, raw: rawFile, response: {} });
|
|
190
244
|
if (state.isEdm) {
|
|
@@ -194,9 +248,18 @@ const addFileToList = ({ api, constants, emit, props, state, mode }) => (rawFile
|
|
|
194
248
|
}
|
|
195
249
|
state.cacheDocuments[file.uid] = file;
|
|
196
250
|
mode === "mobile" && calcFileForMobile(rawFile, file);
|
|
197
|
-
if (
|
|
251
|
+
if ([
|
|
252
|
+
constants.LIST_TYPE.PICTURE_CARD,
|
|
253
|
+
constants.LIST_TYPE.PICTURE,
|
|
254
|
+
constants.LIST_TYPE.PICTURE_SINGLE,
|
|
255
|
+
constants.LIST_TYPE.DRAG_SINGLE
|
|
256
|
+
].includes(props.listType) && !state.isHwh5) {
|
|
198
257
|
try {
|
|
199
|
-
|
|
258
|
+
if (state.isHwh5) {
|
|
259
|
+
file.url = rawFile.filePath;
|
|
260
|
+
} else {
|
|
261
|
+
file.url = URL.createObjectURL(rawFile);
|
|
262
|
+
}
|
|
200
263
|
} catch (err) {
|
|
201
264
|
return;
|
|
202
265
|
}
|
|
@@ -207,60 +270,120 @@ const addFileToList = ({ api, constants, emit, props, state, mode }) => (rawFile
|
|
|
207
270
|
return;
|
|
208
271
|
}
|
|
209
272
|
state.updateId = updateId || props.edm.updateId || "";
|
|
210
|
-
if (
|
|
273
|
+
if (reUpload) {
|
|
274
|
+
const index = state.uploadFiles.findIndex((item) => item.uid === file.uid);
|
|
275
|
+
state.uploadFiles.splice(index, 1);
|
|
276
|
+
} else if (state.updateId) {
|
|
211
277
|
const index = state.uploadFiles.findIndex((item) => item.docId === updateId);
|
|
212
278
|
state.uploadFiles.splice(index, 1, file);
|
|
213
279
|
emit("change", file, state.uploadFiles);
|
|
214
280
|
return;
|
|
215
281
|
}
|
|
216
282
|
}
|
|
283
|
+
if (!state.isEdm) {
|
|
284
|
+
const proper = api.properFileSize(file);
|
|
285
|
+
if (!proper) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
217
289
|
state.uploadFiles.push(file);
|
|
218
290
|
state.currentUploadingFileUids.push(file.uid);
|
|
219
291
|
emit("change", file, state.uploadFiles);
|
|
220
292
|
};
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
293
|
+
const getFileHash = ({ emit, Modal, constants, t, CryptoJS, state }) => ({ file, chunkSize, showTips }) => {
|
|
294
|
+
if (showTips) {
|
|
295
|
+
Modal.message({
|
|
296
|
+
message: `${t(constants.EDM.CALCHASH)}`,
|
|
297
|
+
status: "warning"
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
const chunks = Math.ceil(file.size / chunkSize);
|
|
301
|
+
let chunkIndex = 0;
|
|
302
|
+
let start = chunkIndex * chunkSize;
|
|
303
|
+
let end = Math.min(file.size, start + chunkSize);
|
|
304
|
+
let chunk = file.raw.slice(start, end);
|
|
305
|
+
const hasher = CryptoJS.algo.SHA256.create();
|
|
306
|
+
let calculated = 0;
|
|
307
|
+
return new Promise((resolve) => {
|
|
308
|
+
const reader = new FileReader();
|
|
309
|
+
reader.readAsArrayBuffer(chunk);
|
|
310
|
+
reader.onload = (e) => {
|
|
311
|
+
if (file.status === constants.FILE_STATUS.FAIL)
|
|
312
|
+
return;
|
|
313
|
+
chunkIndex++;
|
|
314
|
+
let wordArray = CryptoJS.lib.WordArray.create(e.target.result);
|
|
315
|
+
hasher.update(wordArray);
|
|
316
|
+
wordArray = null;
|
|
317
|
+
if (chunkIndex < chunks) {
|
|
318
|
+
start = chunkIndex * chunkSize;
|
|
319
|
+
end = Math.min(file.size, start + chunkSize);
|
|
320
|
+
calculated += end - start;
|
|
321
|
+
emit("hash-progress", Math.min(Math.floor(calculated / file.size * 100), 100));
|
|
322
|
+
chunk = file.raw.slice(start, end);
|
|
323
|
+
reader.readAsArrayBuffer(chunk);
|
|
324
|
+
} else {
|
|
325
|
+
const hash = hasher.finalize().toString();
|
|
326
|
+
file.hash = file.raw.hash = hash;
|
|
327
|
+
resolve(hash);
|
|
328
|
+
emit("hash-progress", 100);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
reader.onerror = (err) => {
|
|
332
|
+
file.status = constants.FILE_STATUS.FAIL;
|
|
333
|
+
emit("error", err, file, state.uploadFiles);
|
|
334
|
+
};
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
const handleHwh5Files = (files) => {
|
|
338
|
+
return files.map((file) => {
|
|
339
|
+
if (file instanceof File)
|
|
340
|
+
return file;
|
|
341
|
+
let f = {};
|
|
342
|
+
if (isObject(file)) {
|
|
343
|
+
const { fileName, fileSize, filePath } = file;
|
|
344
|
+
f = __spreadProps(__spreadValues({}, file), {
|
|
345
|
+
name: fileName,
|
|
346
|
+
size: fileSize,
|
|
347
|
+
webkitRelativePath: filePath
|
|
231
348
|
});
|
|
349
|
+
} else {
|
|
350
|
+
const [name, index] = file.match(/[^/]*$/);
|
|
351
|
+
const [type] = file.match(/\.[^.]*$/);
|
|
352
|
+
const filePath = file.substring(0, index);
|
|
353
|
+
f = { type, name, filePath, webkitRelativePath: filePath };
|
|
232
354
|
}
|
|
233
|
-
|
|
355
|
+
return f;
|
|
356
|
+
});
|
|
234
357
|
};
|
|
235
|
-
const handleStart = ({ api, constants, props, state,
|
|
358
|
+
const handleStart = ({ api, constants, props, state, vm }) => (rawFiles, updateId, reUpload = false) => {
|
|
359
|
+
if (state.isHwh5) {
|
|
360
|
+
rawFiles = handleHwh5Files(rawFiles);
|
|
361
|
+
}
|
|
236
362
|
state.currentUploadingFileUids = [];
|
|
237
|
-
rawFiles.forEach((rawFile) => api.addFileToList(rawFile, updateId));
|
|
363
|
+
rawFiles.forEach((rawFile) => api.addFileToList(rawFile, updateId, reUpload));
|
|
238
364
|
const { UPLOADING, READY } = constants.FILE_STATUS;
|
|
239
365
|
state.uploadingFiles = state.uploadFiles.filter((file) => [UPLOADING, READY].includes(file.status));
|
|
240
366
|
if (state.isEdm && state.isSuccess) {
|
|
241
367
|
rawFiles.forEach((rawFile) => {
|
|
242
368
|
const file = api.getFile(rawFile);
|
|
243
|
-
if (!file)
|
|
369
|
+
if (!file)
|
|
244
370
|
return;
|
|
245
|
-
}
|
|
246
371
|
api.beforeUpload(file, true, (file2) => {
|
|
247
372
|
typeof props.edm.upload.loading === "function" && props.edm.upload.loading(file2);
|
|
248
373
|
new Promise((resolve) => {
|
|
249
|
-
if (
|
|
374
|
+
if (state.isHwh5)
|
|
250
375
|
return resolve();
|
|
251
|
-
|
|
252
|
-
if (
|
|
376
|
+
let isLargeFileHash = false;
|
|
377
|
+
if (props.edm.isCheckCode !== true)
|
|
253
378
|
return resolve();
|
|
379
|
+
if (file2.size > state.docSize && file2.size > state.chunkSize) {
|
|
380
|
+
if (!state.isEntireCheckCode) {
|
|
381
|
+
return resolve();
|
|
382
|
+
} else {
|
|
383
|
+
isLargeFileHash = true;
|
|
384
|
+
}
|
|
254
385
|
}
|
|
255
|
-
|
|
256
|
-
reader.readAsArrayBuffer(file2.raw);
|
|
257
|
-
reader.onload = (e) => {
|
|
258
|
-
const cryptoJS = props.edm.upload.plugin();
|
|
259
|
-
const wordArray = cryptoJS.lib.WordArray.create(e.target.result);
|
|
260
|
-
const hash = cryptoJS[shaMap.shaMap](wordArray).toString();
|
|
261
|
-
file2.hash = file2.raw.hash = hash;
|
|
262
|
-
resolve(hash);
|
|
263
|
-
};
|
|
386
|
+
api.getFileHash({ file: file2, chunkSize: state.chunkSize, showTips: isLargeFileHash }).then((hash) => resolve(hash));
|
|
264
387
|
}).then(() => {
|
|
265
388
|
if (props.autoUpload) {
|
|
266
389
|
const tokenParams = { token: props.edm.upload.token, file: file2, type: "upload" };
|
|
@@ -275,16 +398,38 @@ const handleStart = ({ api, constants, props, state, refs }) => (rawFiles, updat
|
|
|
275
398
|
});
|
|
276
399
|
});
|
|
277
400
|
}
|
|
278
|
-
|
|
401
|
+
if (!state.isEdm && props.autoUpload) {
|
|
402
|
+
if (props.multiple && props.mergeService) {
|
|
403
|
+
const handler = (file) => (vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw), void 0);
|
|
404
|
+
rawFiles.length && api.beforeUpload({ raw: rawFiles }, true, handler);
|
|
405
|
+
} else {
|
|
406
|
+
rawFiles.forEach((rawFile) => {
|
|
407
|
+
const file = api.getFile(rawFile);
|
|
408
|
+
if (!file)
|
|
409
|
+
return;
|
|
410
|
+
const handler = (file2) => (vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file2.raw), void 0);
|
|
411
|
+
api.beforeUpload(file, true, handler);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
}
|
|
279
415
|
};
|
|
280
|
-
const calcUploadingFilesInfo = ({ state }) => () => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
416
|
+
const calcUploadingFilesInfo = ({ state, constants }) => () => {
|
|
417
|
+
let percentage;
|
|
418
|
+
if (state.isHwh5) {
|
|
419
|
+
const totalPercentage = state.uploadingFiles.reduce((total, file) => {
|
|
420
|
+
const curPercentage = file.status !== constants.FILE_STATUS.FAIL ? file.percentage / 100 : 0;
|
|
421
|
+
return total + curPercentage;
|
|
422
|
+
}, 0);
|
|
423
|
+
percentage = Math.floor(totalPercentage / state.uploadingFiles.length * 100);
|
|
424
|
+
} else {
|
|
425
|
+
const totalLoadedSize = state.uploadingFiles.reduce((loadedSize, file) => {
|
|
426
|
+
const loaded = file.status !== constants.FILE_STATUS.FAIL ? file.size * file.percentage / 100 : 0;
|
|
427
|
+
return loadedSize + loaded;
|
|
428
|
+
}, 0);
|
|
429
|
+
percentage = Math.floor(totalLoadedSize / state.uploadingSize * 100);
|
|
430
|
+
}
|
|
287
431
|
percentage = Math.min(percentage, 100);
|
|
432
|
+
const uploadedFiles = state.uploadingFiles.filter((file) => file.percentage === 100);
|
|
288
433
|
return {
|
|
289
434
|
percentage,
|
|
290
435
|
uploadList: state.uploadingFiles,
|
|
@@ -306,12 +451,21 @@ const handleProgress = ({ api, constants, emit, state }) => (event, rawFile) =>
|
|
|
306
451
|
const file = api.getFile(rawFile);
|
|
307
452
|
if (file) {
|
|
308
453
|
file.status = constants.FILE_STATUS.UPLOADING;
|
|
309
|
-
if (
|
|
310
|
-
|
|
454
|
+
if (state.isHwh5) {
|
|
455
|
+
const { progress } = JSON.parse(event);
|
|
456
|
+
file.percentage = progress;
|
|
311
457
|
if (file.percentage >= 100) {
|
|
312
458
|
file.isFinished = true;
|
|
313
459
|
}
|
|
314
460
|
emit("progress", file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
461
|
+
} else {
|
|
462
|
+
if (event.lengthComputable && !file.isLargeFile) {
|
|
463
|
+
file.percentage = Math.floor(event.loaded * 100 / event.total) || 0;
|
|
464
|
+
if (file.percentage >= 100) {
|
|
465
|
+
file.isFinished = true;
|
|
466
|
+
}
|
|
467
|
+
emit("progress", file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
468
|
+
}
|
|
315
469
|
}
|
|
316
470
|
}
|
|
317
471
|
}
|
|
@@ -345,14 +499,17 @@ const handleSuccess = ({ api, constants, emit, state, props }) => (res, rawFile)
|
|
|
345
499
|
}
|
|
346
500
|
file.isLargeFile && delete res.config;
|
|
347
501
|
file.response = res;
|
|
348
|
-
if (state.isEdm
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
file.
|
|
353
|
-
file.
|
|
502
|
+
if (state.isEdm) {
|
|
503
|
+
const result = state.isHwh5 ? res : res.data.result;
|
|
504
|
+
if (!result)
|
|
505
|
+
return;
|
|
506
|
+
file.serverName = result.serverName;
|
|
507
|
+
file.docRelativePath = result.docRelativePath;
|
|
508
|
+
file.docId = result.docId;
|
|
509
|
+
file.docVersion = result.version;
|
|
510
|
+
file.docSize = result.docSize;
|
|
354
511
|
file.isLargeFile && delete file.raw;
|
|
355
|
-
Object.assign(file,
|
|
512
|
+
Object.assign(file, result);
|
|
356
513
|
}
|
|
357
514
|
emit("success", res, file, currentUploadFiles);
|
|
358
515
|
emit("change", file, state.uploadFiles);
|
|
@@ -362,26 +519,27 @@ const handleSuccess = ({ api, constants, emit, state, props }) => (res, rawFile)
|
|
|
362
519
|
};
|
|
363
520
|
const handleError = ({ api, constants, emit, state }) => (err, rawFile) => {
|
|
364
521
|
const file = api.getFile(rawFile);
|
|
365
|
-
if (file)
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
api.clearUploadingFiles();
|
|
372
|
-
emit("error", err, file, state.uploadFiles);
|
|
373
|
-
emit("change", file, state.uploadFiles);
|
|
522
|
+
if (!file)
|
|
523
|
+
return;
|
|
524
|
+
file.status = constants.FILE_STATUS.FAIL;
|
|
525
|
+
file.percentage = 100;
|
|
526
|
+
if (!state.isEdm) {
|
|
527
|
+
state.uploadFiles.splice(state.uploadFiles.indexOf(file), 1);
|
|
374
528
|
}
|
|
529
|
+
api.clearUploadingFiles();
|
|
530
|
+
emit("error", err, file, state.uploadFiles);
|
|
531
|
+
emit("change", file, state.uploadFiles);
|
|
375
532
|
};
|
|
376
|
-
const handleRemove = ({ api, emit, props, state }) => (file, raw) => {
|
|
533
|
+
const handleRemove = ({ api, emit, props, state, constants }) => (file, raw) => {
|
|
377
534
|
if (raw) {
|
|
378
535
|
file = api.getFile(raw);
|
|
379
536
|
}
|
|
380
537
|
let doRemove = () => {
|
|
538
|
+
file.status = constants.FILE_STATUS.FAIL;
|
|
381
539
|
api.abort(file);
|
|
382
540
|
let fileList = state.uploadFiles;
|
|
383
541
|
fileList.splice(fileList.indexOf(file), 1);
|
|
384
|
-
emit("remove", file, fileList);
|
|
542
|
+
emit("remove", __spreadProps(__spreadValues({}, file), { status: constants.FILE_STATUS.FAIL }), fileList);
|
|
385
543
|
};
|
|
386
544
|
if (!props.beforeRemove) {
|
|
387
545
|
doRemove();
|
|
@@ -415,11 +573,54 @@ const getFile = (state) => (rawFile) => {
|
|
|
415
573
|
});
|
|
416
574
|
return target;
|
|
417
575
|
};
|
|
418
|
-
const abort = ({ constants,
|
|
576
|
+
const abort = ({ constants, vm, state }) => (file) => {
|
|
577
|
+
const { READY, UPLOADING, FAIL } = constants.FILE_STATUS;
|
|
578
|
+
if (file) {
|
|
579
|
+
state.uploadingFiles.forEach((f) => {
|
|
580
|
+
const uid = file.uid || file;
|
|
581
|
+
if (f.uid === uid && [READY, UPLOADING].includes(f.status)) {
|
|
582
|
+
f.status = FAIL;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
} else {
|
|
586
|
+
state.uploadingFiles.forEach((f) => {
|
|
587
|
+
if ([READY, UPLOADING].includes(f.status)) {
|
|
588
|
+
f.status = FAIL;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].abort(file);
|
|
593
|
+
};
|
|
594
|
+
const abortDownload = ({ state }) => (file, batch = false) => {
|
|
595
|
+
const cancel = (docId) => {
|
|
596
|
+
if (!docId)
|
|
597
|
+
return;
|
|
598
|
+
const cancels = state.downloadCancelToken[docId];
|
|
599
|
+
cancels && cancels.forEach((cancel2) => cancel2());
|
|
600
|
+
delete state.downloadCancelToken[docId];
|
|
601
|
+
const clearDataFn = state.downloadCancelData[docId];
|
|
602
|
+
clearDataFn && clearDataFn(docId);
|
|
603
|
+
};
|
|
604
|
+
if (Array.isArray(file)) {
|
|
605
|
+
if (batch) {
|
|
606
|
+
cancel(
|
|
607
|
+
file.map((f) => f.docId || f).sort().join(",")
|
|
608
|
+
);
|
|
609
|
+
} else {
|
|
610
|
+
file.forEach((f) => f && cancel(file.docId || file));
|
|
611
|
+
}
|
|
612
|
+
} else if (file) {
|
|
613
|
+
cancel(file.docId || file);
|
|
614
|
+
} else {
|
|
615
|
+
Object.keys(state.downloadCancelToken).forEach((docId) => {
|
|
616
|
+
cancel(docId);
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
};
|
|
419
620
|
const clearFiles = (state) => () => {
|
|
420
621
|
state.uploadFiles = [];
|
|
421
622
|
};
|
|
422
|
-
const submit = ({ api, constants,
|
|
623
|
+
const submit = ({ api, constants, vm, state, props }) => () => {
|
|
423
624
|
const files = state.uploadFiles.filter((file) => file.status === constants.FILE_STATUS.READY);
|
|
424
625
|
if (state.isEdm && state.isSuccess) {
|
|
425
626
|
files.forEach((file) => {
|
|
@@ -439,18 +640,18 @@ const submit = ({ api, constants, refs, state, props }) => () => {
|
|
|
439
640
|
if (props.multiple && props.mergeService) {
|
|
440
641
|
const rawFiles = files.map((file) => file.raw);
|
|
441
642
|
rawFiles.length && api.beforeUpload({ raw: rawFiles }, false, (file) => {
|
|
442
|
-
refs[constants.UPLOAD_INNER].upload(file.raw);
|
|
643
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw);
|
|
443
644
|
});
|
|
444
645
|
} else {
|
|
445
646
|
files.forEach((file) => {
|
|
446
647
|
api.beforeUpload(file, false, (file2) => {
|
|
447
|
-
refs[constants.UPLOAD_INNER].upload(file2.raw);
|
|
648
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file2.raw);
|
|
448
649
|
});
|
|
449
650
|
});
|
|
450
651
|
}
|
|
451
652
|
}
|
|
452
653
|
};
|
|
453
|
-
const handleClick = ({ constants,
|
|
654
|
+
const handleClick = ({ constants, vm }) => () => vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleClick();
|
|
454
655
|
const getFileUploadUrl = (service) => () => service.getFileUploadUrl();
|
|
455
656
|
const updateUrl = ({ api, props, state }) => () => {
|
|
456
657
|
if (props.action) {
|
|
@@ -459,67 +660,70 @@ const updateUrl = ({ api, props, state }) => () => {
|
|
|
459
660
|
api.getFileUploadUrl().then((url) => state.url = url);
|
|
460
661
|
}
|
|
461
662
|
};
|
|
462
|
-
const getTranslateFile = ({ api, isChunk }) => (data, type, index) => {
|
|
663
|
+
const getTranslateFile = ({ api, isChunk, isLessThan17G, file, state }) => (data, type, index) => {
|
|
463
664
|
if (isChunk) {
|
|
464
665
|
if (index === 0) {
|
|
465
|
-
api.setWriterFile({ data, index });
|
|
666
|
+
state.downloadCancelData[file.docId] = api.setWriterFile({ data, index, isLessThan17G, file });
|
|
466
667
|
}
|
|
467
668
|
} else {
|
|
468
669
|
const content = data.headers["content-disposition"];
|
|
469
670
|
const name = content.match(/fileName.?=(.*)/)[1] || content.match(/fileName=(.*)/)[1];
|
|
470
671
|
const blob = new Blob([data.data], { type: type !== "zip" ? "application / x - xls" : "application/zip" });
|
|
471
|
-
|
|
472
|
-
window.navigator.msSaveOrOpenBlob(blob, decodeURIComponent(name));
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
const url = window.URL || window.webkitURL || window.moxURL;
|
|
476
|
-
const downloadHref = xss.filterUrl(url.createObjectURL(blob));
|
|
477
|
-
let downloadLink = document.createElement("a");
|
|
478
|
-
downloadLink.href = downloadHref;
|
|
479
|
-
downloadLink.download = decodeURIComponent(name);
|
|
480
|
-
downloadLink.click();
|
|
672
|
+
aLinkDownload({ blob, name });
|
|
481
673
|
}
|
|
482
674
|
};
|
|
483
|
-
const
|
|
675
|
+
const aLinkDownload = ({ blob, name }) => {
|
|
676
|
+
if (window && window.navigator.msSaveOrOpenBlob) {
|
|
677
|
+
window.navigator.msSaveOrOpenBlob(blob, decodeURIComponent(name));
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
const url = window.URL || window.webkitURL || window.moxURL;
|
|
681
|
+
const downloadHref = xss.filterUrl(url.createObjectURL(blob));
|
|
682
|
+
let downloadLink = document.createElement("a");
|
|
683
|
+
downloadLink.href = downloadHref;
|
|
684
|
+
downloadLink.download = decodeURIComponent(name);
|
|
685
|
+
downloadLink.click();
|
|
686
|
+
url.revokeObjectURL && url.revokeObjectURL(downloadHref);
|
|
687
|
+
};
|
|
688
|
+
const getHandleSuccess = ({ state, downloadOps, file, translateFile, isChunk, isLessThan17G }) => (data, type, index) => {
|
|
484
689
|
if (isChunk) {
|
|
485
|
-
|
|
690
|
+
const res = isLessThan17G ? data.data : new Uint8Array(data.data);
|
|
691
|
+
let downloadChunkFile = state.downloadChunkFile[file.docId];
|
|
692
|
+
if (!downloadChunkFile) {
|
|
693
|
+
downloadChunkFile = {};
|
|
694
|
+
}
|
|
695
|
+
downloadChunkFile[index] = res;
|
|
486
696
|
translateFile(data, type, index);
|
|
487
697
|
} else {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
reader.onload = (e) => {
|
|
491
|
-
if (typeof downloadOps.fail === "function") {
|
|
492
|
-
downloadOps.fail(JSON.parse(e.target.result), file);
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
reader.readAsText(data.data);
|
|
496
|
-
} else {
|
|
497
|
-
typeof downloadOps.loading === "function" && downloadOps.loading(file);
|
|
498
|
-
translateFile(data, type);
|
|
499
|
-
}
|
|
698
|
+
typeof downloadOps.loading === "function" && downloadOps.loading(file);
|
|
699
|
+
translateFile(data, type);
|
|
500
700
|
}
|
|
701
|
+
return true;
|
|
501
702
|
};
|
|
502
703
|
const getCalcProgress = () => (evt) => {
|
|
503
|
-
let total
|
|
704
|
+
let total;
|
|
705
|
+
if (evt.target && evt.target.getResponseHeader) {
|
|
706
|
+
total = Number(evt.target.getResponseHeader("Content-Size"));
|
|
707
|
+
} else {
|
|
708
|
+
total = Number(evt.total);
|
|
709
|
+
}
|
|
504
710
|
total = Math.max(total, evt.loaded);
|
|
505
711
|
let progress = Math.ceil(evt.loaded / total * 100) || 0;
|
|
506
712
|
progress = Math.max(progress, 0);
|
|
507
713
|
progress = Math.min(progress, 100);
|
|
508
714
|
return progress;
|
|
509
715
|
};
|
|
510
|
-
const modifyServiceUrlSingle = ({ file, serviceUrl, range
|
|
716
|
+
const modifyServiceUrlSingle = ({ constants }) => ({ file, serviceUrl, range }) => {
|
|
511
717
|
if (typeof file === "object") {
|
|
512
|
-
let tempFile =
|
|
718
|
+
let tempFile = Object.assign({}, file, range);
|
|
513
719
|
delete tempFile.docId;
|
|
514
720
|
delete tempFile.docVersion;
|
|
515
721
|
delete tempFile["x-download-sign"];
|
|
516
722
|
for (let key in tempFile) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
serviceUrl += `&${key}=${value}`;
|
|
522
|
-
}
|
|
723
|
+
const value = tempFile[key];
|
|
724
|
+
const dataType = typeof value;
|
|
725
|
+
if (!~["undefined", "object", "function"].indexOf(dataType)) {
|
|
726
|
+
serviceUrl += `&${key}=${value}`;
|
|
523
727
|
}
|
|
524
728
|
}
|
|
525
729
|
file.status = constants.FILE_STATUS.DOWNLOADING;
|
|
@@ -527,27 +731,71 @@ const modifyServiceUrlSingle = ({ file, serviceUrl, range, constants }) => {
|
|
|
527
731
|
}
|
|
528
732
|
return serviceUrl;
|
|
529
733
|
};
|
|
530
|
-
const getKiaScanTip = ({
|
|
531
|
-
if (data.status ===
|
|
734
|
+
const getKiaScanTip = ({ Modal, constants, t }) => ({ data }) => {
|
|
735
|
+
if (data.status === constants.EDM.KIASTATUS) {
|
|
532
736
|
return Modal.message({
|
|
533
737
|
message: `${t(constants.EDM.KIASCANTIP)}`,
|
|
534
738
|
status: "warning"
|
|
535
739
|
});
|
|
536
740
|
}
|
|
537
741
|
};
|
|
538
|
-
const
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
742
|
+
const validateDownloadStatus = ({ state, Modal }) => ({ downloadOps, file, isLessThan17G, data }) => {
|
|
743
|
+
const errorHandle = ({ state: state2, file: file2, errRes, Modal: Modal2, downloadOps: downloadOps2 }) => {
|
|
744
|
+
if (state2.currentDownloadFiles && state2.currentDownloadFiles.docId === file2.docId)
|
|
745
|
+
return;
|
|
746
|
+
if (errRes && errRes.message) {
|
|
747
|
+
Modal2.message({
|
|
748
|
+
message: errRes.message,
|
|
749
|
+
status: "warning"
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
state2.currentDownloadFiles = file2;
|
|
753
|
+
if (typeof downloadOps2.fail === "function") {
|
|
754
|
+
downloadOps2.fail(errRes, file2);
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
if (data.data && data.data.type && data.data.type.includes("application/json")) {
|
|
758
|
+
const reader = new FileReader();
|
|
759
|
+
reader.onload = (e) => {
|
|
760
|
+
const errRes = JSON.parse(e.target.result);
|
|
761
|
+
errorHandle({ state, file, errRes, Modal, downloadOps });
|
|
762
|
+
};
|
|
763
|
+
reader.readAsText(data.data);
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
if (!isLessThan17G && data.headers["content-type"].includes("application/json")) {
|
|
767
|
+
const errRes = JSON.parse(String.fromCharCode.apply(null, new Uint8Array(data.data)));
|
|
768
|
+
errorHandle({ state, file, errRes, Modal, downloadOps });
|
|
769
|
+
return true;
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
const createDownloadCancelToken = ({ state, service }) => (file) => {
|
|
773
|
+
let docId;
|
|
774
|
+
if (Array.isArray(file)) {
|
|
775
|
+
docId = file.map((f) => f.docId || f).sort().join(",");
|
|
776
|
+
} else {
|
|
777
|
+
docId = file.docId || file;
|
|
778
|
+
}
|
|
779
|
+
if (!state.downloadCancelToken[docId]) {
|
|
780
|
+
state.downloadCancelToken[docId] = [];
|
|
781
|
+
}
|
|
782
|
+
const { cancel, token } = service.cancelToken();
|
|
783
|
+
state.downloadCancelToken[docId].push(cancel);
|
|
784
|
+
return token;
|
|
785
|
+
};
|
|
786
|
+
const downloadFileSingle = ({ service, constants, props, state, api, emit }) => (args) => {
|
|
787
|
+
let { file, batchIndex, isChunk, calcProgress, handleSuccess: handleSuccess2, range = {}, isBatch, isLessThan17G } = args;
|
|
788
|
+
let getServiceUrl = ({ url, file: file2 }) => url.replace(/{docId}/, file2.docId || file2) + `${~url.indexOf("?") ? "&" : "?"}x-download-sign=true&docVersion=${file2.docVersion || ""}`;
|
|
542
789
|
let sdResolver = (url) => {
|
|
543
790
|
let serviceUrl = getServiceUrl({ url, file });
|
|
544
|
-
serviceUrl = modifyServiceUrlSingle({ file, serviceUrl, range
|
|
791
|
+
serviceUrl = api.modifyServiceUrlSingle({ file, serviceUrl, range });
|
|
545
792
|
serviceUrl = xss.filterUrl(serviceUrl);
|
|
546
793
|
let params = {
|
|
547
794
|
withCredentials: props.withCredentials,
|
|
548
795
|
headers: Object.assign(props.headers, state.headers),
|
|
549
|
-
responseType: isChunk ? "arraybuffer" : "blob",
|
|
796
|
+
responseType: isChunk && !isLessThan17G ? "arraybuffer" : "blob",
|
|
550
797
|
hideErr: true,
|
|
798
|
+
cancelToken: api.createDownloadCancelToken(file),
|
|
551
799
|
onDownloadProgress(evt) {
|
|
552
800
|
let progress = calcProgress(evt, isChunk);
|
|
553
801
|
if (progress !== 100) {
|
|
@@ -559,44 +807,45 @@ const downloadFileSingle = (args) => {
|
|
|
559
807
|
}
|
|
560
808
|
};
|
|
561
809
|
service.get(serviceUrl, params).then((data) => {
|
|
562
|
-
if (getKiaScanTip({ data
|
|
810
|
+
if (api.getKiaScanTip({ data }))
|
|
811
|
+
return;
|
|
812
|
+
if (api.validateDownloadStatus({ downloadOps: props.edm.download || {}, file, isLessThan17G, data }))
|
|
563
813
|
return;
|
|
564
|
-
}
|
|
565
|
-
const { checkcode, "content-size": fileSize } = data.headers;
|
|
566
|
-
!isChunk && emit("download", 100, { checkcode, fileSize });
|
|
567
814
|
handleSuccess2(data, "", range.index);
|
|
815
|
+
const { checkcode, "content-size": fileSize } = data.headers;
|
|
816
|
+
!isChunk && emit("download", 100, "", { checkcode, fileSize });
|
|
568
817
|
if (typeof file === "object") {
|
|
569
818
|
file.percentage = 100;
|
|
570
819
|
setTimeout(() => file.status = constants.FILE_STATUS.SUCESS, 1e3);
|
|
571
820
|
}
|
|
572
821
|
api.afterDownload({ batchIndex, data, file });
|
|
573
822
|
}).catch((data) => {
|
|
574
|
-
if (data.response && data.response.status
|
|
823
|
+
if (data.response && state.errorStatusCodes.includes(data.response.status)) {
|
|
575
824
|
const downloadOps = props.edm.download || {};
|
|
576
825
|
const tokenParams = { token: downloadOps.token, file, type: "download" };
|
|
577
826
|
api.getToken(tokenParams).then((data2) => {
|
|
578
|
-
api.afterDownload({ batchIndex, data: data2, file, range, isChunk, isBatch });
|
|
827
|
+
api.afterDownload({ batchIndex, data: data2, file, range, isChunk, isBatch, isLessThan17G });
|
|
579
828
|
});
|
|
580
829
|
}
|
|
581
830
|
});
|
|
582
831
|
};
|
|
583
832
|
service.getSingleDownloadUrl().then(sdResolver);
|
|
584
833
|
};
|
|
585
|
-
const downloadFileBatch = (args) => {
|
|
586
|
-
let {
|
|
587
|
-
let { t, Modal, constants, range = {} } = args;
|
|
834
|
+
const downloadFileBatch = ({ api, service, props, state, emit }) => (args) => {
|
|
835
|
+
let { downloadOps, file, calcProgress, handleSuccess: handleSuccess2, range = {} } = args;
|
|
588
836
|
let tokenParams = { token: downloadOps.packageToken, file, type: "download" };
|
|
589
837
|
api.getToken(tokenParams).then((data) => {
|
|
590
838
|
if (!data) {
|
|
591
839
|
return;
|
|
592
840
|
}
|
|
593
841
|
const params = { downloadTOs: [], attachdownloadTOs: [], isZip: "true", transformType: "sync", type: "package" };
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
842
|
+
file.forEach((item) => {
|
|
843
|
+
if (item.wmType) {
|
|
844
|
+
params.attachdownloadTOs.push(item);
|
|
845
|
+
} else {
|
|
846
|
+
params.downloadTOs.push(item);
|
|
847
|
+
}
|
|
848
|
+
});
|
|
600
849
|
service.getPackageDownloadUrl().then((url) => {
|
|
601
850
|
url += `${~url.indexOf("?") ? "&" : "?"}x-download-sign=true`;
|
|
602
851
|
url = xss.filterUrl(url);
|
|
@@ -607,6 +856,7 @@ const downloadFileBatch = (args) => {
|
|
|
607
856
|
withCredentials: props.withCredentials,
|
|
608
857
|
headers: Object.assign(props.headers, state.headers),
|
|
609
858
|
responseType: "blob",
|
|
859
|
+
cancelToken: api.createDownloadCancelToken(file),
|
|
610
860
|
onDownloadProgress(evt) {
|
|
611
861
|
let progress = calcProgress(evt);
|
|
612
862
|
if (progress !== 100) {
|
|
@@ -615,80 +865,131 @@ const downloadFileBatch = (args) => {
|
|
|
615
865
|
}
|
|
616
866
|
}
|
|
617
867
|
).then((data2) => {
|
|
618
|
-
if (getKiaScanTip({ data: data2
|
|
868
|
+
if (api.getKiaScanTip({ data: data2 }))
|
|
619
869
|
return;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
emit("download", 100, { fileSize });
|
|
870
|
+
const { "content-size": fileSize, checkcode } = data2.headers;
|
|
871
|
+
emit("download", 100, "", { fileSize, checkcode });
|
|
623
872
|
handleSuccess2(data2, "zip");
|
|
624
873
|
});
|
|
625
874
|
});
|
|
626
875
|
});
|
|
627
876
|
};
|
|
628
|
-
const
|
|
877
|
+
const downloadFileSingleHwh5 = ({ state, props, emit, constants }) => ({ file }) => {
|
|
878
|
+
const { HWH5, appId } = props.hwh5;
|
|
879
|
+
const { downloadToEDM } = HWH5();
|
|
880
|
+
const options = {
|
|
881
|
+
edmAuth: {
|
|
882
|
+
edmToken: state.headers[constants.EDM.EDMTOKEN],
|
|
883
|
+
appId
|
|
884
|
+
},
|
|
885
|
+
docId: file.docId || file,
|
|
886
|
+
docVersion: file.docVersion,
|
|
887
|
+
filePath: file.filePath,
|
|
888
|
+
progress: 1,
|
|
889
|
+
onProgress: (event) => {
|
|
890
|
+
const { progress } = JSON.parse(event);
|
|
891
|
+
if (progress * 1 !== 100) {
|
|
892
|
+
emit("download", progress);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
downloadToEDM(options).then((data) => {
|
|
897
|
+
emit("download", 100, "", { data });
|
|
898
|
+
});
|
|
899
|
+
};
|
|
900
|
+
const downloadFile = ({ api, state }) => (file) => {
|
|
901
|
+
state.currentDownloadFiles = "";
|
|
629
902
|
if (!state.isEdm) {
|
|
630
903
|
api.ordinaryDownload(file);
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
904
|
+
} else {
|
|
905
|
+
const isBatch = Array.isArray(file);
|
|
906
|
+
if (state.isHwh5) {
|
|
907
|
+
let files = file;
|
|
908
|
+
if (!isBatch) {
|
|
909
|
+
files = [file];
|
|
910
|
+
}
|
|
911
|
+
files.forEach((f) => api.downloadFileSingleInner({ file: f, isBatch: false }));
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
if (isBatch) {
|
|
915
|
+
api.downloadFileInner({ file, isBatch });
|
|
916
|
+
} else {
|
|
917
|
+
api.downloadFileSingleInner({ file, isBatch });
|
|
918
|
+
}
|
|
636
919
|
}
|
|
920
|
+
};
|
|
921
|
+
const downloadFileSingleInner = ({ props, state, api, constants }) => ({ file, isBatch }) => {
|
|
922
|
+
const { SIZE_17G } = constants.EDM;
|
|
637
923
|
const downloadOps = props.edm.download || {};
|
|
638
924
|
let tokenParams = { token: downloadOps.token, file, type: "download" };
|
|
639
925
|
api.getToken(tokenParams).then((data) => {
|
|
640
|
-
if (!data)
|
|
926
|
+
if (!data)
|
|
927
|
+
return;
|
|
928
|
+
if (state.isHwh5) {
|
|
929
|
+
api.downloadFileSingleHwh5({ file });
|
|
641
930
|
return;
|
|
642
931
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
932
|
+
if (state.hasFileInfoInterface) {
|
|
933
|
+
api.getDownloadFileInfo({ docId: file.docId }).then((res) => {
|
|
934
|
+
let fileInfo;
|
|
935
|
+
if (res && res.outDocQueryList[0].verInfo[0]) {
|
|
936
|
+
fileInfo = res.outDocQueryList[0].verInfo[0].docInfo[0];
|
|
937
|
+
}
|
|
938
|
+
const { fileSize } = fileInfo;
|
|
939
|
+
const isLargeFile = fileSize > state.docSize && fileSize > state.chunkSize;
|
|
940
|
+
const isLessThan17G = fileSize < SIZE_17G * 1024;
|
|
941
|
+
if (isLargeFile) {
|
|
942
|
+
api.largeDocumentDownload({ file: fileInfo, isBatch, isLessThan17G });
|
|
943
|
+
} else {
|
|
944
|
+
api.downloadFileInner({ file, isBatch });
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
} else {
|
|
948
|
+
api.downloadFileInner({ file, isBatch });
|
|
949
|
+
}
|
|
656
950
|
});
|
|
657
951
|
};
|
|
658
|
-
const getDownloadFileInfo = ({ state, props, service }) => ({ docId }) =>
|
|
659
|
-
(
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
952
|
+
const getDownloadFileInfo = ({ api, state, props, service }) => ({ docId }) => {
|
|
953
|
+
return service.getDocumentInfoUrl().then((url) => {
|
|
954
|
+
return new Promise((resolve, reject) => {
|
|
955
|
+
service.request({
|
|
956
|
+
method: "post",
|
|
957
|
+
url: xss.filterUrl(url),
|
|
958
|
+
withCredentials: props.withCredentials,
|
|
959
|
+
headers: Object.assign(props.headers, state.headers),
|
|
960
|
+
cancelToken: api.createDownloadCancelToken({ docId }),
|
|
961
|
+
data: { docInfoVO: { ids: [docId], docType: "", docVersion: "" } }
|
|
962
|
+
}).then((res) => {
|
|
963
|
+
if (res.data.status === 200) {
|
|
964
|
+
resolve(res.data.result);
|
|
965
|
+
} else {
|
|
966
|
+
reject(res);
|
|
967
|
+
}
|
|
968
|
+
});
|
|
672
969
|
});
|
|
673
|
-
})
|
|
674
|
-
|
|
675
|
-
const largeDocumentDownload = ({ api, state }) => ({ file, isBatch }) => {
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
state.
|
|
679
|
-
state.dowuloadChunkFile.set("docName", file.docName);
|
|
970
|
+
});
|
|
971
|
+
};
|
|
972
|
+
const largeDocumentDownload = ({ api, state }) => ({ file, isBatch, isLessThan17G }) => {
|
|
973
|
+
const { fileSize, docId, docName } = file;
|
|
974
|
+
const chunkSize = Math.ceil(fileSize / state.chunkSize);
|
|
975
|
+
state.downloadChunkFile[docId] = { chunkNum: chunkSize, fileSize, docName };
|
|
680
976
|
file.chunkSize = chunkSize;
|
|
681
977
|
const batches = api.sliceDownloadChunk(file);
|
|
682
|
-
api.batchSegmentDownload({ batchIndex: 0, batches, docId: file.docId, isBatch });
|
|
978
|
+
api.batchSegmentDownload({ batchIndex: 0, batches, docId: file.docId, isBatch, isLessThan17G });
|
|
683
979
|
};
|
|
684
980
|
const sliceDownloadChunk = ({ state }) => (file) => {
|
|
685
981
|
const chunkSize = file.chunkSize;
|
|
686
982
|
const downloadChunkArray = [[]];
|
|
687
983
|
state.downloadBatchQueue[file.docId + "-0"] = 0;
|
|
688
984
|
state.downloadBatchQueueListen[file.docId + "-0"] = 0;
|
|
985
|
+
let startRange = 0;
|
|
986
|
+
let endRange = -1;
|
|
689
987
|
for (let i = 0; i < chunkSize; i++) {
|
|
690
|
-
|
|
691
|
-
|
|
988
|
+
startRange = endRange + 1;
|
|
989
|
+
endRange = Math.min(file.fileSize, startRange + state.chunkSize);
|
|
990
|
+
if (endRange < startRange) {
|
|
991
|
+
return downloadChunkArray;
|
|
992
|
+
}
|
|
692
993
|
const lastIndex = downloadChunkArray.length - 1;
|
|
693
994
|
if (downloadChunkArray[lastIndex].length < state.downloadChunkLimit) {
|
|
694
995
|
downloadChunkArray[lastIndex].push({ startRange, endRange, index: i });
|
|
@@ -705,7 +1006,7 @@ const sliceDownloadChunk = ({ state }) => (file) => {
|
|
|
705
1006
|
}
|
|
706
1007
|
return downloadChunkArray;
|
|
707
1008
|
};
|
|
708
|
-
const batchSegmentDownload = ({ state, api }) => ({ batchIndex, batches, docId, isBatch }) => {
|
|
1009
|
+
const batchSegmentDownload = ({ state, api }) => ({ batchIndex, batches, docId, isBatch, isLessThan17G }) => {
|
|
709
1010
|
if (batchIndex < batches.length) {
|
|
710
1011
|
const batch = batches[batchIndex];
|
|
711
1012
|
const key = docId + "-" + batchIndex;
|
|
@@ -720,33 +1021,66 @@ const batchSegmentDownload = ({ state, api }) => ({ batchIndex, batches, docId,
|
|
|
720
1021
|
docId,
|
|
721
1022
|
batchIndex: ++batchIndex,
|
|
722
1023
|
batches,
|
|
723
|
-
isBatch
|
|
1024
|
+
isBatch,
|
|
1025
|
+
isLessThan17G
|
|
724
1026
|
});
|
|
725
1027
|
}
|
|
726
1028
|
}
|
|
727
1029
|
});
|
|
728
1030
|
let index = 0;
|
|
729
1031
|
while (batch.length - index > 0) {
|
|
730
|
-
api.downloadFileInner({
|
|
1032
|
+
api.downloadFileInner({
|
|
1033
|
+
batchIndex,
|
|
1034
|
+
range: batch[index++],
|
|
1035
|
+
file: { docId },
|
|
1036
|
+
isBatch,
|
|
1037
|
+
isChunk: true,
|
|
1038
|
+
isLessThan17G
|
|
1039
|
+
});
|
|
731
1040
|
}
|
|
732
1041
|
}
|
|
733
1042
|
};
|
|
734
|
-
const downloadFileInner = ({ api, props,
|
|
1043
|
+
const downloadFileInner = ({ api, props, state }) => ({
|
|
1044
|
+
batchIndex,
|
|
1045
|
+
file,
|
|
1046
|
+
range,
|
|
1047
|
+
isBatch,
|
|
1048
|
+
isChunk,
|
|
1049
|
+
isLessThan17G
|
|
1050
|
+
}) => {
|
|
735
1051
|
const downloadOps = props.edm.download || {};
|
|
736
|
-
const translateFile = getTranslateFile({ api, isChunk });
|
|
737
|
-
const handleSuccess2 = getHandleSuccess({ downloadOps, file, translateFile, isChunk, state });
|
|
1052
|
+
const translateFile = getTranslateFile({ api, isChunk, isLessThan17G, file, state });
|
|
1053
|
+
const handleSuccess2 = getHandleSuccess({ downloadOps, file, translateFile, isChunk, state, isLessThan17G });
|
|
738
1054
|
const calcProgress = getCalcProgress();
|
|
739
1055
|
let { isFinished = false } = {};
|
|
740
1056
|
if (!isBatch) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
1057
|
+
const args = {
|
|
1058
|
+
calcProgress,
|
|
1059
|
+
isFinished,
|
|
1060
|
+
handleSuccess: handleSuccess2,
|
|
1061
|
+
range,
|
|
1062
|
+
batchIndex,
|
|
1063
|
+
isBatch,
|
|
1064
|
+
downloadOps,
|
|
1065
|
+
file,
|
|
1066
|
+
isChunk,
|
|
1067
|
+
isLessThan17G
|
|
1068
|
+
};
|
|
1069
|
+
api.downloadFileSingle(args);
|
|
744
1070
|
return;
|
|
745
1071
|
}
|
|
746
|
-
const params = {
|
|
747
|
-
isBatch && downloadFileBatch(params);
|
|
1072
|
+
const params = { downloadOps, file, calcProgress, handleSuccess: handleSuccess2, range };
|
|
1073
|
+
isBatch && api.downloadFileBatch(params);
|
|
748
1074
|
};
|
|
749
|
-
const afterDownload = ({ api, state }) => ({
|
|
1075
|
+
const afterDownload = ({ api, state }) => ({
|
|
1076
|
+
batchIndex,
|
|
1077
|
+
range,
|
|
1078
|
+
data,
|
|
1079
|
+
file,
|
|
1080
|
+
isBatch,
|
|
1081
|
+
isChunk,
|
|
1082
|
+
isLessThan17G
|
|
1083
|
+
}) => {
|
|
750
1084
|
if (data.status === 200) {
|
|
751
1085
|
const key = file.docId + "-" + batchIndex;
|
|
752
1086
|
const count = state.downloadBatchQueue[key];
|
|
@@ -754,60 +1088,91 @@ const afterDownload = ({ api, state }) => ({ batchIndex, range, data, file, isBa
|
|
|
754
1088
|
} else {
|
|
755
1089
|
const countDownloadReplay = state.downloadReplayAtoms[file.docId + "-" + range.index];
|
|
756
1090
|
if (countDownloadReplay && countDownloadReplay >= 2) {
|
|
757
|
-
const msgArray = [
|
|
1091
|
+
const msgArray = [
|
|
1092
|
+
"The number of retry times exceeds the threshold! [docId:",
|
|
1093
|
+
file.docId,
|
|
1094
|
+
", chunk:",
|
|
1095
|
+
range.index,
|
|
1096
|
+
"]"
|
|
1097
|
+
];
|
|
758
1098
|
log.logger.warn(msgArray.join(""));
|
|
759
1099
|
delete state.downloadReplayAtoms[file.docId + "-" + range.index];
|
|
760
1100
|
} else {
|
|
761
1101
|
const msgArray = ["replay ", countDownloadReplay, "! [docId:", file.docId, ", chunk:", range.index, "]"];
|
|
762
1102
|
log.logger.warn(msgArray.join(""));
|
|
763
1103
|
state.downloadReplayAtoms[file.docId + "-" + range.index] = countDownloadReplay + 1;
|
|
764
|
-
api.downloadFileInner({ batchIndex, range, file, isBatch, isChunk });
|
|
1104
|
+
api.downloadFileInner({ batchIndex, range, file, isBatch, isChunk, isLessThan17G });
|
|
765
1105
|
}
|
|
766
1106
|
}
|
|
767
1107
|
};
|
|
768
|
-
const setWriterFile = ({ state, emit,
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
const
|
|
773
|
-
let
|
|
774
|
-
|
|
1108
|
+
const setWriterFile = ({ state, emit, Streamsaver }) => ({ data, index, isLessThan17G, file }) => {
|
|
1109
|
+
let { fileStream, writer, fileData = [], downloaded = 0 } = {};
|
|
1110
|
+
const { checkcode } = data.headers;
|
|
1111
|
+
const content = data.headers["content-disposition"];
|
|
1112
|
+
const name = content.match(/fileName.?=(.*)/)[1] || content.match(/fileName=(.*)/)[1];
|
|
1113
|
+
let { chunkNum, fileSize, docName } = state.downloadChunkFile[file.docId];
|
|
1114
|
+
docName = name || docName;
|
|
1115
|
+
if (!isLessThan17G) {
|
|
1116
|
+
fileStream = Streamsaver.createWriteStream(docName, { size: data.byteLength });
|
|
1117
|
+
writer = fileStream.getWriter();
|
|
1118
|
+
}
|
|
775
1119
|
const writerStreamSaver = () => {
|
|
776
|
-
|
|
1120
|
+
const downloadChunkFile = state.downloadChunkFile[file.docId] || {};
|
|
1121
|
+
let chunk = downloadChunkFile[index];
|
|
777
1122
|
if (chunk) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
1123
|
+
if (!isLessThan17G) {
|
|
1124
|
+
writer.write(chunk).then(() => {
|
|
1125
|
+
downloaded += chunk.byteLength;
|
|
1126
|
+
downloadChunkFile[index] = null;
|
|
1127
|
+
delete downloadChunkFile[index];
|
|
1128
|
+
if (index + 1 >= chunkNum) {
|
|
1129
|
+
delete state.downloadChunkFile[file.docId];
|
|
1130
|
+
emit("download", 100, "", { fileSize, checkcode });
|
|
1131
|
+
writer.close();
|
|
1132
|
+
} else {
|
|
1133
|
+
const progress = Math.ceil(downloaded / fileSize * 100) || 0;
|
|
1134
|
+
progress !== 100 && emit("download", progress);
|
|
1135
|
+
index++;
|
|
1136
|
+
writerStreamSaver();
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
} else {
|
|
1140
|
+
fileData.push(chunk);
|
|
1141
|
+
downloaded += chunk.size;
|
|
1142
|
+
state.downloadChunkFile[file.docId][index] = null;
|
|
1143
|
+
delete state.downloadChunkFile[file.docId][index];
|
|
1144
|
+
if (index + 1 >= chunkNum) {
|
|
1145
|
+
delete state.downloadChunkFile[file.docId];
|
|
1146
|
+
aLinkDownload({ blob: new Blob(fileData), name: docName });
|
|
1147
|
+
emit("download", 100, "", { fileSize, checkcode });
|
|
784
1148
|
} else {
|
|
785
1149
|
const progress = Math.ceil(downloaded / fileSize * 100) || 0;
|
|
786
|
-
|
|
787
|
-
emit("download", progress);
|
|
788
|
-
}
|
|
1150
|
+
progress !== 100 && emit("download", progress);
|
|
789
1151
|
index++;
|
|
790
1152
|
writerStreamSaver();
|
|
791
1153
|
}
|
|
792
|
-
|
|
793
|
-
});
|
|
1154
|
+
}
|
|
794
1155
|
} else {
|
|
795
|
-
setTimeout(() =>
|
|
796
|
-
writerStreamSaver();
|
|
797
|
-
}, 1e3);
|
|
1156
|
+
setTimeout(() => writerStreamSaver(), 1e3);
|
|
798
1157
|
}
|
|
799
1158
|
};
|
|
800
1159
|
writerStreamSaver();
|
|
1160
|
+
return (docId) => {
|
|
1161
|
+
const downloadChunkFile = state.downloadChunkFile[docId];
|
|
1162
|
+
Object.keys(downloadChunkFile).forEach((k) => downloadChunkFile[k] = null);
|
|
1163
|
+
delete state.downloadChunkFile[docId];
|
|
1164
|
+
if (isLessThan17G) {
|
|
1165
|
+
fileData = [];
|
|
1166
|
+
} else {
|
|
1167
|
+
writer && writer.close();
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
801
1170
|
};
|
|
802
1171
|
const getFormData = ({ constants, props, state }) => ({ formData, file, type }) => {
|
|
803
1172
|
if (state.isEdm && props.edm.upload) {
|
|
804
|
-
const
|
|
805
|
-
const edmData = props.edm.upload.params || {};
|
|
806
|
-
const params = __spreadValues(__spreadValues({}, propData), edmData);
|
|
1173
|
+
const params = Object.assign({}, props.data || {}, props.edm.upload.params || {});
|
|
807
1174
|
for (let key in params) {
|
|
808
|
-
|
|
809
|
-
formData.set(key, params[key] || "");
|
|
810
|
-
}
|
|
1175
|
+
formData.set(key, params[key] || "");
|
|
811
1176
|
}
|
|
812
1177
|
}
|
|
813
1178
|
if (props.edm.isCheckCode === true) {
|
|
@@ -854,8 +1219,8 @@ const largeDocumentUpload = ({ api, Modal, state, t, emit, constants }) => (file
|
|
|
854
1219
|
status: "warning",
|
|
855
1220
|
duration: "1000"
|
|
856
1221
|
});
|
|
857
|
-
const
|
|
858
|
-
state.uploadFiles.splice(state.uploadFiles.indexOf(
|
|
1222
|
+
const file2 = api.getFile(file2);
|
|
1223
|
+
state.uploadFiles.splice(state.uploadFiles.indexOf(file2), 1);
|
|
859
1224
|
}
|
|
860
1225
|
}).catch((err) => {
|
|
861
1226
|
file.status = constants.FILE_STATUS.FAIL;
|
|
@@ -890,7 +1255,13 @@ const afterUpload = ({ data, file, batchIndex, state, api, progress }) => {
|
|
|
890
1255
|
} else {
|
|
891
1256
|
const countReplay = state.replayAtoms[file.docId + "-" + file.chunk];
|
|
892
1257
|
if (countReplay && countReplay >= 2) {
|
|
893
|
-
const msgArray = [
|
|
1258
|
+
const msgArray = [
|
|
1259
|
+
"The number of retry times exceeds the threshold! [docId:",
|
|
1260
|
+
file.docId,
|
|
1261
|
+
", chunk:",
|
|
1262
|
+
file.chunk,
|
|
1263
|
+
"]"
|
|
1264
|
+
];
|
|
894
1265
|
log.logger.warn(msgArray.join(""));
|
|
895
1266
|
delete state.replayAtoms[file.docId + "-" + file.chunk];
|
|
896
1267
|
} else {
|
|
@@ -901,22 +1272,13 @@ const afterUpload = ({ data, file, batchIndex, state, api, progress }) => {
|
|
|
901
1272
|
}
|
|
902
1273
|
}
|
|
903
1274
|
};
|
|
904
|
-
const chunkUpload = ({ state, service, postChunk }) => {
|
|
905
|
-
if (!state.chunkUploadUrl) {
|
|
906
|
-
service.getChunkUploadUrl().then((data) => {
|
|
907
|
-
state.chunkUploadUrl = data;
|
|
908
|
-
postChunk(data);
|
|
909
|
-
});
|
|
910
|
-
} else {
|
|
911
|
-
postChunk(state.chunkUploadUrl);
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
1275
|
const segmentUploadInner = ({ api, props, service, state, emit, constants, batchIndex, file, progress }) => {
|
|
915
1276
|
const formData = new FormData();
|
|
916
1277
|
const postChunk = (url) => {
|
|
917
1278
|
const source = service.cancelToken();
|
|
918
1279
|
if (progress.file.cancelToken) {
|
|
919
1280
|
progress.file.cancelToken.push(source.cancel);
|
|
1281
|
+
const { SUCESS, FAIL } = constants.FILE_STATUS;
|
|
920
1282
|
service.request({
|
|
921
1283
|
method: "post",
|
|
922
1284
|
url: xss.filterUrl(url),
|
|
@@ -931,33 +1293,51 @@ const segmentUploadInner = ({ api, props, service, state, emit, constants, batch
|
|
|
931
1293
|
let percentage = Math.floor(count / progress.size * 100) || 0;
|
|
932
1294
|
file.percentage = Math.floor(event.loaded / event.total * 100);
|
|
933
1295
|
event.percentage = progress.file.percentage = percentage > 100 ? 100 : percentage;
|
|
934
|
-
|
|
935
|
-
progress.file.isFinished = true;
|
|
936
|
-
}
|
|
1296
|
+
percentage >= 100 && (progress.file.isFinished = true);
|
|
937
1297
|
emit("progress", progress.file, state.uploadFiles, api.calcUploadingFilesInfo());
|
|
938
1298
|
}
|
|
939
1299
|
}).then((data) => {
|
|
940
1300
|
afterUpload({ data, file, batchIndex, state, api, progress });
|
|
941
|
-
|
|
942
|
-
progress.file.status = constants.FILE_STATUS.SUCESS;
|
|
943
|
-
}
|
|
1301
|
+
progress.file.percentage === 100 && (progress.file.status = SUCESS);
|
|
944
1302
|
}).catch((data) => {
|
|
945
|
-
if (data.response && data.response.status
|
|
1303
|
+
if (data.response && state.errorStatusCodes.includes(data.response.status)) {
|
|
946
1304
|
const tokenParams = { token: props.edm.upload.token, file, type: "upload" };
|
|
947
|
-
api.getToken(tokenParams).then((data2) => {
|
|
948
|
-
afterUpload({ data: data2, file, batchIndex, state, api, progress });
|
|
949
|
-
});
|
|
1305
|
+
api.getToken(tokenParams).then((data2) => afterUpload({ data: data2, file, batchIndex, state, api, progress }));
|
|
950
1306
|
} else {
|
|
951
|
-
file.
|
|
1307
|
+
progress.file.status !== FAIL && emit("error", data, progress.file, state.uploadFiles);
|
|
1308
|
+
progress.file.status = FAIL;
|
|
1309
|
+
progress.file.docId = "";
|
|
952
1310
|
}
|
|
953
1311
|
});
|
|
954
1312
|
}
|
|
955
1313
|
};
|
|
956
|
-
|
|
1314
|
+
if (!state.chunkUploadUrl) {
|
|
1315
|
+
service.getChunkUploadUrl().then((data) => {
|
|
1316
|
+
state.chunkUploadUrl = data;
|
|
1317
|
+
postChunk(data);
|
|
1318
|
+
});
|
|
1319
|
+
} else {
|
|
1320
|
+
postChunk(state.chunkUploadUrl);
|
|
1321
|
+
}
|
|
957
1322
|
};
|
|
958
|
-
const segmentUpload = ({ api, props, service, state, emit, constants }) => (batchIndex, file, progress) => {
|
|
1323
|
+
const segmentUpload = ({ api, props, service, state, emit, constants, CryptoJS }) => (batchIndex, file, progress) => {
|
|
959
1324
|
if (typeof file.then === "function") {
|
|
960
|
-
file.then(
|
|
1325
|
+
file.then(
|
|
1326
|
+
(file2) => new Promise((resolve) => {
|
|
1327
|
+
if (props.edm.isCheckCode !== true)
|
|
1328
|
+
return resolve(file2);
|
|
1329
|
+
const reader = new FileReader();
|
|
1330
|
+
reader.readAsArrayBuffer(file2);
|
|
1331
|
+
reader.onload = (e) => {
|
|
1332
|
+
if (props.edm.isCheckCode === true) {
|
|
1333
|
+
let wordArray = CryptoJS.lib.WordArray.create(e.target.result);
|
|
1334
|
+
const hash = CryptoJS.SHA256(wordArray).toString();
|
|
1335
|
+
file2.hash = hash;
|
|
1336
|
+
}
|
|
1337
|
+
resolve(file2);
|
|
1338
|
+
};
|
|
1339
|
+
})
|
|
1340
|
+
).then((file2) => {
|
|
961
1341
|
segmentUploadInner({
|
|
962
1342
|
batchIndex,
|
|
963
1343
|
api,
|
|
@@ -984,7 +1364,12 @@ const segmentUpload = ({ api, props, service, state, emit, constants }) => (batc
|
|
|
984
1364
|
});
|
|
985
1365
|
}
|
|
986
1366
|
};
|
|
987
|
-
const batchSegmentUpload = ({ api, constants, props,
|
|
1367
|
+
const batchSegmentUpload = ({ api, constants, props, vm, state }) => ({
|
|
1368
|
+
docId,
|
|
1369
|
+
batchIndex,
|
|
1370
|
+
batches,
|
|
1371
|
+
progress
|
|
1372
|
+
}) => {
|
|
988
1373
|
if (batchIndex < batches.length && progress.file.cancelToken) {
|
|
989
1374
|
const key = docId + "-" + batchIndex;
|
|
990
1375
|
const batch = batches[batchIndex];
|
|
@@ -1010,10 +1395,10 @@ const batchSegmentUpload = ({ api, constants, props, refs, state }) => ({ docId,
|
|
|
1010
1395
|
}
|
|
1011
1396
|
} else {
|
|
1012
1397
|
typeof props.edm.upload.closeloading === "function" && props.edm.upload.closeloading();
|
|
1013
|
-
refs[constants.UPLOAD_INNER].upload(state.largeFileInfo[docId]);
|
|
1398
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(state.largeFileInfo[docId]);
|
|
1014
1399
|
}
|
|
1015
1400
|
};
|
|
1016
|
-
const sliceChunk = ({ state
|
|
1401
|
+
const sliceChunk = ({ state }) => (file) => {
|
|
1017
1402
|
const chunkSize = file.chunkSize;
|
|
1018
1403
|
const chunkBatchArray = [[]];
|
|
1019
1404
|
state.batchQueue[file.docId + "-0"] = 0;
|
|
@@ -1032,22 +1417,7 @@ const sliceChunk = ({ state, props }) => (file) => {
|
|
|
1032
1417
|
atom.cacheSign = file.cacheSign;
|
|
1033
1418
|
atom.records = file.records;
|
|
1034
1419
|
atom.percentage = file.percentage;
|
|
1035
|
-
const promise =
|
|
1036
|
-
if (props.edm.isCheckCode !== true) {
|
|
1037
|
-
return resolve(atom);
|
|
1038
|
-
}
|
|
1039
|
-
const reader = new FileReader();
|
|
1040
|
-
reader.readAsArrayBuffer(atom);
|
|
1041
|
-
reader.onload = (e) => {
|
|
1042
|
-
if (props.edm.isCheckCode === true) {
|
|
1043
|
-
const cryptoJS = props.edm.upload.plugin();
|
|
1044
|
-
const wordArray = cryptoJS.lib.WordArray.create(e.target.result);
|
|
1045
|
-
const hash = cryptoJS[shaMap.shaMap](wordArray).toString();
|
|
1046
|
-
atom.hash = hash;
|
|
1047
|
-
}
|
|
1048
|
-
resolve(atom);
|
|
1049
|
-
};
|
|
1050
|
-
});
|
|
1420
|
+
const promise = Promise.resolve(atom);
|
|
1051
1421
|
const lastIndex = chunkBatchArray.length - 1;
|
|
1052
1422
|
if (chunkBatchArray[lastIndex].length < state.chunkBatchLimit) {
|
|
1053
1423
|
chunkBatchArray[lastIndex].push(promise);
|
|
@@ -1060,7 +1430,13 @@ const sliceChunk = ({ state, props }) => (file) => {
|
|
|
1060
1430
|
}
|
|
1061
1431
|
return chunkBatchArray;
|
|
1062
1432
|
};
|
|
1063
|
-
const getToken = ({ constants, props, state, t, Modal }) => ({
|
|
1433
|
+
const getToken = ({ constants, props, state, t, Modal }) => ({
|
|
1434
|
+
token,
|
|
1435
|
+
file,
|
|
1436
|
+
isOnlinePreview = false,
|
|
1437
|
+
type = "",
|
|
1438
|
+
isinit = false
|
|
1439
|
+
}) => {
|
|
1064
1440
|
if (props.edm.isExtranet && !isOnlinePreview) {
|
|
1065
1441
|
state.isSuccess = true;
|
|
1066
1442
|
state.accept = props.accept;
|
|
@@ -1090,7 +1466,7 @@ const getToken = ({ constants, props, state, t, Modal }) => ({ token, file, isOn
|
|
|
1090
1466
|
const result = data || {};
|
|
1091
1467
|
const whitelist = result.config && result.config.fileWhiteList || "";
|
|
1092
1468
|
state.isSuccess = true;
|
|
1093
|
-
state.accept = type === "download" || type === "preview" ? props.accept : `${whitelist}
|
|
1469
|
+
state.accept = type === "download" || type === "preview" ? props.accept : `${whitelist}${props.accept ? `,${props.accept}` : ""}`;
|
|
1094
1470
|
state.headers[constants.EDM.EDMTOKEN] = result.edmToken || "";
|
|
1095
1471
|
state.headers[constants.EDM.TRACEID] = result.traceId || "";
|
|
1096
1472
|
if (result.config) {
|
|
@@ -1104,13 +1480,32 @@ const getToken = ({ constants, props, state, t, Modal }) => ({ token, file, isOn
|
|
|
1104
1480
|
}
|
|
1105
1481
|
});
|
|
1106
1482
|
};
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1483
|
+
const previewFile = ({ api, props }) => (file, open = false) => {
|
|
1484
|
+
return new Promise((resolve, reject) => {
|
|
1485
|
+
try {
|
|
1486
|
+
const tokenParams = { isOnlinePreview: true, file, type: "preview", token: props.edm.preview.token };
|
|
1487
|
+
api.getToken(tokenParams).then((data) => {
|
|
1488
|
+
if (!data) {
|
|
1489
|
+
const message = "[TINY Error][FileUpload] No edm token";
|
|
1490
|
+
reject(new Error(message));
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
if (isObject(file) || Array.isArray(file) && file.length === 1) {
|
|
1494
|
+
api.previewFileSingle({ file: Array.isArray(file) ? __spreadValues({}, file[0]) : file, resolve, open });
|
|
1495
|
+
} else if (Array.isArray(file) && file.length > 1) {
|
|
1496
|
+
api.previewFileBatch({ file, resolve, open });
|
|
1497
|
+
}
|
|
1498
|
+
}).catch((e) => reject(new Error(e)));
|
|
1499
|
+
} catch (e) {
|
|
1500
|
+
reject(new Error(e));
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
};
|
|
1504
|
+
const getNewTabPreviewUrl = ({ api }) => (file) => api.previewFile(file, true);
|
|
1505
|
+
const previewFileSingle = ({ api, state, props, constants, service }) => ({ file, resolve, open }) => {
|
|
1113
1506
|
const iframeUrl = api.getPreviewUrlSync(file);
|
|
1507
|
+
if (open)
|
|
1508
|
+
return resolve(iframeUrl);
|
|
1114
1509
|
if (iframeUrl) {
|
|
1115
1510
|
state.showPreview = true;
|
|
1116
1511
|
state.iframeUrl = iframeUrl;
|
|
@@ -1144,101 +1539,138 @@ const getTokenResolver = ({ reject, api, file, state, resolve, props, constants,
|
|
|
1144
1539
|
})
|
|
1145
1540
|
);
|
|
1146
1541
|
};
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
const
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
};
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
}).catch((e) => {
|
|
1177
|
-
reject(new Error(e));
|
|
1542
|
+
const previewFileBatch = ({ service, props, state, api }) => ({ file, resolve, open }) => {
|
|
1543
|
+
service.getPreviewUrlBatch().then((url) => {
|
|
1544
|
+
const edm = props.edm || {};
|
|
1545
|
+
const preview = edm.preview || {};
|
|
1546
|
+
const online = preview.online || {};
|
|
1547
|
+
const { jslibhtml, baseurl } = online;
|
|
1548
|
+
const { text } = preview.watermark || {};
|
|
1549
|
+
service.request({
|
|
1550
|
+
method: "post",
|
|
1551
|
+
url: xss.filterUrl(url),
|
|
1552
|
+
withCredentials: props.withCredentials,
|
|
1553
|
+
headers: state.headers,
|
|
1554
|
+
data: {
|
|
1555
|
+
documents: file,
|
|
1556
|
+
asposeClient: jslibhtml,
|
|
1557
|
+
asposeService: baseurl,
|
|
1558
|
+
watermark: text
|
|
1559
|
+
}
|
|
1560
|
+
}).then(({ data }) => {
|
|
1561
|
+
const iframeUrl = api.getPreviewUrlSync({ generate: data.result.generate, size: file.length }, true);
|
|
1562
|
+
if (open)
|
|
1563
|
+
return resolve(iframeUrl);
|
|
1564
|
+
if (iframeUrl) {
|
|
1565
|
+
state.showPreview = true;
|
|
1566
|
+
state.iframeUrl = iframeUrl;
|
|
1567
|
+
resolve(state.iframeUrl);
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1178
1570
|
});
|
|
1179
|
-
}
|
|
1180
|
-
const getPreviewUrlSync = ({ constants, props, state }) => (file) => {
|
|
1571
|
+
};
|
|
1572
|
+
const getPreviewUrlSync = ({ constants, props, state }) => (file, batch) => {
|
|
1573
|
+
const { ASPOSE, WPS } = constants.EDM.FILE_PREVIEW_TYPE;
|
|
1181
1574
|
const edm = props.edm || {};
|
|
1182
1575
|
const preview = edm.preview || {};
|
|
1183
|
-
const online = preview
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
if (
|
|
1189
|
-
|
|
1576
|
+
const { watermark, online, bar = {}, lang } = preview;
|
|
1577
|
+
const { filePreviewType = ASPOSE, http = false, jslibhtml, appid, baseurl } = online;
|
|
1578
|
+
const { styles } = bar;
|
|
1579
|
+
bar.styles = JSON.stringify(styles);
|
|
1580
|
+
let html;
|
|
1581
|
+
if (filePreviewType === WPS) {
|
|
1582
|
+
html = `${http ? "http:" : "https:"}${baseurl.replace(/\/$/, "")}/edm/projects/${appid}/web/preview`;
|
|
1583
|
+
} else {
|
|
1584
|
+
html = jslibhtml.split("?").shift();
|
|
1190
1585
|
}
|
|
1191
|
-
const watermark = preview.watermark || {};
|
|
1192
|
-
const paramsData = __spreadValues(__spreadValues(__spreadValues({}, online), watermark), {
|
|
1193
|
-
jslibhtml: html,
|
|
1194
|
-
authToken: state.headers[constants.EDM.EDMTOKEN],
|
|
1195
|
-
docId: file.docId,
|
|
1196
|
-
docVersion: file.docVersion || file.version || "V1",
|
|
1197
|
-
type: "doc",
|
|
1198
|
-
pageNum: "1"
|
|
1199
|
-
});
|
|
1200
1586
|
const params = [];
|
|
1587
|
+
let paramsData;
|
|
1588
|
+
const edmToken = state.headers[constants.EDM.EDMTOKEN];
|
|
1589
|
+
if (batch) {
|
|
1590
|
+
html = html = `${baseurl.replace(/\/$/, "")}/edm/projects/${appid}/web/batchPreview`;
|
|
1591
|
+
const { generate, size } = file;
|
|
1592
|
+
paramsData = { generate, "EDM-Authorization": edmToken, docIndex: 1, size };
|
|
1593
|
+
} else {
|
|
1594
|
+
paramsData = Object.assign(
|
|
1595
|
+
{},
|
|
1596
|
+
online,
|
|
1597
|
+
watermark,
|
|
1598
|
+
filePreviewType === WPS ? { "EDM-Authorization": edmToken } : { authToken: edmToken },
|
|
1599
|
+
{
|
|
1600
|
+
jslibhtml: html,
|
|
1601
|
+
docId: file.docId,
|
|
1602
|
+
docVersion: file.docVersion || file.version || "V1",
|
|
1603
|
+
type: "doc",
|
|
1604
|
+
pageNum: "1",
|
|
1605
|
+
lang,
|
|
1606
|
+
bar: window.btoa(JSON.stringify(bar))
|
|
1607
|
+
}
|
|
1608
|
+
);
|
|
1609
|
+
}
|
|
1201
1610
|
for (let key in paramsData) {
|
|
1202
|
-
|
|
1203
|
-
|
|
1611
|
+
const val = paramsData[key];
|
|
1612
|
+
if (!isObject(val)) {
|
|
1613
|
+
if (key === "text") {
|
|
1614
|
+
params.push(`watermark=${encodeURIComponent(val)}`);
|
|
1615
|
+
}
|
|
1616
|
+
params.push(`${key}=${val}`);
|
|
1204
1617
|
}
|
|
1205
1618
|
}
|
|
1206
|
-
|
|
1207
|
-
return iframeUrl;
|
|
1619
|
+
return html + "?" + params.join("&");
|
|
1208
1620
|
};
|
|
1209
|
-
const previewImage = ({ api, props, service
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
withCredentials: props.withCredentials,
|
|
1228
|
-
headers: Object.assign(props.headers, state.headers),
|
|
1229
|
-
responseType: "blob"
|
|
1230
|
-
}).then((data2) => {
|
|
1231
|
-
const blob = new Blob([data2.data]);
|
|
1232
|
-
const URL2 = window.URL || window.webkitURL;
|
|
1233
|
-
const link = URL2.createObjectURL(blob);
|
|
1234
|
-
resolve(link);
|
|
1621
|
+
const previewImage = ({ api, props, service }) => (file) => {
|
|
1622
|
+
return new Promise((resolve, reject) => {
|
|
1623
|
+
try {
|
|
1624
|
+
api.getToken({
|
|
1625
|
+
token: props.edm.preview.token,
|
|
1626
|
+
file,
|
|
1627
|
+
type: "preview"
|
|
1628
|
+
}).then((data) => {
|
|
1629
|
+
if (!data) {
|
|
1630
|
+
reject(new Error("[TINY Error][FileUpload] No edm token"));
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
service.getPreviewUrl().then((url) => {
|
|
1634
|
+
if (isObject(file) || Array.isArray(file) && file.length === 1) {
|
|
1635
|
+
api.previewImageSingle({ url, file: Array.isArray(file) ? __spreadValues({}, file[0]) : file }).then((link) => resolve(link));
|
|
1636
|
+
} else if (Array.isArray(file) && file.length > 1) {
|
|
1637
|
+
api.previewImageBatch({ url, file }).then((links) => resolve(links));
|
|
1638
|
+
}
|
|
1235
1639
|
});
|
|
1236
1640
|
});
|
|
1237
|
-
})
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1641
|
+
} catch (e) {
|
|
1642
|
+
reject(new Error(e));
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
};
|
|
1646
|
+
const previewImageSingle = ({ service, state, props }) => ({ file, url }) => {
|
|
1647
|
+
const edm = props.edm || {};
|
|
1648
|
+
const preview = edm.preview || {};
|
|
1649
|
+
let { text, textStyle } = preview.watermark || {};
|
|
1650
|
+
textStyle = __spreadValues({ tile: true }, textStyle);
|
|
1651
|
+
const imgParam = Object.assign(file, {
|
|
1652
|
+
type: "image",
|
|
1653
|
+
imageType: "image",
|
|
1654
|
+
watermark: text,
|
|
1655
|
+
textStyle
|
|
1656
|
+
});
|
|
1657
|
+
return service.post(xss.filterUrl(url.replace(/{docId}/, file.docId)), imgParam, {
|
|
1658
|
+
withCredentials: props.withCredentials,
|
|
1659
|
+
headers: Object.assign(props.headers, state.headers),
|
|
1660
|
+
responseType: "blob"
|
|
1661
|
+
}).then((data) => {
|
|
1662
|
+
const blob = new Blob([data.data]);
|
|
1663
|
+
const URL2 = window.URL || window.webkitURL;
|
|
1664
|
+
return URL2.createObjectURL(blob);
|
|
1665
|
+
});
|
|
1666
|
+
};
|
|
1667
|
+
const previewImageBatch = ({ service, api }) => ({ url, file }) => {
|
|
1668
|
+
const promises = [];
|
|
1669
|
+
file.forEach((f) => {
|
|
1670
|
+
promises.push(api.previewImageSingle({ url, file: f }));
|
|
1671
|
+
});
|
|
1672
|
+
return service.all(promises);
|
|
1673
|
+
};
|
|
1242
1674
|
const getDialogConfigObj = ({ props, state }) => () => {
|
|
1243
1675
|
const dialogConfigDefault = {
|
|
1244
1676
|
class: "single-download-modal single-download-modal1",
|
|
@@ -1272,29 +1704,37 @@ const getDialogConfigObj = ({ props, state }) => () => {
|
|
|
1272
1704
|
on: __spreadValues({}, events)
|
|
1273
1705
|
});
|
|
1274
1706
|
};
|
|
1275
|
-
const computeDocChunkSize = ({ props, state,
|
|
1707
|
+
const computeDocChunkSize = ({ props, state, constants }) => () => {
|
|
1276
1708
|
const isDefaultChunkSize = !(props.edm && props.edm.chunkSize);
|
|
1709
|
+
const { SIZE_0M, SIZE_2M, SIZE_4M, SIZE_8M, SIZE_16M, SIZE_20M, SIZE_32M, SIZE_64M, SIZE_2G } = constants.EDM;
|
|
1277
1710
|
let { docSize = SIZE_20M, chunkSize = SIZE_8M } = props.edm || {};
|
|
1278
1711
|
docSize = docSize < 0 ? 0 : docSize;
|
|
1279
1712
|
docSize = docSize > SIZE_2G ? SIZE_2G : docSize;
|
|
1280
|
-
if (docSize)
|
|
1713
|
+
if (docSize)
|
|
1281
1714
|
chunkSize = chunkSize < 0 ? 0 : chunkSize;
|
|
1282
|
-
}
|
|
1283
1715
|
if (!isDefaultChunkSize) {
|
|
1284
|
-
const chunkSizes = [
|
|
1716
|
+
const chunkSizes = [SIZE_64M, SIZE_32M, SIZE_16M, SIZE_8M, SIZE_4M, SIZE_2M, SIZE_0M];
|
|
1285
1717
|
chunkSizes.some((size) => {
|
|
1286
1718
|
if (chunkSize >= size) {
|
|
1287
|
-
chunkSize = Math.max(size,
|
|
1719
|
+
chunkSize = Math.max(size, SIZE_2M);
|
|
1288
1720
|
return true;
|
|
1289
1721
|
}
|
|
1290
|
-
return false;
|
|
1291
1722
|
});
|
|
1292
1723
|
}
|
|
1293
1724
|
state.docSize = docSize * 1024;
|
|
1294
1725
|
state.chunkSize = chunkSize * 1024;
|
|
1295
1726
|
};
|
|
1296
|
-
const updateFile = ({ constants,
|
|
1297
|
-
refs[constants.UPLOAD_INNER].handleUpdate(file);
|
|
1727
|
+
const updateFile = ({ constants, vm }) => (file) => {
|
|
1728
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleUpdate(file);
|
|
1729
|
+
};
|
|
1730
|
+
const handleChange = ({ vm, constants }) => (file) => {
|
|
1731
|
+
if (typeof file === "object" && file !== null && file !== void 0) {
|
|
1732
|
+
let files = file;
|
|
1733
|
+
if (!Array.isArray(file)) {
|
|
1734
|
+
files = [file];
|
|
1735
|
+
}
|
|
1736
|
+
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleChange({ target: { files } });
|
|
1737
|
+
}
|
|
1298
1738
|
};
|
|
1299
1739
|
const onBeforeDestroy = (state) => () => {
|
|
1300
1740
|
state.uploadFiles.forEach((file) => {
|
|
@@ -1303,8 +1743,16 @@ const onBeforeDestroy = (state) => () => {
|
|
|
1303
1743
|
}
|
|
1304
1744
|
});
|
|
1305
1745
|
};
|
|
1746
|
+
const handleClickFileList = ({ state, emit }) => (file) => {
|
|
1747
|
+
state.selected = file;
|
|
1748
|
+
emit("click-file-list", file);
|
|
1749
|
+
};
|
|
1750
|
+
const mounted = ({ vm, state }) => () => {
|
|
1751
|
+
vm.$on("drag-over", (isDragover) => state.isDragover = isDragover);
|
|
1752
|
+
};
|
|
1306
1753
|
export {
|
|
1307
1754
|
abort,
|
|
1755
|
+
abortDownload,
|
|
1308
1756
|
addFileToList,
|
|
1309
1757
|
afterDownload,
|
|
1310
1758
|
batchSegmentDownload,
|
|
@@ -1316,17 +1764,26 @@ export {
|
|
|
1316
1764
|
computeDocChunkSize,
|
|
1317
1765
|
computedUploadDisabled,
|
|
1318
1766
|
computedUploadingSize,
|
|
1767
|
+
createDownloadCancelToken,
|
|
1319
1768
|
downloadFile,
|
|
1769
|
+
downloadFileBatch,
|
|
1320
1770
|
downloadFileInner,
|
|
1771
|
+
downloadFileSingle,
|
|
1772
|
+
downloadFileSingleHwh5,
|
|
1773
|
+
downloadFileSingleInner,
|
|
1321
1774
|
getDialogConfigObj,
|
|
1322
1775
|
getDownloadFileInfo,
|
|
1323
1776
|
getFile,
|
|
1777
|
+
getFileHash,
|
|
1324
1778
|
getFileUploadUrl,
|
|
1325
1779
|
getFormData,
|
|
1780
|
+
getKiaScanTip,
|
|
1326
1781
|
getNewTabPreviewUrl,
|
|
1327
1782
|
getPreviewUrlSync,
|
|
1328
1783
|
getToken,
|
|
1784
|
+
handleChange,
|
|
1329
1785
|
handleClick,
|
|
1786
|
+
handleClickFileList,
|
|
1330
1787
|
handleError,
|
|
1331
1788
|
handleProgress,
|
|
1332
1789
|
handleRemove,
|
|
@@ -1335,9 +1792,15 @@ export {
|
|
|
1335
1792
|
initService,
|
|
1336
1793
|
largeDocumentDownload,
|
|
1337
1794
|
largeDocumentUpload,
|
|
1795
|
+
modifyServiceUrlSingle,
|
|
1796
|
+
mounted,
|
|
1338
1797
|
onBeforeDestroy,
|
|
1339
1798
|
previewFile,
|
|
1799
|
+
previewFileBatch,
|
|
1800
|
+
previewFileSingle,
|
|
1340
1801
|
previewImage,
|
|
1802
|
+
previewImageBatch,
|
|
1803
|
+
previewImageSingle,
|
|
1341
1804
|
properFileSize,
|
|
1342
1805
|
segmentUpload,
|
|
1343
1806
|
segmentUploadInit,
|
|
@@ -1348,6 +1811,7 @@ export {
|
|
|
1348
1811
|
submit,
|
|
1349
1812
|
updateFile,
|
|
1350
1813
|
updateUrl,
|
|
1814
|
+
validateDownloadStatus,
|
|
1351
1815
|
watchFileList,
|
|
1352
1816
|
watchListType
|
|
1353
1817
|
};
|