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 = 159);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 163);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4467,7 +4467,7 @@ var getTableData = function getTableData(_ref9) {
4467
4467
 
4468
4468
  /***/ }),
4469
4469
 
4470
- /***/ 105:
4470
+ /***/ 107:
4471
4471
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4472
4472
 
4473
4473
  "use strict";
@@ -4530,17 +4530,17 @@ render._withStripped = true
4530
4530
  // CONCATENATED MODULE: ./packages/checkbox/src/checkbox-group.vue?vue&type=template&id=61423f1a&
4531
4531
 
4532
4532
  // EXTERNAL MODULE: external "sortablejs"
4533
- var external_sortablejs_ = __webpack_require__(56);
4533
+ var external_sortablejs_ = __webpack_require__(55);
4534
4534
  var external_sortablejs_default = /*#__PURE__*/__webpack_require__.n(external_sortablejs_);
4535
4535
 
4536
4536
  // EXTERNAL MODULE: ./src/mixins/emitter.js
4537
4537
  var emitter = __webpack_require__(15);
4538
4538
 
4539
4539
  // EXTERNAL MODULE: ./packages/checkbox/src/checkbox.vue + 4 modules
4540
- var src_checkbox = __webpack_require__(88);
4540
+ var src_checkbox = __webpack_require__(90);
4541
4541
 
4542
4542
  // EXTERNAL MODULE: ./packages/checkbox/src/checkbox-button.vue + 4 modules
4543
- var checkbox_button = __webpack_require__(89);
4543
+ var checkbox_button = __webpack_require__(91);
4544
4544
 
4545
4545
  // EXTERNAL MODULE: ./src/utils/ajax.js
4546
4546
  var ajax = __webpack_require__(10);
@@ -5123,12 +5123,19 @@ function _broadcast(componentName, eventName, params) {
5123
5123
 
5124
5124
  /***/ }),
5125
5125
 
5126
- /***/ 159:
5126
+ /***/ 16:
5127
+ /***/ (function(module, exports) {
5128
+
5129
+ module.exports = require("eoss/lib/loading");
5130
+
5131
+ /***/ }),
5132
+
5133
+ /***/ 163:
5127
5134
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5128
5135
 
5129
5136
  "use strict";
5130
5137
  __webpack_require__.r(__webpack_exports__);
5131
- /* harmony import */ var _checkbox_src_checkbox_group_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(105);
5138
+ /* harmony import */ var _checkbox_src_checkbox_group_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(107);
5132
5139
 
5133
5140
 
5134
5141
  /* istanbul ignore next */
@@ -5140,13 +5147,6 @@ _checkbox_src_checkbox_group_vue__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]
5140
5147
 
5141
5148
  /***/ }),
5142
5149
 
5143
- /***/ 16:
5144
- /***/ (function(module, exports) {
5145
-
5146
- module.exports = require("eoss/lib/loading");
5147
-
5148
- /***/ }),
5149
-
5150
5150
  /***/ 17:
5151
5151
  /***/ (function(module, exports) {
5152
5152
 
@@ -5455,7 +5455,7 @@ module.exports = require("sm-crypto");
5455
5455
 
5456
5456
  /***/ }),
5457
5457
 
5458
- /***/ 56:
5458
+ /***/ 55:
5459
5459
  /***/ (function(module, exports) {
5460
5460
 
5461
5461
  module.exports = require("sortablejs");
@@ -6085,759 +6085,736 @@ var changeInTime = '/baseIssueRules/changeInTime';
6085
6085
  /* unused harmony export getSecond */
6086
6086
  /* unused harmony export getWeekday */
6087
6087
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
6088
- /* Modified from https://github.com/taylorhakes/fecha
6089
- *
6090
- * The MIT License (MIT)
6091
- *
6092
- * Copyright (c) 2015 Taylor Hakes
6093
- *
6094
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6095
- * of this software and associated documentation files (the "Software"), to deal
6096
- * in the Software without restriction, including without limitation the rights
6097
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6098
- * copies of the Software, and to permit persons to whom the Software is
6099
- * furnished to do so, subject to the following conditions:
6100
- *
6101
- * The above copyright notice and this permission notice shall be included in all
6102
- * copies or substantial portions of the Software.
6103
- *
6104
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6105
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6106
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6107
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6108
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6109
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6110
- * SOFTWARE.
6111
- */
6112
-
6113
- /*eslint-disable*/
6114
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
6115
-
6116
-
6088
+
6089
+
6117
6090
  /**
6118
6091
  * Parse or format dates
6119
6092
  * @class fecha
6120
- */
6121
- const fecha = {};
6122
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6123
- const twoDigits = '\\d\\d?';
6124
- const threeDigits = '\\d{3}';
6125
- const fourDigits = '\\d{4}';
6126
- const word = '[^\\s]+';
6127
- const literal = /\[([^]*?)\]/gm;
6128
- const noop = function () {};
6129
-
6130
- function regexEscape(str) {
6131
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6132
- }
6133
-
6134
- function shorten(arr, sLen) {
6135
- const newArr = [];
6136
- for (let i = 0, len = arr.length; i < len; i++) {
6137
- newArr.push(arr[i].substr(0, sLen));
6138
- }
6139
- return newArr;
6140
- }
6141
-
6142
- function monthUpdate() {
6143
- return function (d, v) {
6144
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6145
- if (~index) {
6146
- d.month = index;
6147
- }
6148
- };
6149
- }
6150
-
6151
- function pad(val, len) {
6152
- val = String(val);
6153
- len = len || 2;
6154
- while (val.length < len) {
6155
- val = '0' + val;
6156
- }
6157
- return val;
6158
- }
6159
-
6160
- // 直接使用中文日期名称常量
6161
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6162
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6163
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6164
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6165
- const amPm = ['上午', '下午'];
6166
- const DoFn = function DoFn(D) {
6167
- return D + '日';
6168
- };
6169
-
6170
- const formatFlags = {
6171
- D: function(dateObj) {
6172
- return dateObj.getDay();
6173
- },
6174
- DD: function(dateObj) {
6175
- return pad(dateObj.getDay());
6176
- },
6177
- Do: function(dateObj) {
6178
- return DoFn(dateObj.getDate());
6179
- },
6180
- d: function(dateObj) {
6181
- return dateObj.getDate();
6182
- },
6183
- dd: function(dateObj) {
6184
- return pad(dateObj.getDate());
6185
- },
6186
- ddd: function(dateObj) {
6187
- return dayNamesShort[dateObj.getDay()];
6188
- },
6189
- dddd: function(dateObj) {
6190
- return dayNames[dateObj.getDay()];
6191
- },
6192
- M: function(dateObj) {
6193
- return dateObj.getMonth() + 1;
6194
- },
6195
- MM: function(dateObj) {
6196
- return pad(dateObj.getMonth() + 1);
6197
- },
6198
- MMM: function(dateObj) {
6199
- return monthNamesShort[dateObj.getMonth()];
6200
- },
6201
- MMMM: function(dateObj) {
6202
- return monthNames[dateObj.getMonth()];
6203
- },
6204
- yy: function(dateObj) {
6205
- return pad(String(dateObj.getFullYear()), 4).substr(2);
6206
- },
6207
- yyyy: function(dateObj) {
6208
- return pad(dateObj.getFullYear(), 4);
6209
- },
6210
- h: function(dateObj) {
6211
- return dateObj.getHours() % 12 || 12;
6212
- },
6213
- hh: function(dateObj) {
6214
- return pad(dateObj.getHours() % 12 || 12);
6215
- },
6216
- H: function(dateObj) {
6217
- return dateObj.getHours();
6218
- },
6219
- HH: function(dateObj) {
6220
- return pad(dateObj.getHours());
6221
- },
6222
- m: function(dateObj) {
6223
- return dateObj.getMinutes();
6224
- },
6225
- mm: function(dateObj) {
6226
- return pad(dateObj.getMinutes());
6227
- },
6228
- s: function(dateObj) {
6229
- return dateObj.getSeconds();
6230
- },
6231
- ss: function(dateObj) {
6232
- return pad(dateObj.getSeconds());
6233
- },
6234
- S: function(dateObj) {
6235
- return Math.round(dateObj.getMilliseconds() / 100);
6236
- },
6237
- SS: function(dateObj) {
6238
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6239
- },
6240
- SSS: function(dateObj) {
6241
- return pad(dateObj.getMilliseconds(), 3);
6242
- },
6243
- a: function(dateObj) {
6244
- return dateObj.getHours() < 12 ? '上午' : '下午';
6245
- },
6246
- A: function(dateObj) {
6247
- return dateObj.getHours() < 12 ? '上午' : '下午';
6248
- },
6249
- ZZ: function(dateObj) {
6250
- const o = dateObj.getTimezoneOffset();
6251
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6252
- }
6253
- };
6254
-
6255
- const parseFlags = {
6256
- d: [twoDigits, function (d, v) {
6257
- d.day = v;
6258
- }],
6259
- Do: [twoDigits + word, function (d, v) {
6260
- d.day = parseInt(v, 10);
6261
- }],
6262
- M: [twoDigits, function (d, v) {
6263
- d.month = v - 1;
6264
- }],
6265
- yy: [twoDigits, function (d, v) {
6266
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
6267
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6268
- }],
6269
- h: [twoDigits, function (d, v) {
6270
- d.hour = v;
6271
- }],
6272
- m: [twoDigits, function (d, v) {
6273
- d.minute = v;
6274
- }],
6275
- s: [twoDigits, function (d, v) {
6276
- d.second = v;
6277
- }],
6278
- yyyy: [fourDigits, function (d, v) {
6279
- d.year = v;
6280
- }],
6281
- S: ['\\d', function (d, v) {
6282
- d.millisecond = v * 100;
6283
- }],
6284
- SS: ['\\d{2}', function (d, v) {
6285
- d.millisecond = v * 10;
6286
- }],
6287
- SSS: [threeDigits, function (d, v) {
6288
- d.millisecond = v;
6289
- }],
6290
- D: [twoDigits, noop],
6291
- ddd: [word, noop],
6292
- MMM: [word, monthUpdate('monthNamesShort')],
6293
- MMMM: [word, monthUpdate('monthNames')],
6294
- a: [word, function (d, v) {
6295
- const val = v.toLowerCase();
6296
- if (val === '上午') {
6297
- d.isPm = false;
6298
- } else if (val === '下午') {
6299
- d.isPm = true;
6300
- }
6301
- }],
6302
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6303
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
6304
-
6305
- if (parts) {
6306
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6307
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6308
- }
6309
- }]
6310
- };
6311
- parseFlags.dd = parseFlags.d;
6312
- parseFlags.dddd = parseFlags.ddd;
6313
- parseFlags.DD = parseFlags.D;
6314
- parseFlags.mm = parseFlags.m;
6315
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6316
- parseFlags.MM = parseFlags.M;
6317
- parseFlags.ss = parseFlags.s;
6318
- parseFlags.A = parseFlags.a;
6319
-
6320
-
6321
- // Some common format strings
6322
- fecha.masks = {
6323
- default: 'ddd MMM dd yyyy HH:mm:ss',
6324
- shortDate: 'M/D/yy',
6325
- mediumDate: 'MMM d, yyyy',
6326
- longDate: 'MMMM d, yyyy',
6327
- fullDate: 'dddd, MMMM d, yyyy',
6328
- shortTime: 'HH:mm',
6329
- mediumTime: 'HH:mm:ss',
6330
- longTime: 'HH:mm:ss.SSS'
6331
- };
6332
-
6093
+ */
6094
+ var fecha = {};
6095
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6096
+ var twoDigits = '\\d\\d?';
6097
+ var threeDigits = '\\d{3}';
6098
+ var fourDigits = '\\d{4}';
6099
+ var word = '[^\\s]+';
6100
+ var literal = /\[([^]*?)\]/gm;
6101
+ var noop = function noop() {};
6102
+
6103
+ function regexEscape(str) {
6104
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6105
+ }
6106
+
6107
+ function shorten(arr, sLen) {
6108
+ var newArr = [];
6109
+ for (var i = 0, len = arr.length; i < len; i++) {
6110
+ newArr.push(arr[i].substr(0, sLen));
6111
+ }
6112
+ return newArr;
6113
+ }
6114
+
6115
+ function monthUpdate() {
6116
+ return function (d, v) {
6117
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6118
+ if (~index) {
6119
+ d.month = index;
6120
+ }
6121
+ };
6122
+ }
6123
+
6124
+ function pad(val, len) {
6125
+ val = String(val);
6126
+ len = len || 2;
6127
+ while (val.length < len) {
6128
+ val = '0' + val;
6129
+ }
6130
+ return val;
6131
+ }
6132
+
6133
+ // 直接使用中文日期名称常量
6134
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6135
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6136
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6137
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6138
+ var amPm = ['上午', '下午'];
6139
+ var DoFn = function DoFn(D) {
6140
+ return D + '日';
6141
+ };
6142
+
6143
+ var formatFlags = {
6144
+ D: function D(dateObj) {
6145
+ return dateObj.getDay();
6146
+ },
6147
+ DD: function DD(dateObj) {
6148
+ return pad(dateObj.getDay());
6149
+ },
6150
+ Do: function Do(dateObj) {
6151
+ return DoFn(dateObj.getDate());
6152
+ },
6153
+ d: function d(dateObj) {
6154
+ return dateObj.getDate();
6155
+ },
6156
+ dd: function dd(dateObj) {
6157
+ return pad(dateObj.getDate());
6158
+ },
6159
+ ddd: function ddd(dateObj) {
6160
+ return dayNamesShort[dateObj.getDay()];
6161
+ },
6162
+ dddd: function dddd(dateObj) {
6163
+ return dayNames[dateObj.getDay()];
6164
+ },
6165
+ M: function M(dateObj) {
6166
+ return dateObj.getMonth() + 1;
6167
+ },
6168
+ MM: function MM(dateObj) {
6169
+ return pad(dateObj.getMonth() + 1);
6170
+ },
6171
+ MMM: function MMM(dateObj) {
6172
+ return monthNamesShort[dateObj.getMonth()];
6173
+ },
6174
+ MMMM: function MMMM(dateObj) {
6175
+ return monthNames[dateObj.getMonth()];
6176
+ },
6177
+ yy: function yy(dateObj) {
6178
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
6179
+ },
6180
+ yyyy: function yyyy(dateObj) {
6181
+ return pad(dateObj.getFullYear(), 4);
6182
+ },
6183
+ h: function h(dateObj) {
6184
+ return dateObj.getHours() % 12 || 12;
6185
+ },
6186
+ hh: function hh(dateObj) {
6187
+ return pad(dateObj.getHours() % 12 || 12);
6188
+ },
6189
+ H: function H(dateObj) {
6190
+ return dateObj.getHours();
6191
+ },
6192
+ HH: function HH(dateObj) {
6193
+ return pad(dateObj.getHours());
6194
+ },
6195
+ m: function m(dateObj) {
6196
+ return dateObj.getMinutes();
6197
+ },
6198
+ mm: function mm(dateObj) {
6199
+ return pad(dateObj.getMinutes());
6200
+ },
6201
+ s: function s(dateObj) {
6202
+ return dateObj.getSeconds();
6203
+ },
6204
+ ss: function ss(dateObj) {
6205
+ return pad(dateObj.getSeconds());
6206
+ },
6207
+ S: function S(dateObj) {
6208
+ return Math.round(dateObj.getMilliseconds() / 100);
6209
+ },
6210
+ SS: function SS(dateObj) {
6211
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6212
+ },
6213
+ SSS: function SSS(dateObj) {
6214
+ return pad(dateObj.getMilliseconds(), 3);
6215
+ },
6216
+ a: function a(dateObj) {
6217
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6218
+ },
6219
+ A: function A(dateObj) {
6220
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6221
+ },
6222
+ ZZ: function ZZ(dateObj) {
6223
+ var o = dateObj.getTimezoneOffset();
6224
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6225
+ }
6226
+ };
6227
+
6228
+ var parseFlags = {
6229
+ d: [twoDigits, function (d, v) {
6230
+ d.day = v;
6231
+ }],
6232
+ Do: [twoDigits + word, function (d, v) {
6233
+ d.day = parseInt(v, 10);
6234
+ }],
6235
+ M: [twoDigits, function (d, v) {
6236
+ d.month = v - 1;
6237
+ }],
6238
+ yy: [twoDigits, function (d, v) {
6239
+ var da = new Date(),
6240
+ cent = +('' + da.getFullYear()).substr(0, 2);
6241
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6242
+ }],
6243
+ h: [twoDigits, function (d, v) {
6244
+ d.hour = v;
6245
+ }],
6246
+ m: [twoDigits, function (d, v) {
6247
+ d.minute = v;
6248
+ }],
6249
+ s: [twoDigits, function (d, v) {
6250
+ d.second = v;
6251
+ }],
6252
+ yyyy: [fourDigits, function (d, v) {
6253
+ d.year = v;
6254
+ }],
6255
+ S: ['\\d', function (d, v) {
6256
+ d.millisecond = v * 100;
6257
+ }],
6258
+ SS: ['\\d{2}', function (d, v) {
6259
+ d.millisecond = v * 10;
6260
+ }],
6261
+ SSS: [threeDigits, function (d, v) {
6262
+ d.millisecond = v;
6263
+ }],
6264
+ D: [twoDigits, noop],
6265
+ ddd: [word, noop],
6266
+ MMM: [word, monthUpdate('monthNamesShort')],
6267
+ MMMM: [word, monthUpdate('monthNames')],
6268
+ a: [word, function (d, v) {
6269
+ var val = v.toLowerCase();
6270
+ if (val === '上午') {
6271
+ d.isPm = false;
6272
+ } else if (val === '下午') {
6273
+ d.isPm = true;
6274
+ }
6275
+ }],
6276
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6277
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
6278
+ minutes = void 0;
6279
+
6280
+ if (parts) {
6281
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6282
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6283
+ }
6284
+ }]
6285
+ };
6286
+ parseFlags.dd = parseFlags.d;
6287
+ parseFlags.dddd = parseFlags.ddd;
6288
+ parseFlags.DD = parseFlags.D;
6289
+ parseFlags.mm = parseFlags.m;
6290
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6291
+ parseFlags.MM = parseFlags.M;
6292
+ parseFlags.ss = parseFlags.s;
6293
+ parseFlags.A = parseFlags.a;
6294
+
6295
+ // Some common format strings
6296
+ fecha.masks = {
6297
+ default: 'ddd MMM dd yyyy HH:mm:ss',
6298
+ shortDate: 'M/D/yy',
6299
+ mediumDate: 'MMM d, yyyy',
6300
+ longDate: 'MMMM d, yyyy',
6301
+ fullDate: 'dddd, MMMM d, yyyy',
6302
+ shortTime: 'HH:mm',
6303
+ mediumTime: 'HH:mm:ss',
6304
+ longTime: 'HH:mm:ss.SSS'
6305
+ };
6306
+
6333
6307
  /***
6334
6308
  * Format a date
6335
6309
  * @method format
6336
6310
  * @param {Date|number} dateObj
6337
6311
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
6338
- */
6339
- fecha.format = function (dateObj, mask) {
6340
- if (typeof dateObj === 'number') {
6341
- dateObj = new Date(dateObj);
6342
- }
6343
-
6344
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6345
- throw new Error('Invalid Date in fecha.format');
6346
- }
6347
-
6348
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
6349
-
6350
- const literals = [];
6351
-
6352
- // Make literals inactive by replacing them with ??
6353
- mask = mask.replace(literal, function($0, $1) {
6354
- literals.push($1);
6355
- return '@@@';
6356
- });
6357
- // Apply formatting rules
6358
- mask = mask.replace(token, function ($0) {
6359
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6360
- });
6361
- // Inline literal values back into the formatted value
6362
- return mask.replace(/@@@/g, function() {
6363
- return literals.shift();
6364
- });
6365
- };
6366
-
6312
+ */
6313
+ fecha.format = function (dateObj, mask) {
6314
+ if (typeof dateObj === 'number') {
6315
+ dateObj = new Date(dateObj);
6316
+ }
6317
+
6318
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6319
+ throw new Error('Invalid Date in fecha.format');
6320
+ }
6321
+
6322
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
6323
+
6324
+ var literals = [];
6325
+
6326
+ // Make literals inactive by replacing them with ??
6327
+ mask = mask.replace(literal, function ($0, $1) {
6328
+ literals.push($1);
6329
+ return '@@@';
6330
+ });
6331
+ // Apply formatting rules
6332
+ mask = mask.replace(token, function ($0) {
6333
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6334
+ });
6335
+ // Inline literal values back into the formatted value
6336
+ return mask.replace(/@@@/g, function () {
6337
+ return literals.shift();
6338
+ });
6339
+ };
6340
+
6367
6341
  /**
6368
6342
  * Parse a date string into an object, changes - into /
6369
6343
  * @method parse
6370
6344
  * @param {string} dateStr Date string
6371
6345
  * @param {string} format Date parse format
6372
6346
  * @returns {Date|boolean}
6373
- */
6374
- fecha.parse = function (dateStr, format) {
6375
- if (typeof format !== 'string') {
6376
- throw new Error('Invalid format in fecha.parse');
6377
- }
6378
-
6379
- format = fecha.masks[format] || format;
6380
-
6381
- // Avoid regular expression denial of service, fail early for really long strings
6382
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6383
- if (dateStr.length > 1000) {
6384
- return null;
6385
- }
6386
-
6387
- const dateInfo = {};
6388
- const parseInfo = [];
6389
- const literals = [];
6390
- format = format.replace(literal, function($0, $1) {
6391
- literals.push($1);
6392
- return '@@@';
6393
- });
6394
- let newFormat = regexEscape(format).replace(token, function ($0) {
6395
- if (parseFlags[$0]) {
6396
- const info = parseFlags[$0];
6397
- parseInfo.push(info[1]);
6398
- return '(' + info[0] + ')';
6399
- }
6400
-
6401
- return $0;
6402
- });
6403
- newFormat = newFormat.replace(/@@@/g, function() {
6404
- return literals.shift();
6405
- });
6406
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
6407
- if (!matches) {
6408
- return null;
6409
- }
6410
-
6411
- for (let i = 1; i < matches.length; i++) {
6412
- parseInfo[i - 1](dateInfo, matches[i]);
6413
- }
6414
-
6415
- const today = new Date();
6416
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6417
- dateInfo.hour = +dateInfo.hour + 12;
6418
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6419
- dateInfo.hour = 0;
6420
- }
6421
-
6422
- let date;
6423
- if (dateInfo.timezoneOffset != null) {
6424
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6425
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6426
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
6427
- } else {
6428
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6429
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
6430
- }
6431
- return date;
6432
- };
6433
-
6434
- // 导出fecha对象
6435
-
6436
-
6437
- // 以下是从date-util.js合并的函数
6438
- const newArray = function(start, end) {
6439
- let result = [];
6440
- for (let i = start; i <= end; i++) {
6441
- result.push(i);
6442
- }
6443
- return result;
6444
- };
6445
-
6446
- const getSettings = () => {
6447
- return {
6448
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6449
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6450
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6451
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6452
- amPm: ['上午', '下午']
6453
- };
6454
- };
6455
-
6456
- const toDate = function(date) {
6457
- return isDate(date) ? new Date(date) : null;
6458
- };
6459
-
6460
- const isDate = function(date) {
6461
- if (date === null || date === undefined) return false;
6462
- if (isNaN(new Date(date).getTime())) return false;
6463
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6464
- return true;
6465
- };
6466
-
6467
- const isDateObject = function(val) {
6468
- return val instanceof Date;
6469
- };
6470
-
6471
- const formatDate = function (date, format = 'yyyy-MM-dd') {
6472
- // 处理多种输入类型
6473
- if (!date) return '';
6474
-
6475
- // 如果是时间戳,转成日期对象
6476
- if (typeof date === 'number') {
6477
- date = new Date(date);
6478
- }
6479
- // 如果是字符串,转成日期对象
6480
- if (typeof date === 'string') {
6481
- date = new Date(date);
6482
- }
6483
-
6484
- // 调用toDate进一步验证和转换
6485
- date = toDate(date);
6486
- if (!date) return '';
6487
-
6488
- // 兼容大写和小写的格式标记
6489
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6490
- const lowercaseFormat = format
6491
- .replace(/YYYY/g, 'yyyy')
6492
- .replace(/D/g, 'd')
6493
-
6494
- // 使用fecha库进行格式化,支持中文配置
6495
- const str = fecha.format(date, lowercaseFormat, getSettings());
6496
- return str;
6497
- };
6498
-
6499
- const parseDate = function(string, format) {
6500
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6501
- };
6502
-
6503
- const getDayCountOfMonth = function(year, month) {
6504
- if (month === 3 || month === 5 || month === 8 || month === 10) {
6505
- return 30;
6506
- }
6507
-
6508
- if (month === 1) {
6509
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6510
- return 29;
6511
- } else {
6512
- return 28;
6513
- }
6514
- }
6515
-
6516
- return 31;
6517
- };
6518
-
6519
- const getDayCountOfYear = function(year) {
6520
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
6521
- return isLeapYear ? 366 : 365;
6522
- };
6523
-
6524
- const getFirstDayOfMonth = function(date) {
6525
- const temp = new Date(date.getTime());
6526
- temp.setDate(1);
6527
- return temp.getDay();
6528
- };
6529
-
6530
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6531
- // {prev, next} Date should work for Daylight Saving Time
6532
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6533
- const prevDate = function(date, amount = 1) {
6534
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6535
- };
6536
-
6537
- const nextDate = function(date, amount = 1) {
6538
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6539
- };
6540
-
6541
- const getStartDateOfMonth = function(year, month) {
6542
- const result = new Date(year, month, 1);
6543
- const day = result.getDay();
6544
-
6545
- if (day === 0) {
6546
- return prevDate(result, 7);
6547
- } else {
6548
- return prevDate(result, day);
6549
- }
6550
- };
6551
-
6552
- const getWeekNumber = function(date) {
6553
- // 支持多种输入类型
6554
- if (!date||!isDate(date)) {
6555
- date = new Date();
6556
- }
6557
- if (typeof date === 'string') {
6558
- date = new Date(date);
6559
- }
6560
-
6561
- // 验证日期有效性
6562
- if (!isDate(date)) return null;
6563
-
6564
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6565
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6566
- // 将星期日的星期数设为7
6567
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6568
- // 获取当年的第一天
6569
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6570
- // 计算到最近的星期四的完整周数
6571
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
6572
- // 返回周数
6573
- return weekNo;
6574
- };
6575
-
6576
- const getRangeHours = function(ranges) {
6577
- const hours = [];
6578
- let disabledHours = [];
6579
-
6580
- (ranges || []).forEach(range => {
6581
- const value = range.map(date => date.getHours());
6582
-
6583
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6584
- });
6585
-
6586
- if (disabledHours.length) {
6587
- for (let i = 0; i < 24; i++) {
6588
- hours[i] = disabledHours.indexOf(i) === -1;
6589
- }
6590
- } else {
6591
- for (let i = 0; i < 24; i++) {
6592
- hours[i] = false;
6593
- }
6594
- }
6595
-
6596
- return hours;
6597
- };
6598
-
6599
- const getPrevMonthLastDays = (date, amount) => {
6600
- if (amount <= 0) return [];
6601
- const temp = new Date(date.getTime());
6602
- temp.setDate(0);
6603
- const lastDay = temp.getDate();
6604
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
6605
- };
6606
-
6607
- const getMonthDays = (date) => {
6608
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6609
- const days = temp.getDate();
6610
- return range(days).map((_, index) => index + 1);
6611
- };
6612
-
6613
- function setRangeData(arr, start, end, value) {
6614
- for (let i = start; i < end; i++) {
6615
- arr[i] = value;
6616
- }
6617
- }
6618
-
6619
- const getRangeMinutes = function(ranges, hour) {
6620
- const minutes = new Array(60);
6621
-
6622
- if (ranges.length > 0) {
6623
- ranges.forEach(range => {
6624
- const start = range[0];
6625
- const end = range[1];
6626
- const startHour = start.getHours();
6627
- const startMinute = start.getMinutes();
6628
- const endHour = end.getHours();
6629
- const endMinute = end.getMinutes();
6630
- if (startHour === hour && endHour !== hour) {
6631
- setRangeData(minutes, startMinute, 60, true);
6632
- } else if (startHour === hour && endHour === hour) {
6633
- setRangeData(minutes, startMinute, endMinute + 1, true);
6634
- } else if (startHour !== hour && endHour === hour) {
6635
- setRangeData(minutes, 0, endMinute + 1, true);
6636
- } else if (startHour < hour && endHour > hour) {
6637
- setRangeData(minutes, 0, 60, true);
6638
- }
6639
- });
6640
- } else {
6641
- setRangeData(minutes, 0, 60, true);
6642
- }
6643
- return minutes;
6644
- };
6645
-
6646
- const range = function(n) {
6647
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6648
- return Array.apply(null, {length: n}).map((_, n) => n);
6649
- };
6650
-
6651
- const modifyDate = function(date, y, m, d) {
6652
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6653
- };
6654
-
6655
- const modifyTime = function(date, h, m, s) {
6656
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6657
- };
6658
-
6659
- const modifyWithTimeString = (date, time) => {
6660
- if (date == null || !time) {
6661
- return date;
6662
- }
6663
- time = parseDate(time, 'HH:mm:ss');
6664
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6665
- };
6666
-
6667
- const clearTime = function(date) {
6668
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6669
- };
6670
-
6671
- const clearMilliseconds = function(date) {
6672
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6673
- };
6674
-
6675
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
6676
- // TODO: refactory a more elegant solution
6677
- if (ranges.length === 0) return date;
6678
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
6679
- const ndate = normalizeDate(date);
6680
- const nranges = ranges.map(range => range.map(normalizeDate));
6681
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
6682
-
6683
- let minDate = nranges[0][0];
6684
- let maxDate = nranges[0][0];
6685
-
6686
- nranges.forEach(nrange => {
6687
- minDate = new Date(Math.min(nrange[0], minDate));
6688
- maxDate = new Date(Math.max(nrange[1], minDate));
6689
- });
6690
-
6691
- const ret = ndate < minDate ? minDate : maxDate;
6692
- // preserve Year/Month/Date
6693
- return modifyDate(
6694
- ret,
6695
- date.getFullYear(),
6696
- date.getMonth(),
6697
- date.getDate()
6698
- );
6699
- };
6700
-
6701
- const timeWithinRange = function(date, selectableRange, format) {
6702
- const limitedDate = limitTimeRange(date, selectableRange, format);
6703
- return limitedDate.getTime() === date.getTime();
6704
- };
6705
-
6706
- const changeYearMonthAndClampDate = function(date, year, month) {
6707
- // clamp date to the number of days in `year`, `month`
6708
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
6709
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6710
- return modifyDate(date, year, month, monthDate);
6711
- };
6712
-
6713
- const prevMonth = function(date) {
6714
- const year = date.getFullYear();
6715
- const month = date.getMonth();
6716
- return month === 0
6717
- ? changeYearMonthAndClampDate(date, year - 1, 11)
6718
- : changeYearMonthAndClampDate(date, year, month - 1);
6719
- };
6720
-
6721
- const nextMonth = function(date) {
6722
- const year = date.getFullYear();
6723
- const month = date.getMonth();
6724
- return month === 11
6725
- ? changeYearMonthAndClampDate(date, year + 1, 0)
6726
- : changeYearMonthAndClampDate(date, year, month + 1);
6727
- };
6728
-
6729
- const prevYear = function(date, amount = 1) {
6730
- const year = date.getFullYear();
6731
- const month = date.getMonth();
6732
- return changeYearMonthAndClampDate(date, year - amount, month);
6733
- };
6734
-
6735
- const nextYear = function(date, amount = 1) {
6736
- const year = date.getFullYear();
6737
- const month = date.getMonth();
6738
- return changeYearMonthAndClampDate(date, year + amount, month);
6739
- };
6740
-
6741
- const extractDateFormat = function(format) {
6742
- return format
6743
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
6744
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
6745
- .trim();
6746
- };
6747
-
6748
- const extractTimeFormat = function(format) {
6749
- return format
6750
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
6751
- .trim();
6752
- };
6753
-
6754
- const validateRangeInOneMonth = function(start, end) {
6755
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
6756
- };
6757
-
6347
+ */
6348
+ fecha.parse = function (dateStr, format) {
6349
+ if (typeof format !== 'string') {
6350
+ throw new Error('Invalid format in fecha.parse');
6351
+ }
6352
+
6353
+ format = fecha.masks[format] || format;
6354
+
6355
+ // Avoid regular expression denial of service, fail early for really long strings
6356
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6357
+ if (dateStr.length > 1000) {
6358
+ return null;
6359
+ }
6360
+
6361
+ var dateInfo = {};
6362
+ var parseInfo = [];
6363
+ var literals = [];
6364
+ format = format.replace(literal, function ($0, $1) {
6365
+ literals.push($1);
6366
+ return '@@@';
6367
+ });
6368
+ var newFormat = regexEscape(format).replace(token, function ($0) {
6369
+ if (parseFlags[$0]) {
6370
+ var info = parseFlags[$0];
6371
+ parseInfo.push(info[1]);
6372
+ return '(' + info[0] + ')';
6373
+ }
6374
+
6375
+ return $0;
6376
+ });
6377
+ newFormat = newFormat.replace(/@@@/g, function () {
6378
+ return literals.shift();
6379
+ });
6380
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
6381
+ if (!matches) {
6382
+ return null;
6383
+ }
6384
+
6385
+ for (var i = 1; i < matches.length; i++) {
6386
+ parseInfo[i - 1](dateInfo, matches[i]);
6387
+ }
6388
+
6389
+ var today = new Date();
6390
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6391
+ dateInfo.hour = +dateInfo.hour + 12;
6392
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6393
+ dateInfo.hour = 0;
6394
+ }
6395
+
6396
+ var date = void 0;
6397
+ if (dateInfo.timezoneOffset != null) {
6398
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6399
+ 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));
6400
+ } else {
6401
+ 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);
6402
+ }
6403
+ return date;
6404
+ };
6405
+
6406
+ // 导出fecha对象
6407
+
6408
+
6409
+ // 以下是从date-util.js合并的函数
6410
+ var newArray = function newArray(start, end) {
6411
+ var result = [];
6412
+ for (var i = start; i <= end; i++) {
6413
+ result.push(i);
6414
+ }
6415
+ return result;
6416
+ };
6417
+
6418
+ var getSettings = function getSettings() {
6419
+ return {
6420
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6421
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6422
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6423
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6424
+ amPm: ['上午', '下午']
6425
+ };
6426
+ };
6427
+
6428
+ var toDate = function toDate(date) {
6429
+ return isDate(date) ? new Date(date) : null;
6430
+ };
6431
+
6432
+ var isDate = function isDate(date) {
6433
+ if (date === null || date === undefined) return false;
6434
+ if (isNaN(new Date(date).getTime())) return false;
6435
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6436
+ return true;
6437
+ };
6438
+
6439
+ var isDateObject = function isDateObject(val) {
6440
+ return val instanceof Date;
6441
+ };
6442
+
6443
+ var formatDate = function formatDate(date) {
6444
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
6445
+
6446
+ // 处理多种输入类型
6447
+ if (!date) return '';
6448
+
6449
+ // 如果是时间戳,转成日期对象
6450
+ if (typeof date === 'number') {
6451
+ date = new Date(date);
6452
+ }
6453
+ // 如果是字符串,转成日期对象
6454
+ if (typeof date === 'string') {
6455
+ date = new Date(date);
6456
+ }
6457
+
6458
+ // 调用toDate进一步验证和转换
6459
+ date = toDate(date);
6460
+ if (!date) return '';
6461
+
6462
+ // 兼容大写和小写的格式标记
6463
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6464
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
6465
+
6466
+ // 使用fecha库进行格式化,支持中文配置
6467
+ var str = fecha.format(date, lowercaseFormat, getSettings());
6468
+ return str;
6469
+ };
6470
+
6471
+ var parseDate = function parseDate(string, format) {
6472
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6473
+ };
6474
+
6475
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
6476
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
6477
+ return 30;
6478
+ }
6479
+
6480
+ if (month === 1) {
6481
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6482
+ return 29;
6483
+ } else {
6484
+ return 28;
6485
+ }
6486
+ }
6487
+
6488
+ return 31;
6489
+ };
6490
+
6491
+ var getDayCountOfYear = function getDayCountOfYear(year) {
6492
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
6493
+ return isLeapYear ? 366 : 365;
6494
+ };
6495
+
6496
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
6497
+ var temp = new Date(date.getTime());
6498
+ temp.setDate(1);
6499
+ return temp.getDay();
6500
+ };
6501
+
6502
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6503
+ // {prev, next} Date should work for Daylight Saving Time
6504
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6505
+ var prevDate = function prevDate(date) {
6506
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6507
+
6508
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6509
+ };
6510
+
6511
+ var nextDate = function nextDate(date) {
6512
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6513
+
6514
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6515
+ };
6516
+
6517
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
6518
+ var result = new Date(year, month, 1);
6519
+ var day = result.getDay();
6520
+
6521
+ if (day === 0) {
6522
+ return prevDate(result, 7);
6523
+ } else {
6524
+ return prevDate(result, day);
6525
+ }
6526
+ };
6527
+
6528
+ var getWeekNumber = function getWeekNumber(date) {
6529
+ // 支持多种输入类型
6530
+ if (!date || !isDate(date)) {
6531
+ date = new Date();
6532
+ }
6533
+ if (typeof date === 'string') {
6534
+ date = new Date(date);
6535
+ }
6536
+
6537
+ // 验证日期有效性
6538
+ if (!isDate(date)) return null;
6539
+
6540
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6541
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6542
+ // 将星期日的星期数设为7
6543
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6544
+ // 获取当年的第一天
6545
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6546
+ // 计算到最近的星期四的完整周数
6547
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
6548
+ // 返回周数
6549
+ return weekNo;
6550
+ };
6551
+
6552
+ var getRangeHours = function getRangeHours(ranges) {
6553
+ var hours = [];
6554
+ var disabledHours = [];
6555
+
6556
+ (ranges || []).forEach(function (range) {
6557
+ var value = range.map(function (date) {
6558
+ return date.getHours();
6559
+ });
6560
+
6561
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6562
+ });
6563
+
6564
+ if (disabledHours.length) {
6565
+ for (var i = 0; i < 24; i++) {
6566
+ hours[i] = disabledHours.indexOf(i) === -1;
6567
+ }
6568
+ } else {
6569
+ for (var _i = 0; _i < 24; _i++) {
6570
+ hours[_i] = false;
6571
+ }
6572
+ }
6573
+
6574
+ return hours;
6575
+ };
6576
+
6577
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
6578
+ if (amount <= 0) return [];
6579
+ var temp = new Date(date.getTime());
6580
+ temp.setDate(0);
6581
+ var lastDay = temp.getDate();
6582
+ return range(amount).map(function (_, index) {
6583
+ return lastDay - (amount - index - 1);
6584
+ });
6585
+ };
6586
+
6587
+ var getMonthDays = function getMonthDays(date) {
6588
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6589
+ var days = temp.getDate();
6590
+ return range(days).map(function (_, index) {
6591
+ return index + 1;
6592
+ });
6593
+ };
6594
+
6595
+ function setRangeData(arr, start, end, value) {
6596
+ for (var i = start; i < end; i++) {
6597
+ arr[i] = value;
6598
+ }
6599
+ }
6600
+
6601
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
6602
+ var minutes = new Array(60);
6603
+
6604
+ if (ranges.length > 0) {
6605
+ ranges.forEach(function (range) {
6606
+ var start = range[0];
6607
+ var end = range[1];
6608
+ var startHour = start.getHours();
6609
+ var startMinute = start.getMinutes();
6610
+ var endHour = end.getHours();
6611
+ var endMinute = end.getMinutes();
6612
+ if (startHour === hour && endHour !== hour) {
6613
+ setRangeData(minutes, startMinute, 60, true);
6614
+ } else if (startHour === hour && endHour === hour) {
6615
+ setRangeData(minutes, startMinute, endMinute + 1, true);
6616
+ } else if (startHour !== hour && endHour === hour) {
6617
+ setRangeData(minutes, 0, endMinute + 1, true);
6618
+ } else if (startHour < hour && endHour > hour) {
6619
+ setRangeData(minutes, 0, 60, true);
6620
+ }
6621
+ });
6622
+ } else {
6623
+ setRangeData(minutes, 0, 60, true);
6624
+ }
6625
+ return minutes;
6626
+ };
6627
+
6628
+ var range = function range(n) {
6629
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6630
+ return Array.apply(null, { length: n }).map(function (_, n) {
6631
+ return n;
6632
+ });
6633
+ };
6634
+
6635
+ var modifyDate = function modifyDate(date, y, m, d) {
6636
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6637
+ };
6638
+
6639
+ var modifyTime = function modifyTime(date, h, m, s) {
6640
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6641
+ };
6642
+
6643
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
6644
+ if (date == null || !time) {
6645
+ return date;
6646
+ }
6647
+ time = parseDate(time, 'HH:mm:ss');
6648
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6649
+ };
6650
+
6651
+ var clearTime = function clearTime(date) {
6652
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6653
+ };
6654
+
6655
+ var clearMilliseconds = function clearMilliseconds(date) {
6656
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6657
+ };
6658
+
6659
+ var limitTimeRange = function limitTimeRange(date, ranges) {
6660
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
6661
+
6662
+ // TODO: refactory a more elegant solution
6663
+ if (ranges.length === 0) return date;
6664
+ var normalizeDate = function normalizeDate(date) {
6665
+ return fecha.parse(fecha.format(date, format), format);
6666
+ };
6667
+ var ndate = normalizeDate(date);
6668
+ var nranges = ranges.map(function (range) {
6669
+ return range.map(normalizeDate);
6670
+ });
6671
+ if (nranges.some(function (nrange) {
6672
+ return ndate >= nrange[0] && ndate <= nrange[1];
6673
+ })) return date;
6674
+
6675
+ var minDate = nranges[0][0];
6676
+ var maxDate = nranges[0][0];
6677
+
6678
+ nranges.forEach(function (nrange) {
6679
+ minDate = new Date(Math.min(nrange[0], minDate));
6680
+ maxDate = new Date(Math.max(nrange[1], minDate));
6681
+ });
6682
+
6683
+ var ret = ndate < minDate ? minDate : maxDate;
6684
+ // preserve Year/Month/Date
6685
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
6686
+ };
6687
+
6688
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
6689
+ var limitedDate = limitTimeRange(date, selectableRange, format);
6690
+ return limitedDate.getTime() === date.getTime();
6691
+ };
6692
+
6693
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
6694
+ // clamp date to the number of days in `year`, `month`
6695
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
6696
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6697
+ return modifyDate(date, year, month, monthDate);
6698
+ };
6699
+
6700
+ var prevMonth = function prevMonth(date) {
6701
+ var year = date.getFullYear();
6702
+ var month = date.getMonth();
6703
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
6704
+ };
6705
+
6706
+ var nextMonth = function nextMonth(date) {
6707
+ var year = date.getFullYear();
6708
+ var month = date.getMonth();
6709
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
6710
+ };
6711
+
6712
+ var prevYear = function prevYear(date) {
6713
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6714
+
6715
+ var year = date.getFullYear();
6716
+ var month = date.getMonth();
6717
+ return changeYearMonthAndClampDate(date, year - amount, month);
6718
+ };
6719
+
6720
+ var nextYear = function nextYear(date) {
6721
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6722
+
6723
+ var year = date.getFullYear();
6724
+ var month = date.getMonth();
6725
+ return changeYearMonthAndClampDate(date, year + amount, month);
6726
+ };
6727
+
6728
+ var extractDateFormat = function extractDateFormat(format) {
6729
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
6730
+ };
6731
+
6732
+ var extractTimeFormat = function extractTimeFormat(format) {
6733
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
6734
+ };
6735
+
6736
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
6737
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
6738
+ };
6739
+
6758
6740
  /**
6759
6741
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
6760
6742
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
6761
6743
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
6762
6744
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
6763
6745
  * @returns {number} 工作日数量
6764
- */
6765
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
6766
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6767
- throw new Error(
6768
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
6769
- );
6770
- }
6771
-
6772
- const startDateObj = new Date(start_date);
6773
- const endDateObj = new Date(end_date);
6774
-
6775
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6776
- throw new Error(
6777
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
6778
- );
6779
- }
6780
-
6781
- if (startDateObj > endDateObj) {
6782
- throw new Error('Start date should be earlier than or equal to end date.');
6783
- }
6784
-
6785
- let workdays = 0;
6786
-
6787
- // Iterate through each day in the date range
6788
- for (
6789
- let currentDate = new Date(startDateObj);
6790
- currentDate <= endDateObj;
6791
- currentDate.setDate(currentDate.getDate() + 1)
6792
- ) {
6793
- // Check if the current day is a weekend (Saturday or Sunday)
6794
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6795
-
6796
- // Check if the current day is a holiday
6797
- const isHoliday = holidays.some((holiday) => {
6798
- const holidayDate = new Date(holiday);
6799
- return currentDate.toDateString() === holidayDate.toDateString();
6800
- });
6801
-
6802
- // If it's a workday (not a weekend or holiday), increment the workdays count
6803
- if (!isWeekend && !isHoliday) {
6804
- workdays++;
6805
- }
6806
- }
6807
-
6808
- return workdays;
6809
- };
6810
-
6746
+ */
6747
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
6748
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6749
+
6750
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6751
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6752
+ }
6753
+
6754
+ var startDateObj = new Date(start_date);
6755
+ var endDateObj = new Date(end_date);
6756
+
6757
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6758
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6759
+ }
6760
+
6761
+ if (startDateObj > endDateObj) {
6762
+ throw new Error('Start date should be earlier than or equal to end date.');
6763
+ }
6764
+
6765
+ var workdays = 0;
6766
+
6767
+ // Iterate through each day in the date range
6768
+
6769
+ var _loop = function _loop(currentDate) {
6770
+ // Check if the current day is a weekend (Saturday or Sunday)
6771
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6772
+
6773
+ // Check if the current day is a holiday
6774
+ var isHoliday = holidays.some(function (holiday) {
6775
+ var holidayDate = new Date(holiday);
6776
+ return currentDate.toDateString() === holidayDate.toDateString();
6777
+ });
6778
+
6779
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6780
+ if (!isWeekend && !isHoliday) {
6781
+ workdays++;
6782
+ }
6783
+ };
6784
+
6785
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6786
+ _loop(currentDate);
6787
+ }
6788
+
6789
+ return workdays;
6790
+ };
6791
+
6811
6792
  /**
6812
6793
  * 日期加减天数
6813
6794
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6814
6795
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6815
6796
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6816
- */
6817
- const dateAddDays = function (start_date, days) {
6818
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6819
- throw new Error(
6820
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6821
- );
6822
- }
6823
-
6824
- const startDateObj = new Date(start_date);
6825
- if (isNaN(startDateObj.getTime())) {
6826
- throw new Error(
6827
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6828
- );
6829
- }
6830
-
6831
- const resultDateObj = new Date(startDateObj);
6832
- resultDateObj.setDate(resultDateObj.getDate() + days);
6833
-
6834
- const resultYear = resultDateObj.getFullYear();
6835
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6836
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6837
-
6838
- return `${resultYear}-${resultMonth}-${resultDay}`;
6839
- };
6840
-
6797
+ */
6798
+ var dateAddDays = function dateAddDays(start_date, days) {
6799
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6800
+ 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.");
6801
+ }
6802
+
6803
+ var startDateObj = new Date(start_date);
6804
+ if (isNaN(startDateObj.getTime())) {
6805
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6806
+ }
6807
+
6808
+ var resultDateObj = new Date(startDateObj);
6809
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6810
+
6811
+ var resultYear = resultDateObj.getFullYear();
6812
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6813
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6814
+
6815
+ return resultYear + '-' + resultMonth + '-' + resultDay;
6816
+ };
6817
+
6841
6818
  /**
6842
6819
  * 计算两个日期之间的差值
6843
6820
  * @date 2023年12月14日
@@ -6845,182 +6822,180 @@ const dateAddDays = function (start_date, days) {
6845
6822
  * @param {String} end_date - 结束日期字符串
6846
6823
  * @param {String} unit - 单位:year/month/day
6847
6824
  * @returns {Number} 差值
6848
- */
6849
- const dateDiff = function (start_date, end_date, unit = 'day') {
6850
- // Assuming date strings are in "YYYY-MM-DD" format
6851
- var startDate = new Date(start_date);
6852
- var endDate = new Date(end_date);
6853
-
6854
- // If the date is invalid, return 0
6855
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6856
- return 0;
6857
- }
6858
-
6859
- if (unit === 'year') {
6860
- return endDate.getFullYear() - startDate.getFullYear();
6861
- } else if (unit === 'month') {
6862
- return (
6863
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
6864
- (endDate.getMonth() - startDate.getMonth())
6865
- );
6866
- } else {
6867
- // Default to day
6868
- var timeDifference = endDate - startDate;
6869
- // Calculate days (86400000 milliseconds per day)
6870
- return Math.floor(timeDifference / 86400000);
6871
- }
6872
- };
6873
-
6825
+ */
6826
+ var dateDiff = function dateDiff(start_date, end_date) {
6827
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6828
+
6829
+ // Assuming date strings are in "YYYY-MM-DD" format
6830
+ var startDate = new Date(start_date);
6831
+ var endDate = new Date(end_date);
6832
+
6833
+ // If the date is invalid, return 0
6834
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6835
+ return 0;
6836
+ }
6837
+
6838
+ if (unit === 'year') {
6839
+ return endDate.getFullYear() - startDate.getFullYear();
6840
+ } else if (unit === 'month') {
6841
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
6842
+ } else {
6843
+ // Default to day
6844
+ var timeDifference = endDate - startDate;
6845
+ // Calculate days (86400000 milliseconds per day)
6846
+ return Math.floor(timeDifference / 86400000);
6847
+ }
6848
+ };
6849
+
6874
6850
  /**
6875
6851
  * 获取月份中的日期
6876
6852
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
6877
6853
  * @returns {number} 月份中的日期(1-31)
6878
- */
6879
- const dayOfMonth = function (date) {
6880
- if (typeof date !== 'string') {
6881
- throw new Error(
6882
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
6883
- );
6884
- }
6885
-
6886
- const dateObj = new Date(date);
6887
- if (isNaN(dateObj.getTime())) {
6888
- throw new Error(
6889
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6890
- );
6891
- }
6892
-
6893
- return dateObj.getDate();
6894
- };
6895
-
6854
+ */
6855
+ var dayOfMonth = function dayOfMonth(date) {
6856
+ if (typeof date !== 'string') {
6857
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6858
+ }
6859
+
6860
+ var dateObj = new Date(date);
6861
+ if (isNaN(dateObj.getTime())) {
6862
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6863
+ }
6864
+
6865
+ return dateObj.getDate();
6866
+ };
6867
+
6896
6868
  /**
6897
6869
  * 获取当前日期
6898
6870
  * @date 2022年5月7日
6899
6871
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
6900
6872
  * @returns {string} 当前日期的格式化字符串
6901
- */
6902
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
6903
- return formatDate(new Date(), format);
6904
- };
6905
-
6873
+ */
6874
+ var getCurrentDate = function getCurrentDate() {
6875
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
6876
+
6877
+ return formatDate(new Date(), format);
6878
+ };
6879
+
6906
6880
  /**
6907
6881
  * 获取当前日期时间
6908
6882
  * @date 2022年5月7日
6909
6883
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
6910
6884
  * @returns {string} 当前日期时间的格式化字符串
6911
- */
6912
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
6913
- return formatDate(new Date(), format);
6914
- };
6915
-
6885
+ */
6886
+ var getCurrentDateTime = function getCurrentDateTime() {
6887
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
6888
+
6889
+ return formatDate(new Date(), format);
6890
+ };
6891
+
6916
6892
  /**
6917
6893
  * 获取小时
6918
6894
  * @date 2022年5月7日
6919
6895
  * @param {Date|string} [date] - 日期对象或日期字符串
6920
6896
  * @returns {number} 小时数(0-23)
6921
- */
6922
- const getHour = function (date) {
6923
- if (!date) {
6924
- return new Date().getHours();
6925
- }
6926
- if (typeof date === 'string') {
6927
- date = new Date(date);
6928
- }
6929
- return date.getHours();
6930
- };
6931
-
6897
+ */
6898
+ var getHour = function getHour(date) {
6899
+ if (!date) {
6900
+ return new Date().getHours();
6901
+ }
6902
+ if (typeof date === 'string') {
6903
+ date = new Date(date);
6904
+ }
6905
+ return date.getHours();
6906
+ };
6907
+
6932
6908
  /**
6933
6909
  * 获取分钟
6934
6910
  * @date 2022年5月7日
6935
6911
  * @param {Date|string} [date] - 日期对象或日期字符串
6936
6912
  * @returns {number} 分钟数(0-59)
6937
- */
6938
- const getMinute = function (date) {
6939
- if (!date) {
6940
- return new Date().getMinutes();
6941
- }
6942
- if (typeof date === 'string') {
6943
- date = new Date(date);
6944
- }
6945
- return date.getMinutes();
6946
- };
6947
-
6913
+ */
6914
+ var getMinute = function getMinute(date) {
6915
+ if (!date) {
6916
+ return new Date().getMinutes();
6917
+ }
6918
+ if (typeof date === 'string') {
6919
+ date = new Date(date);
6920
+ }
6921
+ return date.getMinutes();
6922
+ };
6923
+
6948
6924
  /**
6949
6925
  * 获取月份
6950
6926
  * @date 2022年5月7日
6951
6927
  * @param {Date|string} [date] - 日期对象或日期字符串
6952
6928
  * @returns {number} 月份数(1-12)
6953
- */
6954
- const getMonth = function (date) {
6955
- if (!date) {
6956
- return new Date().getMonth() + 1;
6957
- }
6958
- if (typeof date === 'string') {
6959
- date = new Date(date);
6960
- }
6961
- return date.getMonth() + 1;
6962
- };
6963
-
6929
+ */
6930
+ var getMonth = function getMonth(date) {
6931
+ if (!date) {
6932
+ return new Date().getMonth() + 1;
6933
+ }
6934
+ if (typeof date === 'string') {
6935
+ date = new Date(date);
6936
+ }
6937
+ return date.getMonth() + 1;
6938
+ };
6939
+
6964
6940
  /**
6965
6941
  * 获取秒
6966
6942
  * @date 2022年5月7日
6967
6943
  * @param {Date|string} [date] - 日期对象或日期字符串
6968
6944
  * @returns {number} 秒数(0-59)
6969
- */
6970
- const getSecond = function (date) {
6971
- if (!date) {
6972
- return new Date().getSeconds();
6973
- }
6974
- if (typeof date === 'string') {
6975
- date = new Date(date);
6976
- }
6977
- return date.getSeconds();
6978
- };
6979
-
6945
+ */
6946
+ var getSecond = function getSecond(date) {
6947
+ if (!date) {
6948
+ return new Date().getSeconds();
6949
+ }
6950
+ if (typeof date === 'string') {
6951
+ date = new Date(date);
6952
+ }
6953
+ return date.getSeconds();
6954
+ };
6955
+
6980
6956
  /**
6981
6957
  * 获取星期几
6982
6958
  * @date 2022年5月7日
6983
6959
  * @param {Date|string} [date] - 日期对象或日期字符串
6984
6960
  * @returns {number} 星期几(0-6,0表示星期日)
6985
- */
6986
- const getWeekday = function (date) {
6987
- if (!date) {
6988
- return new Date().getDay();
6989
- }
6990
- if (typeof date === 'string') {
6991
- date = new Date(date);
6992
- }
6993
- return date.getDay();
6994
- };
6995
-
6996
-
6961
+ */
6962
+ var getWeekday = function getWeekday(date) {
6963
+ if (!date) {
6964
+ return new Date().getDay();
6965
+ }
6966
+ if (typeof date === 'string') {
6967
+ date = new Date(date);
6968
+ }
6969
+ return date.getDay();
6970
+ };
6971
+
6997
6972
  /**
6998
6973
  * @desc 获取上午/下午/晚上
6999
6974
  * @author huangbo
7000
6975
  * @date 2022年5月7日
7001
6976
  * @param {String} [time] - 时间
7002
- **/
7003
- const timeCycle = function (time) {
7004
- let hour = 0;
7005
- if (!time) {
7006
- hour = new Date().getHours();
7007
- } else if (typeof time === 'string') {
7008
- // 从时间字符串中提取小时
7009
- const match = time.match(/^(\d{1,2})/);
7010
- if (match) {
7011
- hour = parseInt(match[1], 10);
7012
- }
7013
- } else if (typeof time === 'number') {
7014
- hour = time;
7015
- }
7016
- // 判断时间段
7017
- if (hour >= 5 && hour < 12) {
7018
- return '上午';
7019
- } else if (hour >= 12 && hour < 18) {
7020
- return '下午';
7021
- } else {
7022
- return '晚上';
7023
- }
6977
+ **/
6978
+ var timeCycle = function timeCycle(time) {
6979
+ var hour = 0;
6980
+ if (!time) {
6981
+ hour = new Date().getHours();
6982
+ } else if (typeof time === 'string') {
6983
+ // 从时间字符串中提取小时
6984
+ var match = time.match(/^(\d{1,2})/);
6985
+ if (match) {
6986
+ hour = parseInt(match[1], 10);
6987
+ }
6988
+ } else if (typeof time === 'number') {
6989
+ hour = time;
6990
+ }
6991
+ // 判断时间段
6992
+ if (hour >= 5 && hour < 12) {
6993
+ return '上午';
6994
+ } else if (hour >= 12 && hour < 18) {
6995
+ return '下午';
6996
+ } else {
6997
+ return '晚上';
6998
+ }
7024
6999
  };
7025
7000
 
7026
7001
  /***/ }),
@@ -7032,7 +7007,14 @@ module.exports = require("eoss/lib/message-box");
7032
7007
 
7033
7008
  /***/ }),
7034
7009
 
7035
- /***/ 88:
7010
+ /***/ 9:
7011
+ /***/ (function(module, exports) {
7012
+
7013
+ module.exports = require("eoss/lib/message");
7014
+
7015
+ /***/ }),
7016
+
7017
+ /***/ 90:
7036
7018
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
7037
7019
 
7038
7020
  "use strict";
@@ -7730,7 +7712,7 @@ var component = Object(componentNormalizer["a" /* default */])(
7730
7712
 
7731
7713
  /***/ }),
7732
7714
 
7733
- /***/ 89:
7715
+ /***/ 91:
7734
7716
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
7735
7717
 
7736
7718
  "use strict";
@@ -8140,13 +8122,6 @@ var component = Object(componentNormalizer["a" /* default */])(
8140
8122
 
8141
8123
  /* harmony default export */ var checkbox_button = __webpack_exports__["a"] = (component.exports);
8142
8124
 
8143
- /***/ }),
8144
-
8145
- /***/ 9:
8146
- /***/ (function(module, exports) {
8147
-
8148
- module.exports = require("eoss/lib/message");
8149
-
8150
8125
  /***/ })
8151
8126
 
8152
8127
  /******/ });