eoss 0.1.0-alpha.41 → 0.1.0-alpha.43

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 (358) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +1446 -1354
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +183 -160
  86. package/lib/autocomplete.js +2852 -2583
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +4 -4
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +1216 -1147
  95. package/lib/calendar.js +864 -839
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +1199 -1130
  98. package/lib/carousel.js +1201 -1132
  99. package/lib/cascader-panel.js +1286 -1170
  100. package/lib/cascader.js +3309 -2976
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +1670 -1388
  103. package/lib/checkbox.js +9 -7
  104. package/lib/code-editor.js +4 -4
  105. package/lib/col.js +2 -2
  106. package/lib/collapse-item.js +1258 -1191
  107. package/lib/collapse.js +1251 -1184
  108. package/lib/color-picker.js +1506 -1329
  109. package/lib/config/api.js +17 -1
  110. package/lib/container.js +2 -2
  111. package/lib/cron.js +22 -22
  112. package/lib/data-table.js +1677 -1359
  113. package/lib/date-picker.js +2707 -2466
  114. package/lib/descriptions-item.js +4 -4
  115. package/lib/descriptions.js +4 -4
  116. package/lib/dialog.js +1213 -1144
  117. package/lib/divider.js +2 -2
  118. package/lib/drawer.js +9 -9
  119. package/lib/dropdown-item.js +6 -6
  120. package/lib/dropdown-menu.js +1415 -1265
  121. package/lib/dropdown.js +1219 -1150
  122. package/lib/email-login.js +1446 -1354
  123. package/lib/empty.js +2 -2
  124. package/lib/eoss.common.js +31462 -18205
  125. package/lib/flip.js +2 -2
  126. package/lib/flow-group.js +4578 -3381
  127. package/lib/flow-list.js +9566 -0
  128. package/lib/flow.js +19284 -10275
  129. package/lib/flows.js +1483 -1391
  130. package/lib/footer.js +2 -2
  131. package/lib/form-editor.js +2825 -2035
  132. package/lib/form-item.js +1368 -1192
  133. package/lib/form.js +2297 -2036
  134. package/lib/guide.js +2 -2
  135. package/lib/header.js +2 -2
  136. package/lib/icon.js +1384 -1292
  137. package/lib/icons.js +145 -99
  138. package/lib/image-viewer.js +1204 -1135
  139. package/lib/image.js +6 -6
  140. package/lib/index.js +1 -1
  141. package/lib/infinite-scroll.js +4 -4
  142. package/lib/input-number.js +169 -122
  143. package/lib/input.js +1399 -1325
  144. package/lib/link.js +2 -2
  145. package/lib/loading.js +11 -11
  146. package/lib/login.js +1486 -1389
  147. package/lib/lowcode-view.js +1618 -1526
  148. package/lib/lowcode.js +1620 -1586
  149. package/lib/main.js +2062 -1982
  150. package/lib/marquee.js +1202 -1133
  151. package/lib/menu-item-group.js +8 -8
  152. package/lib/menu-item.js +6 -6
  153. package/lib/menu.js +2698 -2479
  154. package/lib/message-box.js +1893 -1824
  155. package/lib/message.js +1782 -1713
  156. package/lib/notification.js +1783 -1714
  157. package/lib/option-group.js +16 -7
  158. package/lib/option.js +1223 -1146
  159. package/lib/page-header.js +2 -2
  160. package/lib/pagination.js +1207 -1138
  161. package/lib/phone-login.js +1441 -1352
  162. package/lib/popconfirm.js +7 -7
  163. package/lib/popover.js +2668 -2449
  164. package/lib/process-config.js +1508 -1416
  165. package/lib/process-module.js +1453 -1361
  166. package/lib/process-rule.js +1473 -1381
  167. package/lib/progress.js +2 -2
  168. package/lib/qr-code.js +4 -4
  169. package/lib/qrcode-login.js +1434 -1342
  170. package/lib/radio-button.js +14 -7
  171. package/lib/radio-group.js +1696 -1383
  172. package/lib/radio.js +31 -9
  173. package/lib/rate.js +1286 -1182
  174. package/lib/retrial-auth.js +1444 -1352
  175. package/lib/row.js +2 -2
  176. package/lib/scrollbar.js +1205 -1136
  177. package/lib/select.js +4176 -3717
  178. package/lib/selector-panel.js +2081 -1623
  179. package/lib/selector.js +2582 -2468
  180. package/lib/slider.js +149 -109
  181. package/lib/step.js +28 -30
  182. package/lib/steps.js +2353 -2278
  183. package/lib/submenu.js +1399 -1249
  184. package/lib/switch.js +1337 -1217
  185. package/lib/tab-pane.js +4 -4
  186. package/lib/table-column.js +1208 -1139
  187. package/lib/table.js +3791 -3476
  188. package/lib/tabs.js +1202 -1133
  189. package/lib/tag.js +2 -2
  190. package/lib/theme-chalk/autocomplete.css +1 -1
  191. package/lib/theme-chalk/base.css +1 -1
  192. package/lib/theme-chalk/cascader.css +1 -1
  193. package/lib/theme-chalk/checkbox-group.css +1 -1
  194. package/lib/theme-chalk/collapse.css +1 -1
  195. package/lib/theme-chalk/date-picker.css +1 -1
  196. package/lib/theme-chalk/flow copy.css +1 -0
  197. package/lib/theme-chalk/flow-group.css +1 -1
  198. package/lib/theme-chalk/flow-list.css +1 -0
  199. package/lib/theme-chalk/flow.css +1 -1
  200. package/lib/theme-chalk/form-editor.css +1 -1
  201. package/lib/theme-chalk/form.css +1 -1
  202. package/lib/theme-chalk/icons.css +1 -1
  203. package/lib/theme-chalk/index.css +1 -1
  204. package/lib/theme-chalk/input-number.css +1 -1
  205. package/lib/theme-chalk/input.css +1 -1
  206. package/lib/theme-chalk/login.css +1 -1
  207. package/lib/theme-chalk/main.css +1 -1
  208. package/lib/theme-chalk/message-box.css +1 -1
  209. package/lib/theme-chalk/pagination.css +1 -1
  210. package/lib/theme-chalk/radio-group.css +1 -1
  211. package/lib/theme-chalk/retrial-auth.css +1 -1
  212. package/lib/theme-chalk/select.css +1 -1
  213. package/lib/theme-chalk/selector.css +1 -1
  214. package/lib/theme-chalk/slider.css +1 -1
  215. package/lib/theme-chalk/switch.css +1 -1
  216. package/lib/theme-chalk/tabs.css +1 -1
  217. package/lib/theme-chalk/time-picker.css +1 -1
  218. package/lib/theme-chalk/transfer.css +1 -1
  219. package/lib/time-picker.js +2294 -2097
  220. package/lib/time-select.js +2286 -2089
  221. package/lib/timeline-item.js +2 -2
  222. package/lib/timeline.js +2 -2
  223. package/lib/tips.js +1429 -1337
  224. package/lib/toolbar.js +71 -48
  225. package/lib/tooltip.js +3277 -3058
  226. package/lib/transfer.js +1351 -1230
  227. package/lib/tree-group.js +1405 -1313
  228. package/lib/tree.js +2214 -2122
  229. package/lib/update-history.js +184 -161
  230. package/lib/upload.js +2432 -2384
  231. package/lib/utils/label.js +56 -0
  232. package/lib/utils/util.js +43 -1
  233. package/lib/wujie.js +1204 -1135
  234. package/package.json +5 -1
  235. package/packages/autocomplete/src/autocomplete.vue +88 -55
  236. package/packages/cascader/src/cascader.vue +166 -99
  237. package/packages/cascader-panel/src/node.js +31 -16
  238. package/packages/cascader-panel/src/store.js +26 -12
  239. package/packages/checkbox/src/checkbox-group.vue +93 -1
  240. package/packages/checkbox/src/checkbox.vue +4 -1
  241. package/packages/color-picker/src/color-picker.vue +279 -261
  242. package/packages/data-table/src/data-table.vue +104 -12
  243. package/packages/data-table/src/mixins/table-methods.js +118 -0
  244. package/packages/date-picker/src/picker.vue +17 -1
  245. package/packages/dialog/src/dialog.vue +2 -2
  246. package/packages/flow/src/component/Circulate.vue +59 -93
  247. package/packages/flow/src/component/CommonOpinions.vue +390 -0
  248. package/packages/flow/src/component/CustomPreset.vue +18 -25
  249. package/packages/flow/src/component/FileList.vue +11 -28
  250. package/packages/flow/src/component/FreeCirculation.vue +48 -59
  251. package/packages/flow/src/component/Preset.vue +10 -25
  252. package/packages/flow/src/component/SendMsg.vue +22 -71
  253. package/packages/flow/src/component/SortFlow.vue +115 -0
  254. package/packages/flow/src/component/TimeLimit.vue +20 -36
  255. package/packages/flow/src/component/opinions.vue +160 -108
  256. package/packages/flow/src/component/taskUnionExamine.vue +143 -145
  257. package/packages/flow/src/flow.vue +4598 -0
  258. package/packages/flow/src/form.vue +14 -20
  259. package/packages/flow/src/freeStartFlow.vue +196 -222
  260. package/packages/flow/src/main.vue +877 -618
  261. package/packages/flow/src/processForm.vue +789 -177
  262. package/packages/flow/src/processReject.vue +87 -83
  263. package/packages/flow/src/reset.vue +71 -70
  264. package/packages/flow/src/selectUser.vue +94 -85
  265. package/packages/flow/src/startTaskRead.vue +150 -156
  266. package/packages/flow/src/supervise.vue +44 -64
  267. package/packages/flow/src/table.vue +2 -10
  268. package/packages/flow-group/src/attachment.js +78 -0
  269. package/packages/flow-group/src/flow-item.vue +250 -0
  270. package/packages/flow-group/src/main.vue +151 -416
  271. package/packages/flow-list/index.js +5 -0
  272. package/packages/flow-list/src/main.vue +2432 -0
  273. package/packages/flowOld/index.js +7 -0
  274. package/packages/flowOld/src/component/Circulate.vue +464 -0
  275. package/packages/flowOld/src/component/CustomPreset.vue +343 -0
  276. package/packages/flowOld/src/component/FileList.vue +117 -0
  277. package/packages/flowOld/src/component/FreeCirculation.vue +278 -0
  278. package/packages/flowOld/src/component/Preset.vue +283 -0
  279. package/packages/flowOld/src/component/SendMsg.vue +309 -0
  280. package/packages/flowOld/src/component/TimeLimit.vue +223 -0
  281. package/packages/flowOld/src/component/opinions-file.vue +126 -0
  282. package/packages/flowOld/src/component/opinions.vue +429 -0
  283. package/packages/flowOld/src/component/taskUnionExamine.vue +832 -0
  284. package/packages/flowOld/src/form.vue +134 -0
  285. package/packages/flowOld/src/freeStartFlow.vue +2945 -0
  286. package/packages/flowOld/src/main.vue +4141 -0
  287. package/packages/flowOld/src/processForm.vue +1431 -0
  288. package/packages/flowOld/src/processReject.vue +338 -0
  289. package/packages/flowOld/src/reset.vue +964 -0
  290. package/packages/flowOld/src/selectUser.vue +520 -0
  291. package/packages/flowOld/src/startTaskRead.vue +737 -0
  292. package/packages/flowOld/src/supervise.vue +197 -0
  293. package/packages/flowOld/src/table.vue +71 -0
  294. package/packages/form/src/collapse.vue +40 -59
  295. package/packages/form/src/form-item-render.vue +117 -13
  296. package/packages/form/src/form-item.vue +121 -22
  297. package/packages/form/src/form.vue +62 -59
  298. package/packages/form/src/label-wrap.vue +5 -4
  299. package/packages/form/src/steps.vue +5 -8
  300. package/packages/form-editor/src/components.js +1077 -145
  301. package/packages/form-editor/src/form-editor.vue +94 -80
  302. package/packages/form-editor/src/props-panel.vue +59 -12
  303. package/packages/icons/src/icons.vue +91 -51
  304. package/packages/input/src/input.vue +787 -783
  305. package/packages/input-number/src/input-number.vue +58 -39
  306. package/packages/login/src/login.vue +9 -1
  307. package/packages/lowcode/src/util/components.js +64 -149
  308. package/packages/main/src/components/pages.vue +6 -42
  309. package/packages/main/src/minxs.js +26 -14
  310. package/packages/pagination/src/pagination.js +4 -4
  311. package/packages/phone-login/src/phone-login.vue +1 -4
  312. package/packages/process-rule/src/main.vue +10 -10
  313. package/packages/radio/src/radio-button.vue +10 -1
  314. package/packages/radio/src/radio-group.vue +110 -1
  315. package/packages/radio/src/radio.vue +32 -4
  316. package/packages/rate/src/rate.vue +49 -26
  317. package/packages/retrial-auth/src/main.vue +12 -12
  318. package/packages/select/src/option-group.vue +9 -1
  319. package/packages/select/src/option.vue +9 -1
  320. package/packages/select/src/select.vue +286 -224
  321. package/packages/selector/src/selector.vue +93 -85
  322. package/packages/selector-panel/src/mixin.js +0 -1
  323. package/packages/selector-panel/src/selection.vue +16 -8
  324. package/packages/selector-panel/src/selector-panel.vue +30 -19
  325. package/packages/slider/src/slider.vue +90 -64
  326. package/packages/steps/src/steps.vue +8 -6
  327. package/packages/switch/src/switch.vue +81 -56
  328. package/packages/table/src/store/index.js +3 -3
  329. package/packages/table/src/table.vue +69 -6
  330. package/packages/theme-chalk/src/autocomplete.scss +1 -1
  331. package/packages/theme-chalk/src/base.scss +16 -0
  332. package/packages/theme-chalk/src/cascader.scss +2 -0
  333. package/packages/theme-chalk/src/checkbox-group.scss +2 -0
  334. package/packages/theme-chalk/src/collapse.scss +2 -6
  335. package/packages/theme-chalk/src/common/var.scss +2 -2
  336. package/packages/theme-chalk/src/flow copy.scss +664 -0
  337. package/packages/theme-chalk/src/flow-group.scss +9 -14
  338. package/packages/theme-chalk/src/flow-list.scss +61 -0
  339. package/packages/theme-chalk/src/flow.scss +244 -360
  340. package/packages/theme-chalk/src/form-editor.scss +14 -5
  341. package/packages/theme-chalk/src/form.scss +26 -2
  342. package/packages/theme-chalk/src/icons.scss +30 -24
  343. package/packages/theme-chalk/src/index.scss +1 -0
  344. package/packages/theme-chalk/src/input.scss +6 -0
  345. package/packages/theme-chalk/src/radio-group.scss +3 -2
  346. package/packages/theme-chalk/src/retrial-auth.scss +3 -3
  347. package/packages/theme-chalk/src/selector.scss +14 -1
  348. package/packages/theme-chalk/src/switch.scss +1 -1
  349. package/packages/theme-chalk/src/tabs.scss +2 -5
  350. package/packages/toolbar/src/toolbar.vue +51 -18
  351. package/packages/transfer/src/transfer.vue +79 -40
  352. package/packages/upload/src/index.vue +1531 -1572
  353. package/packages/upload/src/upload.vue +0 -1
  354. package/src/components/field-render.vue +10 -7
  355. package/src/config/api.js +19 -0
  356. package/src/index.js +345 -342
  357. package/src/utils/label.js +53 -0
  358. package/src/utils/util.js +39 -0
package/lib/switch.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 269);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 273);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -91,348 +91,112 @@ module.exports =
91
91
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
92
92
 
93
93
  "use strict";
94
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return setStorage; });
95
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getStorage; });
96
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return removeStorage; });
97
- /* unused harmony export setCookie */
98
- /* unused harmony export getCookie */
99
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
100
-
101
- /**
102
- * setStorage
103
- * @desc:设置本地储存数据
104
- * @author huangbo
105
- * @date 2022年5月7日
106
- * @param {String|Object} [key] - 数据的名称或包含type、key、value的对象
107
- * @param {String} [value] - 数据的值(当第一个参数为字符串时使用)
108
- **/
109
- var setStorage = function setStorage(key, value) {
110
- // 解析参数,支持两种调用方式:setStorage(key, value) 和 setStorage({type, key, value})
111
- var type = void 0,
112
- finalKey = void 0,
113
- finalValue = void 0;
114
-
115
- if ((typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object' && key !== null) {
116
- // 对象调用方式:setStorage({type, key, value})
117
- type = key.type;
118
- finalKey = key.key;
119
- finalValue = key.value;
120
- } else {
121
- // 字符串调用方式:setStorage(key, value)
122
- type = getStorage('storageType');
123
- finalKey = key;
124
- finalValue = value;
125
- }
126
-
127
- // 使用默认存储类型如果未指定
128
- type = type || getStorage('storageType');
129
-
130
- // 获取存储对象
131
- var storage = type === 'localStorage' ? localStorage : sessionStorage;
132
-
133
- // 处理不同类型的key
134
- if (typeof finalKey === 'string') {
135
- // 单个字符串key
136
- var storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
137
- storage.setItem(finalKey, storedValue);
138
- if (finalKey === 'token') {
139
- setCookie('token', storedValue);
140
- }
141
- } else if (Array.isArray(finalKey)) {
142
- // 数组key,为多个key设置同一个value
143
- var _storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
144
- for (var i = 0; i < finalKey.length; i++) {
145
- storage.setItem(finalKey[i], _storedValue);
146
- if (finalKey[i] === 'token') {
147
- setCookie('token', _storedValue);
148
- }
149
- }
150
- } else if ((typeof finalKey === 'undefined' ? 'undefined' : _typeof(finalKey)) === 'object' && finalKey !== null) {
151
- // 对象key,对象的属性名称作为key,属性值作为value
152
- for (var k in finalKey) {
153
- if (Object.prototype.hasOwnProperty.call(finalKey, k)) {
154
- var _storedValue2 = _typeof(finalKey[k]) === 'object' ? JSON.stringify(finalKey[k]) : finalKey[k];
155
- storage.setItem(k, _storedValue2);
156
- if (k === 'token') {
157
- setCookie('token', _storedValue2);
158
- }
159
- }
160
- }
161
- }
162
- };
163
-
164
- /**
165
- * getStorage
166
- * @desc:获取本地储存数据
167
- * @author huangbo
168
- * @date 2022年5月7日
169
- * @param {String} [key] - 获取的名称
170
- **/
171
- var getStorage = function getStorage(key) {
172
- if (key) {
173
- var res = sessionStorage.getItem(key) || localStorage.getItem(key);
174
- if (!res && key === 'token') {
175
- res = getCookie('token');
176
- }
177
- if (key === 'host' && !res) {
178
- res = '';
179
- }
180
- return res;
181
- }
182
- var defaults = {};
183
- var token = sessionStorage.getItem('token') || localStorage.getItem('token') || getCookie('token');
184
- var ssId = sessionStorage.getItem('ssId') || localStorage.getItem('ssId') || getCookie('ssId');
185
-
186
- var deviceUnique = sessionStorage.getItem('deviceUnique') || localStorage.getItem('deviceUnique') || getCookie('deviceUnique');
187
- if (token) {
188
- defaults.Authorization = token;
189
- }
190
- if (ssId) {
191
- defaults.ssId = ssId;
192
- }
193
- if (deviceUnique) {
194
- defaults.deviceUnique = deviceUnique;
195
- }
196
- return defaults;
197
- };
198
-
199
- /**
200
- * removeStorage
201
- * @desc:删除本地储存数据
202
- * @author huangbo
203
- * @date 2022年5月7日
204
- * @param {String, Array} [key] - 获取的名称
205
- **/
206
- var removeStorage = function removeStorage(key) {
207
- if (Array.isArray(key)) {
208
- for (var i = 0; i < key.length; i++) {
209
- sessionStorage.removeItem(key[i]);
210
- localStorage.removeItem(key[i]);
211
- if (key[i] === 'token') {
212
- removeCookie('token');
213
- }
214
- }
215
- } else if (key) {
216
- sessionStorage.removeItem(key);
217
- localStorage.removeItem(key);
218
- if (key === 'token') {
219
- removeCookie('token');
220
- }
221
- } else {
222
- sessionStorage.clear();
223
- localStorage.clear();
224
- removeCookie('token');
225
- }
226
- };
227
-
228
- /**
229
- * setCookie
230
- * @desc 设置cookie
231
- * @author huangbo
232
- * @param {string} [name] cookie名称
233
- * @param {string} [value] cookie值
234
- * @param {boolean} [isSession] 是否是会话cookie
235
- **/
236
- var setCookie = function setCookie(name, value) {
237
- var isSession = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
238
- var time = arguments[3];
239
-
240
- try {
241
- var cookieParts = [encodeURIComponent(name) + '=' + encodeURIComponent(value), 'path=/' // 仅保留path设置,确保全站访问
242
- ];
243
- // 会话/持久Cookie设置
244
- if (!isSession) {
245
- if (/MSIE|Trident/.test(navigator.userAgent)) {
246
- // IE使用expires
247
- var date = new Date();
248
- date.setTime(date.getTime() + (time || 7 * 24 * 60 * 60 * 1000));
249
- cookieParts.push('expires=' + date.toUTCString());
250
- } else {
251
- // 其他浏览器使用max-age
252
- cookieParts.push('max-age=' + (time || 7 * 24 * 60 * 60));
253
- }
254
- }
255
- // 内核兼容处理
256
- if (/MSIE|Trident/.test(navigator.userAgent)) {
257
- // IE特殊处理:添加P3P协议头
258
- cookieParts.push('P3P=CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
259
- } else {
260
- // 现代浏览器设置
261
- cookieParts.push('samesite=lax');
262
- if (window.location.protocol === 'https:') {
263
- cookieParts.push('secure');
264
- }
265
- }
266
-
267
- // 设置Cookie
268
- document.cookie = cookieParts.join('; ');
269
- return true;
270
- } catch (e) {
271
- console.error('Cookie设置失败:', e);
272
- return false;
273
- }
274
- };
275
-
276
- /**
277
- * getCookie
278
- * @desc 获取cookie中指定名称的值
279
- * @author huangbo
280
- * @param {string} [name] cookie名称
281
- **/
282
- var getCookie = function getCookie(name) {
283
- var cookies = document.cookie.split(';');
284
- for (var _iterator = cookies, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
285
- var _ref;
286
-
287
- if (_isArray) {
288
- if (_i >= _iterator.length) break;
289
- _ref = _iterator[_i++];
290
- } else {
291
- _i = _iterator.next();
292
- if (_i.done) break;
293
- _ref = _i.value;
294
- }
295
-
296
- var cookie = _ref;
297
-
298
- var _cookie$trim$split = cookie.trim().split('='),
299
- cookieName = _cookie$trim$split[0],
300
- cookieValue = _cookie$trim$split[1];
301
-
302
- if (decodeURIComponent(cookieName) === name) {
303
- return decodeURIComponent(cookieValue);
304
- }
305
- }
306
- return null;
307
- };
308
-
309
- /**
310
- * removeCookie
311
- * @desc:删除cookie
312
- * @author huangbo
313
- * @date 2022年5月7日
314
- * @param {String, Array} [key] - 获取的名称
315
- **/
316
- var removeCookie = function removeCookie(key) {
317
- if (Array.isArray(key)) {
318
- for (var i = 0; i < key.length; i++) {
319
- document.cookie = encodeURIComponent(key[i]) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
320
- }
321
- } else {
322
- document.cookie = encodeURIComponent(key) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
323
- }
324
- };
325
-
326
- /***/ }),
327
-
328
- /***/ 1:
329
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
330
-
331
- "use strict";
332
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return noop; });
333
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return hasOwn; });
334
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return toObject; });
335
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return getValueByPath; });
336
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return getPropByPath; });
337
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return generateId; });
338
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return valueEquals; });
339
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return escapeRegexpString; });
94
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return noop; });
95
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return hasOwn; });
96
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return toObject; });
97
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return getValueByPath; });
98
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return getPropByPath; });
99
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return generateId; });
100
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bb", function() { return valueEquals; });
101
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return escapeRegexpString; });
340
102
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return arrayFindIndex; });
341
103
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return arrayFind; });
342
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return coerceTruthyValueToArray; });
343
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return isIE; });
344
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return isEdge; });
345
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return isFirefox; });
104
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return coerceTruthyValueToArray; });
105
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return isIE; });
106
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return isEdge; });
107
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return isFirefox; });
346
108
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return autoprefixer; });
347
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return kebabCase; });
109
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return kebabCase; });
348
110
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return capitalize; });
349
111
  /* unused harmony export looseEqual */
350
112
  /* unused harmony export arrayEquals */
351
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return isEqual; });
352
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return rafThrottle; });
113
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return isEqual; });
114
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return rafThrottle; });
353
115
  /* unused harmony export objToArray */
354
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return requestAnimationFrame; });
116
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return requestAnimationFrame; });
355
117
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return cancelAnimationFrame; });
356
118
  /* unused harmony export debounce */
357
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return throttle; });
119
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return throttle; });
358
120
  /* unused harmony export guid */
359
121
  /* unused harmony export uid */
360
122
  /* unused harmony export get */
361
123
  /* unused harmony export set */
362
- /* unused harmony export cloneDeep */
124
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return cloneDeep; });
363
125
  /* unused harmony export grouping */
364
126
  /* unused harmony export pager */
365
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return getWinTop; });
127
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return getWinTop; });
366
128
  /* unused harmony export getFileType */
367
129
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return arrUnique; });
368
130
  /* unused harmony export average */
369
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return formatFileSize; });
131
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return formatFileSize; });
370
132
  /* unused harmony export browser */
371
133
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return busEmit; });
372
134
  /* unused harmony export chunkToChinese */
373
135
  /* unused harmony export concatenate */
374
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return delUrlParam; });
136
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return delUrlParam; });
375
137
  /* unused harmony export domEval */
376
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return downloadFile; });
377
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return encode; });
378
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return decode; });
379
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return exclAttribute; });
138
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return downloadFile; });
139
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return encode; });
140
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return decode; });
141
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return exclAttribute; });
380
142
  /* unused harmony export exportXls */
381
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return extend; });
143
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return extend; });
382
144
  /* unused harmony export getObjectType */
383
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return getParams; });
145
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return getParams; });
384
146
  /* unused harmony export getScript */
385
147
  /* unused harmony export getStyle */
386
148
  /* unused harmony export getTypeName */
387
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return getTypePrefix; });
149
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return getTypePrefix; });
388
150
  /* unused harmony export getValues */
389
151
  /* unused harmony export getZoom */
390
152
  /* unused harmony export getLength */
391
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return timestampUrl; });
153
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return timestampUrl; });
392
154
  /* unused harmony export hasChars */
393
155
  /* unused harmony export identical */
394
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return indexOfObj; });
395
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return isEmpty; });
396
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return isExist; });
156
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return indexOfObj; });
157
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return isEmpty; });
158
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return isExist; });
397
159
  /* unused harmony export isFunction */
398
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return isObjectEqual; });
399
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return joinUrl; });
160
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return isObjectEqual; });
161
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return joinUrl; });
400
162
  /* unused harmony export getHorizontalMargin */
401
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return layoutWaterfall; });
163
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return layoutWaterfall; });
402
164
  /* unused harmony export loadJs */
403
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return loading; });
165
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return loading; });
404
166
  /* unused harmony export lowerCase */
405
167
  /* unused harmony export overbrim */
406
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return queryParams; });
168
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return queryParams; });
407
169
  /* unused harmony export receiveMessage */
408
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return renderIcon; });
170
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return renderIcon; });
409
171
  /* unused harmony export replenish */
410
172
  /* unused harmony export rmbToCapital */
411
173
  /* unused harmony export setScale */
412
174
  /* unused harmony export sendMessage */
413
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return setFavicon; });
175
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return setFavicon; });
414
176
  /* unused harmony export sum */
415
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return startWith; });
177
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return startWith; });
416
178
  /* unused harmony export takeLeft */
417
179
  /* unused harmony export takeRight */
418
180
  /* unused harmony export trimWhitespace */
419
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return toFixed; });
181
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return toFixed; });
420
182
  /* unused harmony export toFunction */
421
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return updateTheme; });
183
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return updateTheme; });
422
184
  /* unused harmony export upperType */
423
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return urlJoinParams; });
424
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return uuid; });
425
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return watermark; });
185
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return urlJoinParams; });
186
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return uuid; });
187
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "db", function() { return watermark; });
426
188
  /* unused harmony export winTopOpen */
427
189
  /* unused harmony export confirm */
428
- /* unused harmony export success */
429
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return error; });
430
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return warning; });
190
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return success; });
191
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return error; });
192
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cb", function() { return warning; });
193
+ /* unused harmony export base64 */
194
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return renderUrl; });
431
195
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
432
196
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
433
197
  /* harmony import */ var _color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
434
198
  /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
435
- /* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
199
+ /* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
436
200
  /* harmony import */ var _date__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
437
201
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
438
202
 
@@ -3282,10 +3046,290 @@ var warning = function warning(content, _callback3) {
3282
3046
  }
3283
3047
  return MessageBox.alert(content, '提示', config);
3284
3048
  };
3049
+ /**
3050
+ * @desc 基于 Unicode 的 base64 编码,兼容中文等非 Latin1 字符
3051
+ * @param {any} val 任意值,null/undefined 返回空串
3052
+ * @return {string}
3053
+ **/
3054
+ var base64 = function base64(val) {
3055
+ if (val === null || val === undefined) return '';
3056
+ try {
3057
+ return window.btoa(unescape(encodeURIComponent(String(val))));
3058
+ } catch (e) {
3059
+ return '';
3060
+ }
3061
+ };
3062
+
3063
+ /**
3064
+ * @desc URL 渲染,将 userInfo 中的值替换到 URL 中的占位符
3065
+ * @param {string} url 需要渲染的 URL
3066
+ * @param {object} userInfo 用户信息
3067
+ * @return {string}
3068
+ **/
3069
+ var renderUrl = function renderUrl(url) {
3070
+ var userInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3071
+
3072
+ if (!url || typeof url !== 'string') return url;
3073
+ // const userInfo = this.$main.userInfo || this.$main.userModel || {};
3074
+ Object.keys(userInfo).forEach(function (key) {
3075
+ var val = userInfo[key];
3076
+ if (val === null || val === undefined) return;
3077
+ var safeKey = escapeRegexpString(key);
3078
+ var rawVal = String(val);
3079
+ var b64Val = base64(rawVal);
3080
+ // {base64-xxx} 与 {xxx} 两种占位符都要替换;
3081
+ // 使用函数式 replacement,避免值中的 $& / $1 等被特殊解释
3082
+ url = url.replace(new RegExp('\\{base64-' + safeKey + '\\}', 'g'), function () {
3083
+ return b64Val;
3084
+ });
3085
+ url = url.replace(new RegExp('\\{' + safeKey + '\\}', 'g'), function () {
3086
+ return rawVal;
3087
+ });
3088
+ });
3089
+ return url;
3090
+ };
3285
3091
 
3286
3092
  /***/ }),
3287
3093
 
3288
- /***/ 12:
3094
+ /***/ 1:
3095
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3096
+
3097
+ "use strict";
3098
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return setStorage; });
3099
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getStorage; });
3100
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return removeStorage; });
3101
+ /* unused harmony export setCookie */
3102
+ /* unused harmony export getCookie */
3103
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
3104
+
3105
+ /**
3106
+ * setStorage
3107
+ * @desc:设置本地储存数据
3108
+ * @author huangbo
3109
+ * @date 2022年5月7日
3110
+ * @param {String|Object} [key] - 数据的名称或包含type、key、value的对象
3111
+ * @param {String} [value] - 数据的值(当第一个参数为字符串时使用)
3112
+ **/
3113
+ var setStorage = function setStorage(key, value) {
3114
+ // 解析参数,支持两种调用方式:setStorage(key, value) 和 setStorage({type, key, value})
3115
+ var type = void 0,
3116
+ finalKey = void 0,
3117
+ finalValue = void 0;
3118
+
3119
+ if ((typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object' && key !== null) {
3120
+ // 对象调用方式:setStorage({type, key, value})
3121
+ type = key.type;
3122
+ finalKey = key.key;
3123
+ finalValue = key.value;
3124
+ } else {
3125
+ // 字符串调用方式:setStorage(key, value)
3126
+ type = getStorage('storageType');
3127
+ finalKey = key;
3128
+ finalValue = value;
3129
+ }
3130
+
3131
+ // 使用默认存储类型如果未指定
3132
+ type = type || getStorage('storageType');
3133
+
3134
+ // 获取存储对象
3135
+ var storage = type === 'localStorage' ? localStorage : sessionStorage;
3136
+
3137
+ // 处理不同类型的key
3138
+ if (typeof finalKey === 'string') {
3139
+ // 单个字符串key
3140
+ var storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
3141
+ storage.setItem(finalKey, storedValue);
3142
+ if (finalKey === 'token') {
3143
+ setCookie('token', storedValue);
3144
+ }
3145
+ } else if (Array.isArray(finalKey)) {
3146
+ // 数组key,为多个key设置同一个value
3147
+ var _storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
3148
+ for (var i = 0; i < finalKey.length; i++) {
3149
+ storage.setItem(finalKey[i], _storedValue);
3150
+ if (finalKey[i] === 'token') {
3151
+ setCookie('token', _storedValue);
3152
+ }
3153
+ }
3154
+ } else if ((typeof finalKey === 'undefined' ? 'undefined' : _typeof(finalKey)) === 'object' && finalKey !== null) {
3155
+ // 对象key,对象的属性名称作为key,属性值作为value
3156
+ for (var k in finalKey) {
3157
+ if (Object.prototype.hasOwnProperty.call(finalKey, k)) {
3158
+ var _storedValue2 = _typeof(finalKey[k]) === 'object' ? JSON.stringify(finalKey[k]) : finalKey[k];
3159
+ storage.setItem(k, _storedValue2);
3160
+ if (k === 'token') {
3161
+ setCookie('token', _storedValue2);
3162
+ }
3163
+ }
3164
+ }
3165
+ }
3166
+ };
3167
+
3168
+ /**
3169
+ * getStorage
3170
+ * @desc:获取本地储存数据
3171
+ * @author huangbo
3172
+ * @date 2022年5月7日
3173
+ * @param {String} [key] - 获取的名称
3174
+ **/
3175
+ var getStorage = function getStorage(key) {
3176
+ if (key) {
3177
+ var res = sessionStorage.getItem(key) || localStorage.getItem(key);
3178
+ if (!res && key === 'token') {
3179
+ res = getCookie('token');
3180
+ }
3181
+ if (key === 'host' && !res) {
3182
+ res = '';
3183
+ }
3184
+ return res;
3185
+ }
3186
+ var defaults = {};
3187
+ var token = sessionStorage.getItem('token') || localStorage.getItem('token') || getCookie('token');
3188
+ var ssId = sessionStorage.getItem('ssId') || localStorage.getItem('ssId') || getCookie('ssId');
3189
+
3190
+ var deviceUnique = sessionStorage.getItem('deviceUnique') || localStorage.getItem('deviceUnique') || getCookie('deviceUnique');
3191
+ if (token) {
3192
+ defaults.Authorization = token;
3193
+ }
3194
+ if (ssId) {
3195
+ defaults.ssId = ssId;
3196
+ }
3197
+ if (deviceUnique) {
3198
+ defaults.deviceUnique = deviceUnique;
3199
+ }
3200
+ return defaults;
3201
+ };
3202
+
3203
+ /**
3204
+ * removeStorage
3205
+ * @desc:删除本地储存数据
3206
+ * @author huangbo
3207
+ * @date 2022年5月7日
3208
+ * @param {String, Array} [key] - 获取的名称
3209
+ **/
3210
+ var removeStorage = function removeStorage(key) {
3211
+ if (Array.isArray(key)) {
3212
+ for (var i = 0; i < key.length; i++) {
3213
+ sessionStorage.removeItem(key[i]);
3214
+ localStorage.removeItem(key[i]);
3215
+ if (key[i] === 'token') {
3216
+ removeCookie('token');
3217
+ }
3218
+ }
3219
+ } else if (key) {
3220
+ sessionStorage.removeItem(key);
3221
+ localStorage.removeItem(key);
3222
+ if (key === 'token') {
3223
+ removeCookie('token');
3224
+ }
3225
+ } else {
3226
+ sessionStorage.clear();
3227
+ localStorage.clear();
3228
+ removeCookie('token');
3229
+ }
3230
+ };
3231
+
3232
+ /**
3233
+ * setCookie
3234
+ * @desc 设置cookie
3235
+ * @author huangbo
3236
+ * @param {string} [name] cookie名称
3237
+ * @param {string} [value] cookie值
3238
+ * @param {boolean} [isSession] 是否是会话cookie
3239
+ **/
3240
+ var setCookie = function setCookie(name, value) {
3241
+ var isSession = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3242
+ var time = arguments[3];
3243
+
3244
+ try {
3245
+ var cookieParts = [encodeURIComponent(name) + '=' + encodeURIComponent(value), 'path=/' // 仅保留path设置,确保全站访问
3246
+ ];
3247
+ // 会话/持久Cookie设置
3248
+ if (!isSession) {
3249
+ if (/MSIE|Trident/.test(navigator.userAgent)) {
3250
+ // IE使用expires
3251
+ var date = new Date();
3252
+ date.setTime(date.getTime() + (time || 7 * 24 * 60 * 60 * 1000));
3253
+ cookieParts.push('expires=' + date.toUTCString());
3254
+ } else {
3255
+ // 其他浏览器使用max-age
3256
+ cookieParts.push('max-age=' + (time || 7 * 24 * 60 * 60));
3257
+ }
3258
+ }
3259
+ // 内核兼容处理
3260
+ if (/MSIE|Trident/.test(navigator.userAgent)) {
3261
+ // IE特殊处理:添加P3P协议头
3262
+ cookieParts.push('P3P=CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
3263
+ } else {
3264
+ // 现代浏览器设置
3265
+ cookieParts.push('samesite=lax');
3266
+ if (window.location.protocol === 'https:') {
3267
+ cookieParts.push('secure');
3268
+ }
3269
+ }
3270
+
3271
+ // 设置Cookie
3272
+ document.cookie = cookieParts.join('; ');
3273
+ return true;
3274
+ } catch (e) {
3275
+ console.error('Cookie设置失败:', e);
3276
+ return false;
3277
+ }
3278
+ };
3279
+
3280
+ /**
3281
+ * getCookie
3282
+ * @desc 获取cookie中指定名称的值
3283
+ * @author huangbo
3284
+ * @param {string} [name] cookie名称
3285
+ **/
3286
+ var getCookie = function getCookie(name) {
3287
+ var cookies = document.cookie.split(';');
3288
+ for (var _iterator = cookies, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
3289
+ var _ref;
3290
+
3291
+ if (_isArray) {
3292
+ if (_i >= _iterator.length) break;
3293
+ _ref = _iterator[_i++];
3294
+ } else {
3295
+ _i = _iterator.next();
3296
+ if (_i.done) break;
3297
+ _ref = _i.value;
3298
+ }
3299
+
3300
+ var cookie = _ref;
3301
+
3302
+ var _cookie$trim$split = cookie.trim().split('='),
3303
+ cookieName = _cookie$trim$split[0],
3304
+ cookieValue = _cookie$trim$split[1];
3305
+
3306
+ if (decodeURIComponent(cookieName) === name) {
3307
+ return decodeURIComponent(cookieValue);
3308
+ }
3309
+ }
3310
+ return null;
3311
+ };
3312
+
3313
+ /**
3314
+ * removeCookie
3315
+ * @desc:删除cookie
3316
+ * @author huangbo
3317
+ * @date 2022年5月7日
3318
+ * @param {String, Array} [key] - 获取的名称
3319
+ **/
3320
+ var removeCookie = function removeCookie(key) {
3321
+ if (Array.isArray(key)) {
3322
+ for (var i = 0; i < key.length; i++) {
3323
+ document.cookie = encodeURIComponent(key[i]) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
3324
+ }
3325
+ } else {
3326
+ document.cookie = encodeURIComponent(key) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
3327
+ }
3328
+ };
3329
+
3330
+ /***/ }),
3331
+
3332
+ /***/ 12:
3289
3333
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3290
3334
 
3291
3335
  "use strict";
@@ -3297,7 +3341,7 @@ var warning = function warning(content, _callback3) {
3297
3341
  /* unused harmony export hsvTorgb */
3298
3342
  /* unused harmony export mixColor */
3299
3343
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getRgb; });
3300
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
3344
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
3301
3345
 
3302
3346
  var $hueStep = 2;
3303
3347
  var $saturationStep1 = 0.16;
@@ -3348,7 +3392,7 @@ var getColor = function getColor($color, $n) {
3348
3392
  var getLightness = function getLightness($v, $i, $isLight) {
3349
3393
  var $value = $isLight ? $v + $brightnessStep1 * $i : $v - $brightnessStep2 * $i;
3350
3394
  $value = $value < 1 ? $value : 1;
3351
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($value, 2);
3395
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($value, 2);
3352
3396
  };
3353
3397
 
3354
3398
  /**
@@ -3372,7 +3416,7 @@ var getSaturation = function getSaturation($s, $i, $isLight) {
3372
3416
  $saturation = 0.1;
3373
3417
  }
3374
3418
  $saturation = $saturation > 0.06 ? $saturation : 0.06;
3375
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($saturation, 2);
3419
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($saturation, 2);
3376
3420
  };
3377
3421
 
3378
3422
  /**
@@ -3561,14 +3605,14 @@ module.exports = require("vue");
3561
3605
 
3562
3606
  /***/ }),
3563
3607
 
3564
- /***/ 269:
3608
+ /***/ 273:
3565
3609
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3566
3610
 
3567
3611
  "use strict";
3568
3612
  // ESM COMPAT FLAG
3569
3613
  __webpack_require__.r(__webpack_exports__);
3570
3614
 
3571
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/switch/src/switch.vue?vue&type=template&id=7199ffc0&
3615
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/switch/src/switch.vue?vue&type=template&id=9d50ec44&
3572
3616
  var render = function () {
3573
3617
  var _vm = this
3574
3618
  var _h = _vm.$createElement
@@ -3583,94 +3627,118 @@ var render = function () {
3583
3627
  "aria-checked": _vm.checked,
3584
3628
  "aria-disabled": _vm.switchDisabled,
3585
3629
  },
3586
- on: {
3587
- click: function ($event) {
3588
- $event.preventDefault()
3589
- return _vm.switchValue.apply(null, arguments)
3590
- },
3591
- },
3592
3630
  },
3593
3631
  [
3594
- _c("input", {
3595
- ref: "input",
3596
- staticClass: "es-switch__input",
3597
- attrs: {
3598
- type: "checkbox",
3599
- tabindex: "-1",
3600
- id: _vm.id,
3601
- name: _vm.name,
3602
- "true-value": _vm.activeValue,
3603
- "false-value": _vm.inactiveValue,
3604
- disabled: _vm.switchDisabled,
3605
- },
3606
- on: {
3607
- change: _vm.handleChange,
3608
- keydown: function ($event) {
3609
- if (
3610
- !$event.type.indexOf("key") &&
3611
- _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")
3612
- ) {
3613
- return null
3614
- }
3615
- return _vm.switchValue.apply(null, arguments)
3616
- },
3617
- },
3618
- }),
3619
- (_vm.inactiveIconClass || _vm._inactiveText) && !_vm.inlay
3620
- ? _c(
3621
- "span",
3622
- {
3623
- class: [
3624
- "es-switch__label",
3625
- "es-switch__label--left",
3626
- !_vm.checked ? "is-active" : "",
3627
- ],
3628
- },
3629
- [
3630
- _vm.inactiveIconClass
3631
- ? _c("i", { class: [_vm.inactiveIconClass] })
3632
- : _vm._e(),
3633
- !_vm.inactiveIconClass && _vm._inactiveText
3634
- ? _c("span", { attrs: { "aria-hidden": _vm.checked } }, [
3635
- _vm._v(_vm._s(_vm._inactiveText)),
3636
- ])
3637
- : _vm._e(),
3638
- ]
3639
- )
3632
+ _vm.formReadonly
3633
+ ? _c("div", { staticClass: "es-field-readonly" }, [
3634
+ _vm._v("\n " + _vm._s(_vm.readonlyText) + "\n "),
3635
+ ])
3640
3636
  : _vm._e(),
3641
- _vm.inlay
3642
- ? _c(
3643
- "span",
3644
- {
3645
- ref: "core",
3646
- staticClass: "es-switch__core is-inlay",
3647
- staticStyle: { width: "auto" },
3648
- },
3649
- [_vm._v(_vm._s(_vm.checked ? _vm._activeText : _vm._inactiveText))]
3650
- )
3651
- : _c("span", {
3652
- ref: "core",
3653
- staticClass: "es-switch__core",
3654
- style: { width: _vm.coreWidth + "px" },
3655
- }),
3656
- (_vm.activeIconClass || _vm._activeText) && !_vm.inlay
3637
+ !_vm.formReadonly
3657
3638
  ? _c(
3658
3639
  "span",
3659
3640
  {
3660
- class: [
3661
- "es-switch__label",
3662
- "es-switch__label--right",
3663
- _vm.checked ? "is-active" : "",
3664
- ],
3641
+ on: {
3642
+ click: function ($event) {
3643
+ $event.preventDefault()
3644
+ return _vm.switchValue.apply(null, arguments)
3645
+ },
3646
+ },
3665
3647
  },
3666
3648
  [
3667
- _vm.activeIconClass
3668
- ? _c("i", { class: [_vm.activeIconClass] })
3649
+ _c("input", {
3650
+ ref: "input",
3651
+ staticClass: "es-switch__input",
3652
+ attrs: {
3653
+ type: "checkbox",
3654
+ tabindex: "-1",
3655
+ id: _vm.id,
3656
+ name: _vm.name,
3657
+ "true-value": _vm.activeValue,
3658
+ "false-value": _vm.inactiveValue,
3659
+ disabled: _vm.switchDisabled,
3660
+ },
3661
+ on: {
3662
+ change: _vm.handleChange,
3663
+ keydown: function ($event) {
3664
+ if (
3665
+ !$event.type.indexOf("key") &&
3666
+ _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")
3667
+ ) {
3668
+ return null
3669
+ }
3670
+ return _vm.switchValue.apply(null, arguments)
3671
+ },
3672
+ },
3673
+ }),
3674
+ (_vm.inactiveIconClass || _vm._inactiveText) && !_vm.inlay
3675
+ ? _c(
3676
+ "span",
3677
+ {
3678
+ class: [
3679
+ "es-switch__label",
3680
+ "es-switch__label--left",
3681
+ !_vm.checked ? "is-active" : "",
3682
+ ],
3683
+ },
3684
+ [
3685
+ _vm.inactiveIconClass
3686
+ ? _c("i", { class: [_vm.inactiveIconClass] })
3687
+ : _vm._e(),
3688
+ !_vm.inactiveIconClass && _vm._inactiveText
3689
+ ? _c(
3690
+ "span",
3691
+ { attrs: { "aria-hidden": _vm.checked } },
3692
+ [_vm._v(_vm._s(_vm._inactiveText))]
3693
+ )
3694
+ : _vm._e(),
3695
+ ]
3696
+ )
3669
3697
  : _vm._e(),
3670
- !_vm.activeIconClass && _vm._activeText
3671
- ? _c("span", { attrs: { "aria-hidden": !_vm.checked } }, [
3672
- _vm._v(_vm._s(_vm._activeText)),
3673
- ])
3698
+ _vm.inlay
3699
+ ? _c(
3700
+ "span",
3701
+ {
3702
+ ref: "core",
3703
+ staticClass: "es-switch__core is-inlay",
3704
+ staticStyle: { width: "auto" },
3705
+ },
3706
+ [
3707
+ _vm._v(
3708
+ _vm._s(
3709
+ _vm.checked ? _vm._activeText : _vm._inactiveText
3710
+ )
3711
+ ),
3712
+ ]
3713
+ )
3714
+ : _c("span", {
3715
+ ref: "core",
3716
+ staticClass: "es-switch__core",
3717
+ style: { width: _vm.coreWidth + "px" },
3718
+ }),
3719
+ (_vm.activeIconClass || _vm._activeText) && !_vm.inlay
3720
+ ? _c(
3721
+ "span",
3722
+ {
3723
+ class: [
3724
+ "es-switch__label",
3725
+ "es-switch__label--right",
3726
+ _vm.checked ? "is-active" : "",
3727
+ ],
3728
+ },
3729
+ [
3730
+ _vm.activeIconClass
3731
+ ? _c("i", { class: [_vm.activeIconClass] })
3732
+ : _vm._e(),
3733
+ !_vm.activeIconClass && _vm._activeText
3734
+ ? _c(
3735
+ "span",
3736
+ { attrs: { "aria-hidden": !_vm.checked } },
3737
+ [_vm._v(_vm._s(_vm._activeText))]
3738
+ )
3739
+ : _vm._e(),
3740
+ ]
3741
+ )
3674
3742
  : _vm._e(),
3675
3743
  ]
3676
3744
  )
@@ -3682,13 +3750,13 @@ var staticRenderFns = []
3682
3750
  render._withStripped = true
3683
3751
 
3684
3752
 
3685
- // CONCATENATED MODULE: ./packages/switch/src/switch.vue?vue&type=template&id=7199ffc0&
3753
+ // CONCATENATED MODULE: ./packages/switch/src/switch.vue?vue&type=template&id=9d50ec44&
3686
3754
 
3687
3755
  // EXTERNAL MODULE: ./src/mixins/emitter.js
3688
3756
  var emitter = __webpack_require__(15);
3689
3757
 
3690
3758
  // EXTERNAL MODULE: ./src/mixins/focus.js
3691
- var mixins_focus = __webpack_require__(89);
3759
+ var mixins_focus = __webpack_require__(91);
3692
3760
 
3693
3761
  // EXTERNAL MODULE: ./src/mixins/migrating.js
3694
3762
  var migrating = __webpack_require__(46);
@@ -3757,11 +3825,17 @@ var migrating = __webpack_require__(46);
3757
3825
  //
3758
3826
  //
3759
3827
  //
3828
+ //
3829
+ //
3830
+ //
3831
+ //
3832
+ //
3833
+ //
3834
+
3835
+
3760
3836
 
3761
3837
 
3762
3838
 
3763
-
3764
-
3765
3839
  /**
3766
3840
  * Switch 开关组件
3767
3841
  * @description 表示两种相互对立的状态间的切换,多用于触发「开/关」
@@ -3823,6 +3897,15 @@ var migrating = __webpack_require__(46);
3823
3897
  type: Boolean,
3824
3898
  default: false
3825
3899
  },
3900
+ /**
3901
+ * 是否只读(渲染为只读文本,区别于 disabled 的禁用控件)
3902
+ * @type {Boolean}
3903
+ * @default false
3904
+ */
3905
+ readonly: {
3906
+ type: Boolean,
3907
+ default: false
3908
+ },
3826
3909
  /**
3827
3910
  * switch 的宽度(像素)
3828
3911
  * @type {Number}
@@ -3968,6 +4051,18 @@ var migrating = __webpack_require__(46);
3968
4051
  checked: function checked() {
3969
4052
  return this.strict ? this.value === this.activeValue : this.value == this.activeValue; //eslint-disable-line
3970
4053
  },
4054
+
4055
+ // 只读态:控件自身 readonly prop(field-render 原样下传)或 es-form readonly
4056
+ formReadonly: function formReadonly() {
4057
+ return this.readonly || !!(this.esForm || {}).readonly;
4058
+ },
4059
+
4060
+ // 只读态展示文本:优先开/关文案,否则回退到对应值
4061
+ readonlyText: function readonlyText() {
4062
+ var text = this.checked ? this._activeText : this._inactiveText;
4063
+ if (text !== undefined && text !== null && text !== '') return text;
4064
+ return this.checked ? this.activeValue : this.inactiveValue;
4065
+ },
3971
4066
  switchDisabled: function switchDisabled() {
3972
4067
  return this.disabled || (this.esForm || {}).disabled;
3973
4068
  }
@@ -4014,7 +4109,7 @@ var migrating = __webpack_require__(46);
4014
4109
  * 切换开关值
4015
4110
  */
4016
4111
  switchValue: function switchValue() {
4017
- !this.switchDisabled && this.handleChange();
4112
+ !this.switchDisabled && !this.formReadonly && this.handleChange();
4018
4113
  },
4019
4114
 
4020
4115
  /**
@@ -4257,7 +4352,7 @@ function normalizeComponent(
4257
4352
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4258
4353
 
4259
4354
  "use strict";
4260
- /* harmony import */ var eoss_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
4355
+ /* harmony import */ var eoss_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
4261
4356
 
4262
4357
  /**
4263
4358
  * Show migrating guide in browser console.
@@ -4299,14 +4394,14 @@ function normalizeComponent(
4299
4394
  var definedEvents = componentOptions.listeners || {};
4300
4395
 
4301
4396
  for (var propName in definedProps) {
4302
- propName = Object(eoss_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* kebabCase */ "H"])(propName); // compatible with camel case
4397
+ propName = Object(eoss_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* kebabCase */ "I"])(propName); // compatible with camel case
4303
4398
  if (props[propName]) {
4304
4399
  console.warn('[Eoss Migrating][' + this.$options.name + '][Attribute]: ' + props[propName]);
4305
4400
  }
4306
4401
  }
4307
4402
 
4308
4403
  for (var eventName in definedEvents) {
4309
- eventName = Object(eoss_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* kebabCase */ "H"])(eventName); // compatible with camel case
4404
+ eventName = Object(eoss_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* kebabCase */ "I"])(eventName); // compatible with camel case
4310
4405
  if (events[eventName]) {
4311
4406
  console.warn('[Eoss Migrating][' + this.$options.name + '][Event]: ' + events[eventName]);
4312
4407
  }
@@ -4375,736 +4470,759 @@ function normalizeComponent(
4375
4470
  /* unused harmony export getSecond */
4376
4471
  /* unused harmony export getWeekday */
4377
4472
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4378
-
4379
-
4473
+ /* Modified from https://github.com/taylorhakes/fecha
4474
+ *
4475
+ * The MIT License (MIT)
4476
+ *
4477
+ * Copyright (c) 2015 Taylor Hakes
4478
+ *
4479
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4480
+ * of this software and associated documentation files (the "Software"), to deal
4481
+ * in the Software without restriction, including without limitation the rights
4482
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4483
+ * copies of the Software, and to permit persons to whom the Software is
4484
+ * furnished to do so, subject to the following conditions:
4485
+ *
4486
+ * The above copyright notice and this permission notice shall be included in all
4487
+ * copies or substantial portions of the Software.
4488
+ *
4489
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4490
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4491
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4492
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4493
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4494
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4495
+ * SOFTWARE.
4496
+ */
4497
+
4498
+ /*eslint-disable*/
4499
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
4500
+
4501
+
4380
4502
  /**
4381
4503
  * Parse or format dates
4382
4504
  * @class fecha
4383
- */
4384
- var fecha = {};
4385
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4386
- var twoDigits = '\\d\\d?';
4387
- var threeDigits = '\\d{3}';
4388
- var fourDigits = '\\d{4}';
4389
- var word = '[^\\s]+';
4390
- var literal = /\[([^]*?)\]/gm;
4391
- var noop = function noop() {};
4392
-
4393
- function regexEscape(str) {
4394
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4395
- }
4396
-
4397
- function shorten(arr, sLen) {
4398
- var newArr = [];
4399
- for (var i = 0, len = arr.length; i < len; i++) {
4400
- newArr.push(arr[i].substr(0, sLen));
4401
- }
4402
- return newArr;
4403
- }
4404
-
4405
- function monthUpdate() {
4406
- return function (d, v) {
4407
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4408
- if (~index) {
4409
- d.month = index;
4410
- }
4411
- };
4412
- }
4413
-
4414
- function pad(val, len) {
4415
- val = String(val);
4416
- len = len || 2;
4417
- while (val.length < len) {
4418
- val = '0' + val;
4419
- }
4420
- return val;
4421
- }
4422
-
4423
- // 直接使用中文日期名称常量
4424
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4425
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4426
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4427
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4428
- var amPm = ['上午', '下午'];
4429
- var DoFn = function DoFn(D) {
4430
- return D + '日';
4431
- };
4432
-
4433
- var formatFlags = {
4434
- D: function D(dateObj) {
4435
- return dateObj.getDay();
4436
- },
4437
- DD: function DD(dateObj) {
4438
- return pad(dateObj.getDay());
4439
- },
4440
- Do: function Do(dateObj) {
4441
- return DoFn(dateObj.getDate());
4442
- },
4443
- d: function d(dateObj) {
4444
- return dateObj.getDate();
4445
- },
4446
- dd: function dd(dateObj) {
4447
- return pad(dateObj.getDate());
4448
- },
4449
- ddd: function ddd(dateObj) {
4450
- return dayNamesShort[dateObj.getDay()];
4451
- },
4452
- dddd: function dddd(dateObj) {
4453
- return dayNames[dateObj.getDay()];
4454
- },
4455
- M: function M(dateObj) {
4456
- return dateObj.getMonth() + 1;
4457
- },
4458
- MM: function MM(dateObj) {
4459
- return pad(dateObj.getMonth() + 1);
4460
- },
4461
- MMM: function MMM(dateObj) {
4462
- return monthNamesShort[dateObj.getMonth()];
4463
- },
4464
- MMMM: function MMMM(dateObj) {
4465
- return monthNames[dateObj.getMonth()];
4466
- },
4467
- yy: function yy(dateObj) {
4468
- return pad(String(dateObj.getFullYear()), 4).substr(2);
4469
- },
4470
- yyyy: function yyyy(dateObj) {
4471
- return pad(dateObj.getFullYear(), 4);
4472
- },
4473
- h: function h(dateObj) {
4474
- return dateObj.getHours() % 12 || 12;
4475
- },
4476
- hh: function hh(dateObj) {
4477
- return pad(dateObj.getHours() % 12 || 12);
4478
- },
4479
- H: function H(dateObj) {
4480
- return dateObj.getHours();
4481
- },
4482
- HH: function HH(dateObj) {
4483
- return pad(dateObj.getHours());
4484
- },
4485
- m: function m(dateObj) {
4486
- return dateObj.getMinutes();
4487
- },
4488
- mm: function mm(dateObj) {
4489
- return pad(dateObj.getMinutes());
4490
- },
4491
- s: function s(dateObj) {
4492
- return dateObj.getSeconds();
4493
- },
4494
- ss: function ss(dateObj) {
4495
- return pad(dateObj.getSeconds());
4496
- },
4497
- S: function S(dateObj) {
4498
- return Math.round(dateObj.getMilliseconds() / 100);
4499
- },
4500
- SS: function SS(dateObj) {
4501
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4502
- },
4503
- SSS: function SSS(dateObj) {
4504
- return pad(dateObj.getMilliseconds(), 3);
4505
- },
4506
- a: function a(dateObj) {
4507
- return dateObj.getHours() < 12 ? '上午' : '下午';
4508
- },
4509
- A: function A(dateObj) {
4510
- return dateObj.getHours() < 12 ? '上午' : '下午';
4511
- },
4512
- ZZ: function ZZ(dateObj) {
4513
- var o = dateObj.getTimezoneOffset();
4514
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4515
- }
4516
- };
4517
-
4518
- var parseFlags = {
4519
- d: [twoDigits, function (d, v) {
4520
- d.day = v;
4521
- }],
4522
- Do: [twoDigits + word, function (d, v) {
4523
- d.day = parseInt(v, 10);
4524
- }],
4525
- M: [twoDigits, function (d, v) {
4526
- d.month = v - 1;
4527
- }],
4528
- yy: [twoDigits, function (d, v) {
4529
- var da = new Date(),
4530
- cent = +('' + da.getFullYear()).substr(0, 2);
4531
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4532
- }],
4533
- h: [twoDigits, function (d, v) {
4534
- d.hour = v;
4535
- }],
4536
- m: [twoDigits, function (d, v) {
4537
- d.minute = v;
4538
- }],
4539
- s: [twoDigits, function (d, v) {
4540
- d.second = v;
4541
- }],
4542
- yyyy: [fourDigits, function (d, v) {
4543
- d.year = v;
4544
- }],
4545
- S: ['\\d', function (d, v) {
4546
- d.millisecond = v * 100;
4547
- }],
4548
- SS: ['\\d{2}', function (d, v) {
4549
- d.millisecond = v * 10;
4550
- }],
4551
- SSS: [threeDigits, function (d, v) {
4552
- d.millisecond = v;
4553
- }],
4554
- D: [twoDigits, noop],
4555
- ddd: [word, noop],
4556
- MMM: [word, monthUpdate('monthNamesShort')],
4557
- MMMM: [word, monthUpdate('monthNames')],
4558
- a: [word, function (d, v) {
4559
- var val = v.toLowerCase();
4560
- if (val === '上午') {
4561
- d.isPm = false;
4562
- } else if (val === '下午') {
4563
- d.isPm = true;
4564
- }
4565
- }],
4566
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4567
- var parts = (v + '').match(/([+-]|\d\d)/gi),
4568
- minutes = void 0;
4569
-
4570
- if (parts) {
4571
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4572
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4573
- }
4574
- }]
4575
- };
4576
- parseFlags.dd = parseFlags.d;
4577
- parseFlags.dddd = parseFlags.ddd;
4578
- parseFlags.DD = parseFlags.D;
4579
- parseFlags.mm = parseFlags.m;
4580
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4581
- parseFlags.MM = parseFlags.M;
4582
- parseFlags.ss = parseFlags.s;
4583
- parseFlags.A = parseFlags.a;
4584
-
4585
- // Some common format strings
4586
- fecha.masks = {
4587
- default: 'ddd MMM dd yyyy HH:mm:ss',
4588
- shortDate: 'M/D/yy',
4589
- mediumDate: 'MMM d, yyyy',
4590
- longDate: 'MMMM d, yyyy',
4591
- fullDate: 'dddd, MMMM d, yyyy',
4592
- shortTime: 'HH:mm',
4593
- mediumTime: 'HH:mm:ss',
4594
- longTime: 'HH:mm:ss.SSS'
4595
- };
4596
-
4505
+ */
4506
+ const fecha = {};
4507
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4508
+ const twoDigits = '\\d\\d?';
4509
+ const threeDigits = '\\d{3}';
4510
+ const fourDigits = '\\d{4}';
4511
+ const word = '[^\\s]+';
4512
+ const literal = /\[([^]*?)\]/gm;
4513
+ const noop = function () {};
4514
+
4515
+ function regexEscape(str) {
4516
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4517
+ }
4518
+
4519
+ function shorten(arr, sLen) {
4520
+ const newArr = [];
4521
+ for (let i = 0, len = arr.length; i < len; i++) {
4522
+ newArr.push(arr[i].substr(0, sLen));
4523
+ }
4524
+ return newArr;
4525
+ }
4526
+
4527
+ function monthUpdate() {
4528
+ return function (d, v) {
4529
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4530
+ if (~index) {
4531
+ d.month = index;
4532
+ }
4533
+ };
4534
+ }
4535
+
4536
+ function pad(val, len) {
4537
+ val = String(val);
4538
+ len = len || 2;
4539
+ while (val.length < len) {
4540
+ val = '0' + val;
4541
+ }
4542
+ return val;
4543
+ }
4544
+
4545
+ // 直接使用中文日期名称常量
4546
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4547
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4548
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4549
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4550
+ const amPm = ['上午', '下午'];
4551
+ const DoFn = function DoFn(D) {
4552
+ return D + '日';
4553
+ };
4554
+
4555
+ const formatFlags = {
4556
+ D: function(dateObj) {
4557
+ return dateObj.getDay();
4558
+ },
4559
+ DD: function(dateObj) {
4560
+ return pad(dateObj.getDay());
4561
+ },
4562
+ Do: function(dateObj) {
4563
+ return DoFn(dateObj.getDate());
4564
+ },
4565
+ d: function(dateObj) {
4566
+ return dateObj.getDate();
4567
+ },
4568
+ dd: function(dateObj) {
4569
+ return pad(dateObj.getDate());
4570
+ },
4571
+ ddd: function(dateObj) {
4572
+ return dayNamesShort[dateObj.getDay()];
4573
+ },
4574
+ dddd: function(dateObj) {
4575
+ return dayNames[dateObj.getDay()];
4576
+ },
4577
+ M: function(dateObj) {
4578
+ return dateObj.getMonth() + 1;
4579
+ },
4580
+ MM: function(dateObj) {
4581
+ return pad(dateObj.getMonth() + 1);
4582
+ },
4583
+ MMM: function(dateObj) {
4584
+ return monthNamesShort[dateObj.getMonth()];
4585
+ },
4586
+ MMMM: function(dateObj) {
4587
+ return monthNames[dateObj.getMonth()];
4588
+ },
4589
+ yy: function(dateObj) {
4590
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
4591
+ },
4592
+ yyyy: function(dateObj) {
4593
+ return pad(dateObj.getFullYear(), 4);
4594
+ },
4595
+ h: function(dateObj) {
4596
+ return dateObj.getHours() % 12 || 12;
4597
+ },
4598
+ hh: function(dateObj) {
4599
+ return pad(dateObj.getHours() % 12 || 12);
4600
+ },
4601
+ H: function(dateObj) {
4602
+ return dateObj.getHours();
4603
+ },
4604
+ HH: function(dateObj) {
4605
+ return pad(dateObj.getHours());
4606
+ },
4607
+ m: function(dateObj) {
4608
+ return dateObj.getMinutes();
4609
+ },
4610
+ mm: function(dateObj) {
4611
+ return pad(dateObj.getMinutes());
4612
+ },
4613
+ s: function(dateObj) {
4614
+ return dateObj.getSeconds();
4615
+ },
4616
+ ss: function(dateObj) {
4617
+ return pad(dateObj.getSeconds());
4618
+ },
4619
+ S: function(dateObj) {
4620
+ return Math.round(dateObj.getMilliseconds() / 100);
4621
+ },
4622
+ SS: function(dateObj) {
4623
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4624
+ },
4625
+ SSS: function(dateObj) {
4626
+ return pad(dateObj.getMilliseconds(), 3);
4627
+ },
4628
+ a: function(dateObj) {
4629
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4630
+ },
4631
+ A: function(dateObj) {
4632
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4633
+ },
4634
+ ZZ: function(dateObj) {
4635
+ const o = dateObj.getTimezoneOffset();
4636
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4637
+ }
4638
+ };
4639
+
4640
+ const parseFlags = {
4641
+ d: [twoDigits, function (d, v) {
4642
+ d.day = v;
4643
+ }],
4644
+ Do: [twoDigits + word, function (d, v) {
4645
+ d.day = parseInt(v, 10);
4646
+ }],
4647
+ M: [twoDigits, function (d, v) {
4648
+ d.month = v - 1;
4649
+ }],
4650
+ yy: [twoDigits, function (d, v) {
4651
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
4652
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4653
+ }],
4654
+ h: [twoDigits, function (d, v) {
4655
+ d.hour = v;
4656
+ }],
4657
+ m: [twoDigits, function (d, v) {
4658
+ d.minute = v;
4659
+ }],
4660
+ s: [twoDigits, function (d, v) {
4661
+ d.second = v;
4662
+ }],
4663
+ yyyy: [fourDigits, function (d, v) {
4664
+ d.year = v;
4665
+ }],
4666
+ S: ['\\d', function (d, v) {
4667
+ d.millisecond = v * 100;
4668
+ }],
4669
+ SS: ['\\d{2}', function (d, v) {
4670
+ d.millisecond = v * 10;
4671
+ }],
4672
+ SSS: [threeDigits, function (d, v) {
4673
+ d.millisecond = v;
4674
+ }],
4675
+ D: [twoDigits, noop],
4676
+ ddd: [word, noop],
4677
+ MMM: [word, monthUpdate('monthNamesShort')],
4678
+ MMMM: [word, monthUpdate('monthNames')],
4679
+ a: [word, function (d, v) {
4680
+ const val = v.toLowerCase();
4681
+ if (val === '上午') {
4682
+ d.isPm = false;
4683
+ } else if (val === '下午') {
4684
+ d.isPm = true;
4685
+ }
4686
+ }],
4687
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4688
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
4689
+
4690
+ if (parts) {
4691
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4692
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4693
+ }
4694
+ }]
4695
+ };
4696
+ parseFlags.dd = parseFlags.d;
4697
+ parseFlags.dddd = parseFlags.ddd;
4698
+ parseFlags.DD = parseFlags.D;
4699
+ parseFlags.mm = parseFlags.m;
4700
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4701
+ parseFlags.MM = parseFlags.M;
4702
+ parseFlags.ss = parseFlags.s;
4703
+ parseFlags.A = parseFlags.a;
4704
+
4705
+
4706
+ // Some common format strings
4707
+ fecha.masks = {
4708
+ default: 'ddd MMM dd yyyy HH:mm:ss',
4709
+ shortDate: 'M/D/yy',
4710
+ mediumDate: 'MMM d, yyyy',
4711
+ longDate: 'MMMM d, yyyy',
4712
+ fullDate: 'dddd, MMMM d, yyyy',
4713
+ shortTime: 'HH:mm',
4714
+ mediumTime: 'HH:mm:ss',
4715
+ longTime: 'HH:mm:ss.SSS'
4716
+ };
4717
+
4597
4718
  /***
4598
4719
  * Format a date
4599
4720
  * @method format
4600
4721
  * @param {Date|number} dateObj
4601
4722
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
4602
- */
4603
- fecha.format = function (dateObj, mask) {
4604
- if (typeof dateObj === 'number') {
4605
- dateObj = new Date(dateObj);
4606
- }
4607
-
4608
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4609
- throw new Error('Invalid Date in fecha.format');
4610
- }
4611
-
4612
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
4613
-
4614
- var literals = [];
4615
-
4616
- // Make literals inactive by replacing them with ??
4617
- mask = mask.replace(literal, function ($0, $1) {
4618
- literals.push($1);
4619
- return '@@@';
4620
- });
4621
- // Apply formatting rules
4622
- mask = mask.replace(token, function ($0) {
4623
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4624
- });
4625
- // Inline literal values back into the formatted value
4626
- return mask.replace(/@@@/g, function () {
4627
- return literals.shift();
4628
- });
4629
- };
4630
-
4723
+ */
4724
+ fecha.format = function (dateObj, mask) {
4725
+ if (typeof dateObj === 'number') {
4726
+ dateObj = new Date(dateObj);
4727
+ }
4728
+
4729
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4730
+ throw new Error('Invalid Date in fecha.format');
4731
+ }
4732
+
4733
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
4734
+
4735
+ const literals = [];
4736
+
4737
+ // Make literals inactive by replacing them with ??
4738
+ mask = mask.replace(literal, function($0, $1) {
4739
+ literals.push($1);
4740
+ return '@@@';
4741
+ });
4742
+ // Apply formatting rules
4743
+ mask = mask.replace(token, function ($0) {
4744
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4745
+ });
4746
+ // Inline literal values back into the formatted value
4747
+ return mask.replace(/@@@/g, function() {
4748
+ return literals.shift();
4749
+ });
4750
+ };
4751
+
4631
4752
  /**
4632
4753
  * Parse a date string into an object, changes - into /
4633
4754
  * @method parse
4634
4755
  * @param {string} dateStr Date string
4635
4756
  * @param {string} format Date parse format
4636
4757
  * @returns {Date|boolean}
4637
- */
4638
- fecha.parse = function (dateStr, format) {
4639
- if (typeof format !== 'string') {
4640
- throw new Error('Invalid format in fecha.parse');
4641
- }
4642
-
4643
- format = fecha.masks[format] || format;
4644
-
4645
- // Avoid regular expression denial of service, fail early for really long strings
4646
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4647
- if (dateStr.length > 1000) {
4648
- return null;
4649
- }
4650
-
4651
- var dateInfo = {};
4652
- var parseInfo = [];
4653
- var literals = [];
4654
- format = format.replace(literal, function ($0, $1) {
4655
- literals.push($1);
4656
- return '@@@';
4657
- });
4658
- var newFormat = regexEscape(format).replace(token, function ($0) {
4659
- if (parseFlags[$0]) {
4660
- var info = parseFlags[$0];
4661
- parseInfo.push(info[1]);
4662
- return '(' + info[0] + ')';
4663
- }
4664
-
4665
- return $0;
4666
- });
4667
- newFormat = newFormat.replace(/@@@/g, function () {
4668
- return literals.shift();
4669
- });
4670
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
4671
- if (!matches) {
4672
- return null;
4673
- }
4674
-
4675
- for (var i = 1; i < matches.length; i++) {
4676
- parseInfo[i - 1](dateInfo, matches[i]);
4677
- }
4678
-
4679
- var today = new Date();
4680
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4681
- dateInfo.hour = +dateInfo.hour + 12;
4682
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4683
- dateInfo.hour = 0;
4684
- }
4685
-
4686
- var date = void 0;
4687
- if (dateInfo.timezoneOffset != null) {
4688
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4689
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4690
- } else {
4691
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4692
- }
4693
- return date;
4694
- };
4695
-
4696
- // 导出fecha对象
4697
-
4698
-
4699
- // 以下是从date-util.js合并的函数
4700
- var newArray = function newArray(start, end) {
4701
- var result = [];
4702
- for (var i = start; i <= end; i++) {
4703
- result.push(i);
4704
- }
4705
- return result;
4706
- };
4707
-
4708
- var getSettings = function getSettings() {
4709
- return {
4710
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4711
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4712
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4713
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4714
- amPm: ['上午', '下午']
4715
- };
4716
- };
4717
-
4718
- var toDate = function toDate(date) {
4719
- return isDate(date) ? new Date(date) : null;
4720
- };
4721
-
4722
- var isDate = function isDate(date) {
4723
- if (date === null || date === undefined) return false;
4724
- if (isNaN(new Date(date).getTime())) return false;
4725
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4726
- return true;
4727
- };
4728
-
4729
- var isDateObject = function isDateObject(val) {
4730
- return val instanceof Date;
4731
- };
4732
-
4733
- var formatDate = function formatDate(date) {
4734
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
4735
-
4736
- // 处理多种输入类型
4737
- if (!date) return '';
4738
-
4739
- // 如果是时间戳,转成日期对象
4740
- if (typeof date === 'number') {
4741
- date = new Date(date);
4742
- }
4743
- // 如果是字符串,转成日期对象
4744
- if (typeof date === 'string') {
4745
- date = new Date(date);
4746
- }
4747
-
4748
- // 调用toDate进一步验证和转换
4749
- date = toDate(date);
4750
- if (!date) return '';
4751
-
4752
- // 兼容大写和小写的格式标记
4753
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4754
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
4755
-
4756
- // 使用fecha库进行格式化,支持中文配置
4757
- var str = fecha.format(date, lowercaseFormat, getSettings());
4758
- return str;
4759
- };
4760
-
4761
- var parseDate = function parseDate(string, format) {
4762
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4763
- };
4764
-
4765
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
4766
- if (month === 3 || month === 5 || month === 8 || month === 10) {
4767
- return 30;
4768
- }
4769
-
4770
- if (month === 1) {
4771
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4772
- return 29;
4773
- } else {
4774
- return 28;
4775
- }
4776
- }
4777
-
4778
- return 31;
4779
- };
4780
-
4781
- var getDayCountOfYear = function getDayCountOfYear(year) {
4782
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
4783
- return isLeapYear ? 366 : 365;
4784
- };
4785
-
4786
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
4787
- var temp = new Date(date.getTime());
4788
- temp.setDate(1);
4789
- return temp.getDay();
4790
- };
4791
-
4792
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4793
- // {prev, next} Date should work for Daylight Saving Time
4794
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4795
- var prevDate = function prevDate(date) {
4796
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4797
-
4798
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4799
- };
4800
-
4801
- var nextDate = function nextDate(date) {
4802
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4803
-
4804
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4805
- };
4806
-
4807
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
4808
- var result = new Date(year, month, 1);
4809
- var day = result.getDay();
4810
-
4811
- if (day === 0) {
4812
- return prevDate(result, 7);
4813
- } else {
4814
- return prevDate(result, day);
4815
- }
4816
- };
4817
-
4818
- var getWeekNumber = function getWeekNumber(date) {
4819
- // 支持多种输入类型
4820
- if (!date || !isDate(date)) {
4821
- date = new Date();
4822
- }
4823
- if (typeof date === 'string') {
4824
- date = new Date(date);
4825
- }
4826
-
4827
- // 验证日期有效性
4828
- if (!isDate(date)) return null;
4829
-
4830
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4831
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4832
- // 将星期日的星期数设为7
4833
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4834
- // 获取当年的第一天
4835
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4836
- // 计算到最近的星期四的完整周数
4837
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
4838
- // 返回周数
4839
- return weekNo;
4840
- };
4841
-
4842
- var getRangeHours = function getRangeHours(ranges) {
4843
- var hours = [];
4844
- var disabledHours = [];
4845
-
4846
- (ranges || []).forEach(function (range) {
4847
- var value = range.map(function (date) {
4848
- return date.getHours();
4849
- });
4850
-
4851
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4852
- });
4853
-
4854
- if (disabledHours.length) {
4855
- for (var i = 0; i < 24; i++) {
4856
- hours[i] = disabledHours.indexOf(i) === -1;
4857
- }
4858
- } else {
4859
- for (var _i = 0; _i < 24; _i++) {
4860
- hours[_i] = false;
4861
- }
4862
- }
4863
-
4864
- return hours;
4865
- };
4866
-
4867
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
4868
- if (amount <= 0) return [];
4869
- var temp = new Date(date.getTime());
4870
- temp.setDate(0);
4871
- var lastDay = temp.getDate();
4872
- return range(amount).map(function (_, index) {
4873
- return lastDay - (amount - index - 1);
4874
- });
4875
- };
4876
-
4877
- var getMonthDays = function getMonthDays(date) {
4878
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4879
- var days = temp.getDate();
4880
- return range(days).map(function (_, index) {
4881
- return index + 1;
4882
- });
4883
- };
4884
-
4885
- function setRangeData(arr, start, end, value) {
4886
- for (var i = start; i < end; i++) {
4887
- arr[i] = value;
4888
- }
4889
- }
4890
-
4891
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
4892
- var minutes = new Array(60);
4893
-
4894
- if (ranges.length > 0) {
4895
- ranges.forEach(function (range) {
4896
- var start = range[0];
4897
- var end = range[1];
4898
- var startHour = start.getHours();
4899
- var startMinute = start.getMinutes();
4900
- var endHour = end.getHours();
4901
- var endMinute = end.getMinutes();
4902
- if (startHour === hour && endHour !== hour) {
4903
- setRangeData(minutes, startMinute, 60, true);
4904
- } else if (startHour === hour && endHour === hour) {
4905
- setRangeData(minutes, startMinute, endMinute + 1, true);
4906
- } else if (startHour !== hour && endHour === hour) {
4907
- setRangeData(minutes, 0, endMinute + 1, true);
4908
- } else if (startHour < hour && endHour > hour) {
4909
- setRangeData(minutes, 0, 60, true);
4910
- }
4911
- });
4912
- } else {
4913
- setRangeData(minutes, 0, 60, true);
4914
- }
4915
- return minutes;
4916
- };
4917
-
4918
- var range = function range(n) {
4919
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4920
- return Array.apply(null, { length: n }).map(function (_, n) {
4921
- return n;
4922
- });
4923
- };
4924
-
4925
- var modifyDate = function modifyDate(date, y, m, d) {
4926
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4927
- };
4928
-
4929
- var modifyTime = function modifyTime(date, h, m, s) {
4930
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4931
- };
4932
-
4933
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
4934
- if (date == null || !time) {
4935
- return date;
4936
- }
4937
- time = parseDate(time, 'HH:mm:ss');
4938
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4939
- };
4940
-
4941
- var clearTime = function clearTime(date) {
4942
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4943
- };
4944
-
4945
- var clearMilliseconds = function clearMilliseconds(date) {
4946
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4947
- };
4948
-
4949
- var limitTimeRange = function limitTimeRange(date, ranges) {
4950
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
4951
-
4952
- // TODO: refactory a more elegant solution
4953
- if (ranges.length === 0) return date;
4954
- var normalizeDate = function normalizeDate(date) {
4955
- return fecha.parse(fecha.format(date, format), format);
4956
- };
4957
- var ndate = normalizeDate(date);
4958
- var nranges = ranges.map(function (range) {
4959
- return range.map(normalizeDate);
4960
- });
4961
- if (nranges.some(function (nrange) {
4962
- return ndate >= nrange[0] && ndate <= nrange[1];
4963
- })) return date;
4964
-
4965
- var minDate = nranges[0][0];
4966
- var maxDate = nranges[0][0];
4967
-
4968
- nranges.forEach(function (nrange) {
4969
- minDate = new Date(Math.min(nrange[0], minDate));
4970
- maxDate = new Date(Math.max(nrange[1], minDate));
4971
- });
4972
-
4973
- var ret = ndate < minDate ? minDate : maxDate;
4974
- // preserve Year/Month/Date
4975
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
4976
- };
4977
-
4978
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
4979
- var limitedDate = limitTimeRange(date, selectableRange, format);
4980
- return limitedDate.getTime() === date.getTime();
4981
- };
4982
-
4983
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
4984
- // clamp date to the number of days in `year`, `month`
4985
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
4986
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4987
- return modifyDate(date, year, month, monthDate);
4988
- };
4989
-
4990
- var prevMonth = function prevMonth(date) {
4991
- var year = date.getFullYear();
4992
- var month = date.getMonth();
4993
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
4994
- };
4995
-
4996
- var nextMonth = function nextMonth(date) {
4997
- var year = date.getFullYear();
4998
- var month = date.getMonth();
4999
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5000
- };
5001
-
5002
- var prevYear = function prevYear(date) {
5003
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5004
-
5005
- var year = date.getFullYear();
5006
- var month = date.getMonth();
5007
- return changeYearMonthAndClampDate(date, year - amount, month);
5008
- };
5009
-
5010
- var nextYear = function nextYear(date) {
5011
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5012
-
5013
- var year = date.getFullYear();
5014
- var month = date.getMonth();
5015
- return changeYearMonthAndClampDate(date, year + amount, month);
5016
- };
5017
-
5018
- var extractDateFormat = function extractDateFormat(format) {
5019
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5020
- };
5021
-
5022
- var extractTimeFormat = function extractTimeFormat(format) {
5023
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5024
- };
5025
-
5026
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5027
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5028
- };
5029
-
4758
+ */
4759
+ fecha.parse = function (dateStr, format) {
4760
+ if (typeof format !== 'string') {
4761
+ throw new Error('Invalid format in fecha.parse');
4762
+ }
4763
+
4764
+ format = fecha.masks[format] || format;
4765
+
4766
+ // Avoid regular expression denial of service, fail early for really long strings
4767
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4768
+ if (dateStr.length > 1000) {
4769
+ return null;
4770
+ }
4771
+
4772
+ const dateInfo = {};
4773
+ const parseInfo = [];
4774
+ const literals = [];
4775
+ format = format.replace(literal, function($0, $1) {
4776
+ literals.push($1);
4777
+ return '@@@';
4778
+ });
4779
+ let newFormat = regexEscape(format).replace(token, function ($0) {
4780
+ if (parseFlags[$0]) {
4781
+ const info = parseFlags[$0];
4782
+ parseInfo.push(info[1]);
4783
+ return '(' + info[0] + ')';
4784
+ }
4785
+
4786
+ return $0;
4787
+ });
4788
+ newFormat = newFormat.replace(/@@@/g, function() {
4789
+ return literals.shift();
4790
+ });
4791
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
4792
+ if (!matches) {
4793
+ return null;
4794
+ }
4795
+
4796
+ for (let i = 1; i < matches.length; i++) {
4797
+ parseInfo[i - 1](dateInfo, matches[i]);
4798
+ }
4799
+
4800
+ const today = new Date();
4801
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4802
+ dateInfo.hour = +dateInfo.hour + 12;
4803
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4804
+ dateInfo.hour = 0;
4805
+ }
4806
+
4807
+ let date;
4808
+ if (dateInfo.timezoneOffset != null) {
4809
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4810
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4811
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4812
+ } else {
4813
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4814
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4815
+ }
4816
+ return date;
4817
+ };
4818
+
4819
+ // 导出fecha对象
4820
+
4821
+
4822
+ // 以下是从date-util.js合并的函数
4823
+ const newArray = function(start, end) {
4824
+ let result = [];
4825
+ for (let i = start; i <= end; i++) {
4826
+ result.push(i);
4827
+ }
4828
+ return result;
4829
+ };
4830
+
4831
+ const getSettings = () => {
4832
+ return {
4833
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4834
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4835
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4836
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4837
+ amPm: ['上午', '下午']
4838
+ };
4839
+ };
4840
+
4841
+ const toDate = function(date) {
4842
+ return isDate(date) ? new Date(date) : null;
4843
+ };
4844
+
4845
+ const isDate = function(date) {
4846
+ if (date === null || date === undefined) return false;
4847
+ if (isNaN(new Date(date).getTime())) return false;
4848
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4849
+ return true;
4850
+ };
4851
+
4852
+ const isDateObject = function(val) {
4853
+ return val instanceof Date;
4854
+ };
4855
+
4856
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
4857
+ // 处理多种输入类型
4858
+ if (!date) return '';
4859
+
4860
+ // 如果是时间戳,转成日期对象
4861
+ if (typeof date === 'number') {
4862
+ date = new Date(date);
4863
+ }
4864
+ // 如果是字符串,转成日期对象
4865
+ if (typeof date === 'string') {
4866
+ date = new Date(date);
4867
+ }
4868
+
4869
+ // 调用toDate进一步验证和转换
4870
+ date = toDate(date);
4871
+ if (!date) return '';
4872
+
4873
+ // 兼容大写和小写的格式标记
4874
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4875
+ const lowercaseFormat = format
4876
+ .replace(/YYYY/g, 'yyyy')
4877
+ .replace(/D/g, 'd')
4878
+
4879
+ // 使用fecha库进行格式化,支持中文配置
4880
+ const str = fecha.format(date, lowercaseFormat, getSettings());
4881
+ return str;
4882
+ };
4883
+
4884
+ const parseDate = function(string, format) {
4885
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4886
+ };
4887
+
4888
+ const getDayCountOfMonth = function(year, month) {
4889
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
4890
+ return 30;
4891
+ }
4892
+
4893
+ if (month === 1) {
4894
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4895
+ return 29;
4896
+ } else {
4897
+ return 28;
4898
+ }
4899
+ }
4900
+
4901
+ return 31;
4902
+ };
4903
+
4904
+ const getDayCountOfYear = function(year) {
4905
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
4906
+ return isLeapYear ? 366 : 365;
4907
+ };
4908
+
4909
+ const getFirstDayOfMonth = function(date) {
4910
+ const temp = new Date(date.getTime());
4911
+ temp.setDate(1);
4912
+ return temp.getDay();
4913
+ };
4914
+
4915
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4916
+ // {prev, next} Date should work for Daylight Saving Time
4917
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4918
+ const prevDate = function(date, amount = 1) {
4919
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4920
+ };
4921
+
4922
+ const nextDate = function(date, amount = 1) {
4923
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4924
+ };
4925
+
4926
+ const getStartDateOfMonth = function(year, month) {
4927
+ const result = new Date(year, month, 1);
4928
+ const day = result.getDay();
4929
+
4930
+ if (day === 0) {
4931
+ return prevDate(result, 7);
4932
+ } else {
4933
+ return prevDate(result, day);
4934
+ }
4935
+ };
4936
+
4937
+ const getWeekNumber = function(date) {
4938
+ // 支持多种输入类型
4939
+ if (!date||!isDate(date)) {
4940
+ date = new Date();
4941
+ }
4942
+ if (typeof date === 'string') {
4943
+ date = new Date(date);
4944
+ }
4945
+
4946
+ // 验证日期有效性
4947
+ if (!isDate(date)) return null;
4948
+
4949
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4950
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4951
+ // 将星期日的星期数设为7
4952
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4953
+ // 获取当年的第一天
4954
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4955
+ // 计算到最近的星期四的完整周数
4956
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
4957
+ // 返回周数
4958
+ return weekNo;
4959
+ };
4960
+
4961
+ const getRangeHours = function(ranges) {
4962
+ const hours = [];
4963
+ let disabledHours = [];
4964
+
4965
+ (ranges || []).forEach(range => {
4966
+ const value = range.map(date => date.getHours());
4967
+
4968
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4969
+ });
4970
+
4971
+ if (disabledHours.length) {
4972
+ for (let i = 0; i < 24; i++) {
4973
+ hours[i] = disabledHours.indexOf(i) === -1;
4974
+ }
4975
+ } else {
4976
+ for (let i = 0; i < 24; i++) {
4977
+ hours[i] = false;
4978
+ }
4979
+ }
4980
+
4981
+ return hours;
4982
+ };
4983
+
4984
+ const getPrevMonthLastDays = (date, amount) => {
4985
+ if (amount <= 0) return [];
4986
+ const temp = new Date(date.getTime());
4987
+ temp.setDate(0);
4988
+ const lastDay = temp.getDate();
4989
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
4990
+ };
4991
+
4992
+ const getMonthDays = (date) => {
4993
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4994
+ const days = temp.getDate();
4995
+ return range(days).map((_, index) => index + 1);
4996
+ };
4997
+
4998
+ function setRangeData(arr, start, end, value) {
4999
+ for (let i = start; i < end; i++) {
5000
+ arr[i] = value;
5001
+ }
5002
+ }
5003
+
5004
+ const getRangeMinutes = function(ranges, hour) {
5005
+ const minutes = new Array(60);
5006
+
5007
+ if (ranges.length > 0) {
5008
+ ranges.forEach(range => {
5009
+ const start = range[0];
5010
+ const end = range[1];
5011
+ const startHour = start.getHours();
5012
+ const startMinute = start.getMinutes();
5013
+ const endHour = end.getHours();
5014
+ const endMinute = end.getMinutes();
5015
+ if (startHour === hour && endHour !== hour) {
5016
+ setRangeData(minutes, startMinute, 60, true);
5017
+ } else if (startHour === hour && endHour === hour) {
5018
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5019
+ } else if (startHour !== hour && endHour === hour) {
5020
+ setRangeData(minutes, 0, endMinute + 1, true);
5021
+ } else if (startHour < hour && endHour > hour) {
5022
+ setRangeData(minutes, 0, 60, true);
5023
+ }
5024
+ });
5025
+ } else {
5026
+ setRangeData(minutes, 0, 60, true);
5027
+ }
5028
+ return minutes;
5029
+ };
5030
+
5031
+ const range = function(n) {
5032
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5033
+ return Array.apply(null, {length: n}).map((_, n) => n);
5034
+ };
5035
+
5036
+ const modifyDate = function(date, y, m, d) {
5037
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5038
+ };
5039
+
5040
+ const modifyTime = function(date, h, m, s) {
5041
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5042
+ };
5043
+
5044
+ const modifyWithTimeString = (date, time) => {
5045
+ if (date == null || !time) {
5046
+ return date;
5047
+ }
5048
+ time = parseDate(time, 'HH:mm:ss');
5049
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5050
+ };
5051
+
5052
+ const clearTime = function(date) {
5053
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5054
+ };
5055
+
5056
+ const clearMilliseconds = function(date) {
5057
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5058
+ };
5059
+
5060
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5061
+ // TODO: refactory a more elegant solution
5062
+ if (ranges.length === 0) return date;
5063
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5064
+ const ndate = normalizeDate(date);
5065
+ const nranges = ranges.map(range => range.map(normalizeDate));
5066
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5067
+
5068
+ let minDate = nranges[0][0];
5069
+ let maxDate = nranges[0][0];
5070
+
5071
+ nranges.forEach(nrange => {
5072
+ minDate = new Date(Math.min(nrange[0], minDate));
5073
+ maxDate = new Date(Math.max(nrange[1], minDate));
5074
+ });
5075
+
5076
+ const ret = ndate < minDate ? minDate : maxDate;
5077
+ // preserve Year/Month/Date
5078
+ return modifyDate(
5079
+ ret,
5080
+ date.getFullYear(),
5081
+ date.getMonth(),
5082
+ date.getDate()
5083
+ );
5084
+ };
5085
+
5086
+ const timeWithinRange = function(date, selectableRange, format) {
5087
+ const limitedDate = limitTimeRange(date, selectableRange, format);
5088
+ return limitedDate.getTime() === date.getTime();
5089
+ };
5090
+
5091
+ const changeYearMonthAndClampDate = function(date, year, month) {
5092
+ // clamp date to the number of days in `year`, `month`
5093
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5094
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5095
+ return modifyDate(date, year, month, monthDate);
5096
+ };
5097
+
5098
+ const prevMonth = function(date) {
5099
+ const year = date.getFullYear();
5100
+ const month = date.getMonth();
5101
+ return month === 0
5102
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5103
+ : changeYearMonthAndClampDate(date, year, month - 1);
5104
+ };
5105
+
5106
+ const nextMonth = function(date) {
5107
+ const year = date.getFullYear();
5108
+ const month = date.getMonth();
5109
+ return month === 11
5110
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5111
+ : changeYearMonthAndClampDate(date, year, month + 1);
5112
+ };
5113
+
5114
+ const prevYear = function(date, amount = 1) {
5115
+ const year = date.getFullYear();
5116
+ const month = date.getMonth();
5117
+ return changeYearMonthAndClampDate(date, year - amount, month);
5118
+ };
5119
+
5120
+ const nextYear = function(date, amount = 1) {
5121
+ const year = date.getFullYear();
5122
+ const month = date.getMonth();
5123
+ return changeYearMonthAndClampDate(date, year + amount, month);
5124
+ };
5125
+
5126
+ const extractDateFormat = function(format) {
5127
+ return format
5128
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
5129
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5130
+ .trim();
5131
+ };
5132
+
5133
+ const extractTimeFormat = function(format) {
5134
+ return format
5135
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5136
+ .trim();
5137
+ };
5138
+
5139
+ const validateRangeInOneMonth = function(start, end) {
5140
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5141
+ };
5142
+
5030
5143
  /**
5031
5144
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5032
5145
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5033
5146
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5034
5147
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5035
5148
  * @returns {number} 工作日数量
5036
- */
5037
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5038
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5039
-
5040
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5041
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5042
- }
5043
-
5044
- var startDateObj = new Date(start_date);
5045
- var endDateObj = new Date(end_date);
5046
-
5047
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5048
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5049
- }
5050
-
5051
- if (startDateObj > endDateObj) {
5052
- throw new Error('Start date should be earlier than or equal to end date.');
5053
- }
5054
-
5055
- var workdays = 0;
5056
-
5057
- // Iterate through each day in the date range
5058
-
5059
- var _loop = function _loop(currentDate) {
5060
- // Check if the current day is a weekend (Saturday or Sunday)
5061
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5062
-
5063
- // Check if the current day is a holiday
5064
- var isHoliday = holidays.some(function (holiday) {
5065
- var holidayDate = new Date(holiday);
5066
- return currentDate.toDateString() === holidayDate.toDateString();
5067
- });
5068
-
5069
- // If it's a workday (not a weekend or holiday), increment the workdays count
5070
- if (!isWeekend && !isHoliday) {
5071
- workdays++;
5072
- }
5073
- };
5074
-
5075
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5076
- _loop(currentDate);
5077
- }
5078
-
5079
- return workdays;
5080
- };
5081
-
5149
+ */
5150
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5151
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5152
+ throw new Error(
5153
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5154
+ );
5155
+ }
5156
+
5157
+ const startDateObj = new Date(start_date);
5158
+ const endDateObj = new Date(end_date);
5159
+
5160
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5161
+ throw new Error(
5162
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5163
+ );
5164
+ }
5165
+
5166
+ if (startDateObj > endDateObj) {
5167
+ throw new Error('Start date should be earlier than or equal to end date.');
5168
+ }
5169
+
5170
+ let workdays = 0;
5171
+
5172
+ // Iterate through each day in the date range
5173
+ for (
5174
+ let currentDate = new Date(startDateObj);
5175
+ currentDate <= endDateObj;
5176
+ currentDate.setDate(currentDate.getDate() + 1)
5177
+ ) {
5178
+ // Check if the current day is a weekend (Saturday or Sunday)
5179
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5180
+
5181
+ // Check if the current day is a holiday
5182
+ const isHoliday = holidays.some((holiday) => {
5183
+ const holidayDate = new Date(holiday);
5184
+ return currentDate.toDateString() === holidayDate.toDateString();
5185
+ });
5186
+
5187
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5188
+ if (!isWeekend && !isHoliday) {
5189
+ workdays++;
5190
+ }
5191
+ }
5192
+
5193
+ return workdays;
5194
+ };
5195
+
5082
5196
  /**
5083
5197
  * 日期加减天数
5084
5198
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5085
5199
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5086
5200
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5087
- */
5088
- var dateAddDays = function dateAddDays(start_date, days) {
5089
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5090
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days.");
5091
- }
5092
-
5093
- var startDateObj = new Date(start_date);
5094
- if (isNaN(startDateObj.getTime())) {
5095
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5096
- }
5097
-
5098
- var resultDateObj = new Date(startDateObj);
5099
- resultDateObj.setDate(resultDateObj.getDate() + days);
5100
-
5101
- var resultYear = resultDateObj.getFullYear();
5102
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5103
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5104
-
5105
- return resultYear + '-' + resultMonth + '-' + resultDay;
5106
- };
5107
-
5201
+ */
5202
+ const dateAddDays = function (start_date, days) {
5203
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5204
+ throw new Error(
5205
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5206
+ );
5207
+ }
5208
+
5209
+ const startDateObj = new Date(start_date);
5210
+ if (isNaN(startDateObj.getTime())) {
5211
+ throw new Error(
5212
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5213
+ );
5214
+ }
5215
+
5216
+ const resultDateObj = new Date(startDateObj);
5217
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5218
+
5219
+ const resultYear = resultDateObj.getFullYear();
5220
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5221
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5222
+
5223
+ return `${resultYear}-${resultMonth}-${resultDay}`;
5224
+ };
5225
+
5108
5226
  /**
5109
5227
  * 计算两个日期之间的差值
5110
5228
  * @date 2023年12月14日
@@ -5112,180 +5230,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
5112
5230
  * @param {String} end_date - 结束日期字符串
5113
5231
  * @param {String} unit - 单位:year/month/day
5114
5232
  * @returns {Number} 差值
5115
- */
5116
- var dateDiff = function dateDiff(start_date, end_date) {
5117
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5118
-
5119
- // Assuming date strings are in "YYYY-MM-DD" format
5120
- var startDate = new Date(start_date);
5121
- var endDate = new Date(end_date);
5122
-
5123
- // If the date is invalid, return 0
5124
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5125
- return 0;
5126
- }
5127
-
5128
- if (unit === 'year') {
5129
- return endDate.getFullYear() - startDate.getFullYear();
5130
- } else if (unit === 'month') {
5131
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5132
- } else {
5133
- // Default to day
5134
- var timeDifference = endDate - startDate;
5135
- // Calculate days (86400000 milliseconds per day)
5136
- return Math.floor(timeDifference / 86400000);
5137
- }
5138
- };
5139
-
5233
+ */
5234
+ const dateDiff = function (start_date, end_date, unit = 'day') {
5235
+ // Assuming date strings are in "YYYY-MM-DD" format
5236
+ var startDate = new Date(start_date);
5237
+ var endDate = new Date(end_date);
5238
+
5239
+ // If the date is invalid, return 0
5240
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5241
+ return 0;
5242
+ }
5243
+
5244
+ if (unit === 'year') {
5245
+ return endDate.getFullYear() - startDate.getFullYear();
5246
+ } else if (unit === 'month') {
5247
+ return (
5248
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5249
+ (endDate.getMonth() - startDate.getMonth())
5250
+ );
5251
+ } else {
5252
+ // Default to day
5253
+ var timeDifference = endDate - startDate;
5254
+ // Calculate days (86400000 milliseconds per day)
5255
+ return Math.floor(timeDifference / 86400000);
5256
+ }
5257
+ };
5258
+
5140
5259
  /**
5141
5260
  * 获取月份中的日期
5142
5261
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5143
5262
  * @returns {number} 月份中的日期(1-31)
5144
- */
5145
- var dayOfMonth = function dayOfMonth(date) {
5146
- if (typeof date !== 'string') {
5147
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5148
- }
5149
-
5150
- var dateObj = new Date(date);
5151
- if (isNaN(dateObj.getTime())) {
5152
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5153
- }
5154
-
5155
- return dateObj.getDate();
5156
- };
5157
-
5263
+ */
5264
+ const dayOfMonth = function (date) {
5265
+ if (typeof date !== 'string') {
5266
+ throw new Error(
5267
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5268
+ );
5269
+ }
5270
+
5271
+ const dateObj = new Date(date);
5272
+ if (isNaN(dateObj.getTime())) {
5273
+ throw new Error(
5274
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5275
+ );
5276
+ }
5277
+
5278
+ return dateObj.getDate();
5279
+ };
5280
+
5158
5281
  /**
5159
5282
  * 获取当前日期
5160
5283
  * @date 2022年5月7日
5161
5284
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5162
5285
  * @returns {string} 当前日期的格式化字符串
5163
- */
5164
- var getCurrentDate = function getCurrentDate() {
5165
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5166
-
5167
- return formatDate(new Date(), format);
5168
- };
5169
-
5286
+ */
5287
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
5288
+ return formatDate(new Date(), format);
5289
+ };
5290
+
5170
5291
  /**
5171
5292
  * 获取当前日期时间
5172
5293
  * @date 2022年5月7日
5173
5294
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
5174
5295
  * @returns {string} 当前日期时间的格式化字符串
5175
- */
5176
- var getCurrentDateTime = function getCurrentDateTime() {
5177
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
5178
-
5179
- return formatDate(new Date(), format);
5180
- };
5181
-
5296
+ */
5297
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5298
+ return formatDate(new Date(), format);
5299
+ };
5300
+
5182
5301
  /**
5183
5302
  * 获取小时
5184
5303
  * @date 2022年5月7日
5185
5304
  * @param {Date|string} [date] - 日期对象或日期字符串
5186
5305
  * @returns {number} 小时数(0-23)
5187
- */
5188
- var getHour = function getHour(date) {
5189
- if (!date) {
5190
- return new Date().getHours();
5191
- }
5192
- if (typeof date === 'string') {
5193
- date = new Date(date);
5194
- }
5195
- return date.getHours();
5196
- };
5197
-
5306
+ */
5307
+ const getHour = function (date) {
5308
+ if (!date) {
5309
+ return new Date().getHours();
5310
+ }
5311
+ if (typeof date === 'string') {
5312
+ date = new Date(date);
5313
+ }
5314
+ return date.getHours();
5315
+ };
5316
+
5198
5317
  /**
5199
5318
  * 获取分钟
5200
5319
  * @date 2022年5月7日
5201
5320
  * @param {Date|string} [date] - 日期对象或日期字符串
5202
5321
  * @returns {number} 分钟数(0-59)
5203
- */
5204
- var getMinute = function getMinute(date) {
5205
- if (!date) {
5206
- return new Date().getMinutes();
5207
- }
5208
- if (typeof date === 'string') {
5209
- date = new Date(date);
5210
- }
5211
- return date.getMinutes();
5212
- };
5213
-
5322
+ */
5323
+ const getMinute = function (date) {
5324
+ if (!date) {
5325
+ return new Date().getMinutes();
5326
+ }
5327
+ if (typeof date === 'string') {
5328
+ date = new Date(date);
5329
+ }
5330
+ return date.getMinutes();
5331
+ };
5332
+
5214
5333
  /**
5215
5334
  * 获取月份
5216
5335
  * @date 2022年5月7日
5217
5336
  * @param {Date|string} [date] - 日期对象或日期字符串
5218
5337
  * @returns {number} 月份数(1-12)
5219
- */
5220
- var getMonth = function getMonth(date) {
5221
- if (!date) {
5222
- return new Date().getMonth() + 1;
5223
- }
5224
- if (typeof date === 'string') {
5225
- date = new Date(date);
5226
- }
5227
- return date.getMonth() + 1;
5228
- };
5229
-
5338
+ */
5339
+ const getMonth = function (date) {
5340
+ if (!date) {
5341
+ return new Date().getMonth() + 1;
5342
+ }
5343
+ if (typeof date === 'string') {
5344
+ date = new Date(date);
5345
+ }
5346
+ return date.getMonth() + 1;
5347
+ };
5348
+
5230
5349
  /**
5231
5350
  * 获取秒
5232
5351
  * @date 2022年5月7日
5233
5352
  * @param {Date|string} [date] - 日期对象或日期字符串
5234
5353
  * @returns {number} 秒数(0-59)
5235
- */
5236
- var getSecond = function getSecond(date) {
5237
- if (!date) {
5238
- return new Date().getSeconds();
5239
- }
5240
- if (typeof date === 'string') {
5241
- date = new Date(date);
5242
- }
5243
- return date.getSeconds();
5244
- };
5245
-
5354
+ */
5355
+ const getSecond = function (date) {
5356
+ if (!date) {
5357
+ return new Date().getSeconds();
5358
+ }
5359
+ if (typeof date === 'string') {
5360
+ date = new Date(date);
5361
+ }
5362
+ return date.getSeconds();
5363
+ };
5364
+
5246
5365
  /**
5247
5366
  * 获取星期几
5248
5367
  * @date 2022年5月7日
5249
5368
  * @param {Date|string} [date] - 日期对象或日期字符串
5250
5369
  * @returns {number} 星期几(0-6,0表示星期日)
5251
- */
5252
- var getWeekday = function getWeekday(date) {
5253
- if (!date) {
5254
- return new Date().getDay();
5255
- }
5256
- if (typeof date === 'string') {
5257
- date = new Date(date);
5258
- }
5259
- return date.getDay();
5260
- };
5261
-
5370
+ */
5371
+ const getWeekday = function (date) {
5372
+ if (!date) {
5373
+ return new Date().getDay();
5374
+ }
5375
+ if (typeof date === 'string') {
5376
+ date = new Date(date);
5377
+ }
5378
+ return date.getDay();
5379
+ };
5380
+
5381
+
5262
5382
  /**
5263
5383
  * @desc 获取上午/下午/晚上
5264
5384
  * @author huangbo
5265
5385
  * @date 2022年5月7日
5266
5386
  * @param {String} [time] - 时间
5267
- **/
5268
- var timeCycle = function timeCycle(time) {
5269
- var hour = 0;
5270
- if (!time) {
5271
- hour = new Date().getHours();
5272
- } else if (typeof time === 'string') {
5273
- // 从时间字符串中提取小时
5274
- var match = time.match(/^(\d{1,2})/);
5275
- if (match) {
5276
- hour = parseInt(match[1], 10);
5277
- }
5278
- } else if (typeof time === 'number') {
5279
- hour = time;
5280
- }
5281
- // 判断时间段
5282
- if (hour >= 5 && hour < 12) {
5283
- return '上午';
5284
- } else if (hour >= 12 && hour < 18) {
5285
- return '下午';
5286
- } else {
5287
- return '晚上';
5288
- }
5387
+ **/
5388
+ const timeCycle = function (time) {
5389
+ let hour = 0;
5390
+ if (!time) {
5391
+ hour = new Date().getHours();
5392
+ } else if (typeof time === 'string') {
5393
+ // 从时间字符串中提取小时
5394
+ const match = time.match(/^(\d{1,2})/);
5395
+ if (match) {
5396
+ hour = parseInt(match[1], 10);
5397
+ }
5398
+ } else if (typeof time === 'number') {
5399
+ hour = time;
5400
+ }
5401
+ // 判断时间段
5402
+ if (hour >= 5 && hour < 12) {
5403
+ return '上午';
5404
+ } else if (hour >= 12 && hour < 18) {
5405
+ return '下午';
5406
+ } else {
5407
+ return '晚上';
5408
+ }
5289
5409
  };
5290
5410
 
5291
5411
  /***/ }),
@@ -5297,7 +5417,7 @@ module.exports = require("eoss/lib/message-box");
5297
5417
 
5298
5418
  /***/ }),
5299
5419
 
5300
- /***/ 89:
5420
+ /***/ 91:
5301
5421
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5302
5422
 
5303
5423
  "use strict";