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/form-item.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 = 169);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 172);
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,15 +3046,295 @@ 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
- /***/ 108:
3094
+ /***/ 1:
3289
3095
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3290
3096
 
3291
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;
3292
3290
 
3293
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form-item.vue?vue&type=template&id=29d321d6&
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
+ /***/ 110:
3333
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3334
+
3335
+ "use strict";
3336
+
3337
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/form-item.vue?vue&type=template&id=4f172582&
3294
3338
  var render = function () {
3295
3339
  var _vm = this
3296
3340
  var _h = _vm.$createElement
@@ -3392,23 +3436,23 @@ var staticRenderFns = []
3392
3436
  render._withStripped = true
3393
3437
 
3394
3438
 
3395
- // CONCATENATED MODULE: ./packages/form/src/form-item.vue?vue&type=template&id=29d321d6&
3439
+ // CONCATENATED MODULE: ./packages/form/src/form-item.vue?vue&type=template&id=4f172582&
3396
3440
 
3397
3441
  // EXTERNAL MODULE: external "async-validator"
3398
- var external_async_validator_ = __webpack_require__(124);
3442
+ var external_async_validator_ = __webpack_require__(126);
3399
3443
  var external_async_validator_default = /*#__PURE__*/__webpack_require__.n(external_async_validator_);
3400
3444
 
3401
3445
  // EXTERNAL MODULE: ./src/mixins/emitter.js
3402
3446
  var emitter = __webpack_require__(15);
3403
3447
 
3404
3448
  // EXTERNAL MODULE: ./src/utils/merge.js
3405
- var merge = __webpack_require__(22);
3449
+ var merge = __webpack_require__(23);
3406
3450
 
3407
3451
  // EXTERNAL MODULE: ./src/utils/util.js
3408
- var util = __webpack_require__(1);
3452
+ var util = __webpack_require__(0);
3409
3453
 
3410
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/label-wrap.vue?vue&type=template&id=5b1fb22a&
3411
- var label_wrapvue_type_template_id_5b1fb22a_render = function () {
3454
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/label-wrap.vue?vue&type=template&id=bb759994&
3455
+ var label_wrapvue_type_template_id_bb759994_render = function () {
3412
3456
  var _vm = this
3413
3457
  var _h = _vm.$createElement
3414
3458
  var _c = _vm._self._c || _h
@@ -3474,18 +3518,18 @@ var label_wrapvue_type_template_id_5b1fb22a_render = function () {
3474
3518
  2
3475
3519
  )
3476
3520
  }
3477
- var label_wrapvue_type_template_id_5b1fb22a_staticRenderFns = []
3478
- label_wrapvue_type_template_id_5b1fb22a_render._withStripped = true
3521
+ var label_wrapvue_type_template_id_bb759994_staticRenderFns = []
3522
+ label_wrapvue_type_template_id_bb759994_render._withStripped = true
3479
3523
 
3480
3524
 
3481
- // CONCATENATED MODULE: ./packages/form/src/label-wrap.vue?vue&type=template&id=5b1fb22a&
3525
+ // CONCATENATED MODULE: ./packages/form/src/label-wrap.vue?vue&type=template&id=bb759994&
3482
3526
 
3483
3527
  // EXTERNAL MODULE: external "eoss/lib/icon"
3484
- var icon_ = __webpack_require__(27);
3528
+ var icon_ = __webpack_require__(33);
3485
3529
  var icon_default = /*#__PURE__*/__webpack_require__.n(icon_);
3486
3530
 
3487
3531
  // EXTERNAL MODULE: external "eoss/lib/tips"
3488
- var tips_ = __webpack_require__(125);
3532
+ var tips_ = __webpack_require__(127);
3489
3533
  var tips_default = /*#__PURE__*/__webpack_require__.n(tips_);
3490
3534
 
3491
3535
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/form/src/label-wrap.vue?vue&type=script&lang=js&
@@ -3569,14 +3613,15 @@ var tips_default = /*#__PURE__*/__webpack_require__.n(tips_);
3569
3613
  labelContainerClass: function labelContainerClass() {
3570
3614
  return this.autoWidth ? {
3571
3615
  'es-form-item__label-wrap': true,
3572
- 'es-label-wrapper': true
3573
- } : {};
3616
+ 'es-label-wrapper': true,
3617
+ 'is-left': this.position === 'left'
3618
+ } : { 'is-left': this.position === 'left' };
3574
3619
  },
3575
3620
 
3576
3621
  // 标签容器样式
3577
3622
  labelWrapStyle: function labelWrapStyle() {
3578
3623
  // 非自动宽度模式下才设置固定宽度
3579
- if (!this.autoWidth && this.esForm && this.esForm.labelPosition !== 'top' && this.position !== 'top') {
3624
+ if (!this.autoWidth && this.esForm && (this.position === 'left' || this.esForm.labelPosition !== 'top' && this.position !== 'top')) {
3580
3625
  var labelWidth = parseInt((this.esFormItem || {}).labelWidth || this.esForm.labelWidth || this.computedWidth, 10);
3581
3626
  return this.$slots.default || this.contents && this.contents.length > 0 ? labelWidth ? { width: labelWidth + 'px' } : {} : { width: '0' };
3582
3627
  }
@@ -3673,8 +3718,8 @@ var componentNormalizer = __webpack_require__(4);
3673
3718
 
3674
3719
  var component = Object(componentNormalizer["a" /* default */])(
3675
3720
  src_label_wrapvue_type_script_lang_js_,
3676
- label_wrapvue_type_template_id_5b1fb22a_render,
3677
- label_wrapvue_type_template_id_5b1fb22a_staticRenderFns,
3721
+ label_wrapvue_type_template_id_bb759994_render,
3722
+ label_wrapvue_type_template_id_bb759994_staticRenderFns,
3678
3723
  false,
3679
3724
  null,
3680
3725
  null,
@@ -3894,13 +3939,23 @@ function debounce(fn) {
3894
3939
  return value >= 1 && value <= 12;
3895
3940
  }
3896
3941
  },
3942
+ col: {
3943
+ type: Number,
3944
+ validator: function validator(value) {
3945
+ return value >= 1 && value <= 12;
3946
+ }
3947
+ },
3897
3948
  /**
3898
3949
  * 是否最后一个表单项
3899
3950
  */
3900
3951
  last: {
3901
3952
  type: Boolean,
3902
3953
  default: false
3903
- }
3954
+ },
3955
+ /**
3956
+ * 后面是否留空(即下一个元素换行)
3957
+ */
3958
+ space: Boolean
3904
3959
  },
3905
3960
  components: {
3906
3961
  LabelWrap: label_wrap
@@ -3917,6 +3972,30 @@ function debounce(fn) {
3917
3972
  this.validateState = value;
3918
3973
  },
3919
3974
 
3975
+ // 表单切换为只读时,清除已有校验错误(只读不应展示校验报错)
3976
+ formReadonly: function formReadonly(val) {
3977
+ if (val) {
3978
+ this.clearValidate();
3979
+ }
3980
+ },
3981
+
3982
+ // space 开启/关闭时重新实测并注册 resize 监听
3983
+ space: function space(val) {
3984
+ var _this2 = this;
3985
+
3986
+ if (val) {
3987
+ this.$nextTick(this.calcSpaceMargin);
3988
+ if (!this._resizeHandler) {
3989
+ this._resizeHandler = debounce(function () {
3990
+ return _this2.calcSpaceMargin();
3991
+ }, 100);
3992
+ window.addEventListener('resize', this._resizeHandler);
3993
+ }
3994
+ } else {
3995
+ this.spaceRight = null;
3996
+ }
3997
+ },
3998
+
3920
3999
  // 监听prop变化,重新绑定事件
3921
4000
  prop: {
3922
4001
  immediate: false,
@@ -3933,6 +4012,11 @@ function debounce(fn) {
3933
4012
  return this.for || this.prop || this.name;
3934
4013
  },
3935
4014
 
4015
+ // 表单级只读(插槽模式下控件靠 inject 取值,配置模式由 form 下传)
4016
+ formReadonly: function formReadonly() {
4017
+ return !!(this.esForm && this.esForm.readonly);
4018
+ },
4019
+
3936
4020
  // 表单项样式
3937
4021
  itemStyle: function itemStyle() {
3938
4022
  if (this.esForm.inline) {
@@ -3944,23 +4028,23 @@ function debounce(fn) {
3944
4028
  };
3945
4029
  }
3946
4030
  var columns = this.esForm.columns;
3947
- if (this.span) {
3948
- if (this.span > columns) {
3949
- return {
3950
- width: this.span / 12 * 100 + '%'
3951
- };
3952
- }
3953
-
3954
- return {
3955
- width: 100 / columns * this.span + '%'
3956
- };
4031
+ var width = '';
4032
+ if (this.span || this.col) {
4033
+ var span = this.span || this.col;
4034
+ width = span > columns ? span / 12 * 100 + '%' : 100 / columns * span + '%';
3957
4035
  }
3958
- if (columns > 1) {
3959
- return {
3960
- width: 100 / columns + '%'
3961
- };
4036
+ if (!width) {
4037
+ return {};
3962
4038
  }
3963
- return {};
4039
+ var style = { width: width };
4040
+ // space=true:让下一个元素换行——margin-right 需占满“本行剩余空间”,
4041
+ // 且必须 <= 剩余空间,否则当前元素自身会被挤到下一行。
4042
+ // 剩余空间取决于元素在当前行中的列位置,静态百分比无法覆盖多列场景,
4043
+ // 故首次渲染先用 calc 兜底,挂载后按实测的 spaceRight 精确修正。
4044
+ if (this.space) {
4045
+ style.marginRight = this.spaceRight != null ? this.spaceRight + 'px' : 'calc(100% - ' + width + ')';
4046
+ }
4047
+ return style;
3964
4048
  },
3965
4049
  contentStyle: function contentStyle() {
3966
4050
  // 缓存form和相关配置,避免多次访问
@@ -3968,8 +4052,18 @@ function debounce(fn) {
3968
4052
  var labelWidth = this.labelWidth || form.labelWidth;
3969
4053
  var label = this.label || this.$slots.label;
3970
4054
  // 快速路径:无需计算样式
3971
- if (!label || this.labelPosition === 'top' || form.labelPosition === 'top' || form.inline) return {};
3972
- if (!this.labelWidth && this.isNested) return {};
4055
+ // 无 label 直接返回;labelPosition 为 left 时,内容需按 labelWidth
4056
+ // 预留 marginLeft,即使 form 级为 top/inline 也不能走快速返回
4057
+ if (!label || form.inline) {
4058
+ return {};
4059
+ }
4060
+
4061
+ if (this.labelPosition !== 'left' && (this.labelPosition === 'top' || form.labelPosition === 'top')) {
4062
+ return {};
4063
+ }
4064
+ if (!this.labelWidth && this.isNested) {
4065
+ return {};
4066
+ }
3973
4067
 
3974
4068
  // 构建样式对象
3975
4069
  var ret = {};
@@ -3994,7 +4088,7 @@ function debounce(fn) {
3994
4088
  // 优化路径解析逻辑
3995
4089
  var target = this.index === undefined ? model : this.name ? model[this.name] && model[this.name][this.index] : model[this.index];
3996
4090
 
3997
- return target ? Object(util["t" /* getPropByPath */])(target, path, true).v : undefined;
4091
+ return target ? Object(util["u" /* getPropByPath */])(target, path, true).v : undefined;
3998
4092
  },
3999
4093
  isRequired: function isRequired() {
4000
4094
  // 缓存规则计算结果
@@ -4028,12 +4122,44 @@ function debounce(fn) {
4028
4122
  _formCache: null,
4029
4123
  _requiredCache: undefined,
4030
4124
  _needUpdateRequired: true,
4125
+ // space=true 时实测出的“本行右侧剩余空间”(px),用于精确 margin-right
4126
+ spaceRight: null,
4031
4127
  // 缓存验证Promise避免重复验证
4032
4128
  _validatePromise: null
4033
4129
  };
4034
4130
  },
4035
4131
 
4036
4132
  methods: {
4133
+ /**
4134
+ * 实测当前元素所在行右侧剩余空间,用于精确计算 space=true 时的 margin-right。
4135
+ * 因 margin-right 不影响元素自身左边与宽度,故可任意时刻重复测量,结果稳定。
4136
+ */
4137
+ calcSpaceMargin: function calcSpaceMargin() {
4138
+ if (!this.space || !this.esForm || this.esForm.inline || this.inline) {
4139
+ if (this.spaceRight !== null) this.spaceRight = null;
4140
+ return;
4141
+ }
4142
+ var el = this.$el;
4143
+ var parent = el && el.parentElement;
4144
+ if (!parent || !el) return;
4145
+ // 临时去除自身 margin-right,测量“本应所在列位置”,
4146
+ // 避免初始 calc 兜底值把元素先顶到下一行导致误测
4147
+ var prevMarginRight = el.style.marginRight;
4148
+ el.style.marginRight = '0px';
4149
+ var elRect = el.getBoundingClientRect();
4150
+ var parentRect = parent.getBoundingClientRect();
4151
+ el.style.marginRight = prevMarginRight;
4152
+ var paddingRight = parseFloat(getComputedStyle(parent).paddingRight) || 0;
4153
+ var contentRight = parentRect.right - paddingRight;
4154
+ // floor 保证 margin-right <= 剩余空间,避免当前元素自身被挤到下一行
4155
+ var remaining = Math.floor(contentRight - elRect.right);
4156
+ var spaceRight = remaining > 0 ? remaining : 0;
4157
+ if (spaceRight !== this.spaceRight) {
4158
+ this.spaceRight = spaceRight;
4159
+ }
4160
+ },
4161
+
4162
+
4037
4163
  // 使用防抖优化change事件的验证
4038
4164
  onFieldChange: debounce(function () {
4039
4165
  if (this.validateDisabled) {
@@ -4044,11 +4170,18 @@ function debounce(fn) {
4044
4170
  }, 100),
4045
4171
 
4046
4172
  validate: function validate(trigger) {
4047
- var _this2 = this;
4173
+ var _this3 = this;
4048
4174
 
4049
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : util["K" /* noop */];
4175
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : util["L" /* noop */];
4050
4176
 
4051
4177
  this.validateDisabled = false;
4178
+ // 只读表单不参与校验:直接复位错误态并视为通过
4179
+ if (this.formReadonly) {
4180
+ this.validateState = '';
4181
+ this.validateMessage = '';
4182
+ callback();
4183
+ return true;
4184
+ }
4052
4185
  var rules = this.getFilteredRule(trigger);
4053
4186
  if ((!rules || rules.length === 0) && this.required === undefined) {
4054
4187
  callback();
@@ -4070,10 +4203,10 @@ function debounce(fn) {
4070
4203
 
4071
4204
  model[this.prop] = this.fieldValue;
4072
4205
  validator.validate(model, { firstFields: true }, function (errors, invalidFields) {
4073
- _this2.validateState = !errors ? 'success' : 'error';
4074
- _this2.validateMessage = errors ? errors[0].message : '';
4075
- callback(_this2.validateMessage, invalidFields, errors ? _this2.$el : null);
4076
- _this2.esForm && _this2.esForm.$emit('validate', _this2.prop, !errors, _this2.validateMessage || null, _this2.$el);
4206
+ _this3.validateState = !errors ? 'success' : 'error';
4207
+ _this3.validateMessage = errors ? errors[0].message : '';
4208
+ callback(_this3.validateMessage, invalidFields, errors ? _this3.$el : null);
4209
+ _this3.esForm && _this3.esForm.$emit('validate', _this3.prop, !errors, _this3.validateMessage || null, _this3.$el);
4077
4210
  });
4078
4211
  },
4079
4212
  clearValidate: function clearValidate() {
@@ -4084,7 +4217,7 @@ function debounce(fn) {
4084
4217
  this._validatePromise = null;
4085
4218
  },
4086
4219
  resetField: function resetField() {
4087
- var _this3 = this;
4220
+ var _this4 = this;
4088
4221
 
4089
4222
  this.validateState = '';
4090
4223
  this.validateMessage = '';
@@ -4102,7 +4235,7 @@ function debounce(fn) {
4102
4235
 
4103
4236
  var prop = void 0;
4104
4237
  try {
4105
- prop = Object(util["t" /* getPropByPath */])(model, normalizedPath, true);
4238
+ prop = Object(util["u" /* getPropByPath */])(model, normalizedPath, true);
4106
4239
  } catch (error) {
4107
4240
  console.error('获取属性路径失败:', error);
4108
4241
  return;
@@ -4123,7 +4256,7 @@ function debounce(fn) {
4123
4256
 
4124
4257
  // reset validateDisabled after onFieldChange triggered
4125
4258
  this.$nextTick(function () {
4126
- _this3.validateDisabled = false;
4259
+ _this4.validateDisabled = false;
4127
4260
  });
4128
4261
 
4129
4262
  // 使用try-catch避免广播失败
@@ -4147,7 +4280,7 @@ function debounce(fn) {
4147
4280
  var formFieldRules = [];
4148
4281
  if (formRules && this.prop) {
4149
4282
  try {
4150
- var prop = Object(util["t" /* getPropByPath */])(formRules, this.prop);
4283
+ var prop = Object(util["u" /* getPropByPath */])(formRules, this.prop);
4151
4284
  formFieldRules = prop.o[this.prop] || prop.v || [];
4152
4285
  } catch (error) {
4153
4286
  console.warn('\u83B7\u53D6\u8868\u5355\u89C4\u5219\u5931\u8D25: ' + this.prop, error);
@@ -4218,6 +4351,8 @@ function debounce(fn) {
4218
4351
  },
4219
4352
 
4220
4353
  mounted: function mounted() {
4354
+ var _this5 = this;
4355
+
4221
4356
  if (this.prop) {
4222
4357
  try {
4223
4358
  this.dispatch('EsForm', 'es.form.addField', [this]);
@@ -4238,6 +4373,18 @@ function debounce(fn) {
4238
4373
  console.error('表单字段初始化失败:', error);
4239
4374
  }
4240
4375
  }
4376
+ if (this.space) {
4377
+ this.$nextTick(this.calcSpaceMargin);
4378
+ this._resizeHandler = debounce(function () {
4379
+ return _this5.calcSpaceMargin();
4380
+ }, 100);
4381
+ window.addEventListener('resize', this._resizeHandler);
4382
+ }
4383
+ },
4384
+ updated: function updated() {
4385
+ if (this.space) {
4386
+ this.calcSpaceMargin();
4387
+ }
4241
4388
  },
4242
4389
  beforeDestroy: function beforeDestroy() {
4243
4390
  try {
@@ -4253,6 +4400,10 @@ function debounce(fn) {
4253
4400
  this._formCache = null;
4254
4401
  this.validator = null;
4255
4402
  this._validatePromise = null;
4403
+ if (this._resizeHandler) {
4404
+ window.removeEventListener('resize', this._resizeHandler);
4405
+ this._resizeHandler = null;
4406
+ }
4256
4407
  // 避免循环引用
4257
4408
  if (this.$parent && this.$parent.$options && this.$parent.$options.componentName === 'EsForm') {
4258
4409
  // 清理对父组件的引用
@@ -4299,7 +4450,7 @@ var form_item_component = Object(componentNormalizer["a" /* default */])(
4299
4450
  /* unused harmony export hsvTorgb */
4300
4451
  /* unused harmony export mixColor */
4301
4452
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getRgb; });
4302
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
4453
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
4303
4454
 
4304
4455
  var $hueStep = 2;
4305
4456
  var $saturationStep1 = 0.16;
@@ -4350,7 +4501,7 @@ var getColor = function getColor($color, $n) {
4350
4501
  var getLightness = function getLightness($v, $i, $isLight) {
4351
4502
  var $value = $isLight ? $v + $brightnessStep1 * $i : $v - $brightnessStep2 * $i;
4352
4503
  $value = $value < 1 ? $value : 1;
4353
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($value, 2);
4504
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($value, 2);
4354
4505
  };
4355
4506
 
4356
4507
  /**
@@ -4374,7 +4525,7 @@ var getSaturation = function getSaturation($s, $i, $isLight) {
4374
4525
  $saturation = 0.1;
4375
4526
  }
4376
4527
  $saturation = $saturation > 0.06 ? $saturation : 0.06;
4377
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($saturation, 2);
4528
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($saturation, 2);
4378
4529
  };
4379
4530
 
4380
4531
  /**
@@ -4488,14 +4639,14 @@ var getRgb = function getRgb($color) {
4488
4639
 
4489
4640
  /***/ }),
4490
4641
 
4491
- /***/ 124:
4642
+ /***/ 126:
4492
4643
  /***/ (function(module, exports) {
4493
4644
 
4494
4645
  module.exports = require("async-validator");
4495
4646
 
4496
4647
  /***/ }),
4497
4648
 
4498
- /***/ 125:
4649
+ /***/ 127:
4499
4650
  /***/ (function(module, exports) {
4500
4651
 
4501
4652
  module.exports = require("eoss/lib/tips");
@@ -4549,12 +4700,19 @@ module.exports = require("eoss/lib/loading");
4549
4700
 
4550
4701
  /***/ }),
4551
4702
 
4552
- /***/ 169:
4703
+ /***/ 17:
4704
+ /***/ (function(module, exports) {
4705
+
4706
+ module.exports = require("lodash/get");
4707
+
4708
+ /***/ }),
4709
+
4710
+ /***/ 172:
4553
4711
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4554
4712
 
4555
4713
  "use strict";
4556
4714
  __webpack_require__.r(__webpack_exports__);
4557
- /* harmony import */ var _form_src_form_item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(108);
4715
+ /* harmony import */ var _form_src_form_item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(110);
4558
4716
 
4559
4717
 
4560
4718
  /* istanbul ignore next */
@@ -4566,13 +4724,6 @@ _form_src_form_item__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].install = fu
4566
4724
 
4567
4725
  /***/ }),
4568
4726
 
4569
- /***/ 17:
4570
- /***/ (function(module, exports) {
4571
-
4572
- module.exports = require("lodash/get");
4573
-
4574
- /***/ }),
4575
-
4576
4727
  /***/ 18:
4577
4728
  /***/ (function(module, exports) {
4578
4729
 
@@ -4594,7 +4745,7 @@ module.exports = require("vue");
4594
4745
 
4595
4746
  /***/ }),
4596
4747
 
4597
- /***/ 22:
4748
+ /***/ 23:
4598
4749
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4599
4750
 
4600
4751
  "use strict";
@@ -4616,13 +4767,6 @@ module.exports = require("vue");
4616
4767
 
4617
4768
  /***/ }),
4618
4769
 
4619
- /***/ 27:
4620
- /***/ (function(module, exports) {
4621
-
4622
- module.exports = require("eoss/lib/icon");
4623
-
4624
- /***/ }),
4625
-
4626
4770
  /***/ 3:
4627
4771
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4628
4772
 
@@ -4690,6 +4834,13 @@ function isDefined(val) {
4690
4834
 
4691
4835
  /***/ }),
4692
4836
 
4837
+ /***/ 33:
4838
+ /***/ (function(module, exports) {
4839
+
4840
+ module.exports = require("eoss/lib/icon");
4841
+
4842
+ /***/ }),
4843
+
4693
4844
  /***/ 4:
4694
4845
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4695
4846
 
@@ -4845,736 +4996,759 @@ function normalizeComponent(
4845
4996
  /* unused harmony export getSecond */
4846
4997
  /* unused harmony export getWeekday */
4847
4998
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4848
-
4849
-
4999
+ /* Modified from https://github.com/taylorhakes/fecha
5000
+ *
5001
+ * The MIT License (MIT)
5002
+ *
5003
+ * Copyright (c) 2015 Taylor Hakes
5004
+ *
5005
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5006
+ * of this software and associated documentation files (the "Software"), to deal
5007
+ * in the Software without restriction, including without limitation the rights
5008
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5009
+ * copies of the Software, and to permit persons to whom the Software is
5010
+ * furnished to do so, subject to the following conditions:
5011
+ *
5012
+ * The above copyright notice and this permission notice shall be included in all
5013
+ * copies or substantial portions of the Software.
5014
+ *
5015
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5016
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5017
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5018
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5019
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5020
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5021
+ * SOFTWARE.
5022
+ */
5023
+
5024
+ /*eslint-disable*/
5025
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5026
+
5027
+
4850
5028
  /**
4851
5029
  * Parse or format dates
4852
5030
  * @class fecha
4853
- */
4854
- var fecha = {};
4855
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4856
- var twoDigits = '\\d\\d?';
4857
- var threeDigits = '\\d{3}';
4858
- var fourDigits = '\\d{4}';
4859
- var word = '[^\\s]+';
4860
- var literal = /\[([^]*?)\]/gm;
4861
- var noop = function noop() {};
4862
-
4863
- function regexEscape(str) {
4864
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4865
- }
4866
-
4867
- function shorten(arr, sLen) {
4868
- var newArr = [];
4869
- for (var i = 0, len = arr.length; i < len; i++) {
4870
- newArr.push(arr[i].substr(0, sLen));
4871
- }
4872
- return newArr;
4873
- }
4874
-
4875
- function monthUpdate() {
4876
- return function (d, v) {
4877
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4878
- if (~index) {
4879
- d.month = index;
4880
- }
4881
- };
4882
- }
4883
-
4884
- function pad(val, len) {
4885
- val = String(val);
4886
- len = len || 2;
4887
- while (val.length < len) {
4888
- val = '0' + val;
4889
- }
4890
- return val;
4891
- }
4892
-
4893
- // 直接使用中文日期名称常量
4894
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4895
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4896
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4897
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4898
- var amPm = ['上午', '下午'];
4899
- var DoFn = function DoFn(D) {
4900
- return D + '日';
4901
- };
4902
-
4903
- var formatFlags = {
4904
- D: function D(dateObj) {
4905
- return dateObj.getDay();
4906
- },
4907
- DD: function DD(dateObj) {
4908
- return pad(dateObj.getDay());
4909
- },
4910
- Do: function Do(dateObj) {
4911
- return DoFn(dateObj.getDate());
4912
- },
4913
- d: function d(dateObj) {
4914
- return dateObj.getDate();
4915
- },
4916
- dd: function dd(dateObj) {
4917
- return pad(dateObj.getDate());
4918
- },
4919
- ddd: function ddd(dateObj) {
4920
- return dayNamesShort[dateObj.getDay()];
4921
- },
4922
- dddd: function dddd(dateObj) {
4923
- return dayNames[dateObj.getDay()];
4924
- },
4925
- M: function M(dateObj) {
4926
- return dateObj.getMonth() + 1;
4927
- },
4928
- MM: function MM(dateObj) {
4929
- return pad(dateObj.getMonth() + 1);
4930
- },
4931
- MMM: function MMM(dateObj) {
4932
- return monthNamesShort[dateObj.getMonth()];
4933
- },
4934
- MMMM: function MMMM(dateObj) {
4935
- return monthNames[dateObj.getMonth()];
4936
- },
4937
- yy: function yy(dateObj) {
4938
- return pad(String(dateObj.getFullYear()), 4).substr(2);
4939
- },
4940
- yyyy: function yyyy(dateObj) {
4941
- return pad(dateObj.getFullYear(), 4);
4942
- },
4943
- h: function h(dateObj) {
4944
- return dateObj.getHours() % 12 || 12;
4945
- },
4946
- hh: function hh(dateObj) {
4947
- return pad(dateObj.getHours() % 12 || 12);
4948
- },
4949
- H: function H(dateObj) {
4950
- return dateObj.getHours();
4951
- },
4952
- HH: function HH(dateObj) {
4953
- return pad(dateObj.getHours());
4954
- },
4955
- m: function m(dateObj) {
4956
- return dateObj.getMinutes();
4957
- },
4958
- mm: function mm(dateObj) {
4959
- return pad(dateObj.getMinutes());
4960
- },
4961
- s: function s(dateObj) {
4962
- return dateObj.getSeconds();
4963
- },
4964
- ss: function ss(dateObj) {
4965
- return pad(dateObj.getSeconds());
4966
- },
4967
- S: function S(dateObj) {
4968
- return Math.round(dateObj.getMilliseconds() / 100);
4969
- },
4970
- SS: function SS(dateObj) {
4971
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4972
- },
4973
- SSS: function SSS(dateObj) {
4974
- return pad(dateObj.getMilliseconds(), 3);
4975
- },
4976
- a: function a(dateObj) {
4977
- return dateObj.getHours() < 12 ? '上午' : '下午';
4978
- },
4979
- A: function A(dateObj) {
4980
- return dateObj.getHours() < 12 ? '上午' : '下午';
4981
- },
4982
- ZZ: function ZZ(dateObj) {
4983
- var o = dateObj.getTimezoneOffset();
4984
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4985
- }
4986
- };
4987
-
4988
- var parseFlags = {
4989
- d: [twoDigits, function (d, v) {
4990
- d.day = v;
4991
- }],
4992
- Do: [twoDigits + word, function (d, v) {
4993
- d.day = parseInt(v, 10);
4994
- }],
4995
- M: [twoDigits, function (d, v) {
4996
- d.month = v - 1;
4997
- }],
4998
- yy: [twoDigits, function (d, v) {
4999
- var da = new Date(),
5000
- cent = +('' + da.getFullYear()).substr(0, 2);
5001
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5002
- }],
5003
- h: [twoDigits, function (d, v) {
5004
- d.hour = v;
5005
- }],
5006
- m: [twoDigits, function (d, v) {
5007
- d.minute = v;
5008
- }],
5009
- s: [twoDigits, function (d, v) {
5010
- d.second = v;
5011
- }],
5012
- yyyy: [fourDigits, function (d, v) {
5013
- d.year = v;
5014
- }],
5015
- S: ['\\d', function (d, v) {
5016
- d.millisecond = v * 100;
5017
- }],
5018
- SS: ['\\d{2}', function (d, v) {
5019
- d.millisecond = v * 10;
5020
- }],
5021
- SSS: [threeDigits, function (d, v) {
5022
- d.millisecond = v;
5023
- }],
5024
- D: [twoDigits, noop],
5025
- ddd: [word, noop],
5026
- MMM: [word, monthUpdate('monthNamesShort')],
5027
- MMMM: [word, monthUpdate('monthNames')],
5028
- a: [word, function (d, v) {
5029
- var val = v.toLowerCase();
5030
- if (val === '上午') {
5031
- d.isPm = false;
5032
- } else if (val === '下午') {
5033
- d.isPm = true;
5034
- }
5035
- }],
5036
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5037
- var parts = (v + '').match(/([+-]|\d\d)/gi),
5038
- minutes = void 0;
5039
-
5040
- if (parts) {
5041
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5042
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5043
- }
5044
- }]
5045
- };
5046
- parseFlags.dd = parseFlags.d;
5047
- parseFlags.dddd = parseFlags.ddd;
5048
- parseFlags.DD = parseFlags.D;
5049
- parseFlags.mm = parseFlags.m;
5050
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5051
- parseFlags.MM = parseFlags.M;
5052
- parseFlags.ss = parseFlags.s;
5053
- parseFlags.A = parseFlags.a;
5054
-
5055
- // Some common format strings
5056
- fecha.masks = {
5057
- default: 'ddd MMM dd yyyy HH:mm:ss',
5058
- shortDate: 'M/D/yy',
5059
- mediumDate: 'MMM d, yyyy',
5060
- longDate: 'MMMM d, yyyy',
5061
- fullDate: 'dddd, MMMM d, yyyy',
5062
- shortTime: 'HH:mm',
5063
- mediumTime: 'HH:mm:ss',
5064
- longTime: 'HH:mm:ss.SSS'
5065
- };
5066
-
5031
+ */
5032
+ const fecha = {};
5033
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5034
+ const twoDigits = '\\d\\d?';
5035
+ const threeDigits = '\\d{3}';
5036
+ const fourDigits = '\\d{4}';
5037
+ const word = '[^\\s]+';
5038
+ const literal = /\[([^]*?)\]/gm;
5039
+ const noop = function () {};
5040
+
5041
+ function regexEscape(str) {
5042
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5043
+ }
5044
+
5045
+ function shorten(arr, sLen) {
5046
+ const newArr = [];
5047
+ for (let i = 0, len = arr.length; i < len; i++) {
5048
+ newArr.push(arr[i].substr(0, sLen));
5049
+ }
5050
+ return newArr;
5051
+ }
5052
+
5053
+ function monthUpdate() {
5054
+ return function (d, v) {
5055
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5056
+ if (~index) {
5057
+ d.month = index;
5058
+ }
5059
+ };
5060
+ }
5061
+
5062
+ function pad(val, len) {
5063
+ val = String(val);
5064
+ len = len || 2;
5065
+ while (val.length < len) {
5066
+ val = '0' + val;
5067
+ }
5068
+ return val;
5069
+ }
5070
+
5071
+ // 直接使用中文日期名称常量
5072
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5073
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5074
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5075
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5076
+ const amPm = ['上午', '下午'];
5077
+ const DoFn = function DoFn(D) {
5078
+ return D + '日';
5079
+ };
5080
+
5081
+ const formatFlags = {
5082
+ D: function(dateObj) {
5083
+ return dateObj.getDay();
5084
+ },
5085
+ DD: function(dateObj) {
5086
+ return pad(dateObj.getDay());
5087
+ },
5088
+ Do: function(dateObj) {
5089
+ return DoFn(dateObj.getDate());
5090
+ },
5091
+ d: function(dateObj) {
5092
+ return dateObj.getDate();
5093
+ },
5094
+ dd: function(dateObj) {
5095
+ return pad(dateObj.getDate());
5096
+ },
5097
+ ddd: function(dateObj) {
5098
+ return dayNamesShort[dateObj.getDay()];
5099
+ },
5100
+ dddd: function(dateObj) {
5101
+ return dayNames[dateObj.getDay()];
5102
+ },
5103
+ M: function(dateObj) {
5104
+ return dateObj.getMonth() + 1;
5105
+ },
5106
+ MM: function(dateObj) {
5107
+ return pad(dateObj.getMonth() + 1);
5108
+ },
5109
+ MMM: function(dateObj) {
5110
+ return monthNamesShort[dateObj.getMonth()];
5111
+ },
5112
+ MMMM: function(dateObj) {
5113
+ return monthNames[dateObj.getMonth()];
5114
+ },
5115
+ yy: function(dateObj) {
5116
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5117
+ },
5118
+ yyyy: function(dateObj) {
5119
+ return pad(dateObj.getFullYear(), 4);
5120
+ },
5121
+ h: function(dateObj) {
5122
+ return dateObj.getHours() % 12 || 12;
5123
+ },
5124
+ hh: function(dateObj) {
5125
+ return pad(dateObj.getHours() % 12 || 12);
5126
+ },
5127
+ H: function(dateObj) {
5128
+ return dateObj.getHours();
5129
+ },
5130
+ HH: function(dateObj) {
5131
+ return pad(dateObj.getHours());
5132
+ },
5133
+ m: function(dateObj) {
5134
+ return dateObj.getMinutes();
5135
+ },
5136
+ mm: function(dateObj) {
5137
+ return pad(dateObj.getMinutes());
5138
+ },
5139
+ s: function(dateObj) {
5140
+ return dateObj.getSeconds();
5141
+ },
5142
+ ss: function(dateObj) {
5143
+ return pad(dateObj.getSeconds());
5144
+ },
5145
+ S: function(dateObj) {
5146
+ return Math.round(dateObj.getMilliseconds() / 100);
5147
+ },
5148
+ SS: function(dateObj) {
5149
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5150
+ },
5151
+ SSS: function(dateObj) {
5152
+ return pad(dateObj.getMilliseconds(), 3);
5153
+ },
5154
+ a: function(dateObj) {
5155
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5156
+ },
5157
+ A: function(dateObj) {
5158
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5159
+ },
5160
+ ZZ: function(dateObj) {
5161
+ const o = dateObj.getTimezoneOffset();
5162
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5163
+ }
5164
+ };
5165
+
5166
+ const parseFlags = {
5167
+ d: [twoDigits, function (d, v) {
5168
+ d.day = v;
5169
+ }],
5170
+ Do: [twoDigits + word, function (d, v) {
5171
+ d.day = parseInt(v, 10);
5172
+ }],
5173
+ M: [twoDigits, function (d, v) {
5174
+ d.month = v - 1;
5175
+ }],
5176
+ yy: [twoDigits, function (d, v) {
5177
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5178
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5179
+ }],
5180
+ h: [twoDigits, function (d, v) {
5181
+ d.hour = v;
5182
+ }],
5183
+ m: [twoDigits, function (d, v) {
5184
+ d.minute = v;
5185
+ }],
5186
+ s: [twoDigits, function (d, v) {
5187
+ d.second = v;
5188
+ }],
5189
+ yyyy: [fourDigits, function (d, v) {
5190
+ d.year = v;
5191
+ }],
5192
+ S: ['\\d', function (d, v) {
5193
+ d.millisecond = v * 100;
5194
+ }],
5195
+ SS: ['\\d{2}', function (d, v) {
5196
+ d.millisecond = v * 10;
5197
+ }],
5198
+ SSS: [threeDigits, function (d, v) {
5199
+ d.millisecond = v;
5200
+ }],
5201
+ D: [twoDigits, noop],
5202
+ ddd: [word, noop],
5203
+ MMM: [word, monthUpdate('monthNamesShort')],
5204
+ MMMM: [word, monthUpdate('monthNames')],
5205
+ a: [word, function (d, v) {
5206
+ const val = v.toLowerCase();
5207
+ if (val === '上午') {
5208
+ d.isPm = false;
5209
+ } else if (val === '下午') {
5210
+ d.isPm = true;
5211
+ }
5212
+ }],
5213
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5214
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5215
+
5216
+ if (parts) {
5217
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5218
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5219
+ }
5220
+ }]
5221
+ };
5222
+ parseFlags.dd = parseFlags.d;
5223
+ parseFlags.dddd = parseFlags.ddd;
5224
+ parseFlags.DD = parseFlags.D;
5225
+ parseFlags.mm = parseFlags.m;
5226
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5227
+ parseFlags.MM = parseFlags.M;
5228
+ parseFlags.ss = parseFlags.s;
5229
+ parseFlags.A = parseFlags.a;
5230
+
5231
+
5232
+ // Some common format strings
5233
+ fecha.masks = {
5234
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5235
+ shortDate: 'M/D/yy',
5236
+ mediumDate: 'MMM d, yyyy',
5237
+ longDate: 'MMMM d, yyyy',
5238
+ fullDate: 'dddd, MMMM d, yyyy',
5239
+ shortTime: 'HH:mm',
5240
+ mediumTime: 'HH:mm:ss',
5241
+ longTime: 'HH:mm:ss.SSS'
5242
+ };
5243
+
5067
5244
  /***
5068
5245
  * Format a date
5069
5246
  * @method format
5070
5247
  * @param {Date|number} dateObj
5071
5248
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5072
- */
5073
- fecha.format = function (dateObj, mask) {
5074
- if (typeof dateObj === 'number') {
5075
- dateObj = new Date(dateObj);
5076
- }
5077
-
5078
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5079
- throw new Error('Invalid Date in fecha.format');
5080
- }
5081
-
5082
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5083
-
5084
- var literals = [];
5085
-
5086
- // Make literals inactive by replacing them with ??
5087
- mask = mask.replace(literal, function ($0, $1) {
5088
- literals.push($1);
5089
- return '@@@';
5090
- });
5091
- // Apply formatting rules
5092
- mask = mask.replace(token, function ($0) {
5093
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5094
- });
5095
- // Inline literal values back into the formatted value
5096
- return mask.replace(/@@@/g, function () {
5097
- return literals.shift();
5098
- });
5099
- };
5100
-
5249
+ */
5250
+ fecha.format = function (dateObj, mask) {
5251
+ if (typeof dateObj === 'number') {
5252
+ dateObj = new Date(dateObj);
5253
+ }
5254
+
5255
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5256
+ throw new Error('Invalid Date in fecha.format');
5257
+ }
5258
+
5259
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5260
+
5261
+ const literals = [];
5262
+
5263
+ // Make literals inactive by replacing them with ??
5264
+ mask = mask.replace(literal, function($0, $1) {
5265
+ literals.push($1);
5266
+ return '@@@';
5267
+ });
5268
+ // Apply formatting rules
5269
+ mask = mask.replace(token, function ($0) {
5270
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5271
+ });
5272
+ // Inline literal values back into the formatted value
5273
+ return mask.replace(/@@@/g, function() {
5274
+ return literals.shift();
5275
+ });
5276
+ };
5277
+
5101
5278
  /**
5102
5279
  * Parse a date string into an object, changes - into /
5103
5280
  * @method parse
5104
5281
  * @param {string} dateStr Date string
5105
5282
  * @param {string} format Date parse format
5106
5283
  * @returns {Date|boolean}
5107
- */
5108
- fecha.parse = function (dateStr, format) {
5109
- if (typeof format !== 'string') {
5110
- throw new Error('Invalid format in fecha.parse');
5111
- }
5112
-
5113
- format = fecha.masks[format] || format;
5114
-
5115
- // Avoid regular expression denial of service, fail early for really long strings
5116
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5117
- if (dateStr.length > 1000) {
5118
- return null;
5119
- }
5120
-
5121
- var dateInfo = {};
5122
- var parseInfo = [];
5123
- var literals = [];
5124
- format = format.replace(literal, function ($0, $1) {
5125
- literals.push($1);
5126
- return '@@@';
5127
- });
5128
- var newFormat = regexEscape(format).replace(token, function ($0) {
5129
- if (parseFlags[$0]) {
5130
- var info = parseFlags[$0];
5131
- parseInfo.push(info[1]);
5132
- return '(' + info[0] + ')';
5133
- }
5134
-
5135
- return $0;
5136
- });
5137
- newFormat = newFormat.replace(/@@@/g, function () {
5138
- return literals.shift();
5139
- });
5140
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
5141
- if (!matches) {
5142
- return null;
5143
- }
5144
-
5145
- for (var i = 1; i < matches.length; i++) {
5146
- parseInfo[i - 1](dateInfo, matches[i]);
5147
- }
5148
-
5149
- var today = new Date();
5150
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5151
- dateInfo.hour = +dateInfo.hour + 12;
5152
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5153
- dateInfo.hour = 0;
5154
- }
5155
-
5156
- var date = void 0;
5157
- if (dateInfo.timezoneOffset != null) {
5158
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5159
- 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));
5160
- } else {
5161
- 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);
5162
- }
5163
- return date;
5164
- };
5165
-
5166
- // 导出fecha对象
5167
-
5168
-
5169
- // 以下是从date-util.js合并的函数
5170
- var newArray = function newArray(start, end) {
5171
- var result = [];
5172
- for (var i = start; i <= end; i++) {
5173
- result.push(i);
5174
- }
5175
- return result;
5176
- };
5177
-
5178
- var getSettings = function getSettings() {
5179
- return {
5180
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5181
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5182
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5183
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5184
- amPm: ['上午', '下午']
5185
- };
5186
- };
5187
-
5188
- var toDate = function toDate(date) {
5189
- return isDate(date) ? new Date(date) : null;
5190
- };
5191
-
5192
- var isDate = function isDate(date) {
5193
- if (date === null || date === undefined) return false;
5194
- if (isNaN(new Date(date).getTime())) return false;
5195
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5196
- return true;
5197
- };
5198
-
5199
- var isDateObject = function isDateObject(val) {
5200
- return val instanceof Date;
5201
- };
5202
-
5203
- var formatDate = function formatDate(date) {
5204
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5205
-
5206
- // 处理多种输入类型
5207
- if (!date) return '';
5208
-
5209
- // 如果是时间戳,转成日期对象
5210
- if (typeof date === 'number') {
5211
- date = new Date(date);
5212
- }
5213
- // 如果是字符串,转成日期对象
5214
- if (typeof date === 'string') {
5215
- date = new Date(date);
5216
- }
5217
-
5218
- // 调用toDate进一步验证和转换
5219
- date = toDate(date);
5220
- if (!date) return '';
5221
-
5222
- // 兼容大写和小写的格式标记
5223
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5224
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5225
-
5226
- // 使用fecha库进行格式化,支持中文配置
5227
- var str = fecha.format(date, lowercaseFormat, getSettings());
5228
- return str;
5229
- };
5230
-
5231
- var parseDate = function parseDate(string, format) {
5232
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5233
- };
5234
-
5235
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5236
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5237
- return 30;
5238
- }
5239
-
5240
- if (month === 1) {
5241
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5242
- return 29;
5243
- } else {
5244
- return 28;
5245
- }
5246
- }
5247
-
5248
- return 31;
5249
- };
5250
-
5251
- var getDayCountOfYear = function getDayCountOfYear(year) {
5252
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5253
- return isLeapYear ? 366 : 365;
5254
- };
5255
-
5256
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5257
- var temp = new Date(date.getTime());
5258
- temp.setDate(1);
5259
- return temp.getDay();
5260
- };
5261
-
5262
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5263
- // {prev, next} Date should work for Daylight Saving Time
5264
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5265
- var prevDate = function prevDate(date) {
5266
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5267
-
5268
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5269
- };
5270
-
5271
- var nextDate = function nextDate(date) {
5272
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5273
-
5274
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5275
- };
5276
-
5277
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5278
- var result = new Date(year, month, 1);
5279
- var day = result.getDay();
5280
-
5281
- if (day === 0) {
5282
- return prevDate(result, 7);
5283
- } else {
5284
- return prevDate(result, day);
5285
- }
5286
- };
5287
-
5288
- var getWeekNumber = function getWeekNumber(date) {
5289
- // 支持多种输入类型
5290
- if (!date || !isDate(date)) {
5291
- date = new Date();
5292
- }
5293
- if (typeof date === 'string') {
5294
- date = new Date(date);
5295
- }
5296
-
5297
- // 验证日期有效性
5298
- if (!isDate(date)) return null;
5299
-
5300
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5301
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5302
- // 将星期日的星期数设为7
5303
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5304
- // 获取当年的第一天
5305
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5306
- // 计算到最近的星期四的完整周数
5307
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5308
- // 返回周数
5309
- return weekNo;
5310
- };
5311
-
5312
- var getRangeHours = function getRangeHours(ranges) {
5313
- var hours = [];
5314
- var disabledHours = [];
5315
-
5316
- (ranges || []).forEach(function (range) {
5317
- var value = range.map(function (date) {
5318
- return date.getHours();
5319
- });
5320
-
5321
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5322
- });
5323
-
5324
- if (disabledHours.length) {
5325
- for (var i = 0; i < 24; i++) {
5326
- hours[i] = disabledHours.indexOf(i) === -1;
5327
- }
5328
- } else {
5329
- for (var _i = 0; _i < 24; _i++) {
5330
- hours[_i] = false;
5331
- }
5332
- }
5333
-
5334
- return hours;
5335
- };
5336
-
5337
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5338
- if (amount <= 0) return [];
5339
- var temp = new Date(date.getTime());
5340
- temp.setDate(0);
5341
- var lastDay = temp.getDate();
5342
- return range(amount).map(function (_, index) {
5343
- return lastDay - (amount - index - 1);
5344
- });
5345
- };
5346
-
5347
- var getMonthDays = function getMonthDays(date) {
5348
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5349
- var days = temp.getDate();
5350
- return range(days).map(function (_, index) {
5351
- return index + 1;
5352
- });
5353
- };
5354
-
5355
- function setRangeData(arr, start, end, value) {
5356
- for (var i = start; i < end; i++) {
5357
- arr[i] = value;
5358
- }
5359
- }
5360
-
5361
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5362
- var minutes = new Array(60);
5363
-
5364
- if (ranges.length > 0) {
5365
- ranges.forEach(function (range) {
5366
- var start = range[0];
5367
- var end = range[1];
5368
- var startHour = start.getHours();
5369
- var startMinute = start.getMinutes();
5370
- var endHour = end.getHours();
5371
- var endMinute = end.getMinutes();
5372
- if (startHour === hour && endHour !== hour) {
5373
- setRangeData(minutes, startMinute, 60, true);
5374
- } else if (startHour === hour && endHour === hour) {
5375
- setRangeData(minutes, startMinute, endMinute + 1, true);
5376
- } else if (startHour !== hour && endHour === hour) {
5377
- setRangeData(minutes, 0, endMinute + 1, true);
5378
- } else if (startHour < hour && endHour > hour) {
5379
- setRangeData(minutes, 0, 60, true);
5380
- }
5381
- });
5382
- } else {
5383
- setRangeData(minutes, 0, 60, true);
5384
- }
5385
- return minutes;
5386
- };
5387
-
5388
- var range = function range(n) {
5389
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5390
- return Array.apply(null, { length: n }).map(function (_, n) {
5391
- return n;
5392
- });
5393
- };
5394
-
5395
- var modifyDate = function modifyDate(date, y, m, d) {
5396
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5397
- };
5398
-
5399
- var modifyTime = function modifyTime(date, h, m, s) {
5400
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5401
- };
5402
-
5403
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
5404
- if (date == null || !time) {
5405
- return date;
5406
- }
5407
- time = parseDate(time, 'HH:mm:ss');
5408
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5409
- };
5410
-
5411
- var clearTime = function clearTime(date) {
5412
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5413
- };
5414
-
5415
- var clearMilliseconds = function clearMilliseconds(date) {
5416
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5417
- };
5418
-
5419
- var limitTimeRange = function limitTimeRange(date, ranges) {
5420
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5421
-
5422
- // TODO: refactory a more elegant solution
5423
- if (ranges.length === 0) return date;
5424
- var normalizeDate = function normalizeDate(date) {
5425
- return fecha.parse(fecha.format(date, format), format);
5426
- };
5427
- var ndate = normalizeDate(date);
5428
- var nranges = ranges.map(function (range) {
5429
- return range.map(normalizeDate);
5430
- });
5431
- if (nranges.some(function (nrange) {
5432
- return ndate >= nrange[0] && ndate <= nrange[1];
5433
- })) return date;
5434
-
5435
- var minDate = nranges[0][0];
5436
- var maxDate = nranges[0][0];
5437
-
5438
- nranges.forEach(function (nrange) {
5439
- minDate = new Date(Math.min(nrange[0], minDate));
5440
- maxDate = new Date(Math.max(nrange[1], minDate));
5441
- });
5442
-
5443
- var ret = ndate < minDate ? minDate : maxDate;
5444
- // preserve Year/Month/Date
5445
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5446
- };
5447
-
5448
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5449
- var limitedDate = limitTimeRange(date, selectableRange, format);
5450
- return limitedDate.getTime() === date.getTime();
5451
- };
5452
-
5453
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5454
- // clamp date to the number of days in `year`, `month`
5455
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5456
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5457
- return modifyDate(date, year, month, monthDate);
5458
- };
5459
-
5460
- var prevMonth = function prevMonth(date) {
5461
- var year = date.getFullYear();
5462
- var month = date.getMonth();
5463
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5464
- };
5465
-
5466
- var nextMonth = function nextMonth(date) {
5467
- var year = date.getFullYear();
5468
- var month = date.getMonth();
5469
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5470
- };
5471
-
5472
- var prevYear = function prevYear(date) {
5473
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5474
-
5475
- var year = date.getFullYear();
5476
- var month = date.getMonth();
5477
- return changeYearMonthAndClampDate(date, year - amount, month);
5478
- };
5479
-
5480
- var nextYear = function nextYear(date) {
5481
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5482
-
5483
- var year = date.getFullYear();
5484
- var month = date.getMonth();
5485
- return changeYearMonthAndClampDate(date, year + amount, month);
5486
- };
5487
-
5488
- var extractDateFormat = function extractDateFormat(format) {
5489
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5490
- };
5491
-
5492
- var extractTimeFormat = function extractTimeFormat(format) {
5493
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5494
- };
5495
-
5496
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5497
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5498
- };
5499
-
5284
+ */
5285
+ fecha.parse = function (dateStr, format) {
5286
+ if (typeof format !== 'string') {
5287
+ throw new Error('Invalid format in fecha.parse');
5288
+ }
5289
+
5290
+ format = fecha.masks[format] || format;
5291
+
5292
+ // Avoid regular expression denial of service, fail early for really long strings
5293
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5294
+ if (dateStr.length > 1000) {
5295
+ return null;
5296
+ }
5297
+
5298
+ const dateInfo = {};
5299
+ const parseInfo = [];
5300
+ const literals = [];
5301
+ format = format.replace(literal, function($0, $1) {
5302
+ literals.push($1);
5303
+ return '@@@';
5304
+ });
5305
+ let newFormat = regexEscape(format).replace(token, function ($0) {
5306
+ if (parseFlags[$0]) {
5307
+ const info = parseFlags[$0];
5308
+ parseInfo.push(info[1]);
5309
+ return '(' + info[0] + ')';
5310
+ }
5311
+
5312
+ return $0;
5313
+ });
5314
+ newFormat = newFormat.replace(/@@@/g, function() {
5315
+ return literals.shift();
5316
+ });
5317
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
5318
+ if (!matches) {
5319
+ return null;
5320
+ }
5321
+
5322
+ for (let i = 1; i < matches.length; i++) {
5323
+ parseInfo[i - 1](dateInfo, matches[i]);
5324
+ }
5325
+
5326
+ const today = new Date();
5327
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5328
+ dateInfo.hour = +dateInfo.hour + 12;
5329
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5330
+ dateInfo.hour = 0;
5331
+ }
5332
+
5333
+ let date;
5334
+ if (dateInfo.timezoneOffset != null) {
5335
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5336
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5337
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5338
+ } else {
5339
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5340
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5341
+ }
5342
+ return date;
5343
+ };
5344
+
5345
+ // 导出fecha对象
5346
+
5347
+
5348
+ // 以下是从date-util.js合并的函数
5349
+ const newArray = function(start, end) {
5350
+ let result = [];
5351
+ for (let i = start; i <= end; i++) {
5352
+ result.push(i);
5353
+ }
5354
+ return result;
5355
+ };
5356
+
5357
+ const getSettings = () => {
5358
+ return {
5359
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5360
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5361
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5362
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5363
+ amPm: ['上午', '下午']
5364
+ };
5365
+ };
5366
+
5367
+ const toDate = function(date) {
5368
+ return isDate(date) ? new Date(date) : null;
5369
+ };
5370
+
5371
+ const isDate = function(date) {
5372
+ if (date === null || date === undefined) return false;
5373
+ if (isNaN(new Date(date).getTime())) return false;
5374
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5375
+ return true;
5376
+ };
5377
+
5378
+ const isDateObject = function(val) {
5379
+ return val instanceof Date;
5380
+ };
5381
+
5382
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
5383
+ // 处理多种输入类型
5384
+ if (!date) return '';
5385
+
5386
+ // 如果是时间戳,转成日期对象
5387
+ if (typeof date === 'number') {
5388
+ date = new Date(date);
5389
+ }
5390
+ // 如果是字符串,转成日期对象
5391
+ if (typeof date === 'string') {
5392
+ date = new Date(date);
5393
+ }
5394
+
5395
+ // 调用toDate进一步验证和转换
5396
+ date = toDate(date);
5397
+ if (!date) return '';
5398
+
5399
+ // 兼容大写和小写的格式标记
5400
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5401
+ const lowercaseFormat = format
5402
+ .replace(/YYYY/g, 'yyyy')
5403
+ .replace(/D/g, 'd')
5404
+
5405
+ // 使用fecha库进行格式化,支持中文配置
5406
+ const str = fecha.format(date, lowercaseFormat, getSettings());
5407
+ return str;
5408
+ };
5409
+
5410
+ const parseDate = function(string, format) {
5411
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5412
+ };
5413
+
5414
+ const getDayCountOfMonth = function(year, month) {
5415
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5416
+ return 30;
5417
+ }
5418
+
5419
+ if (month === 1) {
5420
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5421
+ return 29;
5422
+ } else {
5423
+ return 28;
5424
+ }
5425
+ }
5426
+
5427
+ return 31;
5428
+ };
5429
+
5430
+ const getDayCountOfYear = function(year) {
5431
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5432
+ return isLeapYear ? 366 : 365;
5433
+ };
5434
+
5435
+ const getFirstDayOfMonth = function(date) {
5436
+ const temp = new Date(date.getTime());
5437
+ temp.setDate(1);
5438
+ return temp.getDay();
5439
+ };
5440
+
5441
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5442
+ // {prev, next} Date should work for Daylight Saving Time
5443
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5444
+ const prevDate = function(date, amount = 1) {
5445
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5446
+ };
5447
+
5448
+ const nextDate = function(date, amount = 1) {
5449
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5450
+ };
5451
+
5452
+ const getStartDateOfMonth = function(year, month) {
5453
+ const result = new Date(year, month, 1);
5454
+ const day = result.getDay();
5455
+
5456
+ if (day === 0) {
5457
+ return prevDate(result, 7);
5458
+ } else {
5459
+ return prevDate(result, day);
5460
+ }
5461
+ };
5462
+
5463
+ const getWeekNumber = function(date) {
5464
+ // 支持多种输入类型
5465
+ if (!date||!isDate(date)) {
5466
+ date = new Date();
5467
+ }
5468
+ if (typeof date === 'string') {
5469
+ date = new Date(date);
5470
+ }
5471
+
5472
+ // 验证日期有效性
5473
+ if (!isDate(date)) return null;
5474
+
5475
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5476
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5477
+ // 将星期日的星期数设为7
5478
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5479
+ // 获取当年的第一天
5480
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5481
+ // 计算到最近的星期四的完整周数
5482
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5483
+ // 返回周数
5484
+ return weekNo;
5485
+ };
5486
+
5487
+ const getRangeHours = function(ranges) {
5488
+ const hours = [];
5489
+ let disabledHours = [];
5490
+
5491
+ (ranges || []).forEach(range => {
5492
+ const value = range.map(date => date.getHours());
5493
+
5494
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5495
+ });
5496
+
5497
+ if (disabledHours.length) {
5498
+ for (let i = 0; i < 24; i++) {
5499
+ hours[i] = disabledHours.indexOf(i) === -1;
5500
+ }
5501
+ } else {
5502
+ for (let i = 0; i < 24; i++) {
5503
+ hours[i] = false;
5504
+ }
5505
+ }
5506
+
5507
+ return hours;
5508
+ };
5509
+
5510
+ const getPrevMonthLastDays = (date, amount) => {
5511
+ if (amount <= 0) return [];
5512
+ const temp = new Date(date.getTime());
5513
+ temp.setDate(0);
5514
+ const lastDay = temp.getDate();
5515
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
5516
+ };
5517
+
5518
+ const getMonthDays = (date) => {
5519
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5520
+ const days = temp.getDate();
5521
+ return range(days).map((_, index) => index + 1);
5522
+ };
5523
+
5524
+ function setRangeData(arr, start, end, value) {
5525
+ for (let i = start; i < end; i++) {
5526
+ arr[i] = value;
5527
+ }
5528
+ }
5529
+
5530
+ const getRangeMinutes = function(ranges, hour) {
5531
+ const minutes = new Array(60);
5532
+
5533
+ if (ranges.length > 0) {
5534
+ ranges.forEach(range => {
5535
+ const start = range[0];
5536
+ const end = range[1];
5537
+ const startHour = start.getHours();
5538
+ const startMinute = start.getMinutes();
5539
+ const endHour = end.getHours();
5540
+ const endMinute = end.getMinutes();
5541
+ if (startHour === hour && endHour !== hour) {
5542
+ setRangeData(minutes, startMinute, 60, true);
5543
+ } else if (startHour === hour && endHour === hour) {
5544
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5545
+ } else if (startHour !== hour && endHour === hour) {
5546
+ setRangeData(minutes, 0, endMinute + 1, true);
5547
+ } else if (startHour < hour && endHour > hour) {
5548
+ setRangeData(minutes, 0, 60, true);
5549
+ }
5550
+ });
5551
+ } else {
5552
+ setRangeData(minutes, 0, 60, true);
5553
+ }
5554
+ return minutes;
5555
+ };
5556
+
5557
+ const range = function(n) {
5558
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5559
+ return Array.apply(null, {length: n}).map((_, n) => n);
5560
+ };
5561
+
5562
+ const modifyDate = function(date, y, m, d) {
5563
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5564
+ };
5565
+
5566
+ const modifyTime = function(date, h, m, s) {
5567
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5568
+ };
5569
+
5570
+ const modifyWithTimeString = (date, time) => {
5571
+ if (date == null || !time) {
5572
+ return date;
5573
+ }
5574
+ time = parseDate(time, 'HH:mm:ss');
5575
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5576
+ };
5577
+
5578
+ const clearTime = function(date) {
5579
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5580
+ };
5581
+
5582
+ const clearMilliseconds = function(date) {
5583
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5584
+ };
5585
+
5586
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5587
+ // TODO: refactory a more elegant solution
5588
+ if (ranges.length === 0) return date;
5589
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5590
+ const ndate = normalizeDate(date);
5591
+ const nranges = ranges.map(range => range.map(normalizeDate));
5592
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5593
+
5594
+ let minDate = nranges[0][0];
5595
+ let maxDate = nranges[0][0];
5596
+
5597
+ nranges.forEach(nrange => {
5598
+ minDate = new Date(Math.min(nrange[0], minDate));
5599
+ maxDate = new Date(Math.max(nrange[1], minDate));
5600
+ });
5601
+
5602
+ const ret = ndate < minDate ? minDate : maxDate;
5603
+ // preserve Year/Month/Date
5604
+ return modifyDate(
5605
+ ret,
5606
+ date.getFullYear(),
5607
+ date.getMonth(),
5608
+ date.getDate()
5609
+ );
5610
+ };
5611
+
5612
+ const timeWithinRange = function(date, selectableRange, format) {
5613
+ const limitedDate = limitTimeRange(date, selectableRange, format);
5614
+ return limitedDate.getTime() === date.getTime();
5615
+ };
5616
+
5617
+ const changeYearMonthAndClampDate = function(date, year, month) {
5618
+ // clamp date to the number of days in `year`, `month`
5619
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5620
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5621
+ return modifyDate(date, year, month, monthDate);
5622
+ };
5623
+
5624
+ const prevMonth = function(date) {
5625
+ const year = date.getFullYear();
5626
+ const month = date.getMonth();
5627
+ return month === 0
5628
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5629
+ : changeYearMonthAndClampDate(date, year, month - 1);
5630
+ };
5631
+
5632
+ const nextMonth = function(date) {
5633
+ const year = date.getFullYear();
5634
+ const month = date.getMonth();
5635
+ return month === 11
5636
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5637
+ : changeYearMonthAndClampDate(date, year, month + 1);
5638
+ };
5639
+
5640
+ const prevYear = function(date, amount = 1) {
5641
+ const year = date.getFullYear();
5642
+ const month = date.getMonth();
5643
+ return changeYearMonthAndClampDate(date, year - amount, month);
5644
+ };
5645
+
5646
+ const nextYear = function(date, amount = 1) {
5647
+ const year = date.getFullYear();
5648
+ const month = date.getMonth();
5649
+ return changeYearMonthAndClampDate(date, year + amount, month);
5650
+ };
5651
+
5652
+ const extractDateFormat = function(format) {
5653
+ return format
5654
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
5655
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5656
+ .trim();
5657
+ };
5658
+
5659
+ const extractTimeFormat = function(format) {
5660
+ return format
5661
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5662
+ .trim();
5663
+ };
5664
+
5665
+ const validateRangeInOneMonth = function(start, end) {
5666
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5667
+ };
5668
+
5500
5669
  /**
5501
5670
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5502
5671
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5503
5672
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5504
5673
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5505
5674
  * @returns {number} 工作日数量
5506
- */
5507
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5508
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5509
-
5510
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5511
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5512
- }
5513
-
5514
- var startDateObj = new Date(start_date);
5515
- var endDateObj = new Date(end_date);
5516
-
5517
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5518
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5519
- }
5520
-
5521
- if (startDateObj > endDateObj) {
5522
- throw new Error('Start date should be earlier than or equal to end date.');
5523
- }
5524
-
5525
- var workdays = 0;
5526
-
5527
- // Iterate through each day in the date range
5528
-
5529
- var _loop = function _loop(currentDate) {
5530
- // Check if the current day is a weekend (Saturday or Sunday)
5531
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5532
-
5533
- // Check if the current day is a holiday
5534
- var isHoliday = holidays.some(function (holiday) {
5535
- var holidayDate = new Date(holiday);
5536
- return currentDate.toDateString() === holidayDate.toDateString();
5537
- });
5538
-
5539
- // If it's a workday (not a weekend or holiday), increment the workdays count
5540
- if (!isWeekend && !isHoliday) {
5541
- workdays++;
5542
- }
5543
- };
5544
-
5545
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5546
- _loop(currentDate);
5547
- }
5548
-
5549
- return workdays;
5550
- };
5551
-
5675
+ */
5676
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5677
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5678
+ throw new Error(
5679
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5680
+ );
5681
+ }
5682
+
5683
+ const startDateObj = new Date(start_date);
5684
+ const endDateObj = new Date(end_date);
5685
+
5686
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5687
+ throw new Error(
5688
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5689
+ );
5690
+ }
5691
+
5692
+ if (startDateObj > endDateObj) {
5693
+ throw new Error('Start date should be earlier than or equal to end date.');
5694
+ }
5695
+
5696
+ let workdays = 0;
5697
+
5698
+ // Iterate through each day in the date range
5699
+ for (
5700
+ let currentDate = new Date(startDateObj);
5701
+ currentDate <= endDateObj;
5702
+ currentDate.setDate(currentDate.getDate() + 1)
5703
+ ) {
5704
+ // Check if the current day is a weekend (Saturday or Sunday)
5705
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5706
+
5707
+ // Check if the current day is a holiday
5708
+ const isHoliday = holidays.some((holiday) => {
5709
+ const holidayDate = new Date(holiday);
5710
+ return currentDate.toDateString() === holidayDate.toDateString();
5711
+ });
5712
+
5713
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5714
+ if (!isWeekend && !isHoliday) {
5715
+ workdays++;
5716
+ }
5717
+ }
5718
+
5719
+ return workdays;
5720
+ };
5721
+
5552
5722
  /**
5553
5723
  * 日期加减天数
5554
5724
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5555
5725
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5556
5726
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5557
- */
5558
- var dateAddDays = function dateAddDays(start_date, days) {
5559
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5560
- 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.");
5561
- }
5562
-
5563
- var startDateObj = new Date(start_date);
5564
- if (isNaN(startDateObj.getTime())) {
5565
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5566
- }
5567
-
5568
- var resultDateObj = new Date(startDateObj);
5569
- resultDateObj.setDate(resultDateObj.getDate() + days);
5570
-
5571
- var resultYear = resultDateObj.getFullYear();
5572
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5573
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5574
-
5575
- return resultYear + '-' + resultMonth + '-' + resultDay;
5576
- };
5577
-
5727
+ */
5728
+ const dateAddDays = function (start_date, days) {
5729
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5730
+ throw new Error(
5731
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5732
+ );
5733
+ }
5734
+
5735
+ const startDateObj = new Date(start_date);
5736
+ if (isNaN(startDateObj.getTime())) {
5737
+ throw new Error(
5738
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5739
+ );
5740
+ }
5741
+
5742
+ const resultDateObj = new Date(startDateObj);
5743
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5744
+
5745
+ const resultYear = resultDateObj.getFullYear();
5746
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5747
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5748
+
5749
+ return `${resultYear}-${resultMonth}-${resultDay}`;
5750
+ };
5751
+
5578
5752
  /**
5579
5753
  * 计算两个日期之间的差值
5580
5754
  * @date 2023年12月14日
@@ -5582,180 +5756,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
5582
5756
  * @param {String} end_date - 结束日期字符串
5583
5757
  * @param {String} unit - 单位:year/month/day
5584
5758
  * @returns {Number} 差值
5585
- */
5586
- var dateDiff = function dateDiff(start_date, end_date) {
5587
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5588
-
5589
- // Assuming date strings are in "YYYY-MM-DD" format
5590
- var startDate = new Date(start_date);
5591
- var endDate = new Date(end_date);
5592
-
5593
- // If the date is invalid, return 0
5594
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5595
- return 0;
5596
- }
5597
-
5598
- if (unit === 'year') {
5599
- return endDate.getFullYear() - startDate.getFullYear();
5600
- } else if (unit === 'month') {
5601
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5602
- } else {
5603
- // Default to day
5604
- var timeDifference = endDate - startDate;
5605
- // Calculate days (86400000 milliseconds per day)
5606
- return Math.floor(timeDifference / 86400000);
5607
- }
5608
- };
5609
-
5759
+ */
5760
+ const dateDiff = function (start_date, end_date, unit = 'day') {
5761
+ // Assuming date strings are in "YYYY-MM-DD" format
5762
+ var startDate = new Date(start_date);
5763
+ var endDate = new Date(end_date);
5764
+
5765
+ // If the date is invalid, return 0
5766
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5767
+ return 0;
5768
+ }
5769
+
5770
+ if (unit === 'year') {
5771
+ return endDate.getFullYear() - startDate.getFullYear();
5772
+ } else if (unit === 'month') {
5773
+ return (
5774
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5775
+ (endDate.getMonth() - startDate.getMonth())
5776
+ );
5777
+ } else {
5778
+ // Default to day
5779
+ var timeDifference = endDate - startDate;
5780
+ // Calculate days (86400000 milliseconds per day)
5781
+ return Math.floor(timeDifference / 86400000);
5782
+ }
5783
+ };
5784
+
5610
5785
  /**
5611
5786
  * 获取月份中的日期
5612
5787
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5613
5788
  * @returns {number} 月份中的日期(1-31)
5614
- */
5615
- var dayOfMonth = function dayOfMonth(date) {
5616
- if (typeof date !== 'string') {
5617
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5618
- }
5619
-
5620
- var dateObj = new Date(date);
5621
- if (isNaN(dateObj.getTime())) {
5622
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5623
- }
5624
-
5625
- return dateObj.getDate();
5626
- };
5627
-
5789
+ */
5790
+ const dayOfMonth = function (date) {
5791
+ if (typeof date !== 'string') {
5792
+ throw new Error(
5793
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5794
+ );
5795
+ }
5796
+
5797
+ const dateObj = new Date(date);
5798
+ if (isNaN(dateObj.getTime())) {
5799
+ throw new Error(
5800
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5801
+ );
5802
+ }
5803
+
5804
+ return dateObj.getDate();
5805
+ };
5806
+
5628
5807
  /**
5629
5808
  * 获取当前日期
5630
5809
  * @date 2022年5月7日
5631
5810
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5632
5811
  * @returns {string} 当前日期的格式化字符串
5633
- */
5634
- var getCurrentDate = function getCurrentDate() {
5635
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5636
-
5637
- return formatDate(new Date(), format);
5638
- };
5639
-
5812
+ */
5813
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
5814
+ return formatDate(new Date(), format);
5815
+ };
5816
+
5640
5817
  /**
5641
5818
  * 获取当前日期时间
5642
5819
  * @date 2022年5月7日
5643
5820
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
5644
5821
  * @returns {string} 当前日期时间的格式化字符串
5645
- */
5646
- var getCurrentDateTime = function getCurrentDateTime() {
5647
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
5648
-
5649
- return formatDate(new Date(), format);
5650
- };
5651
-
5822
+ */
5823
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5824
+ return formatDate(new Date(), format);
5825
+ };
5826
+
5652
5827
  /**
5653
5828
  * 获取小时
5654
5829
  * @date 2022年5月7日
5655
5830
  * @param {Date|string} [date] - 日期对象或日期字符串
5656
5831
  * @returns {number} 小时数(0-23)
5657
- */
5658
- var getHour = function getHour(date) {
5659
- if (!date) {
5660
- return new Date().getHours();
5661
- }
5662
- if (typeof date === 'string') {
5663
- date = new Date(date);
5664
- }
5665
- return date.getHours();
5666
- };
5667
-
5832
+ */
5833
+ const getHour = function (date) {
5834
+ if (!date) {
5835
+ return new Date().getHours();
5836
+ }
5837
+ if (typeof date === 'string') {
5838
+ date = new Date(date);
5839
+ }
5840
+ return date.getHours();
5841
+ };
5842
+
5668
5843
  /**
5669
5844
  * 获取分钟
5670
5845
  * @date 2022年5月7日
5671
5846
  * @param {Date|string} [date] - 日期对象或日期字符串
5672
5847
  * @returns {number} 分钟数(0-59)
5673
- */
5674
- var getMinute = function getMinute(date) {
5675
- if (!date) {
5676
- return new Date().getMinutes();
5677
- }
5678
- if (typeof date === 'string') {
5679
- date = new Date(date);
5680
- }
5681
- return date.getMinutes();
5682
- };
5683
-
5848
+ */
5849
+ const getMinute = function (date) {
5850
+ if (!date) {
5851
+ return new Date().getMinutes();
5852
+ }
5853
+ if (typeof date === 'string') {
5854
+ date = new Date(date);
5855
+ }
5856
+ return date.getMinutes();
5857
+ };
5858
+
5684
5859
  /**
5685
5860
  * 获取月份
5686
5861
  * @date 2022年5月7日
5687
5862
  * @param {Date|string} [date] - 日期对象或日期字符串
5688
5863
  * @returns {number} 月份数(1-12)
5689
- */
5690
- var getMonth = function getMonth(date) {
5691
- if (!date) {
5692
- return new Date().getMonth() + 1;
5693
- }
5694
- if (typeof date === 'string') {
5695
- date = new Date(date);
5696
- }
5697
- return date.getMonth() + 1;
5698
- };
5699
-
5864
+ */
5865
+ const getMonth = function (date) {
5866
+ if (!date) {
5867
+ return new Date().getMonth() + 1;
5868
+ }
5869
+ if (typeof date === 'string') {
5870
+ date = new Date(date);
5871
+ }
5872
+ return date.getMonth() + 1;
5873
+ };
5874
+
5700
5875
  /**
5701
5876
  * 获取秒
5702
5877
  * @date 2022年5月7日
5703
5878
  * @param {Date|string} [date] - 日期对象或日期字符串
5704
5879
  * @returns {number} 秒数(0-59)
5705
- */
5706
- var getSecond = function getSecond(date) {
5707
- if (!date) {
5708
- return new Date().getSeconds();
5709
- }
5710
- if (typeof date === 'string') {
5711
- date = new Date(date);
5712
- }
5713
- return date.getSeconds();
5714
- };
5715
-
5880
+ */
5881
+ const getSecond = function (date) {
5882
+ if (!date) {
5883
+ return new Date().getSeconds();
5884
+ }
5885
+ if (typeof date === 'string') {
5886
+ date = new Date(date);
5887
+ }
5888
+ return date.getSeconds();
5889
+ };
5890
+
5716
5891
  /**
5717
5892
  * 获取星期几
5718
5893
  * @date 2022年5月7日
5719
5894
  * @param {Date|string} [date] - 日期对象或日期字符串
5720
5895
  * @returns {number} 星期几(0-6,0表示星期日)
5721
- */
5722
- var getWeekday = function getWeekday(date) {
5723
- if (!date) {
5724
- return new Date().getDay();
5725
- }
5726
- if (typeof date === 'string') {
5727
- date = new Date(date);
5728
- }
5729
- return date.getDay();
5730
- };
5731
-
5896
+ */
5897
+ const getWeekday = function (date) {
5898
+ if (!date) {
5899
+ return new Date().getDay();
5900
+ }
5901
+ if (typeof date === 'string') {
5902
+ date = new Date(date);
5903
+ }
5904
+ return date.getDay();
5905
+ };
5906
+
5907
+
5732
5908
  /**
5733
5909
  * @desc 获取上午/下午/晚上
5734
5910
  * @author huangbo
5735
5911
  * @date 2022年5月7日
5736
5912
  * @param {String} [time] - 时间
5737
- **/
5738
- var timeCycle = function timeCycle(time) {
5739
- var hour = 0;
5740
- if (!time) {
5741
- hour = new Date().getHours();
5742
- } else if (typeof time === 'string') {
5743
- // 从时间字符串中提取小时
5744
- var match = time.match(/^(\d{1,2})/);
5745
- if (match) {
5746
- hour = parseInt(match[1], 10);
5747
- }
5748
- } else if (typeof time === 'number') {
5749
- hour = time;
5750
- }
5751
- // 判断时间段
5752
- if (hour >= 5 && hour < 12) {
5753
- return '上午';
5754
- } else if (hour >= 12 && hour < 18) {
5755
- return '下午';
5756
- } else {
5757
- return '晚上';
5758
- }
5913
+ **/
5914
+ const timeCycle = function (time) {
5915
+ let hour = 0;
5916
+ if (!time) {
5917
+ hour = new Date().getHours();
5918
+ } else if (typeof time === 'string') {
5919
+ // 从时间字符串中提取小时
5920
+ const match = time.match(/^(\d{1,2})/);
5921
+ if (match) {
5922
+ hour = parseInt(match[1], 10);
5923
+ }
5924
+ } else if (typeof time === 'number') {
5925
+ hour = time;
5926
+ }
5927
+ // 判断时间段
5928
+ if (hour >= 5 && hour < 12) {
5929
+ return '上午';
5930
+ } else if (hour >= 12 && hour < 18) {
5931
+ return '下午';
5932
+ } else {
5933
+ return '晚上';
5934
+ }
5759
5935
  };
5760
5936
 
5761
5937
  /***/ }),