@opentiny/vue-renderless 3.6.0 → 3.6.1-alpha.2

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