@opentiny/vue-renderless 3.6.7 → 3.8.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.
Files changed (314) hide show
  1. package/action-sheet/index.js +28 -1
  2. package/action-sheet/vue.js +10 -4
  3. package/alert/index.js +24 -2
  4. package/alert/vue.js +15 -11
  5. package/amount/index.js +4 -4
  6. package/anchor/index.js +1 -1
  7. package/autocomplete/vue.js +3 -3
  8. package/autonavi-map/index.js +1 -1
  9. package/badge/vue.js +6 -6
  10. package/baidu-map/index.js +1 -1
  11. package/bulletin-board/index.js +1 -1
  12. package/calendar/index.js +2 -2
  13. package/calendar-bar/index.js +268 -0
  14. package/calendar-bar/vue.js +87 -0
  15. package/card/index.js +84 -0
  16. package/card/vue.js +70 -0
  17. package/card-group/index.js +16 -0
  18. package/card-group/vue.js +21 -0
  19. package/card-template/index.js +1 -1
  20. package/carousel/index.js +89 -2
  21. package/carousel/vue.js +14 -5
  22. package/carousel-item/index.js +8 -0
  23. package/carousel-item/vue.js +7 -3
  24. package/cascader/index.js +6 -6
  25. package/cascader/vue.js +3 -3
  26. package/cascader-menu/vue.js +2 -2
  27. package/cascader-panel/index.js +4 -4
  28. package/cascader-panel/node.js +4 -4
  29. package/cascader-panel/vue.js +2 -2
  30. package/cascader-select/index.js +179 -0
  31. package/cascader-select/vue.js +74 -0
  32. package/cell/vue.js +16 -0
  33. package/chart-bar/index.js +3 -3
  34. package/chart-boxplot/index.js +2 -2
  35. package/chart-candle/index.js +3 -3
  36. package/chart-core/deps/utils.js +7 -7
  37. package/chart-core/index.js +2 -2
  38. package/chart-funnel/index.js +3 -3
  39. package/chart-gauge/index.js +3 -3
  40. package/chart-graph/index.js +1 -1
  41. package/chart-heatmap/index.js +2 -2
  42. package/chart-line/index.js +3 -3
  43. package/chart-liquidfill/index.js +2 -2
  44. package/chart-map/index.js +3 -3
  45. package/chart-pie/index.js +3 -3
  46. package/chart-radar/index.js +3 -3
  47. package/chart-sankey/index.js +3 -3
  48. package/chart-scatter/index.js +4 -4
  49. package/chart-sunburst/index.js +1 -1
  50. package/chart-tree/index.js +2 -2
  51. package/chart-waterfall/index.js +3 -3
  52. package/chart-wordcloud/index.js +2 -2
  53. package/checkbox/index.js +21 -0
  54. package/checkbox/vue.js +16 -3
  55. package/checkbox-button/vue.js +1 -1
  56. package/collapse-item/vue.js +1 -1
  57. package/column-list-group/index.js +0 -0
  58. package/column-list-group/vue.js +14 -0
  59. package/column-list-item/index.js +50 -0
  60. package/column-list-item/vue.js +39 -0
  61. package/common/array.js +3 -3
  62. package/common/bigInt.js +5 -2
  63. package/common/dataset/index.js +3 -3
  64. package/common/date.js +2 -2
  65. package/common/deps/ResizeObserver.js +1 -1
  66. package/common/deps/clickoutside.js +1 -1
  67. package/common/deps/date-util.js +4 -4
  68. package/common/deps/date.js +2 -2
  69. package/common/deps/debounce.js +1 -1
  70. package/common/deps/dom.js +1 -1
  71. package/common/deps/fullscreen/apis.js +3 -3
  72. package/common/deps/fullscreen/screenfull.js +1 -1
  73. package/common/deps/infinite-scroll.js +176 -0
  74. package/common/deps/letter-only.js +1 -1
  75. package/common/deps/number-only.js +1 -1
  76. package/common/deps/observe-visibility.js +106 -0
  77. package/common/deps/popper.js +20 -22
  78. package/common/deps/popup-manager.js +2 -2
  79. package/common/deps/repeat-click.js +1 -1
  80. package/common/deps/resize-event.js +1 -1
  81. package/common/deps/tree-model/node.js +5 -5
  82. package/common/deps/tree-model/tree-store.js +3 -3
  83. package/common/deps/upload-ajax.js +2 -2
  84. package/common/deps/vue-popper.js +4 -4
  85. package/common/deps/vue-popup.js +4 -4
  86. package/common/index.js +2 -2
  87. package/common/object.js +1 -1
  88. package/common/runtime.js +24 -24
  89. package/common/string.js +23 -4
  90. package/common/validate/rules/range.js +2 -2
  91. package/common/validate/rules/required.js +1 -1
  92. package/common/validate/rules/type.js +3 -3
  93. package/common/validate/schema.js +1 -1
  94. package/common/validate/util.js +1 -1
  95. package/common/validate/validations/array.js +1 -1
  96. package/common/validate/validations/date.js +1 -1
  97. package/common/validate/validations/enum.js +1 -1
  98. package/common/validate/validations/float.js +1 -1
  99. package/common/validate/validations/integer.js +1 -1
  100. package/common/validate/validations/method.js +1 -1
  101. package/common/validate/validations/number.js +1 -1
  102. package/common/validate/validations/pattern.js +1 -1
  103. package/common/validate/validations/string.js +1 -1
  104. package/common/validate/validations/type.js +1 -1
  105. package/container/index.js +1 -1
  106. package/crop/index.js +2 -2
  107. package/currency/index.js +2 -2
  108. package/date-panel/index.js +7 -7
  109. package/date-panel/vue.js +3 -2
  110. package/date-picker-mobile/index.js +250 -0
  111. package/date-picker-mobile/vue.js +86 -0
  112. package/date-range/index.js +1 -1
  113. package/date-range/vue.js +1 -1
  114. package/date-table/index.js +3 -3
  115. package/date-table/vue.js +1 -1
  116. package/dialog-box/index.js +10 -6
  117. package/dialog-box/vue.js +1 -1
  118. package/dialog-select/index.js +345 -0
  119. package/dialog-select/vue.js +110 -0
  120. package/drawer/index.js +83 -0
  121. package/drawer/vue.js +51 -0
  122. package/drop-times/index.js +1 -1
  123. package/dropdown/index.js +2 -2
  124. package/dropdown/vue.js +1 -1
  125. package/dropdown-item/index.js +1 -1
  126. package/dropdown-item/mf.js +79 -0
  127. package/dropdown-menu/index.js +30 -1
  128. package/dropdown-menu/vue.js +17 -7
  129. package/dynamic-scroller/index.js +117 -0
  130. package/dynamic-scroller/vue.js +88 -0
  131. package/dynamic-scroller-item/index.js +147 -0
  132. package/dynamic-scroller-item/vue.js +92 -0
  133. package/espace/index.js +1 -1
  134. package/espace/vue.js +1 -1
  135. package/exception/vue.js +3 -1
  136. package/fall-menu/index.js +4 -4
  137. package/file-upload/index.js +872 -408
  138. package/file-upload/vue.js +87 -36
  139. package/filter/index.js +131 -0
  140. package/filter/tag-group.js +43 -0
  141. package/filter/vue.js +73 -0
  142. package/filter-bar/index.js +9 -0
  143. package/filter-bar/vue.js +16 -0
  144. package/filter-box/index.js +17 -0
  145. package/filter-box/vue.js +19 -0
  146. package/filter-panel/index.js +42 -0
  147. package/filter-panel/vue.js +33 -0
  148. package/floatbar/index.js +1 -1
  149. package/flowchart/index.js +721 -0
  150. package/flowchart/vue.js +81 -0
  151. package/form/index.js +15 -1
  152. package/form/vue.js +10 -4
  153. package/form-item/index.js +46 -6
  154. package/form-item/vue.js +27 -3
  155. package/fullscreen/index.js +1 -1
  156. package/fullscreen/vue.js +1 -1
  157. package/grid/plugins/export.js +2 -2
  158. package/grid/plugins/exportExcel.js +2 -2
  159. package/grid/plugins/resize.js +1 -1
  160. package/grid/static/base/helperEqualCompare.js +1 -1
  161. package/grid/static/base/isPlainObject.js +1 -1
  162. package/grid/utils/common.js +3 -3
  163. package/grid/utils/dom.js +3 -3
  164. package/grid/utils/event.js +2 -2
  165. package/guide/index.js +168 -0
  166. package/guide/vue.js +36 -0
  167. package/hrapprover/index.js +1 -1
  168. package/image/index.js +8 -4
  169. package/image/vue.js +12 -6
  170. package/image-viewer/index.js +3 -3
  171. package/image-viewer/vue.js +16 -6
  172. package/input/index.js +34 -1
  173. package/input/vue.js +22 -6
  174. package/ip-address/index.js +1 -1
  175. package/ip-address/vue.js +1 -1
  176. package/link-menu/index.js +2 -2
  177. package/link-menu/vue.js +2 -2
  178. package/loading/index.js +2 -2
  179. package/loading/vue.js +2 -1
  180. package/locales/index.js +1 -1
  181. package/logout/index.js +1 -1
  182. package/milestone/index.js +5 -1
  183. package/modal/index.js +68 -39
  184. package/modal/vue.js +15 -12
  185. package/month-range/index.js +1 -1
  186. package/month-range/vue.js +1 -1
  187. package/month-table/index.js +5 -5
  188. package/month-table/vue.js +1 -1
  189. package/multi-select/index.js +5 -2
  190. package/multi-select/vue.js +4 -5
  191. package/nav-menu/index.js +6 -6
  192. package/notify/index.js +3 -3
  193. package/numeric/index.js +15 -5
  194. package/numeric/vue.js +15 -6
  195. package/option/index.js +1 -1
  196. package/package.json +2 -1
  197. package/pager-item/index.js +1 -1
  198. package/panel/index.js +1 -1
  199. package/picker/index.js +7 -7
  200. package/picker/vue.js +1 -1
  201. package/picker-column/index.js +1 -1
  202. package/popconfirm/index.js +25 -0
  203. package/popconfirm/vue.js +22 -0
  204. package/popeditor/index.js +7 -7
  205. package/popeditor/vue.js +2 -2
  206. package/popover/index.js +11 -3
  207. package/popover/vue.js +33 -10
  208. package/popup/index.js +4 -4
  209. package/pull-refresh/index.js +8 -11
  210. package/pull-refresh/vue.js +7 -7
  211. package/radio/index.js +17 -0
  212. package/radio/vue.js +18 -3
  213. package/radio-button/index.js +8 -0
  214. package/radio-button/vue.js +19 -4
  215. package/radio-group/index.js +1 -1
  216. package/radio-group/vue.js +5 -2
  217. package/rate/index.js +4 -2
  218. package/rate/vue.js +1 -1
  219. package/record/index.js +190 -0
  220. package/record/vue.js +44 -0
  221. package/recycle-scroller/index.js +470 -0
  222. package/recycle-scroller/vue.js +135 -0
  223. package/river/index.js +371 -0
  224. package/river/river.js +352 -0
  225. package/river/vue.js +77 -0
  226. package/roles/index.js +1 -1
  227. package/scrollbar/vue-bar.js +1 -1
  228. package/scrollbar/vue.js +1 -1
  229. package/search/index.js +3 -3
  230. package/select/index.js +17 -14
  231. package/select/vue.js +14 -8
  232. package/select-dropdown/vue.js +1 -1
  233. package/select-mobile/index.js +111 -0
  234. package/select-mobile/vue.js +58 -0
  235. package/select-view/index.js +170 -0
  236. package/select-view/vue.js +82 -0
  237. package/selected-box/index.js +216 -0
  238. package/selected-box/vue.js +98 -0
  239. package/slide-bar/index.js +1 -1
  240. package/slider/index.js +49 -4
  241. package/slider/vue.js +15 -4
  242. package/split/vue.js +1 -1
  243. package/standard-list-item/index.js +18 -0
  244. package/standard-list-item/vue.js +22 -0
  245. package/steps/index.js +30 -0
  246. package/steps/slide-bar.js +122 -0
  247. package/steps/vue.js +15 -3
  248. package/switch/index.js +1 -1
  249. package/switch/vue.js +2 -1
  250. package/tab-bar/index.js +2 -2
  251. package/tab-item/index.js +2 -2
  252. package/tab-item/vue.js +1 -1
  253. package/tab-item-mf/index.js +0 -0
  254. package/tab-item-mf/vue.js +16 -0
  255. package/tab-nav/index.js +78 -4
  256. package/tab-nav/vue.js +11 -3
  257. package/tabbar-item/index.js +1 -1
  258. package/tabbar-item/vue.js +1 -1
  259. package/tabs/index.js +8 -9
  260. package/tabs/vue.js +1 -1
  261. package/tabs-mf/index.js +109 -0
  262. package/tabs-mf/vue-bar.js +49 -0
  263. package/tabs-mf/vue-nav-item.js +22 -0
  264. package/tabs-mf/vue-nav.js +13 -0
  265. package/tabs-mf/vue.js +45 -0
  266. package/tabs-mf/wheel.js +71 -0
  267. package/tag/index.js +8 -2
  268. package/tag/vue.js +13 -5
  269. package/tag-group/index.js +24 -0
  270. package/tag-group/vue.js +29 -0
  271. package/tall-storage/index.js +1 -1
  272. package/tall-storage/vue.js +1 -1
  273. package/time/index.js +1 -1
  274. package/time/vue.js +2 -2
  275. package/time-line/index.js +28 -7
  276. package/time-line/vue.js +9 -4
  277. package/time-panel/index.js +2 -2
  278. package/time-panel/vue.js +1 -1
  279. package/time-picker-mobile/index.js +30 -0
  280. package/time-picker-mobile/vue.js +30 -0
  281. package/time-range/index.js +1 -1
  282. package/time-range/vue.js +1 -1
  283. package/time-spinner/index.js +2 -2
  284. package/time-spinner/vue.js +1 -1
  285. package/toggle-menu/index.js +2 -2
  286. package/toggle-menu/vue.js +1 -1
  287. package/tooltip/index.js +30 -3
  288. package/tooltip/vue.js +33 -12
  289. package/top-box/index.js +3 -3
  290. package/transfer/index.js +1 -1
  291. package/transfer-panel/index.js +2 -2
  292. package/tree/index.js +6 -6
  293. package/tree/vue.js +1 -1
  294. package/tree-node/index.js +1 -1
  295. package/upload/index.js +1 -2
  296. package/upload/vue.js +2 -2
  297. package/upload-dragger/index.js +5 -1
  298. package/upload-dragger/vue.js +9 -3
  299. package/upload-list/index.js +158 -8
  300. package/upload-list/vue.js +77 -25
  301. package/user/index.js +86 -70
  302. package/user/vue.js +15 -5
  303. package/user-account/vue.js +1 -1
  304. package/user-contact/index.js +49 -3
  305. package/user-contact/vue.js +17 -8
  306. package/user-head-group/vue.js +17 -0
  307. package/user-link/index.js +10 -2
  308. package/user-link/vue.js +11 -6
  309. package/wheel/index.js +1 -1
  310. package/wizard/index.js +3 -3
  311. package/year-range/index.js +125 -0
  312. package/year-range/vue.js +88 -0
  313. package/year-table/index.js +175 -11
  314. package/year-table/vue.js +17 -5
@@ -1,64 +1,91 @@
1
1
  import {
2
+ __spreadProps,
2
3
  __spreadValues
3
4
  } from "../chunk-PKUHTIDK.js";
4
- import { extend } from "@opentiny/vue-renderless/common/object";
5
- import { xss, log } from "@opentiny/vue-renderless/common/xss";
6
- import uploadAjax from "@opentiny/vue-renderless/common/deps/upload-ajax";
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 shaMap = {
9
- sHA256: "SHA256"
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(new Error("[TINY Error][FileUpload] This component depends on @opentiny/vue-service"));
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
- const noopFn = noopFnCreator();
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 || noopFn,
24
- post: post || noopFn,
25
- request: request || noopFn,
26
- all: all || noopFn,
27
- spread: spread || noopFn,
28
- cancelToken: CancelToken.source || noopFn,
29
- getSingleUploadUrl: common.getSingleUploadUrl || noopFn,
30
- getFileUploadUrl: common.getFileUploadUrl || noopFn,
31
- getFileDownloadUrl: common.getFileDownloadUrl || noopFn,
32
- getSingleDownloadUrl: common.getSingleDownloadUrl || noopFn,
33
- getPackageDownloadUrl: common.getPackageDownloadUrl || noopFn,
34
- getLargeFileInitUrl: common.getLargeFileInitUrl || noopFn,
35
- getChunkUploadUrl: common.getChunkUploadUrl || noopFn,
36
- getPreviewUrl: common.getPreviewUrl || noopFn,
37
- getDocumentInfoUrl: common.getDocumentInfoUrl || noopFn,
38
- httpRequest: props.httpRequest || request || uploadAjax
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 (type === constants.LIST_TYPE.PICTURE_CARD || type === constants.LIST_TYPE.PICTURE) {
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
- state.uploadFiles = fileList && fileList.map((item) => {
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
- if (Object.prototype.hasOwnProperty.call(rawFile, p)) {
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
- if (autoRemove) {
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, refs, Modal, api, t }) => (file, isList) => {
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 (file.size > maxSize * 1024 * 1024) {
163
- Modal.message({
164
- message: `${file.name} ${t(constants.EDM.EXCEED)} ${maxSize} MB`,
165
- status: "warning"
166
- });
167
- return false;
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 (~[constants.LIST_TYPE.PICTURE_CARD, constants.LIST_TYPE.PICTURE].indexOf(props.listType)) {
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
- file.url = URL.createObjectURL(rawFile);
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 (state.updateId) {
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 rawfileUpload = ({ state, props, refs, constants, rawFiles, api }) => {
222
- if (!state.isEdm && props.autoUpload) {
223
- if (props.multiple && props.mergeService) {
224
- const handler = (file) => refs[constants.UPLOAD_INNER].upload(file.raw);
225
- rawFiles.length && api.beforeUpload({ raw: rawFiles }, true, handler);
226
- } else {
227
- rawFiles.forEach((rawFile) => {
228
- const file = api.getFile(rawFile);
229
- const handler = (file2) => refs[constants.UPLOAD_INNER].upload(file2.raw);
230
- api.beforeUpload(file, true, handler);
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, refs }) => (rawFiles, updateId) => {
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 (props.edm.isCheckCode !== true) {
374
+ if (state.isHwh5)
250
375
  return resolve();
251
- }
252
- if (file2.size > state.docSize && file2.size > state.chunkSize && !state.isEntireCheckCode) {
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
- const reader = new FileReader();
256
- reader.readAsArrayBuffer(file2.raw);
257
- reader.onload = (e) => {
258
- const cryptoJS = props.edm.upload.plugin();
259
- const wordArray = cryptoJS.lib.WordArray.create(e.target.result);
260
- const hash = cryptoJS[shaMap.shaMap](wordArray).toString();
261
- file2.hash = file2.raw.hash = hash;
262
- resolve(hash);
263
- };
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
- rawfileUpload({ state, props, refs, constants, rawFiles, api });
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
- const totalLoadedSize = state.uploadingFiles.reduce((loadedSize, file) => {
282
- const loaded = file.size * file.percentage / 100;
283
- return loadedSize + loaded;
284
- }, 0);
285
- const uploadedFiles = state.uploadingFiles.filter((file) => file.percentage === 100);
286
- let percentage = Math.floor(totalLoadedSize / state.uploadingSize * 100);
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 (event.lengthComputable && !file.isLargeFile) {
310
- file.percentage = Math.floor(event.loaded * 100 / event.total) || 0;
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 && res.data.result) {
349
- file.serverName = res.data.result.serverName;
350
- file.docRelativePath = res.data.result.docRelativePath;
351
- file.docId = res.data.result.docId;
352
- file.docVersion = res.data.result.version;
353
- file.docSize = res.data.result.docSize;
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, res.data.result);
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
- file.status = constants.FILE_STATUS.FAIL;
367
- file.percentage = 100;
368
- if (!state.isEdm) {
369
- state.uploadFiles.splice(state.uploadFiles.indexOf(file), 1);
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, refs }) => (file) => refs[constants.UPLOAD_INNER].abort(file);
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, refs, state, props }) => () => {
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, refs }) => () => refs[constants.UPLOAD_INNER].handleClick();
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
- if (window && window.navigator.msSaveOrOpenBlob) {
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 getHandleSuccess = ({ downloadOps, file, translateFile, isChunk, state }) => (data, type, index) => {
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
- state.dowuloadChunkFile.set(index, new Uint8Array(data.data));
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
- if (data.data.type.includes("application/json")) {
489
- const reader = new FileReader();
490
- reader.onload = (e) => {
491
- if (typeof downloadOps.fail === "function") {
492
- downloadOps.fail(JSON.parse(e.target.result), file);
493
- }
494
- };
495
- reader.readAsText(data.data);
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 = Number(evt.target.getResponseHeader("Content-Size"));
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, constants }) => {
716
+ const modifyServiceUrlSingle = ({ constants }) => ({ file, serviceUrl, range }) => {
511
717
  if (typeof file === "object") {
512
- let tempFile = __spreadValues(__spreadValues({}, file), range);
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
- if (Object.prototype.hasOwnProperty.call(tempFile, key)) {
518
- const value = tempFile[key];
519
- const dataType = typeof value;
520
- if (!~["undefined", "object", "function"].indexOf(dataType)) {
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 = ({ data, t, Modal, constants }) => {
531
- if (data.status === "12079") {
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 getServiceUrl = ({ url, file }) => url.replace(/{docId}/, file.docId || file) + `${~url.indexOf("?") ? "&" : "?"}x-download-sign=true&docVersion=${file.docVersion || ""}`;
539
- const downloadFileSingle = (args) => {
540
- let { file, service, constants, props, state, batchIndex, isChunk, api } = args;
541
- let { calcProgress, emit, handleSuccess: handleSuccess2, t, Modal, range = {}, isBatch } = args;
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, constants });
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, t, Modal, constants })) {
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 === 401) {
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 { api, downloadOps, file, service, props, state, calcProgress, emit, handleSuccess: handleSuccess2 } = args;
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
- const hasWmType = file.some((item) => Boolean(item.wmType));
595
- if (hasWmType) {
596
- params.attachdownloadTOs = file;
597
- } else {
598
- params.downloadTOs = file;
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, t, Modal, constants })) {
868
+ if (api.getKiaScanTip({ data: data2 }))
619
869
  return;
620
- }
621
- const { "content-size": fileSize } = data2.headers;
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 downloadFile = ({ api, state, props }) => (file) => {
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
- return;
632
- }
633
- const isBatch = Array.isArray(file);
634
- if (isBatch) {
635
- return api.downloadFileInner({ file, isBatch });
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
- api.getDownloadFileInfo({ docId: file.docId }).then((res) => {
644
- let fileInfo;
645
- if (res && res.outDocQueryList[0].verInfo[0]) {
646
- fileInfo = res.outDocQueryList[0].verInfo[0].docInfo[0];
647
- }
648
- const { fileSize } = fileInfo;
649
- const isLargeFile = fileSize > state.docSize && fileSize > state.chunkSize && fileSize > 10 * 1024 * 1024 * 1024;
650
- if (isLargeFile) {
651
- api.largeDocumentDownload({ file: fileInfo, isBatch });
652
- } else {
653
- api.downloadFileInner({ file, isBatch });
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 }) => service.getDocumentInfoUrl().then(
659
- (url) => new Promise((resolve, reject) => {
660
- service.request({
661
- method: "post",
662
- url: xss.filterUrl(url),
663
- withCredentials: props.withCredentials,
664
- headers: Object.assign(props.headers, state.headers),
665
- data: { docInfoVO: { ids: [docId], docType: "", docVersion: "" } }
666
- }).then((res) => {
667
- if (res.data.status === 200) {
668
- resolve(res.data.result);
669
- } else {
670
- reject(res);
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 chunkSize = Math.ceil(file.fileSize / state.chunkSize);
677
- state.dowuloadChunkFile.set("chunkSize", chunkSize);
678
- state.dowuloadChunkFile.set("fileSize", file.fileSize);
679
- state.dowuloadChunkFile.set("docName", file.docName);
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
- const startRange = i * state.chunkSize;
691
- const endRange = Math.min(file.fileSize, startRange + state.chunkSize);
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({ batchIndex, range: batch[index++], file: { docId }, isBatch, isChunk: true });
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, service, state, emit, constants, t, Modal }) => ({ batchIndex, file, range, isBatch, isChunk }) => {
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
- let args = { api, downloadOps, file, service, constants, props, state, t, Modal, isChunk };
742
- Object.assign(args, { calcProgress, isFinished, emit, handleSuccess: handleSuccess2, range, batchIndex, isBatch });
743
- downloadFileSingle(args);
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 = { api, downloadOps, file, service, props, state, calcProgress, emit, handleSuccess: handleSuccess2, t, Modal, range };
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 }) => ({ batchIndex, range, data, file, isBatch, isChunk }) => {
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 = ["The number of retry times exceeds the threshold! [docId:", file.docId, ", chunk:", range.index, "]"];
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, props }) => ({ data, index }) => {
769
- const fileStream = props.plugin && props.plugin.createWriteStream(state.dowuloadChunkFile.get("docName"), {
770
- size: data.byteLength
771
- });
772
- const writer = fileStream.getWriter();
773
- let downloaded = 0;
774
- const fileSize = state.dowuloadChunkFile.get("fileSize");
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
- let chunk = state.dowuloadChunkFile.get(index);
1120
+ const downloadChunkFile = state.downloadChunkFile[file.docId] || {};
1121
+ let chunk = downloadChunkFile[index];
777
1122
  if (chunk) {
778
- writer.write(chunk).then(() => {
779
- downloaded += chunk.byteLength;
780
- state.dowuloadChunkFile.delete(index);
781
- if (index + 1 === state.dowuloadChunkFile.get("chunkSize")) {
782
- emit("download", 100);
783
- writer.close();
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
- if (progress !== 100) {
787
- emit("download", progress);
788
- }
1150
+ progress !== 100 && emit("download", progress);
789
1151
  index++;
790
1152
  writerStreamSaver();
791
1153
  }
792
- chunk = null;
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 propData = props.data || {};
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
- if (Object.prototype.hasOwnProperty.call(params, key)) {
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 fileData = api.getFile(file);
858
- state.uploadFiles.splice(state.uploadFiles.indexOf(fileData), 1);
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 = ["The number of retry times exceeds the threshold! [docId:", file.docId, ", chunk:", file.chunk, "]"];
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
- if (percentage >= 100) {
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
- if (progress.file.percentage === 100) {
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 === 401) {
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.state = constants.FILE_STATUS.FAIL;
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
- chunkUpload({ state, service, postChunk });
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((file2) => {
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, refs, state }) => ({ docId, batchIndex, batches, progress }) => {
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, props }) => (file) => {
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 = new Promise((resolve) => {
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 }) => ({ token, file, isOnlinePreview = false, type = "", isinit = false }) => {
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},${props.accept}`;
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 getTokenResolver = ({ reject, api, file, state, resolve, props, constants, service }) => (data) => {
1108
- if (!data) {
1109
- const message = "[TINY Error][FileUpload] No edm token";
1110
- reject(new Error(message));
1111
- return;
1112
- }
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 previewFile = ({ api, constants, props, service, state }) => (file) => new Promise((resolve, reject) => {
1148
- try {
1149
- const tokenParams = { isOnlinePreview: true, file, type: "preview", token: props.edm.preview.token };
1150
- const tokenCatcher = (e) => {
1151
- reject(new Error(e));
1152
- };
1153
- const tokenResolver = getTokenResolver({ reject, api, file, state, resolve, props, constants, service });
1154
- api.getToken(tokenParams).then(tokenResolver).catch(tokenCatcher);
1155
- } catch (e) {
1156
- reject(new Error(e));
1157
- }
1158
- });
1159
- const getNewTabPreviewUrl = ({ api, props }) => (file) => new Promise((resolve, reject) => {
1160
- api.getToken({
1161
- token: props.edm.preview.token,
1162
- file,
1163
- isOnlinePreview: true,
1164
- type: "preview"
1165
- }).then((data) => {
1166
- if (!data) {
1167
- reject(new Error("[TINY Error][FileUpload] No edm token"));
1168
- return;
1169
- }
1170
- const iframeUrl = api.getPreviewUrlSync(file);
1171
- if (!iframeUrl) {
1172
- reject(new Error(new Error("[TINY Error][FileUpload] No preview url")));
1173
- } else {
1174
- resolve(iframeUrl);
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.online;
1184
- if (!online) {
1185
- return;
1186
- }
1187
- const html = online.jslibhtml.split("?").shift();
1188
- if (!html) {
1189
- return;
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
- if (Object.prototype.hasOwnProperty.call(paramsData, key)) {
1203
- params.push(`${key}=${paramsData[key]}`);
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
- const iframeUrl = html + "?" + params.join("&");
1207
- return iframeUrl;
1619
+ return html + "?" + params.join("&");
1208
1620
  };
1209
- const previewImage = ({ api, props, service, state }) => (file) => new Promise((resolve, reject) => {
1210
- try {
1211
- api.getToken({
1212
- token: props.edm.preview.token,
1213
- file,
1214
- type: "preview"
1215
- }).then((data) => {
1216
- if (!data) {
1217
- reject(new Error("[TINY Error][FileUpload] No edm token"));
1218
- return;
1219
- }
1220
- service.getPreviewUrl().then((url) => {
1221
- const imgParam = Object.assign(file, {
1222
- type: "image",
1223
- imageType: "image"
1224
- });
1225
- url = url.replace(/{docId}/, file.docId);
1226
- service.post(xss.filterUrl(url), imgParam, {
1227
- withCredentials: props.withCredentials,
1228
- headers: Object.assign(props.headers, state.headers),
1229
- responseType: "blob"
1230
- }).then((data2) => {
1231
- const blob = new Blob([data2.data]);
1232
- const URL2 = window.URL || window.webkitURL;
1233
- const link = URL2.createObjectURL(blob);
1234
- resolve(link);
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
- } catch (e) {
1239
- reject(new Error(e));
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, SIZE_2G, SIZE_20M, SIZE_8M }) => () => {
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 = [64 * 1024, 32 * 1024, 16 * 1024, 8 * 1024, 4 * 1024, 2 * 1024, 0 * 1024];
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, 2 * 1024);
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, refs }) => (file) => {
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
  };