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/steps.js CHANGED
@@ -136,7 +136,7 @@ module.exports =
136
136
  /******/
137
137
  /******/
138
138
  /******/ // Load entry module and return exports
139
- /******/ return __webpack_require__(__webpack_require__.s = 258);
139
+ /******/ return __webpack_require__(__webpack_require__.s = 265);
140
140
  /******/ })
141
141
  /************************************************************************/
142
142
  /******/ ({
@@ -3339,7 +3339,7 @@ var warning = function warning(content, _callback3) {
3339
3339
 
3340
3340
  /***/ }),
3341
3341
 
3342
- /***/ 112:
3342
+ /***/ 114:
3343
3343
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3344
3344
 
3345
3345
  "use strict";
@@ -3653,7 +3653,7 @@ var icon_ = __webpack_require__(26);
3653
3653
  var icon_default = /*#__PURE__*/__webpack_require__.n(icon_);
3654
3654
 
3655
3655
  // EXTERNAL MODULE: ./src/components/field-render.vue + 4 modules
3656
- var field_render = __webpack_require__(77);
3656
+ var field_render = __webpack_require__(78);
3657
3657
 
3658
3658
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/steps/src/step.vue?vue&type=script&lang=js&
3659
3659
  //
@@ -4277,7 +4277,14 @@ module.exports = require("vue");
4277
4277
 
4278
4278
  /***/ }),
4279
4279
 
4280
- /***/ 258:
4280
+ /***/ 26:
4281
+ /***/ (function(module, exports) {
4282
+
4283
+ module.exports = require("eoss/lib/icon");
4284
+
4285
+ /***/ }),
4286
+
4287
+ /***/ 265:
4281
4288
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4282
4289
 
4283
4290
  "use strict";
@@ -4334,7 +4341,7 @@ render._withStripped = true
4334
4341
  var migrating = __webpack_require__(46);
4335
4342
 
4336
4343
  // EXTERNAL MODULE: ./packages/steps/src/step.vue + 4 modules
4337
- var step = __webpack_require__(112);
4344
+ var step = __webpack_require__(114);
4338
4345
 
4339
4346
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/steps/src/steps.vue?vue&type=script&lang=js&
4340
4347
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
@@ -4589,13 +4596,6 @@ steps.install = function (Vue) {
4589
4596
 
4590
4597
  /***/ }),
4591
4598
 
4592
- /***/ 26:
4593
- /***/ (function(module, exports) {
4594
-
4595
- module.exports = require("eoss/lib/icon");
4596
-
4597
- /***/ }),
4598
-
4599
4599
  /***/ 3:
4600
4600
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4601
4601
 
@@ -4861,42 +4861,42 @@ module.exports = require("eoss/lib/radio-group");
4861
4861
 
4862
4862
  /***/ }),
4863
4863
 
4864
- /***/ 49:
4864
+ /***/ 50:
4865
4865
  /***/ (function(module, exports) {
4866
4866
 
4867
4867
  module.exports = require("eoss/lib/upload");
4868
4868
 
4869
4869
  /***/ }),
4870
4870
 
4871
- /***/ 50:
4871
+ /***/ 51:
4872
4872
  /***/ (function(module, exports) {
4873
4873
 
4874
4874
  module.exports = require("eoss/lib/tree");
4875
4875
 
4876
4876
  /***/ }),
4877
4877
 
4878
- /***/ 54:
4878
+ /***/ 56:
4879
4879
  /***/ (function(module, exports) {
4880
4880
 
4881
4881
  module.exports = require("eoss/lib/input-number");
4882
4882
 
4883
4883
  /***/ }),
4884
4884
 
4885
- /***/ 64:
4885
+ /***/ 65:
4886
4886
  /***/ (function(module, exports) {
4887
4887
 
4888
4888
  module.exports = require("eoss/lib/switch");
4889
4889
 
4890
4890
  /***/ }),
4891
4891
 
4892
- /***/ 65:
4892
+ /***/ 66:
4893
4893
  /***/ (function(module, exports) {
4894
4894
 
4895
4895
  module.exports = require("eoss/lib/color-picker");
4896
4896
 
4897
4897
  /***/ }),
4898
4898
 
4899
- /***/ 66:
4899
+ /***/ 67:
4900
4900
  /***/ (function(module, exports) {
4901
4901
 
4902
4902
  module.exports = require("eoss/lib/selector");
@@ -4953,759 +4953,736 @@ module.exports = require("eoss/lib/selector");
4953
4953
  /* unused harmony export getSecond */
4954
4954
  /* unused harmony export getWeekday */
4955
4955
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4956
- /* Modified from https://github.com/taylorhakes/fecha
4957
- *
4958
- * The MIT License (MIT)
4959
- *
4960
- * Copyright (c) 2015 Taylor Hakes
4961
- *
4962
- * Permission is hereby granted, free of charge, to any person obtaining a copy
4963
- * of this software and associated documentation files (the "Software"), to deal
4964
- * in the Software without restriction, including without limitation the rights
4965
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4966
- * copies of the Software, and to permit persons to whom the Software is
4967
- * furnished to do so, subject to the following conditions:
4968
- *
4969
- * The above copyright notice and this permission notice shall be included in all
4970
- * copies or substantial portions of the Software.
4971
- *
4972
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4973
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4974
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4975
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4976
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4977
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4978
- * SOFTWARE.
4979
- */
4980
-
4981
- /*eslint-disable*/
4982
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
4983
-
4984
-
4956
+
4957
+
4985
4958
  /**
4986
4959
  * Parse or format dates
4987
4960
  * @class fecha
4988
- */
4989
- const fecha = {};
4990
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4991
- const twoDigits = '\\d\\d?';
4992
- const threeDigits = '\\d{3}';
4993
- const fourDigits = '\\d{4}';
4994
- const word = '[^\\s]+';
4995
- const literal = /\[([^]*?)\]/gm;
4996
- const noop = function () {};
4997
-
4998
- function regexEscape(str) {
4999
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5000
- }
5001
-
5002
- function shorten(arr, sLen) {
5003
- const newArr = [];
5004
- for (let i = 0, len = arr.length; i < len; i++) {
5005
- newArr.push(arr[i].substr(0, sLen));
5006
- }
5007
- return newArr;
5008
- }
5009
-
5010
- function monthUpdate() {
5011
- return function (d, v) {
5012
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5013
- if (~index) {
5014
- d.month = index;
5015
- }
5016
- };
5017
- }
5018
-
5019
- function pad(val, len) {
5020
- val = String(val);
5021
- len = len || 2;
5022
- while (val.length < len) {
5023
- val = '0' + val;
5024
- }
5025
- return val;
5026
- }
5027
-
5028
- // 直接使用中文日期名称常量
5029
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5030
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5031
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5032
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5033
- const amPm = ['上午', '下午'];
5034
- const DoFn = function DoFn(D) {
5035
- return D + '日';
5036
- };
5037
-
5038
- const formatFlags = {
5039
- D: function(dateObj) {
5040
- return dateObj.getDay();
5041
- },
5042
- DD: function(dateObj) {
5043
- return pad(dateObj.getDay());
5044
- },
5045
- Do: function(dateObj) {
5046
- return DoFn(dateObj.getDate());
5047
- },
5048
- d: function(dateObj) {
5049
- return dateObj.getDate();
5050
- },
5051
- dd: function(dateObj) {
5052
- return pad(dateObj.getDate());
5053
- },
5054
- ddd: function(dateObj) {
5055
- return dayNamesShort[dateObj.getDay()];
5056
- },
5057
- dddd: function(dateObj) {
5058
- return dayNames[dateObj.getDay()];
5059
- },
5060
- M: function(dateObj) {
5061
- return dateObj.getMonth() + 1;
5062
- },
5063
- MM: function(dateObj) {
5064
- return pad(dateObj.getMonth() + 1);
5065
- },
5066
- MMM: function(dateObj) {
5067
- return monthNamesShort[dateObj.getMonth()];
5068
- },
5069
- MMMM: function(dateObj) {
5070
- return monthNames[dateObj.getMonth()];
5071
- },
5072
- yy: function(dateObj) {
5073
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5074
- },
5075
- yyyy: function(dateObj) {
5076
- return pad(dateObj.getFullYear(), 4);
5077
- },
5078
- h: function(dateObj) {
5079
- return dateObj.getHours() % 12 || 12;
5080
- },
5081
- hh: function(dateObj) {
5082
- return pad(dateObj.getHours() % 12 || 12);
5083
- },
5084
- H: function(dateObj) {
5085
- return dateObj.getHours();
5086
- },
5087
- HH: function(dateObj) {
5088
- return pad(dateObj.getHours());
5089
- },
5090
- m: function(dateObj) {
5091
- return dateObj.getMinutes();
5092
- },
5093
- mm: function(dateObj) {
5094
- return pad(dateObj.getMinutes());
5095
- },
5096
- s: function(dateObj) {
5097
- return dateObj.getSeconds();
5098
- },
5099
- ss: function(dateObj) {
5100
- return pad(dateObj.getSeconds());
5101
- },
5102
- S: function(dateObj) {
5103
- return Math.round(dateObj.getMilliseconds() / 100);
5104
- },
5105
- SS: function(dateObj) {
5106
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5107
- },
5108
- SSS: function(dateObj) {
5109
- return pad(dateObj.getMilliseconds(), 3);
5110
- },
5111
- a: function(dateObj) {
5112
- return dateObj.getHours() < 12 ? '上午' : '下午';
5113
- },
5114
- A: function(dateObj) {
5115
- return dateObj.getHours() < 12 ? '上午' : '下午';
5116
- },
5117
- ZZ: function(dateObj) {
5118
- const o = dateObj.getTimezoneOffset();
5119
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5120
- }
5121
- };
5122
-
5123
- const parseFlags = {
5124
- d: [twoDigits, function (d, v) {
5125
- d.day = v;
5126
- }],
5127
- Do: [twoDigits + word, function (d, v) {
5128
- d.day = parseInt(v, 10);
5129
- }],
5130
- M: [twoDigits, function (d, v) {
5131
- d.month = v - 1;
5132
- }],
5133
- yy: [twoDigits, function (d, v) {
5134
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5135
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5136
- }],
5137
- h: [twoDigits, function (d, v) {
5138
- d.hour = v;
5139
- }],
5140
- m: [twoDigits, function (d, v) {
5141
- d.minute = v;
5142
- }],
5143
- s: [twoDigits, function (d, v) {
5144
- d.second = v;
5145
- }],
5146
- yyyy: [fourDigits, function (d, v) {
5147
- d.year = v;
5148
- }],
5149
- S: ['\\d', function (d, v) {
5150
- d.millisecond = v * 100;
5151
- }],
5152
- SS: ['\\d{2}', function (d, v) {
5153
- d.millisecond = v * 10;
5154
- }],
5155
- SSS: [threeDigits, function (d, v) {
5156
- d.millisecond = v;
5157
- }],
5158
- D: [twoDigits, noop],
5159
- ddd: [word, noop],
5160
- MMM: [word, monthUpdate('monthNamesShort')],
5161
- MMMM: [word, monthUpdate('monthNames')],
5162
- a: [word, function (d, v) {
5163
- const val = v.toLowerCase();
5164
- if (val === '上午') {
5165
- d.isPm = false;
5166
- } else if (val === '下午') {
5167
- d.isPm = true;
5168
- }
5169
- }],
5170
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5171
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5172
-
5173
- if (parts) {
5174
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5175
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5176
- }
5177
- }]
5178
- };
5179
- parseFlags.dd = parseFlags.d;
5180
- parseFlags.dddd = parseFlags.ddd;
5181
- parseFlags.DD = parseFlags.D;
5182
- parseFlags.mm = parseFlags.m;
5183
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5184
- parseFlags.MM = parseFlags.M;
5185
- parseFlags.ss = parseFlags.s;
5186
- parseFlags.A = parseFlags.a;
5187
-
5188
-
5189
- // Some common format strings
5190
- fecha.masks = {
5191
- default: 'ddd MMM dd yyyy HH:mm:ss',
5192
- shortDate: 'M/D/yy',
5193
- mediumDate: 'MMM d, yyyy',
5194
- longDate: 'MMMM d, yyyy',
5195
- fullDate: 'dddd, MMMM d, yyyy',
5196
- shortTime: 'HH:mm',
5197
- mediumTime: 'HH:mm:ss',
5198
- longTime: 'HH:mm:ss.SSS'
5199
- };
5200
-
4961
+ */
4962
+ var fecha = {};
4963
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4964
+ var twoDigits = '\\d\\d?';
4965
+ var threeDigits = '\\d{3}';
4966
+ var fourDigits = '\\d{4}';
4967
+ var word = '[^\\s]+';
4968
+ var literal = /\[([^]*?)\]/gm;
4969
+ var noop = function noop() {};
4970
+
4971
+ function regexEscape(str) {
4972
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4973
+ }
4974
+
4975
+ function shorten(arr, sLen) {
4976
+ var newArr = [];
4977
+ for (var i = 0, len = arr.length; i < len; i++) {
4978
+ newArr.push(arr[i].substr(0, sLen));
4979
+ }
4980
+ return newArr;
4981
+ }
4982
+
4983
+ function monthUpdate() {
4984
+ return function (d, v) {
4985
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4986
+ if (~index) {
4987
+ d.month = index;
4988
+ }
4989
+ };
4990
+ }
4991
+
4992
+ function pad(val, len) {
4993
+ val = String(val);
4994
+ len = len || 2;
4995
+ while (val.length < len) {
4996
+ val = '0' + val;
4997
+ }
4998
+ return val;
4999
+ }
5000
+
5001
+ // 直接使用中文日期名称常量
5002
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5003
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5004
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5005
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5006
+ var amPm = ['上午', '下午'];
5007
+ var DoFn = function DoFn(D) {
5008
+ return D + '日';
5009
+ };
5010
+
5011
+ var formatFlags = {
5012
+ D: function D(dateObj) {
5013
+ return dateObj.getDay();
5014
+ },
5015
+ DD: function DD(dateObj) {
5016
+ return pad(dateObj.getDay());
5017
+ },
5018
+ Do: function Do(dateObj) {
5019
+ return DoFn(dateObj.getDate());
5020
+ },
5021
+ d: function d(dateObj) {
5022
+ return dateObj.getDate();
5023
+ },
5024
+ dd: function dd(dateObj) {
5025
+ return pad(dateObj.getDate());
5026
+ },
5027
+ ddd: function ddd(dateObj) {
5028
+ return dayNamesShort[dateObj.getDay()];
5029
+ },
5030
+ dddd: function dddd(dateObj) {
5031
+ return dayNames[dateObj.getDay()];
5032
+ },
5033
+ M: function M(dateObj) {
5034
+ return dateObj.getMonth() + 1;
5035
+ },
5036
+ MM: function MM(dateObj) {
5037
+ return pad(dateObj.getMonth() + 1);
5038
+ },
5039
+ MMM: function MMM(dateObj) {
5040
+ return monthNamesShort[dateObj.getMonth()];
5041
+ },
5042
+ MMMM: function MMMM(dateObj) {
5043
+ return monthNames[dateObj.getMonth()];
5044
+ },
5045
+ yy: function yy(dateObj) {
5046
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5047
+ },
5048
+ yyyy: function yyyy(dateObj) {
5049
+ return pad(dateObj.getFullYear(), 4);
5050
+ },
5051
+ h: function h(dateObj) {
5052
+ return dateObj.getHours() % 12 || 12;
5053
+ },
5054
+ hh: function hh(dateObj) {
5055
+ return pad(dateObj.getHours() % 12 || 12);
5056
+ },
5057
+ H: function H(dateObj) {
5058
+ return dateObj.getHours();
5059
+ },
5060
+ HH: function HH(dateObj) {
5061
+ return pad(dateObj.getHours());
5062
+ },
5063
+ m: function m(dateObj) {
5064
+ return dateObj.getMinutes();
5065
+ },
5066
+ mm: function mm(dateObj) {
5067
+ return pad(dateObj.getMinutes());
5068
+ },
5069
+ s: function s(dateObj) {
5070
+ return dateObj.getSeconds();
5071
+ },
5072
+ ss: function ss(dateObj) {
5073
+ return pad(dateObj.getSeconds());
5074
+ },
5075
+ S: function S(dateObj) {
5076
+ return Math.round(dateObj.getMilliseconds() / 100);
5077
+ },
5078
+ SS: function SS(dateObj) {
5079
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5080
+ },
5081
+ SSS: function SSS(dateObj) {
5082
+ return pad(dateObj.getMilliseconds(), 3);
5083
+ },
5084
+ a: function a(dateObj) {
5085
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5086
+ },
5087
+ A: function A(dateObj) {
5088
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5089
+ },
5090
+ ZZ: function ZZ(dateObj) {
5091
+ var o = dateObj.getTimezoneOffset();
5092
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5093
+ }
5094
+ };
5095
+
5096
+ var parseFlags = {
5097
+ d: [twoDigits, function (d, v) {
5098
+ d.day = v;
5099
+ }],
5100
+ Do: [twoDigits + word, function (d, v) {
5101
+ d.day = parseInt(v, 10);
5102
+ }],
5103
+ M: [twoDigits, function (d, v) {
5104
+ d.month = v - 1;
5105
+ }],
5106
+ yy: [twoDigits, function (d, v) {
5107
+ var da = new Date(),
5108
+ cent = +('' + da.getFullYear()).substr(0, 2);
5109
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5110
+ }],
5111
+ h: [twoDigits, function (d, v) {
5112
+ d.hour = v;
5113
+ }],
5114
+ m: [twoDigits, function (d, v) {
5115
+ d.minute = v;
5116
+ }],
5117
+ s: [twoDigits, function (d, v) {
5118
+ d.second = v;
5119
+ }],
5120
+ yyyy: [fourDigits, function (d, v) {
5121
+ d.year = v;
5122
+ }],
5123
+ S: ['\\d', function (d, v) {
5124
+ d.millisecond = v * 100;
5125
+ }],
5126
+ SS: ['\\d{2}', function (d, v) {
5127
+ d.millisecond = v * 10;
5128
+ }],
5129
+ SSS: [threeDigits, function (d, v) {
5130
+ d.millisecond = v;
5131
+ }],
5132
+ D: [twoDigits, noop],
5133
+ ddd: [word, noop],
5134
+ MMM: [word, monthUpdate('monthNamesShort')],
5135
+ MMMM: [word, monthUpdate('monthNames')],
5136
+ a: [word, function (d, v) {
5137
+ var val = v.toLowerCase();
5138
+ if (val === '上午') {
5139
+ d.isPm = false;
5140
+ } else if (val === '下午') {
5141
+ d.isPm = true;
5142
+ }
5143
+ }],
5144
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5145
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
5146
+ minutes = void 0;
5147
+
5148
+ if (parts) {
5149
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5150
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5151
+ }
5152
+ }]
5153
+ };
5154
+ parseFlags.dd = parseFlags.d;
5155
+ parseFlags.dddd = parseFlags.ddd;
5156
+ parseFlags.DD = parseFlags.D;
5157
+ parseFlags.mm = parseFlags.m;
5158
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5159
+ parseFlags.MM = parseFlags.M;
5160
+ parseFlags.ss = parseFlags.s;
5161
+ parseFlags.A = parseFlags.a;
5162
+
5163
+ // Some common format strings
5164
+ fecha.masks = {
5165
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5166
+ shortDate: 'M/D/yy',
5167
+ mediumDate: 'MMM d, yyyy',
5168
+ longDate: 'MMMM d, yyyy',
5169
+ fullDate: 'dddd, MMMM d, yyyy',
5170
+ shortTime: 'HH:mm',
5171
+ mediumTime: 'HH:mm:ss',
5172
+ longTime: 'HH:mm:ss.SSS'
5173
+ };
5174
+
5201
5175
  /***
5202
5176
  * Format a date
5203
5177
  * @method format
5204
5178
  * @param {Date|number} dateObj
5205
5179
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5206
- */
5207
- fecha.format = function (dateObj, mask) {
5208
- if (typeof dateObj === 'number') {
5209
- dateObj = new Date(dateObj);
5210
- }
5211
-
5212
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5213
- throw new Error('Invalid Date in fecha.format');
5214
- }
5215
-
5216
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5217
-
5218
- const literals = [];
5219
-
5220
- // Make literals inactive by replacing them with ??
5221
- mask = mask.replace(literal, function($0, $1) {
5222
- literals.push($1);
5223
- return '@@@';
5224
- });
5225
- // Apply formatting rules
5226
- mask = mask.replace(token, function ($0) {
5227
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5228
- });
5229
- // Inline literal values back into the formatted value
5230
- return mask.replace(/@@@/g, function() {
5231
- return literals.shift();
5232
- });
5233
- };
5234
-
5180
+ */
5181
+ fecha.format = function (dateObj, mask) {
5182
+ if (typeof dateObj === 'number') {
5183
+ dateObj = new Date(dateObj);
5184
+ }
5185
+
5186
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5187
+ throw new Error('Invalid Date in fecha.format');
5188
+ }
5189
+
5190
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5191
+
5192
+ var literals = [];
5193
+
5194
+ // Make literals inactive by replacing them with ??
5195
+ mask = mask.replace(literal, function ($0, $1) {
5196
+ literals.push($1);
5197
+ return '@@@';
5198
+ });
5199
+ // Apply formatting rules
5200
+ mask = mask.replace(token, function ($0) {
5201
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5202
+ });
5203
+ // Inline literal values back into the formatted value
5204
+ return mask.replace(/@@@/g, function () {
5205
+ return literals.shift();
5206
+ });
5207
+ };
5208
+
5235
5209
  /**
5236
5210
  * Parse a date string into an object, changes - into /
5237
5211
  * @method parse
5238
5212
  * @param {string} dateStr Date string
5239
5213
  * @param {string} format Date parse format
5240
5214
  * @returns {Date|boolean}
5241
- */
5242
- fecha.parse = function (dateStr, format) {
5243
- if (typeof format !== 'string') {
5244
- throw new Error('Invalid format in fecha.parse');
5245
- }
5246
-
5247
- format = fecha.masks[format] || format;
5248
-
5249
- // Avoid regular expression denial of service, fail early for really long strings
5250
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5251
- if (dateStr.length > 1000) {
5252
- return null;
5253
- }
5254
-
5255
- const dateInfo = {};
5256
- const parseInfo = [];
5257
- const literals = [];
5258
- format = format.replace(literal, function($0, $1) {
5259
- literals.push($1);
5260
- return '@@@';
5261
- });
5262
- let newFormat = regexEscape(format).replace(token, function ($0) {
5263
- if (parseFlags[$0]) {
5264
- const info = parseFlags[$0];
5265
- parseInfo.push(info[1]);
5266
- return '(' + info[0] + ')';
5267
- }
5268
-
5269
- return $0;
5270
- });
5271
- newFormat = newFormat.replace(/@@@/g, function() {
5272
- return literals.shift();
5273
- });
5274
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
5275
- if (!matches) {
5276
- return null;
5277
- }
5278
-
5279
- for (let i = 1; i < matches.length; i++) {
5280
- parseInfo[i - 1](dateInfo, matches[i]);
5281
- }
5282
-
5283
- const today = new Date();
5284
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5285
- dateInfo.hour = +dateInfo.hour + 12;
5286
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5287
- dateInfo.hour = 0;
5288
- }
5289
-
5290
- let date;
5291
- if (dateInfo.timezoneOffset != null) {
5292
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5293
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5294
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5295
- } else {
5296
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5297
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5298
- }
5299
- return date;
5300
- };
5301
-
5302
- // 导出fecha对象
5303
-
5304
-
5305
- // 以下是从date-util.js合并的函数
5306
- const newArray = function(start, end) {
5307
- let result = [];
5308
- for (let i = start; i <= end; i++) {
5309
- result.push(i);
5310
- }
5311
- return result;
5312
- };
5313
-
5314
- const getSettings = () => {
5315
- return {
5316
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5317
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5318
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5319
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5320
- amPm: ['上午', '下午']
5321
- };
5322
- };
5323
-
5324
- const toDate = function(date) {
5325
- return isDate(date) ? new Date(date) : null;
5326
- };
5327
-
5328
- const isDate = function(date) {
5329
- if (date === null || date === undefined) return false;
5330
- if (isNaN(new Date(date).getTime())) return false;
5331
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5332
- return true;
5333
- };
5334
-
5335
- const isDateObject = function(val) {
5336
- return val instanceof Date;
5337
- };
5338
-
5339
- const formatDate = function (date, format = 'yyyy-MM-dd') {
5340
- // 处理多种输入类型
5341
- if (!date) return '';
5342
-
5343
- // 如果是时间戳,转成日期对象
5344
- if (typeof date === 'number') {
5345
- date = new Date(date);
5346
- }
5347
- // 如果是字符串,转成日期对象
5348
- if (typeof date === 'string') {
5349
- date = new Date(date);
5350
- }
5351
-
5352
- // 调用toDate进一步验证和转换
5353
- date = toDate(date);
5354
- if (!date) return '';
5355
-
5356
- // 兼容大写和小写的格式标记
5357
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5358
- const lowercaseFormat = format
5359
- .replace(/YYYY/g, 'yyyy')
5360
- .replace(/D/g, 'd')
5361
-
5362
- // 使用fecha库进行格式化,支持中文配置
5363
- const str = fecha.format(date, lowercaseFormat, getSettings());
5364
- return str;
5365
- };
5366
-
5367
- const parseDate = function(string, format) {
5368
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5369
- };
5370
-
5371
- const getDayCountOfMonth = function(year, month) {
5372
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5373
- return 30;
5374
- }
5375
-
5376
- if (month === 1) {
5377
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5378
- return 29;
5379
- } else {
5380
- return 28;
5381
- }
5382
- }
5383
-
5384
- return 31;
5385
- };
5386
-
5387
- const getDayCountOfYear = function(year) {
5388
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5389
- return isLeapYear ? 366 : 365;
5390
- };
5391
-
5392
- const getFirstDayOfMonth = function(date) {
5393
- const temp = new Date(date.getTime());
5394
- temp.setDate(1);
5395
- return temp.getDay();
5396
- };
5397
-
5398
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5399
- // {prev, next} Date should work for Daylight Saving Time
5400
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5401
- const prevDate = function(date, amount = 1) {
5402
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5403
- };
5404
-
5405
- const nextDate = function(date, amount = 1) {
5406
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5407
- };
5408
-
5409
- const getStartDateOfMonth = function(year, month) {
5410
- const result = new Date(year, month, 1);
5411
- const day = result.getDay();
5412
-
5413
- if (day === 0) {
5414
- return prevDate(result, 7);
5415
- } else {
5416
- return prevDate(result, day);
5417
- }
5418
- };
5419
-
5420
- const getWeekNumber = function(date) {
5421
- // 支持多种输入类型
5422
- if (!date||!isDate(date)) {
5423
- date = new Date();
5424
- }
5425
- if (typeof date === 'string') {
5426
- date = new Date(date);
5427
- }
5428
-
5429
- // 验证日期有效性
5430
- if (!isDate(date)) return null;
5431
-
5432
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5433
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5434
- // 将星期日的星期数设为7
5435
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5436
- // 获取当年的第一天
5437
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5438
- // 计算到最近的星期四的完整周数
5439
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5440
- // 返回周数
5441
- return weekNo;
5442
- };
5443
-
5444
- const getRangeHours = function(ranges) {
5445
- const hours = [];
5446
- let disabledHours = [];
5447
-
5448
- (ranges || []).forEach(range => {
5449
- const value = range.map(date => date.getHours());
5450
-
5451
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5452
- });
5453
-
5454
- if (disabledHours.length) {
5455
- for (let i = 0; i < 24; i++) {
5456
- hours[i] = disabledHours.indexOf(i) === -1;
5457
- }
5458
- } else {
5459
- for (let i = 0; i < 24; i++) {
5460
- hours[i] = false;
5461
- }
5462
- }
5463
-
5464
- return hours;
5465
- };
5466
-
5467
- const getPrevMonthLastDays = (date, amount) => {
5468
- if (amount <= 0) return [];
5469
- const temp = new Date(date.getTime());
5470
- temp.setDate(0);
5471
- const lastDay = temp.getDate();
5472
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
5473
- };
5474
-
5475
- const getMonthDays = (date) => {
5476
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5477
- const days = temp.getDate();
5478
- return range(days).map((_, index) => index + 1);
5479
- };
5480
-
5481
- function setRangeData(arr, start, end, value) {
5482
- for (let i = start; i < end; i++) {
5483
- arr[i] = value;
5484
- }
5485
- }
5486
-
5487
- const getRangeMinutes = function(ranges, hour) {
5488
- const minutes = new Array(60);
5489
-
5490
- if (ranges.length > 0) {
5491
- ranges.forEach(range => {
5492
- const start = range[0];
5493
- const end = range[1];
5494
- const startHour = start.getHours();
5495
- const startMinute = start.getMinutes();
5496
- const endHour = end.getHours();
5497
- const endMinute = end.getMinutes();
5498
- if (startHour === hour && endHour !== hour) {
5499
- setRangeData(minutes, startMinute, 60, true);
5500
- } else if (startHour === hour && endHour === hour) {
5501
- setRangeData(minutes, startMinute, endMinute + 1, true);
5502
- } else if (startHour !== hour && endHour === hour) {
5503
- setRangeData(minutes, 0, endMinute + 1, true);
5504
- } else if (startHour < hour && endHour > hour) {
5505
- setRangeData(minutes, 0, 60, true);
5506
- }
5507
- });
5508
- } else {
5509
- setRangeData(minutes, 0, 60, true);
5510
- }
5511
- return minutes;
5512
- };
5513
-
5514
- const range = function(n) {
5515
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5516
- return Array.apply(null, {length: n}).map((_, n) => n);
5517
- };
5518
-
5519
- const modifyDate = function(date, y, m, d) {
5520
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5521
- };
5522
-
5523
- const modifyTime = function(date, h, m, s) {
5524
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5525
- };
5526
-
5527
- const modifyWithTimeString = (date, time) => {
5528
- if (date == null || !time) {
5529
- return date;
5530
- }
5531
- time = parseDate(time, 'HH:mm:ss');
5532
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5533
- };
5534
-
5535
- const clearTime = function(date) {
5536
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5537
- };
5538
-
5539
- const clearMilliseconds = function(date) {
5540
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5541
- };
5542
-
5543
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5544
- // TODO: refactory a more elegant solution
5545
- if (ranges.length === 0) return date;
5546
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5547
- const ndate = normalizeDate(date);
5548
- const nranges = ranges.map(range => range.map(normalizeDate));
5549
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5550
-
5551
- let minDate = nranges[0][0];
5552
- let maxDate = nranges[0][0];
5553
-
5554
- nranges.forEach(nrange => {
5555
- minDate = new Date(Math.min(nrange[0], minDate));
5556
- maxDate = new Date(Math.max(nrange[1], minDate));
5557
- });
5558
-
5559
- const ret = ndate < minDate ? minDate : maxDate;
5560
- // preserve Year/Month/Date
5561
- return modifyDate(
5562
- ret,
5563
- date.getFullYear(),
5564
- date.getMonth(),
5565
- date.getDate()
5566
- );
5567
- };
5568
-
5569
- const timeWithinRange = function(date, selectableRange, format) {
5570
- const limitedDate = limitTimeRange(date, selectableRange, format);
5571
- return limitedDate.getTime() === date.getTime();
5572
- };
5573
-
5574
- const changeYearMonthAndClampDate = function(date, year, month) {
5575
- // clamp date to the number of days in `year`, `month`
5576
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5577
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5578
- return modifyDate(date, year, month, monthDate);
5579
- };
5580
-
5581
- const prevMonth = function(date) {
5582
- const year = date.getFullYear();
5583
- const month = date.getMonth();
5584
- return month === 0
5585
- ? changeYearMonthAndClampDate(date, year - 1, 11)
5586
- : changeYearMonthAndClampDate(date, year, month - 1);
5587
- };
5588
-
5589
- const nextMonth = function(date) {
5590
- const year = date.getFullYear();
5591
- const month = date.getMonth();
5592
- return month === 11
5593
- ? changeYearMonthAndClampDate(date, year + 1, 0)
5594
- : changeYearMonthAndClampDate(date, year, month + 1);
5595
- };
5596
-
5597
- const prevYear = function(date, amount = 1) {
5598
- const year = date.getFullYear();
5599
- const month = date.getMonth();
5600
- return changeYearMonthAndClampDate(date, year - amount, month);
5601
- };
5602
-
5603
- const nextYear = function(date, amount = 1) {
5604
- const year = date.getFullYear();
5605
- const month = date.getMonth();
5606
- return changeYearMonthAndClampDate(date, year + amount, month);
5607
- };
5608
-
5609
- const extractDateFormat = function(format) {
5610
- return format
5611
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
5612
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5613
- .trim();
5614
- };
5615
-
5616
- const extractTimeFormat = function(format) {
5617
- return format
5618
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5619
- .trim();
5620
- };
5621
-
5622
- const validateRangeInOneMonth = function(start, end) {
5623
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5624
- };
5625
-
5215
+ */
5216
+ fecha.parse = function (dateStr, format) {
5217
+ if (typeof format !== 'string') {
5218
+ throw new Error('Invalid format in fecha.parse');
5219
+ }
5220
+
5221
+ format = fecha.masks[format] || format;
5222
+
5223
+ // Avoid regular expression denial of service, fail early for really long strings
5224
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5225
+ if (dateStr.length > 1000) {
5226
+ return null;
5227
+ }
5228
+
5229
+ var dateInfo = {};
5230
+ var parseInfo = [];
5231
+ var literals = [];
5232
+ format = format.replace(literal, function ($0, $1) {
5233
+ literals.push($1);
5234
+ return '@@@';
5235
+ });
5236
+ var newFormat = regexEscape(format).replace(token, function ($0) {
5237
+ if (parseFlags[$0]) {
5238
+ var info = parseFlags[$0];
5239
+ parseInfo.push(info[1]);
5240
+ return '(' + info[0] + ')';
5241
+ }
5242
+
5243
+ return $0;
5244
+ });
5245
+ newFormat = newFormat.replace(/@@@/g, function () {
5246
+ return literals.shift();
5247
+ });
5248
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
5249
+ if (!matches) {
5250
+ return null;
5251
+ }
5252
+
5253
+ for (var i = 1; i < matches.length; i++) {
5254
+ parseInfo[i - 1](dateInfo, matches[i]);
5255
+ }
5256
+
5257
+ var today = new Date();
5258
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5259
+ dateInfo.hour = +dateInfo.hour + 12;
5260
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5261
+ dateInfo.hour = 0;
5262
+ }
5263
+
5264
+ var date = void 0;
5265
+ if (dateInfo.timezoneOffset != null) {
5266
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5267
+ 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));
5268
+ } else {
5269
+ 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);
5270
+ }
5271
+ return date;
5272
+ };
5273
+
5274
+ // 导出fecha对象
5275
+
5276
+
5277
+ // 以下是从date-util.js合并的函数
5278
+ var newArray = function newArray(start, end) {
5279
+ var result = [];
5280
+ for (var i = start; i <= end; i++) {
5281
+ result.push(i);
5282
+ }
5283
+ return result;
5284
+ };
5285
+
5286
+ var getSettings = function getSettings() {
5287
+ return {
5288
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5289
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5290
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5291
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5292
+ amPm: ['上午', '下午']
5293
+ };
5294
+ };
5295
+
5296
+ var toDate = function toDate(date) {
5297
+ return isDate(date) ? new Date(date) : null;
5298
+ };
5299
+
5300
+ var isDate = function isDate(date) {
5301
+ if (date === null || date === undefined) return false;
5302
+ if (isNaN(new Date(date).getTime())) return false;
5303
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5304
+ return true;
5305
+ };
5306
+
5307
+ var isDateObject = function isDateObject(val) {
5308
+ return val instanceof Date;
5309
+ };
5310
+
5311
+ var formatDate = function formatDate(date) {
5312
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5313
+
5314
+ // 处理多种输入类型
5315
+ if (!date) return '';
5316
+
5317
+ // 如果是时间戳,转成日期对象
5318
+ if (typeof date === 'number') {
5319
+ date = new Date(date);
5320
+ }
5321
+ // 如果是字符串,转成日期对象
5322
+ if (typeof date === 'string') {
5323
+ date = new Date(date);
5324
+ }
5325
+
5326
+ // 调用toDate进一步验证和转换
5327
+ date = toDate(date);
5328
+ if (!date) return '';
5329
+
5330
+ // 兼容大写和小写的格式标记
5331
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5332
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5333
+
5334
+ // 使用fecha库进行格式化,支持中文配置
5335
+ var str = fecha.format(date, lowercaseFormat, getSettings());
5336
+ return str;
5337
+ };
5338
+
5339
+ var parseDate = function parseDate(string, format) {
5340
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5341
+ };
5342
+
5343
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5344
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5345
+ return 30;
5346
+ }
5347
+
5348
+ if (month === 1) {
5349
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5350
+ return 29;
5351
+ } else {
5352
+ return 28;
5353
+ }
5354
+ }
5355
+
5356
+ return 31;
5357
+ };
5358
+
5359
+ var getDayCountOfYear = function getDayCountOfYear(year) {
5360
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5361
+ return isLeapYear ? 366 : 365;
5362
+ };
5363
+
5364
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5365
+ var temp = new Date(date.getTime());
5366
+ temp.setDate(1);
5367
+ return temp.getDay();
5368
+ };
5369
+
5370
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5371
+ // {prev, next} Date should work for Daylight Saving Time
5372
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5373
+ var prevDate = function prevDate(date) {
5374
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5375
+
5376
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5377
+ };
5378
+
5379
+ var nextDate = function nextDate(date) {
5380
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5381
+
5382
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5383
+ };
5384
+
5385
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5386
+ var result = new Date(year, month, 1);
5387
+ var day = result.getDay();
5388
+
5389
+ if (day === 0) {
5390
+ return prevDate(result, 7);
5391
+ } else {
5392
+ return prevDate(result, day);
5393
+ }
5394
+ };
5395
+
5396
+ var getWeekNumber = function getWeekNumber(date) {
5397
+ // 支持多种输入类型
5398
+ if (!date || !isDate(date)) {
5399
+ date = new Date();
5400
+ }
5401
+ if (typeof date === 'string') {
5402
+ date = new Date(date);
5403
+ }
5404
+
5405
+ // 验证日期有效性
5406
+ if (!isDate(date)) return null;
5407
+
5408
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5409
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5410
+ // 将星期日的星期数设为7
5411
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5412
+ // 获取当年的第一天
5413
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5414
+ // 计算到最近的星期四的完整周数
5415
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5416
+ // 返回周数
5417
+ return weekNo;
5418
+ };
5419
+
5420
+ var getRangeHours = function getRangeHours(ranges) {
5421
+ var hours = [];
5422
+ var disabledHours = [];
5423
+
5424
+ (ranges || []).forEach(function (range) {
5425
+ var value = range.map(function (date) {
5426
+ return date.getHours();
5427
+ });
5428
+
5429
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5430
+ });
5431
+
5432
+ if (disabledHours.length) {
5433
+ for (var i = 0; i < 24; i++) {
5434
+ hours[i] = disabledHours.indexOf(i) === -1;
5435
+ }
5436
+ } else {
5437
+ for (var _i = 0; _i < 24; _i++) {
5438
+ hours[_i] = false;
5439
+ }
5440
+ }
5441
+
5442
+ return hours;
5443
+ };
5444
+
5445
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5446
+ if (amount <= 0) return [];
5447
+ var temp = new Date(date.getTime());
5448
+ temp.setDate(0);
5449
+ var lastDay = temp.getDate();
5450
+ return range(amount).map(function (_, index) {
5451
+ return lastDay - (amount - index - 1);
5452
+ });
5453
+ };
5454
+
5455
+ var getMonthDays = function getMonthDays(date) {
5456
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5457
+ var days = temp.getDate();
5458
+ return range(days).map(function (_, index) {
5459
+ return index + 1;
5460
+ });
5461
+ };
5462
+
5463
+ function setRangeData(arr, start, end, value) {
5464
+ for (var i = start; i < end; i++) {
5465
+ arr[i] = value;
5466
+ }
5467
+ }
5468
+
5469
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5470
+ var minutes = new Array(60);
5471
+
5472
+ if (ranges.length > 0) {
5473
+ ranges.forEach(function (range) {
5474
+ var start = range[0];
5475
+ var end = range[1];
5476
+ var startHour = start.getHours();
5477
+ var startMinute = start.getMinutes();
5478
+ var endHour = end.getHours();
5479
+ var endMinute = end.getMinutes();
5480
+ if (startHour === hour && endHour !== hour) {
5481
+ setRangeData(minutes, startMinute, 60, true);
5482
+ } else if (startHour === hour && endHour === hour) {
5483
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5484
+ } else if (startHour !== hour && endHour === hour) {
5485
+ setRangeData(minutes, 0, endMinute + 1, true);
5486
+ } else if (startHour < hour && endHour > hour) {
5487
+ setRangeData(minutes, 0, 60, true);
5488
+ }
5489
+ });
5490
+ } else {
5491
+ setRangeData(minutes, 0, 60, true);
5492
+ }
5493
+ return minutes;
5494
+ };
5495
+
5496
+ var range = function range(n) {
5497
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5498
+ return Array.apply(null, { length: n }).map(function (_, n) {
5499
+ return n;
5500
+ });
5501
+ };
5502
+
5503
+ var modifyDate = function modifyDate(date, y, m, d) {
5504
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5505
+ };
5506
+
5507
+ var modifyTime = function modifyTime(date, h, m, s) {
5508
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5509
+ };
5510
+
5511
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
5512
+ if (date == null || !time) {
5513
+ return date;
5514
+ }
5515
+ time = parseDate(time, 'HH:mm:ss');
5516
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5517
+ };
5518
+
5519
+ var clearTime = function clearTime(date) {
5520
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5521
+ };
5522
+
5523
+ var clearMilliseconds = function clearMilliseconds(date) {
5524
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5525
+ };
5526
+
5527
+ var limitTimeRange = function limitTimeRange(date, ranges) {
5528
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5529
+
5530
+ // TODO: refactory a more elegant solution
5531
+ if (ranges.length === 0) return date;
5532
+ var normalizeDate = function normalizeDate(date) {
5533
+ return fecha.parse(fecha.format(date, format), format);
5534
+ };
5535
+ var ndate = normalizeDate(date);
5536
+ var nranges = ranges.map(function (range) {
5537
+ return range.map(normalizeDate);
5538
+ });
5539
+ if (nranges.some(function (nrange) {
5540
+ return ndate >= nrange[0] && ndate <= nrange[1];
5541
+ })) return date;
5542
+
5543
+ var minDate = nranges[0][0];
5544
+ var maxDate = nranges[0][0];
5545
+
5546
+ nranges.forEach(function (nrange) {
5547
+ minDate = new Date(Math.min(nrange[0], minDate));
5548
+ maxDate = new Date(Math.max(nrange[1], minDate));
5549
+ });
5550
+
5551
+ var ret = ndate < minDate ? minDate : maxDate;
5552
+ // preserve Year/Month/Date
5553
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5554
+ };
5555
+
5556
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5557
+ var limitedDate = limitTimeRange(date, selectableRange, format);
5558
+ return limitedDate.getTime() === date.getTime();
5559
+ };
5560
+
5561
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5562
+ // clamp date to the number of days in `year`, `month`
5563
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5564
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5565
+ return modifyDate(date, year, month, monthDate);
5566
+ };
5567
+
5568
+ var prevMonth = function prevMonth(date) {
5569
+ var year = date.getFullYear();
5570
+ var month = date.getMonth();
5571
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5572
+ };
5573
+
5574
+ var nextMonth = function nextMonth(date) {
5575
+ var year = date.getFullYear();
5576
+ var month = date.getMonth();
5577
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5578
+ };
5579
+
5580
+ var prevYear = function prevYear(date) {
5581
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5582
+
5583
+ var year = date.getFullYear();
5584
+ var month = date.getMonth();
5585
+ return changeYearMonthAndClampDate(date, year - amount, month);
5586
+ };
5587
+
5588
+ var nextYear = function nextYear(date) {
5589
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5590
+
5591
+ var year = date.getFullYear();
5592
+ var month = date.getMonth();
5593
+ return changeYearMonthAndClampDate(date, year + amount, month);
5594
+ };
5595
+
5596
+ var extractDateFormat = function extractDateFormat(format) {
5597
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5598
+ };
5599
+
5600
+ var extractTimeFormat = function extractTimeFormat(format) {
5601
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5602
+ };
5603
+
5604
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5605
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5606
+ };
5607
+
5626
5608
  /**
5627
5609
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5628
5610
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5629
5611
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5630
5612
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5631
5613
  * @returns {number} 工作日数量
5632
- */
5633
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5634
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5635
- throw new Error(
5636
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5637
- );
5638
- }
5639
-
5640
- const startDateObj = new Date(start_date);
5641
- const endDateObj = new Date(end_date);
5642
-
5643
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5644
- throw new Error(
5645
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5646
- );
5647
- }
5648
-
5649
- if (startDateObj > endDateObj) {
5650
- throw new Error('Start date should be earlier than or equal to end date.');
5651
- }
5652
-
5653
- let workdays = 0;
5654
-
5655
- // Iterate through each day in the date range
5656
- for (
5657
- let currentDate = new Date(startDateObj);
5658
- currentDate <= endDateObj;
5659
- currentDate.setDate(currentDate.getDate() + 1)
5660
- ) {
5661
- // Check if the current day is a weekend (Saturday or Sunday)
5662
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5663
-
5664
- // Check if the current day is a holiday
5665
- const isHoliday = holidays.some((holiday) => {
5666
- const holidayDate = new Date(holiday);
5667
- return currentDate.toDateString() === holidayDate.toDateString();
5668
- });
5669
-
5670
- // If it's a workday (not a weekend or holiday), increment the workdays count
5671
- if (!isWeekend && !isHoliday) {
5672
- workdays++;
5673
- }
5674
- }
5675
-
5676
- return workdays;
5677
- };
5678
-
5614
+ */
5615
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5616
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5617
+
5618
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5619
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5620
+ }
5621
+
5622
+ var startDateObj = new Date(start_date);
5623
+ var endDateObj = new Date(end_date);
5624
+
5625
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5626
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5627
+ }
5628
+
5629
+ if (startDateObj > endDateObj) {
5630
+ throw new Error('Start date should be earlier than or equal to end date.');
5631
+ }
5632
+
5633
+ var workdays = 0;
5634
+
5635
+ // Iterate through each day in the date range
5636
+
5637
+ var _loop = function _loop(currentDate) {
5638
+ // Check if the current day is a weekend (Saturday or Sunday)
5639
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5640
+
5641
+ // Check if the current day is a holiday
5642
+ var isHoliday = holidays.some(function (holiday) {
5643
+ var holidayDate = new Date(holiday);
5644
+ return currentDate.toDateString() === holidayDate.toDateString();
5645
+ });
5646
+
5647
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5648
+ if (!isWeekend && !isHoliday) {
5649
+ workdays++;
5650
+ }
5651
+ };
5652
+
5653
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5654
+ _loop(currentDate);
5655
+ }
5656
+
5657
+ return workdays;
5658
+ };
5659
+
5679
5660
  /**
5680
5661
  * 日期加减天数
5681
5662
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5682
5663
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5683
5664
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5684
- */
5685
- const dateAddDays = function (start_date, days) {
5686
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5687
- throw new Error(
5688
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5689
- );
5690
- }
5691
-
5692
- const startDateObj = new Date(start_date);
5693
- if (isNaN(startDateObj.getTime())) {
5694
- throw new Error(
5695
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5696
- );
5697
- }
5698
-
5699
- const resultDateObj = new Date(startDateObj);
5700
- resultDateObj.setDate(resultDateObj.getDate() + days);
5701
-
5702
- const resultYear = resultDateObj.getFullYear();
5703
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5704
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5705
-
5706
- return `${resultYear}-${resultMonth}-${resultDay}`;
5707
- };
5708
-
5665
+ */
5666
+ var dateAddDays = function dateAddDays(start_date, days) {
5667
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5668
+ 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.");
5669
+ }
5670
+
5671
+ var startDateObj = new Date(start_date);
5672
+ if (isNaN(startDateObj.getTime())) {
5673
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5674
+ }
5675
+
5676
+ var resultDateObj = new Date(startDateObj);
5677
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5678
+
5679
+ var resultYear = resultDateObj.getFullYear();
5680
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5681
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5682
+
5683
+ return resultYear + '-' + resultMonth + '-' + resultDay;
5684
+ };
5685
+
5709
5686
  /**
5710
5687
  * 计算两个日期之间的差值
5711
5688
  * @date 2023年12月14日
@@ -5713,236 +5690,234 @@ const dateAddDays = function (start_date, days) {
5713
5690
  * @param {String} end_date - 结束日期字符串
5714
5691
  * @param {String} unit - 单位:year/month/day
5715
5692
  * @returns {Number} 差值
5716
- */
5717
- const dateDiff = function (start_date, end_date, unit = 'day') {
5718
- // Assuming date strings are in "YYYY-MM-DD" format
5719
- var startDate = new Date(start_date);
5720
- var endDate = new Date(end_date);
5721
-
5722
- // If the date is invalid, return 0
5723
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5724
- return 0;
5725
- }
5726
-
5727
- if (unit === 'year') {
5728
- return endDate.getFullYear() - startDate.getFullYear();
5729
- } else if (unit === 'month') {
5730
- return (
5731
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5732
- (endDate.getMonth() - startDate.getMonth())
5733
- );
5734
- } else {
5735
- // Default to day
5736
- var timeDifference = endDate - startDate;
5737
- // Calculate days (86400000 milliseconds per day)
5738
- return Math.floor(timeDifference / 86400000);
5739
- }
5740
- };
5741
-
5693
+ */
5694
+ var dateDiff = function dateDiff(start_date, end_date) {
5695
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5696
+
5697
+ // Assuming date strings are in "YYYY-MM-DD" format
5698
+ var startDate = new Date(start_date);
5699
+ var endDate = new Date(end_date);
5700
+
5701
+ // If the date is invalid, return 0
5702
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5703
+ return 0;
5704
+ }
5705
+
5706
+ if (unit === 'year') {
5707
+ return endDate.getFullYear() - startDate.getFullYear();
5708
+ } else if (unit === 'month') {
5709
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5710
+ } else {
5711
+ // Default to day
5712
+ var timeDifference = endDate - startDate;
5713
+ // Calculate days (86400000 milliseconds per day)
5714
+ return Math.floor(timeDifference / 86400000);
5715
+ }
5716
+ };
5717
+
5742
5718
  /**
5743
5719
  * 获取月份中的日期
5744
5720
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5745
5721
  * @returns {number} 月份中的日期(1-31)
5746
- */
5747
- const dayOfMonth = function (date) {
5748
- if (typeof date !== 'string') {
5749
- throw new Error(
5750
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5751
- );
5752
- }
5753
-
5754
- const dateObj = new Date(date);
5755
- if (isNaN(dateObj.getTime())) {
5756
- throw new Error(
5757
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5758
- );
5759
- }
5760
-
5761
- return dateObj.getDate();
5762
- };
5763
-
5722
+ */
5723
+ var dayOfMonth = function dayOfMonth(date) {
5724
+ if (typeof date !== 'string') {
5725
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5726
+ }
5727
+
5728
+ var dateObj = new Date(date);
5729
+ if (isNaN(dateObj.getTime())) {
5730
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5731
+ }
5732
+
5733
+ return dateObj.getDate();
5734
+ };
5735
+
5764
5736
  /**
5765
5737
  * 获取当前日期
5766
5738
  * @date 2022年5月7日
5767
5739
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5768
5740
  * @returns {string} 当前日期的格式化字符串
5769
- */
5770
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
5771
- return formatDate(new Date(), format);
5772
- };
5773
-
5741
+ */
5742
+ var getCurrentDate = function getCurrentDate() {
5743
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5744
+
5745
+ return formatDate(new Date(), format);
5746
+ };
5747
+
5774
5748
  /**
5775
5749
  * 获取当前日期时间
5776
5750
  * @date 2022年5月7日
5777
5751
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
5778
5752
  * @returns {string} 当前日期时间的格式化字符串
5779
- */
5780
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5781
- return formatDate(new Date(), format);
5782
- };
5783
-
5753
+ */
5754
+ var getCurrentDateTime = function getCurrentDateTime() {
5755
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
5756
+
5757
+ return formatDate(new Date(), format);
5758
+ };
5759
+
5784
5760
  /**
5785
5761
  * 获取小时
5786
5762
  * @date 2022年5月7日
5787
5763
  * @param {Date|string} [date] - 日期对象或日期字符串
5788
5764
  * @returns {number} 小时数(0-23)
5789
- */
5790
- const getHour = function (date) {
5791
- if (!date) {
5792
- return new Date().getHours();
5793
- }
5794
- if (typeof date === 'string') {
5795
- date = new Date(date);
5796
- }
5797
- return date.getHours();
5798
- };
5799
-
5765
+ */
5766
+ var getHour = function getHour(date) {
5767
+ if (!date) {
5768
+ return new Date().getHours();
5769
+ }
5770
+ if (typeof date === 'string') {
5771
+ date = new Date(date);
5772
+ }
5773
+ return date.getHours();
5774
+ };
5775
+
5800
5776
  /**
5801
5777
  * 获取分钟
5802
5778
  * @date 2022年5月7日
5803
5779
  * @param {Date|string} [date] - 日期对象或日期字符串
5804
5780
  * @returns {number} 分钟数(0-59)
5805
- */
5806
- const getMinute = function (date) {
5807
- if (!date) {
5808
- return new Date().getMinutes();
5809
- }
5810
- if (typeof date === 'string') {
5811
- date = new Date(date);
5812
- }
5813
- return date.getMinutes();
5814
- };
5815
-
5781
+ */
5782
+ var getMinute = function getMinute(date) {
5783
+ if (!date) {
5784
+ return new Date().getMinutes();
5785
+ }
5786
+ if (typeof date === 'string') {
5787
+ date = new Date(date);
5788
+ }
5789
+ return date.getMinutes();
5790
+ };
5791
+
5816
5792
  /**
5817
5793
  * 获取月份
5818
5794
  * @date 2022年5月7日
5819
5795
  * @param {Date|string} [date] - 日期对象或日期字符串
5820
5796
  * @returns {number} 月份数(1-12)
5821
- */
5822
- const getMonth = function (date) {
5823
- if (!date) {
5824
- return new Date().getMonth() + 1;
5825
- }
5826
- if (typeof date === 'string') {
5827
- date = new Date(date);
5828
- }
5829
- return date.getMonth() + 1;
5830
- };
5831
-
5797
+ */
5798
+ var getMonth = function getMonth(date) {
5799
+ if (!date) {
5800
+ return new Date().getMonth() + 1;
5801
+ }
5802
+ if (typeof date === 'string') {
5803
+ date = new Date(date);
5804
+ }
5805
+ return date.getMonth() + 1;
5806
+ };
5807
+
5832
5808
  /**
5833
5809
  * 获取秒
5834
5810
  * @date 2022年5月7日
5835
5811
  * @param {Date|string} [date] - 日期对象或日期字符串
5836
5812
  * @returns {number} 秒数(0-59)
5837
- */
5838
- const getSecond = function (date) {
5839
- if (!date) {
5840
- return new Date().getSeconds();
5841
- }
5842
- if (typeof date === 'string') {
5843
- date = new Date(date);
5844
- }
5845
- return date.getSeconds();
5846
- };
5847
-
5813
+ */
5814
+ var getSecond = function getSecond(date) {
5815
+ if (!date) {
5816
+ return new Date().getSeconds();
5817
+ }
5818
+ if (typeof date === 'string') {
5819
+ date = new Date(date);
5820
+ }
5821
+ return date.getSeconds();
5822
+ };
5823
+
5848
5824
  /**
5849
5825
  * 获取星期几
5850
5826
  * @date 2022年5月7日
5851
5827
  * @param {Date|string} [date] - 日期对象或日期字符串
5852
5828
  * @returns {number} 星期几(0-6,0表示星期日)
5853
- */
5854
- const getWeekday = function (date) {
5855
- if (!date) {
5856
- return new Date().getDay();
5857
- }
5858
- if (typeof date === 'string') {
5859
- date = new Date(date);
5860
- }
5861
- return date.getDay();
5862
- };
5863
-
5864
-
5829
+ */
5830
+ var getWeekday = function getWeekday(date) {
5831
+ if (!date) {
5832
+ return new Date().getDay();
5833
+ }
5834
+ if (typeof date === 'string') {
5835
+ date = new Date(date);
5836
+ }
5837
+ return date.getDay();
5838
+ };
5839
+
5865
5840
  /**
5866
5841
  * @desc 获取上午/下午/晚上
5867
5842
  * @author huangbo
5868
5843
  * @date 2022年5月7日
5869
5844
  * @param {String} [time] - 时间
5870
- **/
5871
- const timeCycle = function (time) {
5872
- let hour = 0;
5873
- if (!time) {
5874
- hour = new Date().getHours();
5875
- } else if (typeof time === 'string') {
5876
- // 从时间字符串中提取小时
5877
- const match = time.match(/^(\d{1,2})/);
5878
- if (match) {
5879
- hour = parseInt(match[1], 10);
5880
- }
5881
- } else if (typeof time === 'number') {
5882
- hour = time;
5883
- }
5884
- // 判断时间段
5885
- if (hour >= 5 && hour < 12) {
5886
- return '上午';
5887
- } else if (hour >= 12 && hour < 18) {
5888
- return '下午';
5889
- } else {
5890
- return '晚上';
5891
- }
5845
+ **/
5846
+ var timeCycle = function timeCycle(time) {
5847
+ var hour = 0;
5848
+ if (!time) {
5849
+ hour = new Date().getHours();
5850
+ } else if (typeof time === 'string') {
5851
+ // 从时间字符串中提取小时
5852
+ var match = time.match(/^(\d{1,2})/);
5853
+ if (match) {
5854
+ hour = parseInt(match[1], 10);
5855
+ }
5856
+ } else if (typeof time === 'number') {
5857
+ hour = time;
5858
+ }
5859
+ // 判断时间段
5860
+ if (hour >= 5 && hour < 12) {
5861
+ return '上午';
5862
+ } else if (hour >= 12 && hour < 18) {
5863
+ return '下午';
5864
+ } else {
5865
+ return '晚上';
5866
+ }
5892
5867
  };
5893
5868
 
5894
5869
  /***/ }),
5895
5870
 
5896
- /***/ 70:
5871
+ /***/ 71:
5897
5872
  /***/ (function(module, exports) {
5898
5873
 
5899
5874
  module.exports = require("eoss/lib/cascader");
5900
5875
 
5901
5876
  /***/ }),
5902
5877
 
5903
- /***/ 71:
5878
+ /***/ 72:
5904
5879
  /***/ (function(module, exports) {
5905
5880
 
5906
5881
  module.exports = require("eoss/lib/date-picker");
5907
5882
 
5908
5883
  /***/ }),
5909
5884
 
5910
- /***/ 72:
5885
+ /***/ 73:
5911
5886
  /***/ (function(module, exports) {
5912
5887
 
5913
5888
  module.exports = require("eoss/lib/time-picker");
5914
5889
 
5915
5890
  /***/ }),
5916
5891
 
5917
- /***/ 73:
5892
+ /***/ 74:
5918
5893
  /***/ (function(module, exports) {
5919
5894
 
5920
5895
  module.exports = require("eoss/lib/time-select");
5921
5896
 
5922
5897
  /***/ }),
5923
5898
 
5924
- /***/ 74:
5899
+ /***/ 75:
5925
5900
  /***/ (function(module, exports) {
5926
5901
 
5927
5902
  module.exports = require("eoss/lib/rate");
5928
5903
 
5929
5904
  /***/ }),
5930
5905
 
5931
- /***/ 75:
5906
+ /***/ 76:
5932
5907
  /***/ (function(module, exports) {
5933
5908
 
5934
5909
  module.exports = require("eoss/lib/slider");
5935
5910
 
5936
5911
  /***/ }),
5937
5912
 
5938
- /***/ 76:
5913
+ /***/ 77:
5939
5914
  /***/ (function(module, exports) {
5940
5915
 
5941
5916
  module.exports = require("eoss/lib/transfer");
5942
5917
 
5943
5918
  /***/ }),
5944
5919
 
5945
- /***/ 77:
5920
+ /***/ 78:
5946
5921
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5947
5922
 
5948
5923
  "use strict";
@@ -5994,7 +5969,7 @@ render._withStripped = true
5994
5969
  // CONCATENATED MODULE: ./src/components/field-render.vue?vue&type=template&id=0751ef51&
5995
5970
 
5996
5971
  // EXTERNAL MODULE: external "eoss/lib/input-number"
5997
- var input_number_ = __webpack_require__(54);
5972
+ var input_number_ = __webpack_require__(56);
5998
5973
  var input_number_default = /*#__PURE__*/__webpack_require__.n(input_number_);
5999
5974
 
6000
5975
  // EXTERNAL MODULE: external "eoss/lib/radio-group"
@@ -6010,11 +5985,11 @@ var select_ = __webpack_require__(41);
6010
5985
  var select_default = /*#__PURE__*/__webpack_require__.n(select_);
6011
5986
 
6012
5987
  // EXTERNAL MODULE: external "eoss/lib/cascader"
6013
- var cascader_ = __webpack_require__(70);
5988
+ var cascader_ = __webpack_require__(71);
6014
5989
  var cascader_default = /*#__PURE__*/__webpack_require__.n(cascader_);
6015
5990
 
6016
5991
  // EXTERNAL MODULE: external "eoss/lib/switch"
6017
- var switch_ = __webpack_require__(64);
5992
+ var switch_ = __webpack_require__(65);
6018
5993
  var switch_default = /*#__PURE__*/__webpack_require__.n(switch_);
6019
5994
 
6020
5995
  // EXTERNAL MODULE: external "eoss/lib/input"
@@ -6022,39 +5997,39 @@ var input_ = __webpack_require__(14);
6022
5997
  var input_default = /*#__PURE__*/__webpack_require__.n(input_);
6023
5998
 
6024
5999
  // EXTERNAL MODULE: external "eoss/lib/date-picker"
6025
- var date_picker_ = __webpack_require__(71);
6000
+ var date_picker_ = __webpack_require__(72);
6026
6001
  var date_picker_default = /*#__PURE__*/__webpack_require__.n(date_picker_);
6027
6002
 
6028
6003
  // EXTERNAL MODULE: external "eoss/lib/time-picker"
6029
- var time_picker_ = __webpack_require__(72);
6004
+ var time_picker_ = __webpack_require__(73);
6030
6005
  var time_picker_default = /*#__PURE__*/__webpack_require__.n(time_picker_);
6031
6006
 
6032
6007
  // EXTERNAL MODULE: external "eoss/lib/time-select"
6033
- var time_select_ = __webpack_require__(73);
6008
+ var time_select_ = __webpack_require__(74);
6034
6009
  var time_select_default = /*#__PURE__*/__webpack_require__.n(time_select_);
6035
6010
 
6036
6011
  // EXTERNAL MODULE: external "eoss/lib/upload"
6037
- var upload_ = __webpack_require__(49);
6012
+ var upload_ = __webpack_require__(50);
6038
6013
  var upload_default = /*#__PURE__*/__webpack_require__.n(upload_);
6039
6014
 
6040
6015
  // EXTERNAL MODULE: external "eoss/lib/rate"
6041
- var rate_ = __webpack_require__(74);
6016
+ var rate_ = __webpack_require__(75);
6042
6017
  var rate_default = /*#__PURE__*/__webpack_require__.n(rate_);
6043
6018
 
6044
6019
  // EXTERNAL MODULE: external "eoss/lib/slider"
6045
- var slider_ = __webpack_require__(75);
6020
+ var slider_ = __webpack_require__(76);
6046
6021
  var slider_default = /*#__PURE__*/__webpack_require__.n(slider_);
6047
6022
 
6048
6023
  // EXTERNAL MODULE: external "eoss/lib/color-picker"
6049
- var color_picker_ = __webpack_require__(65);
6024
+ var color_picker_ = __webpack_require__(66);
6050
6025
  var color_picker_default = /*#__PURE__*/__webpack_require__.n(color_picker_);
6051
6026
 
6052
6027
  // EXTERNAL MODULE: external "eoss/lib/transfer"
6053
- var transfer_ = __webpack_require__(76);
6028
+ var transfer_ = __webpack_require__(77);
6054
6029
  var transfer_default = /*#__PURE__*/__webpack_require__.n(transfer_);
6055
6030
 
6056
6031
  // EXTERNAL MODULE: external "eoss/lib/tree"
6057
- var tree_ = __webpack_require__(50);
6032
+ var tree_ = __webpack_require__(51);
6058
6033
  var tree_default = /*#__PURE__*/__webpack_require__.n(tree_);
6059
6034
 
6060
6035
  // EXTERNAL MODULE: external "eoss/lib/button"
@@ -6186,7 +6161,7 @@ var CLASS_INLINE_MAP = {
6186
6161
  EsCascader: cascader_default.a,
6187
6162
  // 异步加载:断开 form → field-render → selector → selector-panel → form 的循环依赖
6188
6163
  EsSelector: function EsSelector() {
6189
- return Promise.resolve(/* import() */).then(__webpack_require__.t.bind(null, 66, 7));
6164
+ return Promise.resolve(/* import() */).then(__webpack_require__.t.bind(null, 67, 7));
6190
6165
  },
6191
6166
  EsSwitch: switch_default.a,
6192
6167
  EsInput: input_default.a,