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
package/lib/data-table.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 = 231);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 238);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4668,7 +4668,7 @@ var getRgb = function getRgb($color) {
4668
4668
 
4669
4669
  /***/ }),
4670
4670
 
4671
- /***/ 134:
4671
+ /***/ 138:
4672
4672
  /***/ (function(module, exports) {
4673
4673
 
4674
4674
  module.exports = require("eoss/lib/toolbar");
@@ -4776,7 +4776,7 @@ module.exports = require("fetch-request-source");
4776
4776
 
4777
4777
  /***/ }),
4778
4778
 
4779
- /***/ 231:
4779
+ /***/ 238:
4780
4780
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4781
4781
 
4782
4782
  "use strict";
@@ -4877,15 +4877,15 @@ render._withStripped = true
4877
4877
  // CONCATENATED MODULE: ./packages/data-table/src/data-table.vue?vue&type=template&id=2fb4ad0f&
4878
4878
 
4879
4879
  // EXTERNAL MODULE: external "eoss/lib/table"
4880
- var table_ = __webpack_require__(92);
4880
+ var table_ = __webpack_require__(94);
4881
4881
  var table_default = /*#__PURE__*/__webpack_require__.n(table_);
4882
4882
 
4883
4883
  // EXTERNAL MODULE: external "eoss/lib/toolbar"
4884
- var toolbar_ = __webpack_require__(134);
4884
+ var toolbar_ = __webpack_require__(138);
4885
4885
  var toolbar_default = /*#__PURE__*/__webpack_require__.n(toolbar_);
4886
4886
 
4887
4887
  // EXTERNAL MODULE: external "eoss/lib/pagination"
4888
- var pagination_ = __webpack_require__(85);
4888
+ var pagination_ = __webpack_require__(87);
4889
4889
  var pagination_default = /*#__PURE__*/__webpack_require__.n(pagination_);
4890
4890
 
4891
4891
  // EXTERNAL MODULE: ./src/utils/ajax.js
@@ -6221,759 +6221,736 @@ var changeInTime = '/baseIssueRules/changeInTime';
6221
6221
  /* unused harmony export getSecond */
6222
6222
  /* unused harmony export getWeekday */
6223
6223
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
6224
- /* Modified from https://github.com/taylorhakes/fecha
6225
- *
6226
- * The MIT License (MIT)
6227
- *
6228
- * Copyright (c) 2015 Taylor Hakes
6229
- *
6230
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6231
- * of this software and associated documentation files (the "Software"), to deal
6232
- * in the Software without restriction, including without limitation the rights
6233
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6234
- * copies of the Software, and to permit persons to whom the Software is
6235
- * furnished to do so, subject to the following conditions:
6236
- *
6237
- * The above copyright notice and this permission notice shall be included in all
6238
- * copies or substantial portions of the Software.
6239
- *
6240
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6241
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6242
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6243
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6244
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6245
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6246
- * SOFTWARE.
6247
- */
6248
-
6249
- /*eslint-disable*/
6250
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
6251
-
6252
-
6224
+
6225
+
6253
6226
  /**
6254
6227
  * Parse or format dates
6255
6228
  * @class fecha
6256
- */
6257
- const fecha = {};
6258
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6259
- const twoDigits = '\\d\\d?';
6260
- const threeDigits = '\\d{3}';
6261
- const fourDigits = '\\d{4}';
6262
- const word = '[^\\s]+';
6263
- const literal = /\[([^]*?)\]/gm;
6264
- const noop = function () {};
6265
-
6266
- function regexEscape(str) {
6267
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6268
- }
6269
-
6270
- function shorten(arr, sLen) {
6271
- const newArr = [];
6272
- for (let i = 0, len = arr.length; i < len; i++) {
6273
- newArr.push(arr[i].substr(0, sLen));
6274
- }
6275
- return newArr;
6276
- }
6277
-
6278
- function monthUpdate() {
6279
- return function (d, v) {
6280
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6281
- if (~index) {
6282
- d.month = index;
6283
- }
6284
- };
6285
- }
6286
-
6287
- function pad(val, len) {
6288
- val = String(val);
6289
- len = len || 2;
6290
- while (val.length < len) {
6291
- val = '0' + val;
6292
- }
6293
- return val;
6294
- }
6295
-
6296
- // 直接使用中文日期名称常量
6297
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6298
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6299
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6300
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6301
- const amPm = ['上午', '下午'];
6302
- const DoFn = function DoFn(D) {
6303
- return D + '日';
6304
- };
6305
-
6306
- const formatFlags = {
6307
- D: function(dateObj) {
6308
- return dateObj.getDay();
6309
- },
6310
- DD: function(dateObj) {
6311
- return pad(dateObj.getDay());
6312
- },
6313
- Do: function(dateObj) {
6314
- return DoFn(dateObj.getDate());
6315
- },
6316
- d: function(dateObj) {
6317
- return dateObj.getDate();
6318
- },
6319
- dd: function(dateObj) {
6320
- return pad(dateObj.getDate());
6321
- },
6322
- ddd: function(dateObj) {
6323
- return dayNamesShort[dateObj.getDay()];
6324
- },
6325
- dddd: function(dateObj) {
6326
- return dayNames[dateObj.getDay()];
6327
- },
6328
- M: function(dateObj) {
6329
- return dateObj.getMonth() + 1;
6330
- },
6331
- MM: function(dateObj) {
6332
- return pad(dateObj.getMonth() + 1);
6333
- },
6334
- MMM: function(dateObj) {
6335
- return monthNamesShort[dateObj.getMonth()];
6336
- },
6337
- MMMM: function(dateObj) {
6338
- return monthNames[dateObj.getMonth()];
6339
- },
6340
- yy: function(dateObj) {
6341
- return pad(String(dateObj.getFullYear()), 4).substr(2);
6342
- },
6343
- yyyy: function(dateObj) {
6344
- return pad(dateObj.getFullYear(), 4);
6345
- },
6346
- h: function(dateObj) {
6347
- return dateObj.getHours() % 12 || 12;
6348
- },
6349
- hh: function(dateObj) {
6350
- return pad(dateObj.getHours() % 12 || 12);
6351
- },
6352
- H: function(dateObj) {
6353
- return dateObj.getHours();
6354
- },
6355
- HH: function(dateObj) {
6356
- return pad(dateObj.getHours());
6357
- },
6358
- m: function(dateObj) {
6359
- return dateObj.getMinutes();
6360
- },
6361
- mm: function(dateObj) {
6362
- return pad(dateObj.getMinutes());
6363
- },
6364
- s: function(dateObj) {
6365
- return dateObj.getSeconds();
6366
- },
6367
- ss: function(dateObj) {
6368
- return pad(dateObj.getSeconds());
6369
- },
6370
- S: function(dateObj) {
6371
- return Math.round(dateObj.getMilliseconds() / 100);
6372
- },
6373
- SS: function(dateObj) {
6374
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6375
- },
6376
- SSS: function(dateObj) {
6377
- return pad(dateObj.getMilliseconds(), 3);
6378
- },
6379
- a: function(dateObj) {
6380
- return dateObj.getHours() < 12 ? '上午' : '下午';
6381
- },
6382
- A: function(dateObj) {
6383
- return dateObj.getHours() < 12 ? '上午' : '下午';
6384
- },
6385
- ZZ: function(dateObj) {
6386
- const o = dateObj.getTimezoneOffset();
6387
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6388
- }
6389
- };
6390
-
6391
- const parseFlags = {
6392
- d: [twoDigits, function (d, v) {
6393
- d.day = v;
6394
- }],
6395
- Do: [twoDigits + word, function (d, v) {
6396
- d.day = parseInt(v, 10);
6397
- }],
6398
- M: [twoDigits, function (d, v) {
6399
- d.month = v - 1;
6400
- }],
6401
- yy: [twoDigits, function (d, v) {
6402
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
6403
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6404
- }],
6405
- h: [twoDigits, function (d, v) {
6406
- d.hour = v;
6407
- }],
6408
- m: [twoDigits, function (d, v) {
6409
- d.minute = v;
6410
- }],
6411
- s: [twoDigits, function (d, v) {
6412
- d.second = v;
6413
- }],
6414
- yyyy: [fourDigits, function (d, v) {
6415
- d.year = v;
6416
- }],
6417
- S: ['\\d', function (d, v) {
6418
- d.millisecond = v * 100;
6419
- }],
6420
- SS: ['\\d{2}', function (d, v) {
6421
- d.millisecond = v * 10;
6422
- }],
6423
- SSS: [threeDigits, function (d, v) {
6424
- d.millisecond = v;
6425
- }],
6426
- D: [twoDigits, noop],
6427
- ddd: [word, noop],
6428
- MMM: [word, monthUpdate('monthNamesShort')],
6429
- MMMM: [word, monthUpdate('monthNames')],
6430
- a: [word, function (d, v) {
6431
- const val = v.toLowerCase();
6432
- if (val === '上午') {
6433
- d.isPm = false;
6434
- } else if (val === '下午') {
6435
- d.isPm = true;
6436
- }
6437
- }],
6438
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6439
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
6440
-
6441
- if (parts) {
6442
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6443
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6444
- }
6445
- }]
6446
- };
6447
- parseFlags.dd = parseFlags.d;
6448
- parseFlags.dddd = parseFlags.ddd;
6449
- parseFlags.DD = parseFlags.D;
6450
- parseFlags.mm = parseFlags.m;
6451
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6452
- parseFlags.MM = parseFlags.M;
6453
- parseFlags.ss = parseFlags.s;
6454
- parseFlags.A = parseFlags.a;
6455
-
6456
-
6457
- // Some common format strings
6458
- fecha.masks = {
6459
- default: 'ddd MMM dd yyyy HH:mm:ss',
6460
- shortDate: 'M/D/yy',
6461
- mediumDate: 'MMM d, yyyy',
6462
- longDate: 'MMMM d, yyyy',
6463
- fullDate: 'dddd, MMMM d, yyyy',
6464
- shortTime: 'HH:mm',
6465
- mediumTime: 'HH:mm:ss',
6466
- longTime: 'HH:mm:ss.SSS'
6467
- };
6468
-
6229
+ */
6230
+ var fecha = {};
6231
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6232
+ var twoDigits = '\\d\\d?';
6233
+ var threeDigits = '\\d{3}';
6234
+ var fourDigits = '\\d{4}';
6235
+ var word = '[^\\s]+';
6236
+ var literal = /\[([^]*?)\]/gm;
6237
+ var noop = function noop() {};
6238
+
6239
+ function regexEscape(str) {
6240
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6241
+ }
6242
+
6243
+ function shorten(arr, sLen) {
6244
+ var newArr = [];
6245
+ for (var i = 0, len = arr.length; i < len; i++) {
6246
+ newArr.push(arr[i].substr(0, sLen));
6247
+ }
6248
+ return newArr;
6249
+ }
6250
+
6251
+ function monthUpdate() {
6252
+ return function (d, v) {
6253
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6254
+ if (~index) {
6255
+ d.month = index;
6256
+ }
6257
+ };
6258
+ }
6259
+
6260
+ function pad(val, len) {
6261
+ val = String(val);
6262
+ len = len || 2;
6263
+ while (val.length < len) {
6264
+ val = '0' + val;
6265
+ }
6266
+ return val;
6267
+ }
6268
+
6269
+ // 直接使用中文日期名称常量
6270
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6271
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6272
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6273
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6274
+ var amPm = ['上午', '下午'];
6275
+ var DoFn = function DoFn(D) {
6276
+ return D + '日';
6277
+ };
6278
+
6279
+ var formatFlags = {
6280
+ D: function D(dateObj) {
6281
+ return dateObj.getDay();
6282
+ },
6283
+ DD: function DD(dateObj) {
6284
+ return pad(dateObj.getDay());
6285
+ },
6286
+ Do: function Do(dateObj) {
6287
+ return DoFn(dateObj.getDate());
6288
+ },
6289
+ d: function d(dateObj) {
6290
+ return dateObj.getDate();
6291
+ },
6292
+ dd: function dd(dateObj) {
6293
+ return pad(dateObj.getDate());
6294
+ },
6295
+ ddd: function ddd(dateObj) {
6296
+ return dayNamesShort[dateObj.getDay()];
6297
+ },
6298
+ dddd: function dddd(dateObj) {
6299
+ return dayNames[dateObj.getDay()];
6300
+ },
6301
+ M: function M(dateObj) {
6302
+ return dateObj.getMonth() + 1;
6303
+ },
6304
+ MM: function MM(dateObj) {
6305
+ return pad(dateObj.getMonth() + 1);
6306
+ },
6307
+ MMM: function MMM(dateObj) {
6308
+ return monthNamesShort[dateObj.getMonth()];
6309
+ },
6310
+ MMMM: function MMMM(dateObj) {
6311
+ return monthNames[dateObj.getMonth()];
6312
+ },
6313
+ yy: function yy(dateObj) {
6314
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
6315
+ },
6316
+ yyyy: function yyyy(dateObj) {
6317
+ return pad(dateObj.getFullYear(), 4);
6318
+ },
6319
+ h: function h(dateObj) {
6320
+ return dateObj.getHours() % 12 || 12;
6321
+ },
6322
+ hh: function hh(dateObj) {
6323
+ return pad(dateObj.getHours() % 12 || 12);
6324
+ },
6325
+ H: function H(dateObj) {
6326
+ return dateObj.getHours();
6327
+ },
6328
+ HH: function HH(dateObj) {
6329
+ return pad(dateObj.getHours());
6330
+ },
6331
+ m: function m(dateObj) {
6332
+ return dateObj.getMinutes();
6333
+ },
6334
+ mm: function mm(dateObj) {
6335
+ return pad(dateObj.getMinutes());
6336
+ },
6337
+ s: function s(dateObj) {
6338
+ return dateObj.getSeconds();
6339
+ },
6340
+ ss: function ss(dateObj) {
6341
+ return pad(dateObj.getSeconds());
6342
+ },
6343
+ S: function S(dateObj) {
6344
+ return Math.round(dateObj.getMilliseconds() / 100);
6345
+ },
6346
+ SS: function SS(dateObj) {
6347
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6348
+ },
6349
+ SSS: function SSS(dateObj) {
6350
+ return pad(dateObj.getMilliseconds(), 3);
6351
+ },
6352
+ a: function a(dateObj) {
6353
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6354
+ },
6355
+ A: function A(dateObj) {
6356
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6357
+ },
6358
+ ZZ: function ZZ(dateObj) {
6359
+ var o = dateObj.getTimezoneOffset();
6360
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6361
+ }
6362
+ };
6363
+
6364
+ var parseFlags = {
6365
+ d: [twoDigits, function (d, v) {
6366
+ d.day = v;
6367
+ }],
6368
+ Do: [twoDigits + word, function (d, v) {
6369
+ d.day = parseInt(v, 10);
6370
+ }],
6371
+ M: [twoDigits, function (d, v) {
6372
+ d.month = v - 1;
6373
+ }],
6374
+ yy: [twoDigits, function (d, v) {
6375
+ var da = new Date(),
6376
+ cent = +('' + da.getFullYear()).substr(0, 2);
6377
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6378
+ }],
6379
+ h: [twoDigits, function (d, v) {
6380
+ d.hour = v;
6381
+ }],
6382
+ m: [twoDigits, function (d, v) {
6383
+ d.minute = v;
6384
+ }],
6385
+ s: [twoDigits, function (d, v) {
6386
+ d.second = v;
6387
+ }],
6388
+ yyyy: [fourDigits, function (d, v) {
6389
+ d.year = v;
6390
+ }],
6391
+ S: ['\\d', function (d, v) {
6392
+ d.millisecond = v * 100;
6393
+ }],
6394
+ SS: ['\\d{2}', function (d, v) {
6395
+ d.millisecond = v * 10;
6396
+ }],
6397
+ SSS: [threeDigits, function (d, v) {
6398
+ d.millisecond = v;
6399
+ }],
6400
+ D: [twoDigits, noop],
6401
+ ddd: [word, noop],
6402
+ MMM: [word, monthUpdate('monthNamesShort')],
6403
+ MMMM: [word, monthUpdate('monthNames')],
6404
+ a: [word, function (d, v) {
6405
+ var val = v.toLowerCase();
6406
+ if (val === '上午') {
6407
+ d.isPm = false;
6408
+ } else if (val === '下午') {
6409
+ d.isPm = true;
6410
+ }
6411
+ }],
6412
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6413
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
6414
+ minutes = void 0;
6415
+
6416
+ if (parts) {
6417
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6418
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6419
+ }
6420
+ }]
6421
+ };
6422
+ parseFlags.dd = parseFlags.d;
6423
+ parseFlags.dddd = parseFlags.ddd;
6424
+ parseFlags.DD = parseFlags.D;
6425
+ parseFlags.mm = parseFlags.m;
6426
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6427
+ parseFlags.MM = parseFlags.M;
6428
+ parseFlags.ss = parseFlags.s;
6429
+ parseFlags.A = parseFlags.a;
6430
+
6431
+ // Some common format strings
6432
+ fecha.masks = {
6433
+ default: 'ddd MMM dd yyyy HH:mm:ss',
6434
+ shortDate: 'M/D/yy',
6435
+ mediumDate: 'MMM d, yyyy',
6436
+ longDate: 'MMMM d, yyyy',
6437
+ fullDate: 'dddd, MMMM d, yyyy',
6438
+ shortTime: 'HH:mm',
6439
+ mediumTime: 'HH:mm:ss',
6440
+ longTime: 'HH:mm:ss.SSS'
6441
+ };
6442
+
6469
6443
  /***
6470
6444
  * Format a date
6471
6445
  * @method format
6472
6446
  * @param {Date|number} dateObj
6473
6447
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
6474
- */
6475
- fecha.format = function (dateObj, mask) {
6476
- if (typeof dateObj === 'number') {
6477
- dateObj = new Date(dateObj);
6478
- }
6479
-
6480
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6481
- throw new Error('Invalid Date in fecha.format');
6482
- }
6483
-
6484
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
6485
-
6486
- const literals = [];
6487
-
6488
- // Make literals inactive by replacing them with ??
6489
- mask = mask.replace(literal, function($0, $1) {
6490
- literals.push($1);
6491
- return '@@@';
6492
- });
6493
- // Apply formatting rules
6494
- mask = mask.replace(token, function ($0) {
6495
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6496
- });
6497
- // Inline literal values back into the formatted value
6498
- return mask.replace(/@@@/g, function() {
6499
- return literals.shift();
6500
- });
6501
- };
6502
-
6448
+ */
6449
+ fecha.format = function (dateObj, mask) {
6450
+ if (typeof dateObj === 'number') {
6451
+ dateObj = new Date(dateObj);
6452
+ }
6453
+
6454
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6455
+ throw new Error('Invalid Date in fecha.format');
6456
+ }
6457
+
6458
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
6459
+
6460
+ var literals = [];
6461
+
6462
+ // Make literals inactive by replacing them with ??
6463
+ mask = mask.replace(literal, function ($0, $1) {
6464
+ literals.push($1);
6465
+ return '@@@';
6466
+ });
6467
+ // Apply formatting rules
6468
+ mask = mask.replace(token, function ($0) {
6469
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6470
+ });
6471
+ // Inline literal values back into the formatted value
6472
+ return mask.replace(/@@@/g, function () {
6473
+ return literals.shift();
6474
+ });
6475
+ };
6476
+
6503
6477
  /**
6504
6478
  * Parse a date string into an object, changes - into /
6505
6479
  * @method parse
6506
6480
  * @param {string} dateStr Date string
6507
6481
  * @param {string} format Date parse format
6508
6482
  * @returns {Date|boolean}
6509
- */
6510
- fecha.parse = function (dateStr, format) {
6511
- if (typeof format !== 'string') {
6512
- throw new Error('Invalid format in fecha.parse');
6513
- }
6514
-
6515
- format = fecha.masks[format] || format;
6516
-
6517
- // Avoid regular expression denial of service, fail early for really long strings
6518
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6519
- if (dateStr.length > 1000) {
6520
- return null;
6521
- }
6522
-
6523
- const dateInfo = {};
6524
- const parseInfo = [];
6525
- const literals = [];
6526
- format = format.replace(literal, function($0, $1) {
6527
- literals.push($1);
6528
- return '@@@';
6529
- });
6530
- let newFormat = regexEscape(format).replace(token, function ($0) {
6531
- if (parseFlags[$0]) {
6532
- const info = parseFlags[$0];
6533
- parseInfo.push(info[1]);
6534
- return '(' + info[0] + ')';
6535
- }
6536
-
6537
- return $0;
6538
- });
6539
- newFormat = newFormat.replace(/@@@/g, function() {
6540
- return literals.shift();
6541
- });
6542
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
6543
- if (!matches) {
6544
- return null;
6545
- }
6546
-
6547
- for (let i = 1; i < matches.length; i++) {
6548
- parseInfo[i - 1](dateInfo, matches[i]);
6549
- }
6550
-
6551
- const today = new Date();
6552
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6553
- dateInfo.hour = +dateInfo.hour + 12;
6554
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6555
- dateInfo.hour = 0;
6556
- }
6557
-
6558
- let date;
6559
- if (dateInfo.timezoneOffset != null) {
6560
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6561
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6562
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
6563
- } else {
6564
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6565
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
6566
- }
6567
- return date;
6568
- };
6569
-
6570
- // 导出fecha对象
6571
-
6572
-
6573
- // 以下是从date-util.js合并的函数
6574
- const newArray = function(start, end) {
6575
- let result = [];
6576
- for (let i = start; i <= end; i++) {
6577
- result.push(i);
6578
- }
6579
- return result;
6580
- };
6581
-
6582
- const getSettings = () => {
6583
- return {
6584
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6585
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6586
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6587
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6588
- amPm: ['上午', '下午']
6589
- };
6590
- };
6591
-
6592
- const toDate = function(date) {
6593
- return isDate(date) ? new Date(date) : null;
6594
- };
6595
-
6596
- const isDate = function(date) {
6597
- if (date === null || date === undefined) return false;
6598
- if (isNaN(new Date(date).getTime())) return false;
6599
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6600
- return true;
6601
- };
6602
-
6603
- const isDateObject = function(val) {
6604
- return val instanceof Date;
6605
- };
6606
-
6607
- const formatDate = function (date, format = 'yyyy-MM-dd') {
6608
- // 处理多种输入类型
6609
- if (!date) return '';
6610
-
6611
- // 如果是时间戳,转成日期对象
6612
- if (typeof date === 'number') {
6613
- date = new Date(date);
6614
- }
6615
- // 如果是字符串,转成日期对象
6616
- if (typeof date === 'string') {
6617
- date = new Date(date);
6618
- }
6619
-
6620
- // 调用toDate进一步验证和转换
6621
- date = toDate(date);
6622
- if (!date) return '';
6623
-
6624
- // 兼容大写和小写的格式标记
6625
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6626
- const lowercaseFormat = format
6627
- .replace(/YYYY/g, 'yyyy')
6628
- .replace(/D/g, 'd')
6629
-
6630
- // 使用fecha库进行格式化,支持中文配置
6631
- const str = fecha.format(date, lowercaseFormat, getSettings());
6632
- return str;
6633
- };
6634
-
6635
- const parseDate = function(string, format) {
6636
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6637
- };
6638
-
6639
- const getDayCountOfMonth = function(year, month) {
6640
- if (month === 3 || month === 5 || month === 8 || month === 10) {
6641
- return 30;
6642
- }
6643
-
6644
- if (month === 1) {
6645
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6646
- return 29;
6647
- } else {
6648
- return 28;
6649
- }
6650
- }
6651
-
6652
- return 31;
6653
- };
6654
-
6655
- const getDayCountOfYear = function(year) {
6656
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
6657
- return isLeapYear ? 366 : 365;
6658
- };
6659
-
6660
- const getFirstDayOfMonth = function(date) {
6661
- const temp = new Date(date.getTime());
6662
- temp.setDate(1);
6663
- return temp.getDay();
6664
- };
6665
-
6666
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6667
- // {prev, next} Date should work for Daylight Saving Time
6668
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6669
- const prevDate = function(date, amount = 1) {
6670
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6671
- };
6672
-
6673
- const nextDate = function(date, amount = 1) {
6674
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6675
- };
6676
-
6677
- const getStartDateOfMonth = function(year, month) {
6678
- const result = new Date(year, month, 1);
6679
- const day = result.getDay();
6680
-
6681
- if (day === 0) {
6682
- return prevDate(result, 7);
6683
- } else {
6684
- return prevDate(result, day);
6685
- }
6686
- };
6687
-
6688
- const getWeekNumber = function(date) {
6689
- // 支持多种输入类型
6690
- if (!date||!isDate(date)) {
6691
- date = new Date();
6692
- }
6693
- if (typeof date === 'string') {
6694
- date = new Date(date);
6695
- }
6696
-
6697
- // 验证日期有效性
6698
- if (!isDate(date)) return null;
6699
-
6700
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6701
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6702
- // 将星期日的星期数设为7
6703
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6704
- // 获取当年的第一天
6705
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6706
- // 计算到最近的星期四的完整周数
6707
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
6708
- // 返回周数
6709
- return weekNo;
6710
- };
6711
-
6712
- const getRangeHours = function(ranges) {
6713
- const hours = [];
6714
- let disabledHours = [];
6715
-
6716
- (ranges || []).forEach(range => {
6717
- const value = range.map(date => date.getHours());
6718
-
6719
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6720
- });
6721
-
6722
- if (disabledHours.length) {
6723
- for (let i = 0; i < 24; i++) {
6724
- hours[i] = disabledHours.indexOf(i) === -1;
6725
- }
6726
- } else {
6727
- for (let i = 0; i < 24; i++) {
6728
- hours[i] = false;
6729
- }
6730
- }
6731
-
6732
- return hours;
6733
- };
6734
-
6735
- const getPrevMonthLastDays = (date, amount) => {
6736
- if (amount <= 0) return [];
6737
- const temp = new Date(date.getTime());
6738
- temp.setDate(0);
6739
- const lastDay = temp.getDate();
6740
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
6741
- };
6742
-
6743
- const getMonthDays = (date) => {
6744
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6745
- const days = temp.getDate();
6746
- return range(days).map((_, index) => index + 1);
6747
- };
6748
-
6749
- function setRangeData(arr, start, end, value) {
6750
- for (let i = start; i < end; i++) {
6751
- arr[i] = value;
6752
- }
6753
- }
6754
-
6755
- const getRangeMinutes = function(ranges, hour) {
6756
- const minutes = new Array(60);
6757
-
6758
- if (ranges.length > 0) {
6759
- ranges.forEach(range => {
6760
- const start = range[0];
6761
- const end = range[1];
6762
- const startHour = start.getHours();
6763
- const startMinute = start.getMinutes();
6764
- const endHour = end.getHours();
6765
- const endMinute = end.getMinutes();
6766
- if (startHour === hour && endHour !== hour) {
6767
- setRangeData(minutes, startMinute, 60, true);
6768
- } else if (startHour === hour && endHour === hour) {
6769
- setRangeData(minutes, startMinute, endMinute + 1, true);
6770
- } else if (startHour !== hour && endHour === hour) {
6771
- setRangeData(minutes, 0, endMinute + 1, true);
6772
- } else if (startHour < hour && endHour > hour) {
6773
- setRangeData(minutes, 0, 60, true);
6774
- }
6775
- });
6776
- } else {
6777
- setRangeData(minutes, 0, 60, true);
6778
- }
6779
- return minutes;
6780
- };
6781
-
6782
- const range = function(n) {
6783
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6784
- return Array.apply(null, {length: n}).map((_, n) => n);
6785
- };
6786
-
6787
- const modifyDate = function(date, y, m, d) {
6788
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6789
- };
6790
-
6791
- const modifyTime = function(date, h, m, s) {
6792
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6793
- };
6794
-
6795
- const modifyWithTimeString = (date, time) => {
6796
- if (date == null || !time) {
6797
- return date;
6798
- }
6799
- time = parseDate(time, 'HH:mm:ss');
6800
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6801
- };
6802
-
6803
- const clearTime = function(date) {
6804
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6805
- };
6806
-
6807
- const clearMilliseconds = function(date) {
6808
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6809
- };
6810
-
6811
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
6812
- // TODO: refactory a more elegant solution
6813
- if (ranges.length === 0) return date;
6814
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
6815
- const ndate = normalizeDate(date);
6816
- const nranges = ranges.map(range => range.map(normalizeDate));
6817
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
6818
-
6819
- let minDate = nranges[0][0];
6820
- let maxDate = nranges[0][0];
6821
-
6822
- nranges.forEach(nrange => {
6823
- minDate = new Date(Math.min(nrange[0], minDate));
6824
- maxDate = new Date(Math.max(nrange[1], minDate));
6825
- });
6826
-
6827
- const ret = ndate < minDate ? minDate : maxDate;
6828
- // preserve Year/Month/Date
6829
- return modifyDate(
6830
- ret,
6831
- date.getFullYear(),
6832
- date.getMonth(),
6833
- date.getDate()
6834
- );
6835
- };
6836
-
6837
- const timeWithinRange = function(date, selectableRange, format) {
6838
- const limitedDate = limitTimeRange(date, selectableRange, format);
6839
- return limitedDate.getTime() === date.getTime();
6840
- };
6841
-
6842
- const changeYearMonthAndClampDate = function(date, year, month) {
6843
- // clamp date to the number of days in `year`, `month`
6844
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
6845
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6846
- return modifyDate(date, year, month, monthDate);
6847
- };
6848
-
6849
- const prevMonth = function(date) {
6850
- const year = date.getFullYear();
6851
- const month = date.getMonth();
6852
- return month === 0
6853
- ? changeYearMonthAndClampDate(date, year - 1, 11)
6854
- : changeYearMonthAndClampDate(date, year, month - 1);
6855
- };
6856
-
6857
- const nextMonth = function(date) {
6858
- const year = date.getFullYear();
6859
- const month = date.getMonth();
6860
- return month === 11
6861
- ? changeYearMonthAndClampDate(date, year + 1, 0)
6862
- : changeYearMonthAndClampDate(date, year, month + 1);
6863
- };
6864
-
6865
- const prevYear = function(date, amount = 1) {
6866
- const year = date.getFullYear();
6867
- const month = date.getMonth();
6868
- return changeYearMonthAndClampDate(date, year - amount, month);
6869
- };
6870
-
6871
- const nextYear = function(date, amount = 1) {
6872
- const year = date.getFullYear();
6873
- const month = date.getMonth();
6874
- return changeYearMonthAndClampDate(date, year + amount, month);
6875
- };
6876
-
6877
- const extractDateFormat = function(format) {
6878
- return format
6879
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
6880
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
6881
- .trim();
6882
- };
6883
-
6884
- const extractTimeFormat = function(format) {
6885
- return format
6886
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
6887
- .trim();
6888
- };
6889
-
6890
- const validateRangeInOneMonth = function(start, end) {
6891
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
6892
- };
6893
-
6483
+ */
6484
+ fecha.parse = function (dateStr, format) {
6485
+ if (typeof format !== 'string') {
6486
+ throw new Error('Invalid format in fecha.parse');
6487
+ }
6488
+
6489
+ format = fecha.masks[format] || format;
6490
+
6491
+ // Avoid regular expression denial of service, fail early for really long strings
6492
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6493
+ if (dateStr.length > 1000) {
6494
+ return null;
6495
+ }
6496
+
6497
+ var dateInfo = {};
6498
+ var parseInfo = [];
6499
+ var literals = [];
6500
+ format = format.replace(literal, function ($0, $1) {
6501
+ literals.push($1);
6502
+ return '@@@';
6503
+ });
6504
+ var newFormat = regexEscape(format).replace(token, function ($0) {
6505
+ if (parseFlags[$0]) {
6506
+ var info = parseFlags[$0];
6507
+ parseInfo.push(info[1]);
6508
+ return '(' + info[0] + ')';
6509
+ }
6510
+
6511
+ return $0;
6512
+ });
6513
+ newFormat = newFormat.replace(/@@@/g, function () {
6514
+ return literals.shift();
6515
+ });
6516
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
6517
+ if (!matches) {
6518
+ return null;
6519
+ }
6520
+
6521
+ for (var i = 1; i < matches.length; i++) {
6522
+ parseInfo[i - 1](dateInfo, matches[i]);
6523
+ }
6524
+
6525
+ var today = new Date();
6526
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6527
+ dateInfo.hour = +dateInfo.hour + 12;
6528
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6529
+ dateInfo.hour = 0;
6530
+ }
6531
+
6532
+ var date = void 0;
6533
+ if (dateInfo.timezoneOffset != null) {
6534
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6535
+ 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));
6536
+ } else {
6537
+ 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);
6538
+ }
6539
+ return date;
6540
+ };
6541
+
6542
+ // 导出fecha对象
6543
+
6544
+
6545
+ // 以下是从date-util.js合并的函数
6546
+ var newArray = function newArray(start, end) {
6547
+ var result = [];
6548
+ for (var i = start; i <= end; i++) {
6549
+ result.push(i);
6550
+ }
6551
+ return result;
6552
+ };
6553
+
6554
+ var getSettings = function getSettings() {
6555
+ return {
6556
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6557
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6558
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6559
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6560
+ amPm: ['上午', '下午']
6561
+ };
6562
+ };
6563
+
6564
+ var toDate = function toDate(date) {
6565
+ return isDate(date) ? new Date(date) : null;
6566
+ };
6567
+
6568
+ var isDate = function isDate(date) {
6569
+ if (date === null || date === undefined) return false;
6570
+ if (isNaN(new Date(date).getTime())) return false;
6571
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6572
+ return true;
6573
+ };
6574
+
6575
+ var isDateObject = function isDateObject(val) {
6576
+ return val instanceof Date;
6577
+ };
6578
+
6579
+ var formatDate = function formatDate(date) {
6580
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
6581
+
6582
+ // 处理多种输入类型
6583
+ if (!date) return '';
6584
+
6585
+ // 如果是时间戳,转成日期对象
6586
+ if (typeof date === 'number') {
6587
+ date = new Date(date);
6588
+ }
6589
+ // 如果是字符串,转成日期对象
6590
+ if (typeof date === 'string') {
6591
+ date = new Date(date);
6592
+ }
6593
+
6594
+ // 调用toDate进一步验证和转换
6595
+ date = toDate(date);
6596
+ if (!date) return '';
6597
+
6598
+ // 兼容大写和小写的格式标记
6599
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6600
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
6601
+
6602
+ // 使用fecha库进行格式化,支持中文配置
6603
+ var str = fecha.format(date, lowercaseFormat, getSettings());
6604
+ return str;
6605
+ };
6606
+
6607
+ var parseDate = function parseDate(string, format) {
6608
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6609
+ };
6610
+
6611
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
6612
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
6613
+ return 30;
6614
+ }
6615
+
6616
+ if (month === 1) {
6617
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6618
+ return 29;
6619
+ } else {
6620
+ return 28;
6621
+ }
6622
+ }
6623
+
6624
+ return 31;
6625
+ };
6626
+
6627
+ var getDayCountOfYear = function getDayCountOfYear(year) {
6628
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
6629
+ return isLeapYear ? 366 : 365;
6630
+ };
6631
+
6632
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
6633
+ var temp = new Date(date.getTime());
6634
+ temp.setDate(1);
6635
+ return temp.getDay();
6636
+ };
6637
+
6638
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6639
+ // {prev, next} Date should work for Daylight Saving Time
6640
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6641
+ var prevDate = function prevDate(date) {
6642
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6643
+
6644
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6645
+ };
6646
+
6647
+ var nextDate = function nextDate(date) {
6648
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6649
+
6650
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6651
+ };
6652
+
6653
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
6654
+ var result = new Date(year, month, 1);
6655
+ var day = result.getDay();
6656
+
6657
+ if (day === 0) {
6658
+ return prevDate(result, 7);
6659
+ } else {
6660
+ return prevDate(result, day);
6661
+ }
6662
+ };
6663
+
6664
+ var getWeekNumber = function getWeekNumber(date) {
6665
+ // 支持多种输入类型
6666
+ if (!date || !isDate(date)) {
6667
+ date = new Date();
6668
+ }
6669
+ if (typeof date === 'string') {
6670
+ date = new Date(date);
6671
+ }
6672
+
6673
+ // 验证日期有效性
6674
+ if (!isDate(date)) return null;
6675
+
6676
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6677
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6678
+ // 将星期日的星期数设为7
6679
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6680
+ // 获取当年的第一天
6681
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6682
+ // 计算到最近的星期四的完整周数
6683
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
6684
+ // 返回周数
6685
+ return weekNo;
6686
+ };
6687
+
6688
+ var getRangeHours = function getRangeHours(ranges) {
6689
+ var hours = [];
6690
+ var disabledHours = [];
6691
+
6692
+ (ranges || []).forEach(function (range) {
6693
+ var value = range.map(function (date) {
6694
+ return date.getHours();
6695
+ });
6696
+
6697
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6698
+ });
6699
+
6700
+ if (disabledHours.length) {
6701
+ for (var i = 0; i < 24; i++) {
6702
+ hours[i] = disabledHours.indexOf(i) === -1;
6703
+ }
6704
+ } else {
6705
+ for (var _i = 0; _i < 24; _i++) {
6706
+ hours[_i] = false;
6707
+ }
6708
+ }
6709
+
6710
+ return hours;
6711
+ };
6712
+
6713
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
6714
+ if (amount <= 0) return [];
6715
+ var temp = new Date(date.getTime());
6716
+ temp.setDate(0);
6717
+ var lastDay = temp.getDate();
6718
+ return range(amount).map(function (_, index) {
6719
+ return lastDay - (amount - index - 1);
6720
+ });
6721
+ };
6722
+
6723
+ var getMonthDays = function getMonthDays(date) {
6724
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6725
+ var days = temp.getDate();
6726
+ return range(days).map(function (_, index) {
6727
+ return index + 1;
6728
+ });
6729
+ };
6730
+
6731
+ function setRangeData(arr, start, end, value) {
6732
+ for (var i = start; i < end; i++) {
6733
+ arr[i] = value;
6734
+ }
6735
+ }
6736
+
6737
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
6738
+ var minutes = new Array(60);
6739
+
6740
+ if (ranges.length > 0) {
6741
+ ranges.forEach(function (range) {
6742
+ var start = range[0];
6743
+ var end = range[1];
6744
+ var startHour = start.getHours();
6745
+ var startMinute = start.getMinutes();
6746
+ var endHour = end.getHours();
6747
+ var endMinute = end.getMinutes();
6748
+ if (startHour === hour && endHour !== hour) {
6749
+ setRangeData(minutes, startMinute, 60, true);
6750
+ } else if (startHour === hour && endHour === hour) {
6751
+ setRangeData(minutes, startMinute, endMinute + 1, true);
6752
+ } else if (startHour !== hour && endHour === hour) {
6753
+ setRangeData(minutes, 0, endMinute + 1, true);
6754
+ } else if (startHour < hour && endHour > hour) {
6755
+ setRangeData(minutes, 0, 60, true);
6756
+ }
6757
+ });
6758
+ } else {
6759
+ setRangeData(minutes, 0, 60, true);
6760
+ }
6761
+ return minutes;
6762
+ };
6763
+
6764
+ var range = function range(n) {
6765
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6766
+ return Array.apply(null, { length: n }).map(function (_, n) {
6767
+ return n;
6768
+ });
6769
+ };
6770
+
6771
+ var modifyDate = function modifyDate(date, y, m, d) {
6772
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6773
+ };
6774
+
6775
+ var modifyTime = function modifyTime(date, h, m, s) {
6776
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6777
+ };
6778
+
6779
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
6780
+ if (date == null || !time) {
6781
+ return date;
6782
+ }
6783
+ time = parseDate(time, 'HH:mm:ss');
6784
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6785
+ };
6786
+
6787
+ var clearTime = function clearTime(date) {
6788
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6789
+ };
6790
+
6791
+ var clearMilliseconds = function clearMilliseconds(date) {
6792
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6793
+ };
6794
+
6795
+ var limitTimeRange = function limitTimeRange(date, ranges) {
6796
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
6797
+
6798
+ // TODO: refactory a more elegant solution
6799
+ if (ranges.length === 0) return date;
6800
+ var normalizeDate = function normalizeDate(date) {
6801
+ return fecha.parse(fecha.format(date, format), format);
6802
+ };
6803
+ var ndate = normalizeDate(date);
6804
+ var nranges = ranges.map(function (range) {
6805
+ return range.map(normalizeDate);
6806
+ });
6807
+ if (nranges.some(function (nrange) {
6808
+ return ndate >= nrange[0] && ndate <= nrange[1];
6809
+ })) return date;
6810
+
6811
+ var minDate = nranges[0][0];
6812
+ var maxDate = nranges[0][0];
6813
+
6814
+ nranges.forEach(function (nrange) {
6815
+ minDate = new Date(Math.min(nrange[0], minDate));
6816
+ maxDate = new Date(Math.max(nrange[1], minDate));
6817
+ });
6818
+
6819
+ var ret = ndate < minDate ? minDate : maxDate;
6820
+ // preserve Year/Month/Date
6821
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
6822
+ };
6823
+
6824
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
6825
+ var limitedDate = limitTimeRange(date, selectableRange, format);
6826
+ return limitedDate.getTime() === date.getTime();
6827
+ };
6828
+
6829
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
6830
+ // clamp date to the number of days in `year`, `month`
6831
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
6832
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6833
+ return modifyDate(date, year, month, monthDate);
6834
+ };
6835
+
6836
+ var prevMonth = function prevMonth(date) {
6837
+ var year = date.getFullYear();
6838
+ var month = date.getMonth();
6839
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
6840
+ };
6841
+
6842
+ var nextMonth = function nextMonth(date) {
6843
+ var year = date.getFullYear();
6844
+ var month = date.getMonth();
6845
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
6846
+ };
6847
+
6848
+ var prevYear = function prevYear(date) {
6849
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6850
+
6851
+ var year = date.getFullYear();
6852
+ var month = date.getMonth();
6853
+ return changeYearMonthAndClampDate(date, year - amount, month);
6854
+ };
6855
+
6856
+ var nextYear = function nextYear(date) {
6857
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6858
+
6859
+ var year = date.getFullYear();
6860
+ var month = date.getMonth();
6861
+ return changeYearMonthAndClampDate(date, year + amount, month);
6862
+ };
6863
+
6864
+ var extractDateFormat = function extractDateFormat(format) {
6865
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
6866
+ };
6867
+
6868
+ var extractTimeFormat = function extractTimeFormat(format) {
6869
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
6870
+ };
6871
+
6872
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
6873
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
6874
+ };
6875
+
6894
6876
  /**
6895
6877
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
6896
6878
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
6897
6879
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
6898
6880
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
6899
6881
  * @returns {number} 工作日数量
6900
- */
6901
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
6902
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6903
- throw new Error(
6904
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
6905
- );
6906
- }
6907
-
6908
- const startDateObj = new Date(start_date);
6909
- const endDateObj = new Date(end_date);
6910
-
6911
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6912
- throw new Error(
6913
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
6914
- );
6915
- }
6916
-
6917
- if (startDateObj > endDateObj) {
6918
- throw new Error('Start date should be earlier than or equal to end date.');
6919
- }
6920
-
6921
- let workdays = 0;
6922
-
6923
- // Iterate through each day in the date range
6924
- for (
6925
- let currentDate = new Date(startDateObj);
6926
- currentDate <= endDateObj;
6927
- currentDate.setDate(currentDate.getDate() + 1)
6928
- ) {
6929
- // Check if the current day is a weekend (Saturday or Sunday)
6930
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6931
-
6932
- // Check if the current day is a holiday
6933
- const isHoliday = holidays.some((holiday) => {
6934
- const holidayDate = new Date(holiday);
6935
- return currentDate.toDateString() === holidayDate.toDateString();
6936
- });
6937
-
6938
- // If it's a workday (not a weekend or holiday), increment the workdays count
6939
- if (!isWeekend && !isHoliday) {
6940
- workdays++;
6941
- }
6942
- }
6943
-
6944
- return workdays;
6945
- };
6946
-
6882
+ */
6883
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
6884
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6885
+
6886
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6887
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6888
+ }
6889
+
6890
+ var startDateObj = new Date(start_date);
6891
+ var endDateObj = new Date(end_date);
6892
+
6893
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6894
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6895
+ }
6896
+
6897
+ if (startDateObj > endDateObj) {
6898
+ throw new Error('Start date should be earlier than or equal to end date.');
6899
+ }
6900
+
6901
+ var workdays = 0;
6902
+
6903
+ // Iterate through each day in the date range
6904
+
6905
+ var _loop = function _loop(currentDate) {
6906
+ // Check if the current day is a weekend (Saturday or Sunday)
6907
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6908
+
6909
+ // Check if the current day is a holiday
6910
+ var isHoliday = holidays.some(function (holiday) {
6911
+ var holidayDate = new Date(holiday);
6912
+ return currentDate.toDateString() === holidayDate.toDateString();
6913
+ });
6914
+
6915
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6916
+ if (!isWeekend && !isHoliday) {
6917
+ workdays++;
6918
+ }
6919
+ };
6920
+
6921
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6922
+ _loop(currentDate);
6923
+ }
6924
+
6925
+ return workdays;
6926
+ };
6927
+
6947
6928
  /**
6948
6929
  * 日期加减天数
6949
6930
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6950
6931
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6951
6932
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6952
- */
6953
- const dateAddDays = function (start_date, days) {
6954
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6955
- throw new Error(
6956
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6957
- );
6958
- }
6959
-
6960
- const startDateObj = new Date(start_date);
6961
- if (isNaN(startDateObj.getTime())) {
6962
- throw new Error(
6963
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6964
- );
6965
- }
6966
-
6967
- const resultDateObj = new Date(startDateObj);
6968
- resultDateObj.setDate(resultDateObj.getDate() + days);
6969
-
6970
- const resultYear = resultDateObj.getFullYear();
6971
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6972
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6973
-
6974
- return `${resultYear}-${resultMonth}-${resultDay}`;
6975
- };
6976
-
6933
+ */
6934
+ var dateAddDays = function dateAddDays(start_date, days) {
6935
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6936
+ 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.");
6937
+ }
6938
+
6939
+ var startDateObj = new Date(start_date);
6940
+ if (isNaN(startDateObj.getTime())) {
6941
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6942
+ }
6943
+
6944
+ var resultDateObj = new Date(startDateObj);
6945
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6946
+
6947
+ var resultYear = resultDateObj.getFullYear();
6948
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6949
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6950
+
6951
+ return resultYear + '-' + resultMonth + '-' + resultDay;
6952
+ };
6953
+
6977
6954
  /**
6978
6955
  * 计算两个日期之间的差值
6979
6956
  * @date 2023年12月14日
@@ -6981,182 +6958,180 @@ const dateAddDays = function (start_date, days) {
6981
6958
  * @param {String} end_date - 结束日期字符串
6982
6959
  * @param {String} unit - 单位:year/month/day
6983
6960
  * @returns {Number} 差值
6984
- */
6985
- const dateDiff = function (start_date, end_date, unit = 'day') {
6986
- // Assuming date strings are in "YYYY-MM-DD" format
6987
- var startDate = new Date(start_date);
6988
- var endDate = new Date(end_date);
6989
-
6990
- // If the date is invalid, return 0
6991
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6992
- return 0;
6993
- }
6994
-
6995
- if (unit === 'year') {
6996
- return endDate.getFullYear() - startDate.getFullYear();
6997
- } else if (unit === 'month') {
6998
- return (
6999
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
7000
- (endDate.getMonth() - startDate.getMonth())
7001
- );
7002
- } else {
7003
- // Default to day
7004
- var timeDifference = endDate - startDate;
7005
- // Calculate days (86400000 milliseconds per day)
7006
- return Math.floor(timeDifference / 86400000);
7007
- }
7008
- };
7009
-
6961
+ */
6962
+ var dateDiff = function dateDiff(start_date, end_date) {
6963
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6964
+
6965
+ // Assuming date strings are in "YYYY-MM-DD" format
6966
+ var startDate = new Date(start_date);
6967
+ var endDate = new Date(end_date);
6968
+
6969
+ // If the date is invalid, return 0
6970
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6971
+ return 0;
6972
+ }
6973
+
6974
+ if (unit === 'year') {
6975
+ return endDate.getFullYear() - startDate.getFullYear();
6976
+ } else if (unit === 'month') {
6977
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
6978
+ } else {
6979
+ // Default to day
6980
+ var timeDifference = endDate - startDate;
6981
+ // Calculate days (86400000 milliseconds per day)
6982
+ return Math.floor(timeDifference / 86400000);
6983
+ }
6984
+ };
6985
+
7010
6986
  /**
7011
6987
  * 获取月份中的日期
7012
6988
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
7013
6989
  * @returns {number} 月份中的日期(1-31)
7014
- */
7015
- const dayOfMonth = function (date) {
7016
- if (typeof date !== 'string') {
7017
- throw new Error(
7018
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
7019
- );
7020
- }
7021
-
7022
- const dateObj = new Date(date);
7023
- if (isNaN(dateObj.getTime())) {
7024
- throw new Error(
7025
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
7026
- );
7027
- }
7028
-
7029
- return dateObj.getDate();
7030
- };
7031
-
6990
+ */
6991
+ var dayOfMonth = function dayOfMonth(date) {
6992
+ if (typeof date !== 'string') {
6993
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6994
+ }
6995
+
6996
+ var dateObj = new Date(date);
6997
+ if (isNaN(dateObj.getTime())) {
6998
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6999
+ }
7000
+
7001
+ return dateObj.getDate();
7002
+ };
7003
+
7032
7004
  /**
7033
7005
  * 获取当前日期
7034
7006
  * @date 2022年5月7日
7035
7007
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
7036
7008
  * @returns {string} 当前日期的格式化字符串
7037
- */
7038
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
7039
- return formatDate(new Date(), format);
7040
- };
7041
-
7009
+ */
7010
+ var getCurrentDate = function getCurrentDate() {
7011
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
7012
+
7013
+ return formatDate(new Date(), format);
7014
+ };
7015
+
7042
7016
  /**
7043
7017
  * 获取当前日期时间
7044
7018
  * @date 2022年5月7日
7045
7019
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
7046
7020
  * @returns {string} 当前日期时间的格式化字符串
7047
- */
7048
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
7049
- return formatDate(new Date(), format);
7050
- };
7051
-
7021
+ */
7022
+ var getCurrentDateTime = function getCurrentDateTime() {
7023
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
7024
+
7025
+ return formatDate(new Date(), format);
7026
+ };
7027
+
7052
7028
  /**
7053
7029
  * 获取小时
7054
7030
  * @date 2022年5月7日
7055
7031
  * @param {Date|string} [date] - 日期对象或日期字符串
7056
7032
  * @returns {number} 小时数(0-23)
7057
- */
7058
- const getHour = function (date) {
7059
- if (!date) {
7060
- return new Date().getHours();
7061
- }
7062
- if (typeof date === 'string') {
7063
- date = new Date(date);
7064
- }
7065
- return date.getHours();
7066
- };
7067
-
7033
+ */
7034
+ var getHour = function getHour(date) {
7035
+ if (!date) {
7036
+ return new Date().getHours();
7037
+ }
7038
+ if (typeof date === 'string') {
7039
+ date = new Date(date);
7040
+ }
7041
+ return date.getHours();
7042
+ };
7043
+
7068
7044
  /**
7069
7045
  * 获取分钟
7070
7046
  * @date 2022年5月7日
7071
7047
  * @param {Date|string} [date] - 日期对象或日期字符串
7072
7048
  * @returns {number} 分钟数(0-59)
7073
- */
7074
- const getMinute = function (date) {
7075
- if (!date) {
7076
- return new Date().getMinutes();
7077
- }
7078
- if (typeof date === 'string') {
7079
- date = new Date(date);
7080
- }
7081
- return date.getMinutes();
7082
- };
7083
-
7049
+ */
7050
+ var getMinute = function getMinute(date) {
7051
+ if (!date) {
7052
+ return new Date().getMinutes();
7053
+ }
7054
+ if (typeof date === 'string') {
7055
+ date = new Date(date);
7056
+ }
7057
+ return date.getMinutes();
7058
+ };
7059
+
7084
7060
  /**
7085
7061
  * 获取月份
7086
7062
  * @date 2022年5月7日
7087
7063
  * @param {Date|string} [date] - 日期对象或日期字符串
7088
7064
  * @returns {number} 月份数(1-12)
7089
- */
7090
- const getMonth = function (date) {
7091
- if (!date) {
7092
- return new Date().getMonth() + 1;
7093
- }
7094
- if (typeof date === 'string') {
7095
- date = new Date(date);
7096
- }
7097
- return date.getMonth() + 1;
7098
- };
7099
-
7065
+ */
7066
+ var getMonth = function getMonth(date) {
7067
+ if (!date) {
7068
+ return new Date().getMonth() + 1;
7069
+ }
7070
+ if (typeof date === 'string') {
7071
+ date = new Date(date);
7072
+ }
7073
+ return date.getMonth() + 1;
7074
+ };
7075
+
7100
7076
  /**
7101
7077
  * 获取秒
7102
7078
  * @date 2022年5月7日
7103
7079
  * @param {Date|string} [date] - 日期对象或日期字符串
7104
7080
  * @returns {number} 秒数(0-59)
7105
- */
7106
- const getSecond = function (date) {
7107
- if (!date) {
7108
- return new Date().getSeconds();
7109
- }
7110
- if (typeof date === 'string') {
7111
- date = new Date(date);
7112
- }
7113
- return date.getSeconds();
7114
- };
7115
-
7081
+ */
7082
+ var getSecond = function getSecond(date) {
7083
+ if (!date) {
7084
+ return new Date().getSeconds();
7085
+ }
7086
+ if (typeof date === 'string') {
7087
+ date = new Date(date);
7088
+ }
7089
+ return date.getSeconds();
7090
+ };
7091
+
7116
7092
  /**
7117
7093
  * 获取星期几
7118
7094
  * @date 2022年5月7日
7119
7095
  * @param {Date|string} [date] - 日期对象或日期字符串
7120
7096
  * @returns {number} 星期几(0-6,0表示星期日)
7121
- */
7122
- const getWeekday = function (date) {
7123
- if (!date) {
7124
- return new Date().getDay();
7125
- }
7126
- if (typeof date === 'string') {
7127
- date = new Date(date);
7128
- }
7129
- return date.getDay();
7130
- };
7131
-
7132
-
7097
+ */
7098
+ var getWeekday = function getWeekday(date) {
7099
+ if (!date) {
7100
+ return new Date().getDay();
7101
+ }
7102
+ if (typeof date === 'string') {
7103
+ date = new Date(date);
7104
+ }
7105
+ return date.getDay();
7106
+ };
7107
+
7133
7108
  /**
7134
7109
  * @desc 获取上午/下午/晚上
7135
7110
  * @author huangbo
7136
7111
  * @date 2022年5月7日
7137
7112
  * @param {String} [time] - 时间
7138
- **/
7139
- const timeCycle = function (time) {
7140
- let hour = 0;
7141
- if (!time) {
7142
- hour = new Date().getHours();
7143
- } else if (typeof time === 'string') {
7144
- // 从时间字符串中提取小时
7145
- const match = time.match(/^(\d{1,2})/);
7146
- if (match) {
7147
- hour = parseInt(match[1], 10);
7148
- }
7149
- } else if (typeof time === 'number') {
7150
- hour = time;
7151
- }
7152
- // 判断时间段
7153
- if (hour >= 5 && hour < 12) {
7154
- return '上午';
7155
- } else if (hour >= 12 && hour < 18) {
7156
- return '下午';
7157
- } else {
7158
- return '晚上';
7159
- }
7113
+ **/
7114
+ var timeCycle = function timeCycle(time) {
7115
+ var hour = 0;
7116
+ if (!time) {
7117
+ hour = new Date().getHours();
7118
+ } else if (typeof time === 'string') {
7119
+ // 从时间字符串中提取小时
7120
+ var match = time.match(/^(\d{1,2})/);
7121
+ if (match) {
7122
+ hour = parseInt(match[1], 10);
7123
+ }
7124
+ } else if (typeof time === 'number') {
7125
+ hour = time;
7126
+ }
7127
+ // 判断时间段
7128
+ if (hour >= 5 && hour < 12) {
7129
+ return '上午';
7130
+ } else if (hour >= 12 && hour < 18) {
7131
+ return '下午';
7132
+ } else {
7133
+ return '晚上';
7134
+ }
7160
7135
  };
7161
7136
 
7162
7137
  /***/ }),
@@ -7168,7 +7143,7 @@ module.exports = require("eoss/lib/message-box");
7168
7143
 
7169
7144
  /***/ }),
7170
7145
 
7171
- /***/ 85:
7146
+ /***/ 87:
7172
7147
  /***/ (function(module, exports) {
7173
7148
 
7174
7149
  module.exports = require("eoss/lib/pagination");
@@ -7182,7 +7157,7 @@ module.exports = require("eoss/lib/message");
7182
7157
 
7183
7158
  /***/ }),
7184
7159
 
7185
- /***/ 92:
7160
+ /***/ 94:
7186
7161
  /***/ (function(module, exports) {
7187
7162
 
7188
7163
  module.exports = require("eoss/lib/table");