eoss 0.1.0-alpha.39 → 0.1.0-alpha.40

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 (233) 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 +837 -862
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +4 -4
  86. package/lib/autocomplete.js +1813 -1988
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +2 -2
  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 +837 -862
  95. package/lib/calendar.js +839 -864
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +846 -871
  98. package/lib/carousel.js +839 -864
  99. package/lib/cascader-panel.js +852 -877
  100. package/lib/cascader.js +2048 -2223
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +859 -884
  103. package/lib/checkbox.js +4 -4
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +1040 -1065
  106. package/lib/collapse.js +1040 -1065
  107. package/lib/color-picker.js +972 -1122
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +12 -12
  110. package/lib/data-table.js +843 -868
  111. package/lib/date-picker.js +10520 -10695
  112. package/lib/descriptions-item.js +4 -4
  113. package/lib/descriptions.js +4 -4
  114. package/lib/dialog.js +837 -862
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +2 -2
  117. package/lib/dropdown-item.js +4 -4
  118. package/lib/dropdown-menu.js +974 -1124
  119. package/lib/dropdown.js +841 -866
  120. package/lib/email-login.js +837 -862
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +4023 -2668
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +853 -878
  125. package/lib/flow.js +868 -893
  126. package/lib/flows.js +854 -879
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +860 -885
  129. package/lib/form.js +933 -950
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +837 -862
  133. package/lib/icons.js +2 -2
  134. package/lib/image-viewer.js +837 -862
  135. package/lib/image.js +4 -4
  136. package/lib/index.js +1 -1
  137. package/lib/infinite-scroll.js +2 -2
  138. package/lib/input-number.js +6 -6
  139. package/lib/input.js +839 -864
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +2 -2
  142. package/lib/login.js +867 -891
  143. package/lib/lowcode-view.js +1843 -1185
  144. package/lib/lowcode.js +3050 -1569
  145. package/lib/main.js +970 -988
  146. package/lib/marquee.js +837 -862
  147. package/lib/menu-item-group.js +15 -15
  148. package/lib/menu-item.js +6 -6
  149. package/lib/menu.js +2227 -2368
  150. package/lib/message-box.js +843 -868
  151. package/lib/message.js +839 -864
  152. package/lib/notification.js +861 -886
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +839 -864
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +839 -864
  157. package/lib/phone-login.js +847 -866
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +1831 -2006
  160. package/lib/process-config.js +839 -864
  161. package/lib/process-module.js +846 -871
  162. package/lib/process-rule.js +905 -930
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +839 -864
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +850 -875
  168. package/lib/radio.js +4 -4
  169. package/lib/rate.js +837 -862
  170. package/lib/retrial-auth.js +837 -862
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +839 -864
  173. package/lib/select.js +2139 -2314
  174. package/lib/selector-panel.js +940 -965
  175. package/lib/selector.js +852 -877
  176. package/lib/slider.js +4 -4
  177. package/lib/step.js +32 -32
  178. package/lib/steps.js +874 -899
  179. package/lib/submenu.js +1269 -1385
  180. package/lib/switch.js +839 -864
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +840 -865
  183. package/lib/table.js +1825 -2000
  184. package/lib/tabs.js +846 -871
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  187. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/lowcode.css +1 -1
  190. package/lib/time-picker.js +6471 -6646
  191. package/lib/time-select.js +5039 -5214
  192. package/lib/timeline-item.js +2 -2
  193. package/lib/timeline.js +2 -2
  194. package/lib/tips.js +837 -862
  195. package/lib/toolbar.js +4 -4
  196. package/lib/tooltip.js +1813 -1988
  197. package/lib/transfer.js +837 -862
  198. package/lib/tree-group.js +853 -878
  199. package/lib/tree.js +1026 -1051
  200. package/lib/update-history.js +4 -4
  201. package/lib/upload.js +859 -884
  202. package/lib/wujie.js +841 -866
  203. package/package.json +1 -1
  204. package/packages/flow-group/src/main.vue +2 -2
  205. package/packages/form/src/form-item-render.vue +1 -0
  206. package/packages/form/src/form-item.vue +12 -6
  207. package/packages/form/src/form.vue +5 -5
  208. package/packages/login/src/login.vue +1 -0
  209. package/packages/lowcode/src/attribute/function.vue +28 -9
  210. package/packages/lowcode/src/attribute/props.vue +202 -0
  211. package/packages/lowcode/src/attribute/styles.vue +79 -5
  212. package/packages/lowcode/src/attribute.vue +61 -4
  213. package/packages/lowcode/src/canvas.vue +159 -2
  214. package/packages/lowcode/src/form-render.vue +305 -0
  215. package/packages/lowcode/src/lowcode.vue +33 -13
  216. package/packages/lowcode/src/modules.vue +53 -37
  217. package/packages/lowcode/src/render.vue +80 -25
  218. package/packages/lowcode/src/util/components.js +100 -0
  219. package/packages/lowcode/src/util/props-util.js +67 -0
  220. package/packages/lowcode/src/util/source-generator.js +69 -9
  221. package/packages/lowcode/src/util/source-parser.js +64 -10
  222. package/packages/lowcode-view/src/render.vue +48 -18
  223. package/packages/main/src/components/userinfo.vue +0 -1
  224. package/packages/menu/src/menu-item-group.vue +1 -1
  225. package/packages/menu/src/mixins.js +8 -4
  226. package/packages/menu/src/submenu.vue +35 -5
  227. package/packages/phone-login/src/phone-login.vue +5 -2
  228. package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
  229. package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
  230. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  231. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  232. package/packages/theme-chalk/src/lowcode.scss +21 -2
  233. package/src/index.js +336 -336
@@ -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 = 196);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 203);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3285,7 +3285,7 @@ var warning = function warning(content, _callback3) {
3285
3285
 
3286
3286
  /***/ }),
3287
3287
 
3288
- /***/ 116:
3288
+ /***/ 118:
3289
3289
  /***/ (function(module, exports) {
3290
3290
 
3291
3291
  module.exports = require("babel-helper-vue-jsx-merge-props");
@@ -3521,7 +3521,14 @@ module.exports = require("lodash/cloneDeep");
3521
3521
 
3522
3522
  /***/ }),
3523
3523
 
3524
- /***/ 196:
3524
+ /***/ 2:
3525
+ /***/ (function(module, exports) {
3526
+
3527
+ module.exports = require("vue");
3528
+
3529
+ /***/ }),
3530
+
3531
+ /***/ 203:
3525
3532
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3526
3533
 
3527
3534
  "use strict";
@@ -3561,7 +3568,7 @@ var scrollbar_ = __webpack_require__(34);
3561
3568
  var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
3562
3569
 
3563
3570
  // EXTERNAL MODULE: external "babel-helper-vue-jsx-merge-props"
3564
- var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(116);
3571
+ var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(118);
3565
3572
  var external_babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(external_babel_helper_vue_jsx_merge_props_);
3566
3573
 
3567
3574
  // EXTERNAL MODULE: external "eoss/lib/checkbox"
@@ -3569,7 +3576,7 @@ var checkbox_ = __webpack_require__(39);
3569
3576
  var checkbox_default = /*#__PURE__*/__webpack_require__.n(checkbox_);
3570
3577
 
3571
3578
  // EXTERNAL MODULE: external "eoss/lib/radio"
3572
- var radio_ = __webpack_require__(48);
3579
+ var radio_ = __webpack_require__(49);
3573
3580
  var radio_default = /*#__PURE__*/__webpack_require__.n(radio_);
3574
3581
 
3575
3582
  // EXTERNAL MODULE: ./src/utils/util.js
@@ -4042,7 +4049,7 @@ var cascader_menu_component = Object(componentNormalizer["a" /* default */])(
4042
4049
 
4043
4050
  /* harmony default export */ var cascader_menu = (cascader_menu_component.exports);
4044
4051
  // EXTERNAL MODULE: ./src/utils/shared.js
4045
- var shared = __webpack_require__(81);
4052
+ var shared = __webpack_require__(82);
4046
4053
 
4047
4054
  // CONCATENATED MODULE: ./packages/cascader-panel/src/node.js
4048
4055
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -4347,7 +4354,7 @@ var store_Store = function () {
4347
4354
  var merge = __webpack_require__(22);
4348
4355
 
4349
4356
  // EXTERNAL MODULE: ./src/utils/aria-utils.js
4350
- var aria_utils = __webpack_require__(61);
4357
+ var aria_utils = __webpack_require__(62);
4351
4358
 
4352
4359
  // EXTERNAL MODULE: ./src/utils/scrollbar.js
4353
4360
  var scrollbar = __webpack_require__(23);
@@ -4810,13 +4817,6 @@ cascader_panel.install = function (Vue) {
4810
4817
 
4811
4818
  /***/ }),
4812
4819
 
4813
- /***/ 2:
4814
- /***/ (function(module, exports) {
4815
-
4816
- module.exports = require("vue");
4817
-
4818
- /***/ }),
4819
-
4820
4820
  /***/ 22:
4821
4821
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4822
4822
 
@@ -5170,14 +5170,14 @@ function normalizeComponent(
5170
5170
 
5171
5171
  /***/ }),
5172
5172
 
5173
- /***/ 48:
5173
+ /***/ 49:
5174
5174
  /***/ (function(module, exports) {
5175
5175
 
5176
5176
  module.exports = require("eoss/lib/radio");
5177
5177
 
5178
5178
  /***/ }),
5179
5179
 
5180
- /***/ 61:
5180
+ /***/ 62:
5181
5181
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5182
5182
 
5183
5183
  "use strict";
@@ -5357,759 +5357,736 @@ aria.Utils.keys = {
5357
5357
  /* unused harmony export getSecond */
5358
5358
  /* unused harmony export getWeekday */
5359
5359
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
5360
- /* Modified from https://github.com/taylorhakes/fecha
5361
- *
5362
- * The MIT License (MIT)
5363
- *
5364
- * Copyright (c) 2015 Taylor Hakes
5365
- *
5366
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5367
- * of this software and associated documentation files (the "Software"), to deal
5368
- * in the Software without restriction, including without limitation the rights
5369
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5370
- * copies of the Software, and to permit persons to whom the Software is
5371
- * furnished to do so, subject to the following conditions:
5372
- *
5373
- * The above copyright notice and this permission notice shall be included in all
5374
- * copies or substantial portions of the Software.
5375
- *
5376
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5377
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5378
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5379
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5380
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5381
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5382
- * SOFTWARE.
5383
- */
5384
-
5385
- /*eslint-disable*/
5386
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5387
-
5388
-
5360
+
5361
+
5389
5362
  /**
5390
5363
  * Parse or format dates
5391
5364
  * @class fecha
5392
- */
5393
- const fecha = {};
5394
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5395
- const twoDigits = '\\d\\d?';
5396
- const threeDigits = '\\d{3}';
5397
- const fourDigits = '\\d{4}';
5398
- const word = '[^\\s]+';
5399
- const literal = /\[([^]*?)\]/gm;
5400
- const noop = function () {};
5401
-
5402
- function regexEscape(str) {
5403
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5404
- }
5405
-
5406
- function shorten(arr, sLen) {
5407
- const newArr = [];
5408
- for (let i = 0, len = arr.length; i < len; i++) {
5409
- newArr.push(arr[i].substr(0, sLen));
5410
- }
5411
- return newArr;
5412
- }
5413
-
5414
- function monthUpdate() {
5415
- return function (d, v) {
5416
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5417
- if (~index) {
5418
- d.month = index;
5419
- }
5420
- };
5421
- }
5422
-
5423
- function pad(val, len) {
5424
- val = String(val);
5425
- len = len || 2;
5426
- while (val.length < len) {
5427
- val = '0' + val;
5428
- }
5429
- return val;
5430
- }
5431
-
5432
- // 直接使用中文日期名称常量
5433
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5434
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5435
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5436
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5437
- const amPm = ['上午', '下午'];
5438
- const DoFn = function DoFn(D) {
5439
- return D + '日';
5440
- };
5441
-
5442
- const formatFlags = {
5443
- D: function(dateObj) {
5444
- return dateObj.getDay();
5445
- },
5446
- DD: function(dateObj) {
5447
- return pad(dateObj.getDay());
5448
- },
5449
- Do: function(dateObj) {
5450
- return DoFn(dateObj.getDate());
5451
- },
5452
- d: function(dateObj) {
5453
- return dateObj.getDate();
5454
- },
5455
- dd: function(dateObj) {
5456
- return pad(dateObj.getDate());
5457
- },
5458
- ddd: function(dateObj) {
5459
- return dayNamesShort[dateObj.getDay()];
5460
- },
5461
- dddd: function(dateObj) {
5462
- return dayNames[dateObj.getDay()];
5463
- },
5464
- M: function(dateObj) {
5465
- return dateObj.getMonth() + 1;
5466
- },
5467
- MM: function(dateObj) {
5468
- return pad(dateObj.getMonth() + 1);
5469
- },
5470
- MMM: function(dateObj) {
5471
- return monthNamesShort[dateObj.getMonth()];
5472
- },
5473
- MMMM: function(dateObj) {
5474
- return monthNames[dateObj.getMonth()];
5475
- },
5476
- yy: function(dateObj) {
5477
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5478
- },
5479
- yyyy: function(dateObj) {
5480
- return pad(dateObj.getFullYear(), 4);
5481
- },
5482
- h: function(dateObj) {
5483
- return dateObj.getHours() % 12 || 12;
5484
- },
5485
- hh: function(dateObj) {
5486
- return pad(dateObj.getHours() % 12 || 12);
5487
- },
5488
- H: function(dateObj) {
5489
- return dateObj.getHours();
5490
- },
5491
- HH: function(dateObj) {
5492
- return pad(dateObj.getHours());
5493
- },
5494
- m: function(dateObj) {
5495
- return dateObj.getMinutes();
5496
- },
5497
- mm: function(dateObj) {
5498
- return pad(dateObj.getMinutes());
5499
- },
5500
- s: function(dateObj) {
5501
- return dateObj.getSeconds();
5502
- },
5503
- ss: function(dateObj) {
5504
- return pad(dateObj.getSeconds());
5505
- },
5506
- S: function(dateObj) {
5507
- return Math.round(dateObj.getMilliseconds() / 100);
5508
- },
5509
- SS: function(dateObj) {
5510
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5511
- },
5512
- SSS: function(dateObj) {
5513
- return pad(dateObj.getMilliseconds(), 3);
5514
- },
5515
- a: function(dateObj) {
5516
- return dateObj.getHours() < 12 ? '上午' : '下午';
5517
- },
5518
- A: function(dateObj) {
5519
- return dateObj.getHours() < 12 ? '上午' : '下午';
5520
- },
5521
- ZZ: function(dateObj) {
5522
- const o = dateObj.getTimezoneOffset();
5523
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5524
- }
5525
- };
5526
-
5527
- const parseFlags = {
5528
- d: [twoDigits, function (d, v) {
5529
- d.day = v;
5530
- }],
5531
- Do: [twoDigits + word, function (d, v) {
5532
- d.day = parseInt(v, 10);
5533
- }],
5534
- M: [twoDigits, function (d, v) {
5535
- d.month = v - 1;
5536
- }],
5537
- yy: [twoDigits, function (d, v) {
5538
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5539
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5540
- }],
5541
- h: [twoDigits, function (d, v) {
5542
- d.hour = v;
5543
- }],
5544
- m: [twoDigits, function (d, v) {
5545
- d.minute = v;
5546
- }],
5547
- s: [twoDigits, function (d, v) {
5548
- d.second = v;
5549
- }],
5550
- yyyy: [fourDigits, function (d, v) {
5551
- d.year = v;
5552
- }],
5553
- S: ['\\d', function (d, v) {
5554
- d.millisecond = v * 100;
5555
- }],
5556
- SS: ['\\d{2}', function (d, v) {
5557
- d.millisecond = v * 10;
5558
- }],
5559
- SSS: [threeDigits, function (d, v) {
5560
- d.millisecond = v;
5561
- }],
5562
- D: [twoDigits, noop],
5563
- ddd: [word, noop],
5564
- MMM: [word, monthUpdate('monthNamesShort')],
5565
- MMMM: [word, monthUpdate('monthNames')],
5566
- a: [word, function (d, v) {
5567
- const val = v.toLowerCase();
5568
- if (val === '上午') {
5569
- d.isPm = false;
5570
- } else if (val === '下午') {
5571
- d.isPm = true;
5572
- }
5573
- }],
5574
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5575
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5576
-
5577
- if (parts) {
5578
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5579
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5580
- }
5581
- }]
5582
- };
5583
- parseFlags.dd = parseFlags.d;
5584
- parseFlags.dddd = parseFlags.ddd;
5585
- parseFlags.DD = parseFlags.D;
5586
- parseFlags.mm = parseFlags.m;
5587
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5588
- parseFlags.MM = parseFlags.M;
5589
- parseFlags.ss = parseFlags.s;
5590
- parseFlags.A = parseFlags.a;
5591
-
5592
-
5593
- // Some common format strings
5594
- fecha.masks = {
5595
- default: 'ddd MMM dd yyyy HH:mm:ss',
5596
- shortDate: 'M/D/yy',
5597
- mediumDate: 'MMM d, yyyy',
5598
- longDate: 'MMMM d, yyyy',
5599
- fullDate: 'dddd, MMMM d, yyyy',
5600
- shortTime: 'HH:mm',
5601
- mediumTime: 'HH:mm:ss',
5602
- longTime: 'HH:mm:ss.SSS'
5603
- };
5604
-
5365
+ */
5366
+ var fecha = {};
5367
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5368
+ var twoDigits = '\\d\\d?';
5369
+ var threeDigits = '\\d{3}';
5370
+ var fourDigits = '\\d{4}';
5371
+ var word = '[^\\s]+';
5372
+ var literal = /\[([^]*?)\]/gm;
5373
+ var noop = function noop() {};
5374
+
5375
+ function regexEscape(str) {
5376
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5377
+ }
5378
+
5379
+ function shorten(arr, sLen) {
5380
+ var newArr = [];
5381
+ for (var i = 0, len = arr.length; i < len; i++) {
5382
+ newArr.push(arr[i].substr(0, sLen));
5383
+ }
5384
+ return newArr;
5385
+ }
5386
+
5387
+ function monthUpdate() {
5388
+ return function (d, v) {
5389
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5390
+ if (~index) {
5391
+ d.month = index;
5392
+ }
5393
+ };
5394
+ }
5395
+
5396
+ function pad(val, len) {
5397
+ val = String(val);
5398
+ len = len || 2;
5399
+ while (val.length < len) {
5400
+ val = '0' + val;
5401
+ }
5402
+ return val;
5403
+ }
5404
+
5405
+ // 直接使用中文日期名称常量
5406
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5407
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5408
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5409
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5410
+ var amPm = ['上午', '下午'];
5411
+ var DoFn = function DoFn(D) {
5412
+ return D + '日';
5413
+ };
5414
+
5415
+ var formatFlags = {
5416
+ D: function D(dateObj) {
5417
+ return dateObj.getDay();
5418
+ },
5419
+ DD: function DD(dateObj) {
5420
+ return pad(dateObj.getDay());
5421
+ },
5422
+ Do: function Do(dateObj) {
5423
+ return DoFn(dateObj.getDate());
5424
+ },
5425
+ d: function d(dateObj) {
5426
+ return dateObj.getDate();
5427
+ },
5428
+ dd: function dd(dateObj) {
5429
+ return pad(dateObj.getDate());
5430
+ },
5431
+ ddd: function ddd(dateObj) {
5432
+ return dayNamesShort[dateObj.getDay()];
5433
+ },
5434
+ dddd: function dddd(dateObj) {
5435
+ return dayNames[dateObj.getDay()];
5436
+ },
5437
+ M: function M(dateObj) {
5438
+ return dateObj.getMonth() + 1;
5439
+ },
5440
+ MM: function MM(dateObj) {
5441
+ return pad(dateObj.getMonth() + 1);
5442
+ },
5443
+ MMM: function MMM(dateObj) {
5444
+ return monthNamesShort[dateObj.getMonth()];
5445
+ },
5446
+ MMMM: function MMMM(dateObj) {
5447
+ return monthNames[dateObj.getMonth()];
5448
+ },
5449
+ yy: function yy(dateObj) {
5450
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5451
+ },
5452
+ yyyy: function yyyy(dateObj) {
5453
+ return pad(dateObj.getFullYear(), 4);
5454
+ },
5455
+ h: function h(dateObj) {
5456
+ return dateObj.getHours() % 12 || 12;
5457
+ },
5458
+ hh: function hh(dateObj) {
5459
+ return pad(dateObj.getHours() % 12 || 12);
5460
+ },
5461
+ H: function H(dateObj) {
5462
+ return dateObj.getHours();
5463
+ },
5464
+ HH: function HH(dateObj) {
5465
+ return pad(dateObj.getHours());
5466
+ },
5467
+ m: function m(dateObj) {
5468
+ return dateObj.getMinutes();
5469
+ },
5470
+ mm: function mm(dateObj) {
5471
+ return pad(dateObj.getMinutes());
5472
+ },
5473
+ s: function s(dateObj) {
5474
+ return dateObj.getSeconds();
5475
+ },
5476
+ ss: function ss(dateObj) {
5477
+ return pad(dateObj.getSeconds());
5478
+ },
5479
+ S: function S(dateObj) {
5480
+ return Math.round(dateObj.getMilliseconds() / 100);
5481
+ },
5482
+ SS: function SS(dateObj) {
5483
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5484
+ },
5485
+ SSS: function SSS(dateObj) {
5486
+ return pad(dateObj.getMilliseconds(), 3);
5487
+ },
5488
+ a: function a(dateObj) {
5489
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5490
+ },
5491
+ A: function A(dateObj) {
5492
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5493
+ },
5494
+ ZZ: function ZZ(dateObj) {
5495
+ var o = dateObj.getTimezoneOffset();
5496
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5497
+ }
5498
+ };
5499
+
5500
+ var parseFlags = {
5501
+ d: [twoDigits, function (d, v) {
5502
+ d.day = v;
5503
+ }],
5504
+ Do: [twoDigits + word, function (d, v) {
5505
+ d.day = parseInt(v, 10);
5506
+ }],
5507
+ M: [twoDigits, function (d, v) {
5508
+ d.month = v - 1;
5509
+ }],
5510
+ yy: [twoDigits, function (d, v) {
5511
+ var da = new Date(),
5512
+ cent = +('' + da.getFullYear()).substr(0, 2);
5513
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5514
+ }],
5515
+ h: [twoDigits, function (d, v) {
5516
+ d.hour = v;
5517
+ }],
5518
+ m: [twoDigits, function (d, v) {
5519
+ d.minute = v;
5520
+ }],
5521
+ s: [twoDigits, function (d, v) {
5522
+ d.second = v;
5523
+ }],
5524
+ yyyy: [fourDigits, function (d, v) {
5525
+ d.year = v;
5526
+ }],
5527
+ S: ['\\d', function (d, v) {
5528
+ d.millisecond = v * 100;
5529
+ }],
5530
+ SS: ['\\d{2}', function (d, v) {
5531
+ d.millisecond = v * 10;
5532
+ }],
5533
+ SSS: [threeDigits, function (d, v) {
5534
+ d.millisecond = v;
5535
+ }],
5536
+ D: [twoDigits, noop],
5537
+ ddd: [word, noop],
5538
+ MMM: [word, monthUpdate('monthNamesShort')],
5539
+ MMMM: [word, monthUpdate('monthNames')],
5540
+ a: [word, function (d, v) {
5541
+ var val = v.toLowerCase();
5542
+ if (val === '上午') {
5543
+ d.isPm = false;
5544
+ } else if (val === '下午') {
5545
+ d.isPm = true;
5546
+ }
5547
+ }],
5548
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5549
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
5550
+ minutes = void 0;
5551
+
5552
+ if (parts) {
5553
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5554
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5555
+ }
5556
+ }]
5557
+ };
5558
+ parseFlags.dd = parseFlags.d;
5559
+ parseFlags.dddd = parseFlags.ddd;
5560
+ parseFlags.DD = parseFlags.D;
5561
+ parseFlags.mm = parseFlags.m;
5562
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5563
+ parseFlags.MM = parseFlags.M;
5564
+ parseFlags.ss = parseFlags.s;
5565
+ parseFlags.A = parseFlags.a;
5566
+
5567
+ // Some common format strings
5568
+ fecha.masks = {
5569
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5570
+ shortDate: 'M/D/yy',
5571
+ mediumDate: 'MMM d, yyyy',
5572
+ longDate: 'MMMM d, yyyy',
5573
+ fullDate: 'dddd, MMMM d, yyyy',
5574
+ shortTime: 'HH:mm',
5575
+ mediumTime: 'HH:mm:ss',
5576
+ longTime: 'HH:mm:ss.SSS'
5577
+ };
5578
+
5605
5579
  /***
5606
5580
  * Format a date
5607
5581
  * @method format
5608
5582
  * @param {Date|number} dateObj
5609
5583
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5610
- */
5611
- fecha.format = function (dateObj, mask) {
5612
- if (typeof dateObj === 'number') {
5613
- dateObj = new Date(dateObj);
5614
- }
5615
-
5616
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5617
- throw new Error('Invalid Date in fecha.format');
5618
- }
5619
-
5620
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5621
-
5622
- const literals = [];
5623
-
5624
- // Make literals inactive by replacing them with ??
5625
- mask = mask.replace(literal, function($0, $1) {
5626
- literals.push($1);
5627
- return '@@@';
5628
- });
5629
- // Apply formatting rules
5630
- mask = mask.replace(token, function ($0) {
5631
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5632
- });
5633
- // Inline literal values back into the formatted value
5634
- return mask.replace(/@@@/g, function() {
5635
- return literals.shift();
5636
- });
5637
- };
5638
-
5584
+ */
5585
+ fecha.format = function (dateObj, mask) {
5586
+ if (typeof dateObj === 'number') {
5587
+ dateObj = new Date(dateObj);
5588
+ }
5589
+
5590
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5591
+ throw new Error('Invalid Date in fecha.format');
5592
+ }
5593
+
5594
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5595
+
5596
+ var literals = [];
5597
+
5598
+ // Make literals inactive by replacing them with ??
5599
+ mask = mask.replace(literal, function ($0, $1) {
5600
+ literals.push($1);
5601
+ return '@@@';
5602
+ });
5603
+ // Apply formatting rules
5604
+ mask = mask.replace(token, function ($0) {
5605
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5606
+ });
5607
+ // Inline literal values back into the formatted value
5608
+ return mask.replace(/@@@/g, function () {
5609
+ return literals.shift();
5610
+ });
5611
+ };
5612
+
5639
5613
  /**
5640
5614
  * Parse a date string into an object, changes - into /
5641
5615
  * @method parse
5642
5616
  * @param {string} dateStr Date string
5643
5617
  * @param {string} format Date parse format
5644
5618
  * @returns {Date|boolean}
5645
- */
5646
- fecha.parse = function (dateStr, format) {
5647
- if (typeof format !== 'string') {
5648
- throw new Error('Invalid format in fecha.parse');
5649
- }
5650
-
5651
- format = fecha.masks[format] || format;
5652
-
5653
- // Avoid regular expression denial of service, fail early for really long strings
5654
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5655
- if (dateStr.length > 1000) {
5656
- return null;
5657
- }
5658
-
5659
- const dateInfo = {};
5660
- const parseInfo = [];
5661
- const literals = [];
5662
- format = format.replace(literal, function($0, $1) {
5663
- literals.push($1);
5664
- return '@@@';
5665
- });
5666
- let newFormat = regexEscape(format).replace(token, function ($0) {
5667
- if (parseFlags[$0]) {
5668
- const info = parseFlags[$0];
5669
- parseInfo.push(info[1]);
5670
- return '(' + info[0] + ')';
5671
- }
5672
-
5673
- return $0;
5674
- });
5675
- newFormat = newFormat.replace(/@@@/g, function() {
5676
- return literals.shift();
5677
- });
5678
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
5679
- if (!matches) {
5680
- return null;
5681
- }
5682
-
5683
- for (let i = 1; i < matches.length; i++) {
5684
- parseInfo[i - 1](dateInfo, matches[i]);
5685
- }
5686
-
5687
- const today = new Date();
5688
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5689
- dateInfo.hour = +dateInfo.hour + 12;
5690
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5691
- dateInfo.hour = 0;
5692
- }
5693
-
5694
- let date;
5695
- if (dateInfo.timezoneOffset != null) {
5696
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5697
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5698
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5699
- } else {
5700
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5701
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5702
- }
5703
- return date;
5704
- };
5705
-
5706
- // 导出fecha对象
5707
-
5708
-
5709
- // 以下是从date-util.js合并的函数
5710
- const newArray = function(start, end) {
5711
- let result = [];
5712
- for (let i = start; i <= end; i++) {
5713
- result.push(i);
5714
- }
5715
- return result;
5716
- };
5717
-
5718
- const getSettings = () => {
5719
- return {
5720
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5721
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5722
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5723
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5724
- amPm: ['上午', '下午']
5725
- };
5726
- };
5727
-
5728
- const toDate = function(date) {
5729
- return isDate(date) ? new Date(date) : null;
5730
- };
5731
-
5732
- const isDate = function(date) {
5733
- if (date === null || date === undefined) return false;
5734
- if (isNaN(new Date(date).getTime())) return false;
5735
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5736
- return true;
5737
- };
5738
-
5739
- const isDateObject = function(val) {
5740
- return val instanceof Date;
5741
- };
5742
-
5743
- const formatDate = function (date, format = 'yyyy-MM-dd') {
5744
- // 处理多种输入类型
5745
- if (!date) return '';
5746
-
5747
- // 如果是时间戳,转成日期对象
5748
- if (typeof date === 'number') {
5749
- date = new Date(date);
5750
- }
5751
- // 如果是字符串,转成日期对象
5752
- if (typeof date === 'string') {
5753
- date = new Date(date);
5754
- }
5755
-
5756
- // 调用toDate进一步验证和转换
5757
- date = toDate(date);
5758
- if (!date) return '';
5759
-
5760
- // 兼容大写和小写的格式标记
5761
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5762
- const lowercaseFormat = format
5763
- .replace(/YYYY/g, 'yyyy')
5764
- .replace(/D/g, 'd')
5765
-
5766
- // 使用fecha库进行格式化,支持中文配置
5767
- const str = fecha.format(date, lowercaseFormat, getSettings());
5768
- return str;
5769
- };
5770
-
5771
- const parseDate = function(string, format) {
5772
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5773
- };
5774
-
5775
- const getDayCountOfMonth = function(year, month) {
5776
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5777
- return 30;
5778
- }
5779
-
5780
- if (month === 1) {
5781
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5782
- return 29;
5783
- } else {
5784
- return 28;
5785
- }
5786
- }
5787
-
5788
- return 31;
5789
- };
5790
-
5791
- const getDayCountOfYear = function(year) {
5792
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5793
- return isLeapYear ? 366 : 365;
5794
- };
5795
-
5796
- const getFirstDayOfMonth = function(date) {
5797
- const temp = new Date(date.getTime());
5798
- temp.setDate(1);
5799
- return temp.getDay();
5800
- };
5801
-
5802
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5803
- // {prev, next} Date should work for Daylight Saving Time
5804
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5805
- const prevDate = function(date, amount = 1) {
5806
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5807
- };
5808
-
5809
- const nextDate = function(date, amount = 1) {
5810
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5811
- };
5812
-
5813
- const getStartDateOfMonth = function(year, month) {
5814
- const result = new Date(year, month, 1);
5815
- const day = result.getDay();
5816
-
5817
- if (day === 0) {
5818
- return prevDate(result, 7);
5819
- } else {
5820
- return prevDate(result, day);
5821
- }
5822
- };
5823
-
5824
- const getWeekNumber = function(date) {
5825
- // 支持多种输入类型
5826
- if (!date||!isDate(date)) {
5827
- date = new Date();
5828
- }
5829
- if (typeof date === 'string') {
5830
- date = new Date(date);
5831
- }
5832
-
5833
- // 验证日期有效性
5834
- if (!isDate(date)) return null;
5835
-
5836
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5837
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5838
- // 将星期日的星期数设为7
5839
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5840
- // 获取当年的第一天
5841
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5842
- // 计算到最近的星期四的完整周数
5843
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5844
- // 返回周数
5845
- return weekNo;
5846
- };
5847
-
5848
- const getRangeHours = function(ranges) {
5849
- const hours = [];
5850
- let disabledHours = [];
5851
-
5852
- (ranges || []).forEach(range => {
5853
- const value = range.map(date => date.getHours());
5854
-
5855
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5856
- });
5857
-
5858
- if (disabledHours.length) {
5859
- for (let i = 0; i < 24; i++) {
5860
- hours[i] = disabledHours.indexOf(i) === -1;
5861
- }
5862
- } else {
5863
- for (let i = 0; i < 24; i++) {
5864
- hours[i] = false;
5865
- }
5866
- }
5867
-
5868
- return hours;
5869
- };
5870
-
5871
- const getPrevMonthLastDays = (date, amount) => {
5872
- if (amount <= 0) return [];
5873
- const temp = new Date(date.getTime());
5874
- temp.setDate(0);
5875
- const lastDay = temp.getDate();
5876
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
5877
- };
5878
-
5879
- const getMonthDays = (date) => {
5880
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5881
- const days = temp.getDate();
5882
- return range(days).map((_, index) => index + 1);
5883
- };
5884
-
5885
- function setRangeData(arr, start, end, value) {
5886
- for (let i = start; i < end; i++) {
5887
- arr[i] = value;
5888
- }
5889
- }
5890
-
5891
- const getRangeMinutes = function(ranges, hour) {
5892
- const minutes = new Array(60);
5893
-
5894
- if (ranges.length > 0) {
5895
- ranges.forEach(range => {
5896
- const start = range[0];
5897
- const end = range[1];
5898
- const startHour = start.getHours();
5899
- const startMinute = start.getMinutes();
5900
- const endHour = end.getHours();
5901
- const endMinute = end.getMinutes();
5902
- if (startHour === hour && endHour !== hour) {
5903
- setRangeData(minutes, startMinute, 60, true);
5904
- } else if (startHour === hour && endHour === hour) {
5905
- setRangeData(minutes, startMinute, endMinute + 1, true);
5906
- } else if (startHour !== hour && endHour === hour) {
5907
- setRangeData(minutes, 0, endMinute + 1, true);
5908
- } else if (startHour < hour && endHour > hour) {
5909
- setRangeData(minutes, 0, 60, true);
5910
- }
5911
- });
5912
- } else {
5913
- setRangeData(minutes, 0, 60, true);
5914
- }
5915
- return minutes;
5916
- };
5917
-
5918
- const range = function(n) {
5919
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5920
- return Array.apply(null, {length: n}).map((_, n) => n);
5921
- };
5922
-
5923
- const modifyDate = function(date, y, m, d) {
5924
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5925
- };
5926
-
5927
- const modifyTime = function(date, h, m, s) {
5928
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5929
- };
5930
-
5931
- const modifyWithTimeString = (date, time) => {
5932
- if (date == null || !time) {
5933
- return date;
5934
- }
5935
- time = parseDate(time, 'HH:mm:ss');
5936
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5937
- };
5938
-
5939
- const clearTime = function(date) {
5940
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5941
- };
5942
-
5943
- const clearMilliseconds = function(date) {
5944
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5945
- };
5946
-
5947
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5948
- // TODO: refactory a more elegant solution
5949
- if (ranges.length === 0) return date;
5950
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5951
- const ndate = normalizeDate(date);
5952
- const nranges = ranges.map(range => range.map(normalizeDate));
5953
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5954
-
5955
- let minDate = nranges[0][0];
5956
- let maxDate = nranges[0][0];
5957
-
5958
- nranges.forEach(nrange => {
5959
- minDate = new Date(Math.min(nrange[0], minDate));
5960
- maxDate = new Date(Math.max(nrange[1], minDate));
5961
- });
5962
-
5963
- const ret = ndate < minDate ? minDate : maxDate;
5964
- // preserve Year/Month/Date
5965
- return modifyDate(
5966
- ret,
5967
- date.getFullYear(),
5968
- date.getMonth(),
5969
- date.getDate()
5970
- );
5971
- };
5972
-
5973
- const timeWithinRange = function(date, selectableRange, format) {
5974
- const limitedDate = limitTimeRange(date, selectableRange, format);
5975
- return limitedDate.getTime() === date.getTime();
5976
- };
5977
-
5978
- const changeYearMonthAndClampDate = function(date, year, month) {
5979
- // clamp date to the number of days in `year`, `month`
5980
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5981
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5982
- return modifyDate(date, year, month, monthDate);
5983
- };
5984
-
5985
- const prevMonth = function(date) {
5986
- const year = date.getFullYear();
5987
- const month = date.getMonth();
5988
- return month === 0
5989
- ? changeYearMonthAndClampDate(date, year - 1, 11)
5990
- : changeYearMonthAndClampDate(date, year, month - 1);
5991
- };
5992
-
5993
- const nextMonth = function(date) {
5994
- const year = date.getFullYear();
5995
- const month = date.getMonth();
5996
- return month === 11
5997
- ? changeYearMonthAndClampDate(date, year + 1, 0)
5998
- : changeYearMonthAndClampDate(date, year, month + 1);
5999
- };
6000
-
6001
- const prevYear = function(date, amount = 1) {
6002
- const year = date.getFullYear();
6003
- const month = date.getMonth();
6004
- return changeYearMonthAndClampDate(date, year - amount, month);
6005
- };
6006
-
6007
- const nextYear = function(date, amount = 1) {
6008
- const year = date.getFullYear();
6009
- const month = date.getMonth();
6010
- return changeYearMonthAndClampDate(date, year + amount, month);
6011
- };
6012
-
6013
- const extractDateFormat = function(format) {
6014
- return format
6015
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
6016
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
6017
- .trim();
6018
- };
6019
-
6020
- const extractTimeFormat = function(format) {
6021
- return format
6022
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
6023
- .trim();
6024
- };
6025
-
6026
- const validateRangeInOneMonth = function(start, end) {
6027
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
6028
- };
6029
-
5619
+ */
5620
+ fecha.parse = function (dateStr, format) {
5621
+ if (typeof format !== 'string') {
5622
+ throw new Error('Invalid format in fecha.parse');
5623
+ }
5624
+
5625
+ format = fecha.masks[format] || format;
5626
+
5627
+ // Avoid regular expression denial of service, fail early for really long strings
5628
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5629
+ if (dateStr.length > 1000) {
5630
+ return null;
5631
+ }
5632
+
5633
+ var dateInfo = {};
5634
+ var parseInfo = [];
5635
+ var literals = [];
5636
+ format = format.replace(literal, function ($0, $1) {
5637
+ literals.push($1);
5638
+ return '@@@';
5639
+ });
5640
+ var newFormat = regexEscape(format).replace(token, function ($0) {
5641
+ if (parseFlags[$0]) {
5642
+ var info = parseFlags[$0];
5643
+ parseInfo.push(info[1]);
5644
+ return '(' + info[0] + ')';
5645
+ }
5646
+
5647
+ return $0;
5648
+ });
5649
+ newFormat = newFormat.replace(/@@@/g, function () {
5650
+ return literals.shift();
5651
+ });
5652
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
5653
+ if (!matches) {
5654
+ return null;
5655
+ }
5656
+
5657
+ for (var i = 1; i < matches.length; i++) {
5658
+ parseInfo[i - 1](dateInfo, matches[i]);
5659
+ }
5660
+
5661
+ var today = new Date();
5662
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5663
+ dateInfo.hour = +dateInfo.hour + 12;
5664
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5665
+ dateInfo.hour = 0;
5666
+ }
5667
+
5668
+ var date = void 0;
5669
+ if (dateInfo.timezoneOffset != null) {
5670
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5671
+ 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));
5672
+ } else {
5673
+ 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);
5674
+ }
5675
+ return date;
5676
+ };
5677
+
5678
+ // 导出fecha对象
5679
+
5680
+
5681
+ // 以下是从date-util.js合并的函数
5682
+ var newArray = function newArray(start, end) {
5683
+ var result = [];
5684
+ for (var i = start; i <= end; i++) {
5685
+ result.push(i);
5686
+ }
5687
+ return result;
5688
+ };
5689
+
5690
+ var getSettings = function getSettings() {
5691
+ return {
5692
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5693
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5694
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5695
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5696
+ amPm: ['上午', '下午']
5697
+ };
5698
+ };
5699
+
5700
+ var toDate = function toDate(date) {
5701
+ return isDate(date) ? new Date(date) : null;
5702
+ };
5703
+
5704
+ var isDate = function isDate(date) {
5705
+ if (date === null || date === undefined) return false;
5706
+ if (isNaN(new Date(date).getTime())) return false;
5707
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5708
+ return true;
5709
+ };
5710
+
5711
+ var isDateObject = function isDateObject(val) {
5712
+ return val instanceof Date;
5713
+ };
5714
+
5715
+ var formatDate = function formatDate(date) {
5716
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5717
+
5718
+ // 处理多种输入类型
5719
+ if (!date) return '';
5720
+
5721
+ // 如果是时间戳,转成日期对象
5722
+ if (typeof date === 'number') {
5723
+ date = new Date(date);
5724
+ }
5725
+ // 如果是字符串,转成日期对象
5726
+ if (typeof date === 'string') {
5727
+ date = new Date(date);
5728
+ }
5729
+
5730
+ // 调用toDate进一步验证和转换
5731
+ date = toDate(date);
5732
+ if (!date) return '';
5733
+
5734
+ // 兼容大写和小写的格式标记
5735
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5736
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5737
+
5738
+ // 使用fecha库进行格式化,支持中文配置
5739
+ var str = fecha.format(date, lowercaseFormat, getSettings());
5740
+ return str;
5741
+ };
5742
+
5743
+ var parseDate = function parseDate(string, format) {
5744
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5745
+ };
5746
+
5747
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5748
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5749
+ return 30;
5750
+ }
5751
+
5752
+ if (month === 1) {
5753
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5754
+ return 29;
5755
+ } else {
5756
+ return 28;
5757
+ }
5758
+ }
5759
+
5760
+ return 31;
5761
+ };
5762
+
5763
+ var getDayCountOfYear = function getDayCountOfYear(year) {
5764
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5765
+ return isLeapYear ? 366 : 365;
5766
+ };
5767
+
5768
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5769
+ var temp = new Date(date.getTime());
5770
+ temp.setDate(1);
5771
+ return temp.getDay();
5772
+ };
5773
+
5774
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5775
+ // {prev, next} Date should work for Daylight Saving Time
5776
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5777
+ var prevDate = function prevDate(date) {
5778
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5779
+
5780
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5781
+ };
5782
+
5783
+ var nextDate = function nextDate(date) {
5784
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5785
+
5786
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5787
+ };
5788
+
5789
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5790
+ var result = new Date(year, month, 1);
5791
+ var day = result.getDay();
5792
+
5793
+ if (day === 0) {
5794
+ return prevDate(result, 7);
5795
+ } else {
5796
+ return prevDate(result, day);
5797
+ }
5798
+ };
5799
+
5800
+ var getWeekNumber = function getWeekNumber(date) {
5801
+ // 支持多种输入类型
5802
+ if (!date || !isDate(date)) {
5803
+ date = new Date();
5804
+ }
5805
+ if (typeof date === 'string') {
5806
+ date = new Date(date);
5807
+ }
5808
+
5809
+ // 验证日期有效性
5810
+ if (!isDate(date)) return null;
5811
+
5812
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5813
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5814
+ // 将星期日的星期数设为7
5815
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5816
+ // 获取当年的第一天
5817
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5818
+ // 计算到最近的星期四的完整周数
5819
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5820
+ // 返回周数
5821
+ return weekNo;
5822
+ };
5823
+
5824
+ var getRangeHours = function getRangeHours(ranges) {
5825
+ var hours = [];
5826
+ var disabledHours = [];
5827
+
5828
+ (ranges || []).forEach(function (range) {
5829
+ var value = range.map(function (date) {
5830
+ return date.getHours();
5831
+ });
5832
+
5833
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5834
+ });
5835
+
5836
+ if (disabledHours.length) {
5837
+ for (var i = 0; i < 24; i++) {
5838
+ hours[i] = disabledHours.indexOf(i) === -1;
5839
+ }
5840
+ } else {
5841
+ for (var _i = 0; _i < 24; _i++) {
5842
+ hours[_i] = false;
5843
+ }
5844
+ }
5845
+
5846
+ return hours;
5847
+ };
5848
+
5849
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5850
+ if (amount <= 0) return [];
5851
+ var temp = new Date(date.getTime());
5852
+ temp.setDate(0);
5853
+ var lastDay = temp.getDate();
5854
+ return range(amount).map(function (_, index) {
5855
+ return lastDay - (amount - index - 1);
5856
+ });
5857
+ };
5858
+
5859
+ var getMonthDays = function getMonthDays(date) {
5860
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5861
+ var days = temp.getDate();
5862
+ return range(days).map(function (_, index) {
5863
+ return index + 1;
5864
+ });
5865
+ };
5866
+
5867
+ function setRangeData(arr, start, end, value) {
5868
+ for (var i = start; i < end; i++) {
5869
+ arr[i] = value;
5870
+ }
5871
+ }
5872
+
5873
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5874
+ var minutes = new Array(60);
5875
+
5876
+ if (ranges.length > 0) {
5877
+ ranges.forEach(function (range) {
5878
+ var start = range[0];
5879
+ var end = range[1];
5880
+ var startHour = start.getHours();
5881
+ var startMinute = start.getMinutes();
5882
+ var endHour = end.getHours();
5883
+ var endMinute = end.getMinutes();
5884
+ if (startHour === hour && endHour !== hour) {
5885
+ setRangeData(minutes, startMinute, 60, true);
5886
+ } else if (startHour === hour && endHour === hour) {
5887
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5888
+ } else if (startHour !== hour && endHour === hour) {
5889
+ setRangeData(minutes, 0, endMinute + 1, true);
5890
+ } else if (startHour < hour && endHour > hour) {
5891
+ setRangeData(minutes, 0, 60, true);
5892
+ }
5893
+ });
5894
+ } else {
5895
+ setRangeData(minutes, 0, 60, true);
5896
+ }
5897
+ return minutes;
5898
+ };
5899
+
5900
+ var range = function range(n) {
5901
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5902
+ return Array.apply(null, { length: n }).map(function (_, n) {
5903
+ return n;
5904
+ });
5905
+ };
5906
+
5907
+ var modifyDate = function modifyDate(date, y, m, d) {
5908
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5909
+ };
5910
+
5911
+ var modifyTime = function modifyTime(date, h, m, s) {
5912
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5913
+ };
5914
+
5915
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
5916
+ if (date == null || !time) {
5917
+ return date;
5918
+ }
5919
+ time = parseDate(time, 'HH:mm:ss');
5920
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5921
+ };
5922
+
5923
+ var clearTime = function clearTime(date) {
5924
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5925
+ };
5926
+
5927
+ var clearMilliseconds = function clearMilliseconds(date) {
5928
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5929
+ };
5930
+
5931
+ var limitTimeRange = function limitTimeRange(date, ranges) {
5932
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5933
+
5934
+ // TODO: refactory a more elegant solution
5935
+ if (ranges.length === 0) return date;
5936
+ var normalizeDate = function normalizeDate(date) {
5937
+ return fecha.parse(fecha.format(date, format), format);
5938
+ };
5939
+ var ndate = normalizeDate(date);
5940
+ var nranges = ranges.map(function (range) {
5941
+ return range.map(normalizeDate);
5942
+ });
5943
+ if (nranges.some(function (nrange) {
5944
+ return ndate >= nrange[0] && ndate <= nrange[1];
5945
+ })) return date;
5946
+
5947
+ var minDate = nranges[0][0];
5948
+ var maxDate = nranges[0][0];
5949
+
5950
+ nranges.forEach(function (nrange) {
5951
+ minDate = new Date(Math.min(nrange[0], minDate));
5952
+ maxDate = new Date(Math.max(nrange[1], minDate));
5953
+ });
5954
+
5955
+ var ret = ndate < minDate ? minDate : maxDate;
5956
+ // preserve Year/Month/Date
5957
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5958
+ };
5959
+
5960
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5961
+ var limitedDate = limitTimeRange(date, selectableRange, format);
5962
+ return limitedDate.getTime() === date.getTime();
5963
+ };
5964
+
5965
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5966
+ // clamp date to the number of days in `year`, `month`
5967
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5968
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5969
+ return modifyDate(date, year, month, monthDate);
5970
+ };
5971
+
5972
+ var prevMonth = function prevMonth(date) {
5973
+ var year = date.getFullYear();
5974
+ var month = date.getMonth();
5975
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5976
+ };
5977
+
5978
+ var nextMonth = function nextMonth(date) {
5979
+ var year = date.getFullYear();
5980
+ var month = date.getMonth();
5981
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5982
+ };
5983
+
5984
+ var prevYear = function prevYear(date) {
5985
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5986
+
5987
+ var year = date.getFullYear();
5988
+ var month = date.getMonth();
5989
+ return changeYearMonthAndClampDate(date, year - amount, month);
5990
+ };
5991
+
5992
+ var nextYear = function nextYear(date) {
5993
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5994
+
5995
+ var year = date.getFullYear();
5996
+ var month = date.getMonth();
5997
+ return changeYearMonthAndClampDate(date, year + amount, month);
5998
+ };
5999
+
6000
+ var extractDateFormat = function extractDateFormat(format) {
6001
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
6002
+ };
6003
+
6004
+ var extractTimeFormat = function extractTimeFormat(format) {
6005
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
6006
+ };
6007
+
6008
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
6009
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
6010
+ };
6011
+
6030
6012
  /**
6031
6013
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
6032
6014
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
6033
6015
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
6034
6016
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
6035
6017
  * @returns {number} 工作日数量
6036
- */
6037
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
6038
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6039
- throw new Error(
6040
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
6041
- );
6042
- }
6043
-
6044
- const startDateObj = new Date(start_date);
6045
- const endDateObj = new Date(end_date);
6046
-
6047
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6048
- throw new Error(
6049
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
6050
- );
6051
- }
6052
-
6053
- if (startDateObj > endDateObj) {
6054
- throw new Error('Start date should be earlier than or equal to end date.');
6055
- }
6056
-
6057
- let workdays = 0;
6058
-
6059
- // Iterate through each day in the date range
6060
- for (
6061
- let currentDate = new Date(startDateObj);
6062
- currentDate <= endDateObj;
6063
- currentDate.setDate(currentDate.getDate() + 1)
6064
- ) {
6065
- // Check if the current day is a weekend (Saturday or Sunday)
6066
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6067
-
6068
- // Check if the current day is a holiday
6069
- const isHoliday = holidays.some((holiday) => {
6070
- const holidayDate = new Date(holiday);
6071
- return currentDate.toDateString() === holidayDate.toDateString();
6072
- });
6073
-
6074
- // If it's a workday (not a weekend or holiday), increment the workdays count
6075
- if (!isWeekend && !isHoliday) {
6076
- workdays++;
6077
- }
6078
- }
6079
-
6080
- return workdays;
6081
- };
6082
-
6018
+ */
6019
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
6020
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6021
+
6022
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6023
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6024
+ }
6025
+
6026
+ var startDateObj = new Date(start_date);
6027
+ var endDateObj = new Date(end_date);
6028
+
6029
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6030
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6031
+ }
6032
+
6033
+ if (startDateObj > endDateObj) {
6034
+ throw new Error('Start date should be earlier than or equal to end date.');
6035
+ }
6036
+
6037
+ var workdays = 0;
6038
+
6039
+ // Iterate through each day in the date range
6040
+
6041
+ var _loop = function _loop(currentDate) {
6042
+ // Check if the current day is a weekend (Saturday or Sunday)
6043
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6044
+
6045
+ // Check if the current day is a holiday
6046
+ var isHoliday = holidays.some(function (holiday) {
6047
+ var holidayDate = new Date(holiday);
6048
+ return currentDate.toDateString() === holidayDate.toDateString();
6049
+ });
6050
+
6051
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6052
+ if (!isWeekend && !isHoliday) {
6053
+ workdays++;
6054
+ }
6055
+ };
6056
+
6057
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6058
+ _loop(currentDate);
6059
+ }
6060
+
6061
+ return workdays;
6062
+ };
6063
+
6083
6064
  /**
6084
6065
  * 日期加减天数
6085
6066
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6086
6067
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6087
6068
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6088
- */
6089
- const dateAddDays = function (start_date, days) {
6090
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6091
- throw new Error(
6092
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6093
- );
6094
- }
6095
-
6096
- const startDateObj = new Date(start_date);
6097
- if (isNaN(startDateObj.getTime())) {
6098
- throw new Error(
6099
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6100
- );
6101
- }
6102
-
6103
- const resultDateObj = new Date(startDateObj);
6104
- resultDateObj.setDate(resultDateObj.getDate() + days);
6105
-
6106
- const resultYear = resultDateObj.getFullYear();
6107
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6108
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6109
-
6110
- return `${resultYear}-${resultMonth}-${resultDay}`;
6111
- };
6112
-
6069
+ */
6070
+ var dateAddDays = function dateAddDays(start_date, days) {
6071
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6072
+ 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.");
6073
+ }
6074
+
6075
+ var startDateObj = new Date(start_date);
6076
+ if (isNaN(startDateObj.getTime())) {
6077
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6078
+ }
6079
+
6080
+ var resultDateObj = new Date(startDateObj);
6081
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6082
+
6083
+ var resultYear = resultDateObj.getFullYear();
6084
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6085
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6086
+
6087
+ return resultYear + '-' + resultMonth + '-' + resultDay;
6088
+ };
6089
+
6113
6090
  /**
6114
6091
  * 计算两个日期之间的差值
6115
6092
  * @date 2023年12月14日
@@ -6117,182 +6094,180 @@ const dateAddDays = function (start_date, days) {
6117
6094
  * @param {String} end_date - 结束日期字符串
6118
6095
  * @param {String} unit - 单位:year/month/day
6119
6096
  * @returns {Number} 差值
6120
- */
6121
- const dateDiff = function (start_date, end_date, unit = 'day') {
6122
- // Assuming date strings are in "YYYY-MM-DD" format
6123
- var startDate = new Date(start_date);
6124
- var endDate = new Date(end_date);
6125
-
6126
- // If the date is invalid, return 0
6127
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6128
- return 0;
6129
- }
6130
-
6131
- if (unit === 'year') {
6132
- return endDate.getFullYear() - startDate.getFullYear();
6133
- } else if (unit === 'month') {
6134
- return (
6135
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
6136
- (endDate.getMonth() - startDate.getMonth())
6137
- );
6138
- } else {
6139
- // Default to day
6140
- var timeDifference = endDate - startDate;
6141
- // Calculate days (86400000 milliseconds per day)
6142
- return Math.floor(timeDifference / 86400000);
6143
- }
6144
- };
6145
-
6097
+ */
6098
+ var dateDiff = function dateDiff(start_date, end_date) {
6099
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6100
+
6101
+ // Assuming date strings are in "YYYY-MM-DD" format
6102
+ var startDate = new Date(start_date);
6103
+ var endDate = new Date(end_date);
6104
+
6105
+ // If the date is invalid, return 0
6106
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6107
+ return 0;
6108
+ }
6109
+
6110
+ if (unit === 'year') {
6111
+ return endDate.getFullYear() - startDate.getFullYear();
6112
+ } else if (unit === 'month') {
6113
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
6114
+ } else {
6115
+ // Default to day
6116
+ var timeDifference = endDate - startDate;
6117
+ // Calculate days (86400000 milliseconds per day)
6118
+ return Math.floor(timeDifference / 86400000);
6119
+ }
6120
+ };
6121
+
6146
6122
  /**
6147
6123
  * 获取月份中的日期
6148
6124
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
6149
6125
  * @returns {number} 月份中的日期(1-31)
6150
- */
6151
- const dayOfMonth = function (date) {
6152
- if (typeof date !== 'string') {
6153
- throw new Error(
6154
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
6155
- );
6156
- }
6157
-
6158
- const dateObj = new Date(date);
6159
- if (isNaN(dateObj.getTime())) {
6160
- throw new Error(
6161
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6162
- );
6163
- }
6164
-
6165
- return dateObj.getDate();
6166
- };
6167
-
6126
+ */
6127
+ var dayOfMonth = function dayOfMonth(date) {
6128
+ if (typeof date !== 'string') {
6129
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6130
+ }
6131
+
6132
+ var dateObj = new Date(date);
6133
+ if (isNaN(dateObj.getTime())) {
6134
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6135
+ }
6136
+
6137
+ return dateObj.getDate();
6138
+ };
6139
+
6168
6140
  /**
6169
6141
  * 获取当前日期
6170
6142
  * @date 2022年5月7日
6171
6143
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
6172
6144
  * @returns {string} 当前日期的格式化字符串
6173
- */
6174
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
6175
- return formatDate(new Date(), format);
6176
- };
6177
-
6145
+ */
6146
+ var getCurrentDate = function getCurrentDate() {
6147
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
6148
+
6149
+ return formatDate(new Date(), format);
6150
+ };
6151
+
6178
6152
  /**
6179
6153
  * 获取当前日期时间
6180
6154
  * @date 2022年5月7日
6181
6155
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
6182
6156
  * @returns {string} 当前日期时间的格式化字符串
6183
- */
6184
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
6185
- return formatDate(new Date(), format);
6186
- };
6187
-
6157
+ */
6158
+ var getCurrentDateTime = function getCurrentDateTime() {
6159
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
6160
+
6161
+ return formatDate(new Date(), format);
6162
+ };
6163
+
6188
6164
  /**
6189
6165
  * 获取小时
6190
6166
  * @date 2022年5月7日
6191
6167
  * @param {Date|string} [date] - 日期对象或日期字符串
6192
6168
  * @returns {number} 小时数(0-23)
6193
- */
6194
- const getHour = function (date) {
6195
- if (!date) {
6196
- return new Date().getHours();
6197
- }
6198
- if (typeof date === 'string') {
6199
- date = new Date(date);
6200
- }
6201
- return date.getHours();
6202
- };
6203
-
6169
+ */
6170
+ var getHour = function getHour(date) {
6171
+ if (!date) {
6172
+ return new Date().getHours();
6173
+ }
6174
+ if (typeof date === 'string') {
6175
+ date = new Date(date);
6176
+ }
6177
+ return date.getHours();
6178
+ };
6179
+
6204
6180
  /**
6205
6181
  * 获取分钟
6206
6182
  * @date 2022年5月7日
6207
6183
  * @param {Date|string} [date] - 日期对象或日期字符串
6208
6184
  * @returns {number} 分钟数(0-59)
6209
- */
6210
- const getMinute = function (date) {
6211
- if (!date) {
6212
- return new Date().getMinutes();
6213
- }
6214
- if (typeof date === 'string') {
6215
- date = new Date(date);
6216
- }
6217
- return date.getMinutes();
6218
- };
6219
-
6185
+ */
6186
+ var getMinute = function getMinute(date) {
6187
+ if (!date) {
6188
+ return new Date().getMinutes();
6189
+ }
6190
+ if (typeof date === 'string') {
6191
+ date = new Date(date);
6192
+ }
6193
+ return date.getMinutes();
6194
+ };
6195
+
6220
6196
  /**
6221
6197
  * 获取月份
6222
6198
  * @date 2022年5月7日
6223
6199
  * @param {Date|string} [date] - 日期对象或日期字符串
6224
6200
  * @returns {number} 月份数(1-12)
6225
- */
6226
- const getMonth = function (date) {
6227
- if (!date) {
6228
- return new Date().getMonth() + 1;
6229
- }
6230
- if (typeof date === 'string') {
6231
- date = new Date(date);
6232
- }
6233
- return date.getMonth() + 1;
6234
- };
6235
-
6201
+ */
6202
+ var getMonth = function getMonth(date) {
6203
+ if (!date) {
6204
+ return new Date().getMonth() + 1;
6205
+ }
6206
+ if (typeof date === 'string') {
6207
+ date = new Date(date);
6208
+ }
6209
+ return date.getMonth() + 1;
6210
+ };
6211
+
6236
6212
  /**
6237
6213
  * 获取秒
6238
6214
  * @date 2022年5月7日
6239
6215
  * @param {Date|string} [date] - 日期对象或日期字符串
6240
6216
  * @returns {number} 秒数(0-59)
6241
- */
6242
- const getSecond = function (date) {
6243
- if (!date) {
6244
- return new Date().getSeconds();
6245
- }
6246
- if (typeof date === 'string') {
6247
- date = new Date(date);
6248
- }
6249
- return date.getSeconds();
6250
- };
6251
-
6217
+ */
6218
+ var getSecond = function getSecond(date) {
6219
+ if (!date) {
6220
+ return new Date().getSeconds();
6221
+ }
6222
+ if (typeof date === 'string') {
6223
+ date = new Date(date);
6224
+ }
6225
+ return date.getSeconds();
6226
+ };
6227
+
6252
6228
  /**
6253
6229
  * 获取星期几
6254
6230
  * @date 2022年5月7日
6255
6231
  * @param {Date|string} [date] - 日期对象或日期字符串
6256
6232
  * @returns {number} 星期几(0-6,0表示星期日)
6257
- */
6258
- const getWeekday = function (date) {
6259
- if (!date) {
6260
- return new Date().getDay();
6261
- }
6262
- if (typeof date === 'string') {
6263
- date = new Date(date);
6264
- }
6265
- return date.getDay();
6266
- };
6267
-
6268
-
6233
+ */
6234
+ var getWeekday = function getWeekday(date) {
6235
+ if (!date) {
6236
+ return new Date().getDay();
6237
+ }
6238
+ if (typeof date === 'string') {
6239
+ date = new Date(date);
6240
+ }
6241
+ return date.getDay();
6242
+ };
6243
+
6269
6244
  /**
6270
6245
  * @desc 获取上午/下午/晚上
6271
6246
  * @author huangbo
6272
6247
  * @date 2022年5月7日
6273
6248
  * @param {String} [time] - 时间
6274
- **/
6275
- const timeCycle = function (time) {
6276
- let hour = 0;
6277
- if (!time) {
6278
- hour = new Date().getHours();
6279
- } else if (typeof time === 'string') {
6280
- // 从时间字符串中提取小时
6281
- const match = time.match(/^(\d{1,2})/);
6282
- if (match) {
6283
- hour = parseInt(match[1], 10);
6284
- }
6285
- } else if (typeof time === 'number') {
6286
- hour = time;
6287
- }
6288
- // 判断时间段
6289
- if (hour >= 5 && hour < 12) {
6290
- return '上午';
6291
- } else if (hour >= 12 && hour < 18) {
6292
- return '下午';
6293
- } else {
6294
- return '晚上';
6295
- }
6249
+ **/
6250
+ var timeCycle = function timeCycle(time) {
6251
+ var hour = 0;
6252
+ if (!time) {
6253
+ hour = new Date().getHours();
6254
+ } else if (typeof time === 'string') {
6255
+ // 从时间字符串中提取小时
6256
+ var match = time.match(/^(\d{1,2})/);
6257
+ if (match) {
6258
+ hour = parseInt(match[1], 10);
6259
+ }
6260
+ } else if (typeof time === 'number') {
6261
+ hour = time;
6262
+ }
6263
+ // 判断时间段
6264
+ if (hour >= 5 && hour < 12) {
6265
+ return '上午';
6266
+ } else if (hour >= 12 && hour < 18) {
6267
+ return '下午';
6268
+ } else {
6269
+ return '晚上';
6270
+ }
6296
6271
  };
6297
6272
 
6298
6273
  /***/ }),
@@ -6304,7 +6279,7 @@ module.exports = require("eoss/lib/message-box");
6304
6279
 
6305
6280
  /***/ }),
6306
6281
 
6307
- /***/ 81:
6282
+ /***/ 82:
6308
6283
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
6309
6284
 
6310
6285
  "use strict";