zartui 2.0.79 → 2.0.80-beta.1

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 (304) hide show
  1. package/es/action-sheet/index.js +15 -26
  2. package/es/area/index.js +5 -41
  3. package/es/avatar/index.js +3 -16
  4. package/es/back-top/index.js +4 -19
  5. package/es/badge/index.js +4 -12
  6. package/es/button/index.js +20 -40
  7. package/es/calendar/components/Header.js +3 -12
  8. package/es/calendar/components/Month.js +12 -65
  9. package/es/calendar/index.js +23 -94
  10. package/es/calendar/types.js +0 -6
  11. package/es/calendar/utils.js +5 -16
  12. package/es/cascader/index.js +4 -37
  13. package/es/cell/index.js +19 -37
  14. package/es/cell-group/index.js +5 -8
  15. package/es/checkbox/index.js +4 -11
  16. package/es/checkbox-group/index.js +4 -9
  17. package/es/col/index.js +6 -11
  18. package/es/collapse/index.js +2 -5
  19. package/es/collapse-item/index.js +19 -35
  20. package/es/count-down/index.js +2 -15
  21. package/es/count-down/utils.js +3 -10
  22. package/es/datetime-picker/DatePicker.js +12 -70
  23. package/es/datetime-picker/TimePicker.js +10 -23
  24. package/es/datetime-picker/index.js +2 -4
  25. package/es/datetime-picker/shared.js +5 -19
  26. package/es/datetime-picker/utils.js +0 -5
  27. package/es/dialog/Dialog.js +6 -21
  28. package/es/dialog/index.js +0 -16
  29. package/es/divider/index.js +5 -6
  30. package/es/dropdown-item/index.js +22 -35
  31. package/es/dropdown-menu/index.js +4 -9
  32. package/es/empty/index.js +3 -11
  33. package/es/field/index.js +20 -83
  34. package/es/fold-dialog/index.js +5 -20
  35. package/es/form/index.js +2 -18
  36. package/es/grid/index.js +2 -6
  37. package/es/grid-item/index.js +17 -30
  38. package/es/hierarchy-select/breadcrumb.js +2 -6
  39. package/es/hierarchy-select/index.js +3 -12
  40. package/es/hierarchy-select/markList.js +2 -25
  41. package/es/hierarchy-select/svg/SubIcon.js +0 -1
  42. package/es/icon/index.js +9 -13
  43. package/es/image/index.js +2 -17
  44. package/es/image-preview/ImagePreview.js +4 -8
  45. package/es/image-preview/ImagePreviewItem.js +14 -30
  46. package/es/image-preview/index.js +0 -12
  47. package/es/image-preview/shared.js +2 -4
  48. package/es/index-anchor/index.js +2 -6
  49. package/es/index-bar/IndexIndicate.js +0 -1
  50. package/es/index-bar/index.js +7 -28
  51. package/es/index.js +1 -4
  52. package/es/info/index.js +6 -8
  53. package/es/list/index.js +11 -27
  54. package/es/loading/index.js +7 -15
  55. package/es/locale/index.js +0 -2
  56. package/es/media-picker/index.js +33 -117
  57. package/es/media-picker/media-util.js +2 -5
  58. package/es/media-picker/type.js +0 -5
  59. package/es/media-player/index.js +7 -17
  60. package/es/mixins/bind-event.js +0 -3
  61. package/es/mixins/checkbox.js +5 -11
  62. package/es/mixins/click-outside.js +0 -2
  63. package/es/mixins/close-on-popstate.js +0 -1
  64. package/es/mixins/field.js +0 -2
  65. package/es/mixins/popup/index.js +12 -28
  66. package/es/mixins/popup/overlay.js +1 -11
  67. package/es/mixins/portal.js +2 -8
  68. package/es/mixins/relation.js +0 -8
  69. package/es/mixins/slots.js +1 -4
  70. package/es/mixins/touch.js +4 -9
  71. package/es/multiple-picker/MultiplePickerOptions.js +2 -18
  72. package/es/multiple-picker/index.js +5 -17
  73. package/es/nav-bar/index.js +4 -12
  74. package/es/notice-bar/index.js +10 -28
  75. package/es/number-keyboard/Key.js +2 -10
  76. package/es/number-keyboard/index.js +4 -19
  77. package/es/overlay/index.js +5 -8
  78. package/es/password-input/index.js +10 -16
  79. package/es/picker/PickerColumn.js +20 -54
  80. package/es/picker/index.js +13 -42
  81. package/es/popover/index.js +11 -20
  82. package/es/popup/index.js +5 -21
  83. package/es/pull-refresh/index.js +15 -32
  84. package/es/radio/index.js +2 -4
  85. package/es/radio-group/index.js +2 -4
  86. package/es/rate/index.js +12 -26
  87. package/es/row/index.js +3 -9
  88. package/es/search/index.js +8 -13
  89. package/es/signature/bezier.js +5 -12
  90. package/es/signature/force-landscape.js +0 -5
  91. package/es/signature/index.js +5 -24
  92. package/es/signature/point.js +1 -6
  93. package/es/signature/throttle.js +1 -10
  94. package/es/skeleton/index.js +5 -15
  95. package/es/slider/index.js +19 -55
  96. package/es/step/index.js +5 -12
  97. package/es/stepper/index.js +10 -37
  98. package/es/steps/index.js +2 -4
  99. package/es/sticky/index.js +8 -50
  100. package/es/swipe/index.js +19 -62
  101. package/es/swipe-cell/index.js +7 -23
  102. package/es/swipe-item/index.js +9 -19
  103. package/es/switch/index.js +8 -10
  104. package/es/switch/shared.js +1 -0
  105. package/es/switch-cell/index.js +7 -7
  106. package/es/tab/index.js +4 -15
  107. package/es/tabbar/index.js +4 -14
  108. package/es/tabbar-item/index.js +7 -15
  109. package/es/table/index.js +10 -35
  110. package/es/tabs/Content.js +5 -9
  111. package/es/tabs/Title.js +11 -19
  112. package/es/tabs/index.js +16 -51
  113. package/es/tabs/utils.js +0 -8
  114. package/es/tag/index.js +13 -17
  115. package/es/timeline/index.js +2 -25
  116. package/es/toast/Toast.js +11 -23
  117. package/es/toast/index.js +6 -33
  118. package/es/toast/lock-click.js +0 -2
  119. package/es/uploader/index.js +11 -62
  120. package/es/uploader/utils.js +0 -10
  121. package/es/utils/constant.js +2 -1
  122. package/es/utils/create/bem.js +1 -5
  123. package/es/utils/create/component.js +4 -7
  124. package/es/utils/create/i18n.js +0 -2
  125. package/es/utils/deep-assign.js +0 -4
  126. package/es/utils/deep-clone.js +0 -3
  127. package/es/utils/dom/event.js +2 -5
  128. package/es/utils/dom/node.js +0 -1
  129. package/es/utils/dom/raf.js +7 -6
  130. package/es/utils/dom/reset-scroll.js +2 -1
  131. package/es/utils/dom/scroll.js +8 -17
  132. package/es/utils/dom/style.js +3 -2
  133. package/es/utils/easings.js +2 -4
  134. package/es/utils/format/date-util.js +54 -122
  135. package/es/utils/format/number.js +2 -11
  136. package/es/utils/format/string.js +0 -3
  137. package/es/utils/format/unit.js +2 -12
  138. package/es/utils/functional.js +6 -9
  139. package/es/utils/getScroll.js +0 -5
  140. package/es/utils/index.js +3 -5
  141. package/es/utils/interceptor.js +2 -4
  142. package/es/utils/media/image-util.js +7 -19
  143. package/es/utils/raf.js +4 -12
  144. package/es/utils/router.js +7 -6
  145. package/es/utils/scrollTo.js +7 -12
  146. package/es/utils/validate/number.js +2 -2
  147. package/es/utils/vnodes.js +2 -8
  148. package/lib/action-sheet/index.js +11 -35
  149. package/lib/area/index.js +5 -45
  150. package/lib/avatar/index.js +3 -18
  151. package/lib/back-top/index.js +4 -25
  152. package/lib/badge/index.js +4 -15
  153. package/lib/button/index.js +19 -50
  154. package/lib/calendar/components/Header.js +3 -18
  155. package/lib/calendar/components/Month.js +12 -71
  156. package/lib/calendar/index.js +21 -106
  157. package/lib/calendar/types.js +0 -7
  158. package/lib/calendar/utils.js +5 -32
  159. package/lib/cascader/index.js +4 -46
  160. package/lib/cell/index.js +18 -48
  161. package/lib/cell-group/index.js +5 -15
  162. package/lib/checkbox/index.js +4 -14
  163. package/lib/checkbox-group/index.js +4 -13
  164. package/lib/col/index.js +6 -14
  165. package/lib/collapse/index.js +2 -8
  166. package/lib/collapse-item/index.js +18 -43
  167. package/lib/count-down/index.js +2 -19
  168. package/lib/count-down/utils.js +3 -15
  169. package/lib/datetime-picker/DatePicker.js +12 -81
  170. package/lib/datetime-picker/TimePicker.js +10 -30
  171. package/lib/datetime-picker/index.js +2 -10
  172. package/lib/datetime-picker/shared.js +5 -27
  173. package/lib/datetime-picker/utils.js +0 -9
  174. package/lib/dialog/Dialog.js +6 -28
  175. package/lib/dialog/index.js +0 -22
  176. package/lib/divider/index.js +5 -12
  177. package/lib/dropdown-item/index.js +21 -44
  178. package/lib/dropdown-menu/index.js +4 -15
  179. package/lib/empty/index.js +3 -23
  180. package/lib/field/index.js +20 -96
  181. package/lib/fold-dialog/index.js +5 -22
  182. package/lib/form/index.js +2 -21
  183. package/lib/grid/index.js +2 -10
  184. package/lib/grid-item/index.js +16 -37
  185. package/lib/hierarchy-select/breadcrumb.js +3 -10
  186. package/lib/hierarchy-select/index.js +4 -20
  187. package/lib/hierarchy-select/markList.js +3 -31
  188. package/lib/hierarchy-select/svg/SubIcon.js +0 -1
  189. package/lib/icon/index.js +8 -19
  190. package/lib/image/index.js +2 -22
  191. package/lib/image-preview/ImagePreview.js +0 -16
  192. package/lib/image-preview/ImagePreviewItem.js +13 -36
  193. package/lib/image-preview/index.js +0 -16
  194. package/lib/image-preview/shared.js +2 -5
  195. package/lib/index-anchor/index.js +2 -11
  196. package/lib/index-bar/IndexIndicate.js +0 -1
  197. package/lib/index-bar/index.js +7 -37
  198. package/lib/index.js +1 -157
  199. package/lib/info/index.js +6 -14
  200. package/lib/lazyload/index.js +0 -3
  201. package/lib/list/index.js +10 -33
  202. package/lib/loading/index.js +7 -21
  203. package/lib/locale/index.js +0 -7
  204. package/lib/media-picker/index.js +27 -153
  205. package/lib/media-picker/media-util.js +2 -15
  206. package/lib/media-picker/type.js +0 -5
  207. package/lib/media-player/index.js +6 -22
  208. package/lib/mixins/bind-event.js +1 -6
  209. package/lib/mixins/checkbox.js +6 -18
  210. package/lib/mixins/click-outside.js +1 -5
  211. package/lib/mixins/close-on-popstate.js +0 -4
  212. package/lib/mixins/field.js +0 -2
  213. package/lib/mixins/popup/index.js +11 -36
  214. package/lib/mixins/popup/overlay.js +1 -23
  215. package/lib/mixins/portal.js +2 -9
  216. package/lib/mixins/relation.js +0 -11
  217. package/lib/mixins/slots.js +1 -5
  218. package/lib/mixins/touch.js +4 -11
  219. package/lib/multiple-picker/MultiplePickerOptions.js +2 -23
  220. package/lib/multiple-picker/index.js +5 -26
  221. package/lib/nav-bar/index.js +4 -16
  222. package/lib/notice-bar/index.js +10 -40
  223. package/lib/number-keyboard/Key.js +2 -17
  224. package/lib/number-keyboard/index.js +4 -26
  225. package/lib/overlay/index.js +5 -16
  226. package/lib/password-input/index.js +10 -23
  227. package/lib/picker/PickerColumn.js +19 -63
  228. package/lib/picker/index.js +13 -53
  229. package/lib/popover/index.js +9 -27
  230. package/lib/popup/index.js +5 -27
  231. package/lib/pull-refresh/index.js +14 -38
  232. package/lib/radio/index.js +2 -7
  233. package/lib/radio-group/index.js +2 -8
  234. package/lib/rate/index.js +11 -31
  235. package/lib/row/index.js +3 -12
  236. package/lib/search/index.js +7 -21
  237. package/lib/signature/bezier.js +5 -15
  238. package/lib/signature/force-landscape.js +0 -11
  239. package/lib/signature/index.js +6 -31
  240. package/lib/signature/point.js +0 -8
  241. package/lib/signature/throttle.js +1 -11
  242. package/lib/skeleton/index.js +5 -21
  243. package/lib/slider/index.js +19 -63
  244. package/lib/step/index.js +5 -18
  245. package/lib/stepper/index.js +10 -46
  246. package/lib/steps/index.js +2 -7
  247. package/lib/sticky/index.js +8 -59
  248. package/lib/swipe/index.js +19 -70
  249. package/lib/swipe-cell/index.js +7 -29
  250. package/lib/swipe-item/index.js +9 -24
  251. package/lib/switch/index.js +7 -14
  252. package/lib/switch/shared.js +1 -1
  253. package/lib/switch-cell/index.js +6 -16
  254. package/lib/tab/index.js +4 -21
  255. package/lib/tabbar/index.js +4 -19
  256. package/lib/tabbar-item/index.js +5 -21
  257. package/lib/table/index.js +10 -38
  258. package/lib/tabs/Content.js +5 -15
  259. package/lib/tabs/Title.js +11 -23
  260. package/lib/tabs/index.js +15 -65
  261. package/lib/tabs/utils.js +0 -13
  262. package/lib/tag/index.js +12 -23
  263. package/lib/timeline/index.js +2 -32
  264. package/lib/toast/Toast.js +10 -30
  265. package/lib/toast/index.js +6 -38
  266. package/lib/toast/lock-click.js +0 -3
  267. package/lib/uploader/index.js +10 -72
  268. package/lib/uploader/utils.js +0 -17
  269. package/lib/utils/constant.js +2 -1
  270. package/lib/utils/create/bem.js +1 -6
  271. package/lib/utils/create/component.js +5 -14
  272. package/lib/utils/create/i18n.js +0 -8
  273. package/lib/utils/create/index.js +0 -4
  274. package/lib/utils/deep-assign.js +0 -6
  275. package/lib/utils/deep-clone.js +0 -5
  276. package/lib/utils/device.js +0 -2
  277. package/lib/utils/dom/event.js +2 -10
  278. package/lib/utils/dom/node.js +0 -2
  279. package/lib/utils/dom/raf.js +7 -11
  280. package/lib/utils/dom/reset-scroll.js +2 -4
  281. package/lib/utils/dom/scroll.js +8 -28
  282. package/lib/utils/dom/style.js +3 -3
  283. package/lib/utils/easings.js +2 -5
  284. package/lib/utils/format/date-util.js +54 -168
  285. package/lib/utils/format/number.js +2 -13
  286. package/lib/utils/format/string.js +0 -5
  287. package/lib/utils/format/unit.js +2 -16
  288. package/lib/utils/functional.js +6 -14
  289. package/lib/utils/getScroll.js +0 -7
  290. package/lib/utils/index.js +3 -19
  291. package/lib/utils/interceptor.js +2 -6
  292. package/lib/utils/media/image-util.js +7 -25
  293. package/lib/utils/raf.js +4 -13
  294. package/lib/utils/router.js +7 -9
  295. package/lib/utils/scrollTo.js +9 -21
  296. package/lib/utils/validate/date.js +0 -2
  297. package/lib/utils/validate/email.js +0 -1
  298. package/lib/utils/validate/mobile.js +0 -1
  299. package/lib/utils/validate/number.js +2 -4
  300. package/lib/utils/validate/system.js +0 -3
  301. package/lib/utils/vnodes.js +2 -9
  302. package/lib/zart.js +57 -18
  303. package/lib/zart.min.js +1 -1
  304. package/package.json +17 -18
@@ -47,15 +47,12 @@ exports.getYearWeekListWh = getYearWeekListWh;
47
47
  exports.isLessThanDate = isLessThanDate;
48
48
  exports.getDateDiff = getDateDiff;
49
49
  exports.FORMAT = exports.weekList = void 0;
50
-
51
50
  var __formatNumber__ = function __formatNumber__(number) {
52
51
  if (number < 10) {
53
52
  return "0" + number;
54
53
  }
55
-
56
54
  return number;
57
55
  };
58
-
59
56
  var weekList = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
60
57
  exports.weekList = weekList;
61
58
  var FORMAT = {
@@ -93,47 +90,39 @@ var FORMAT = {
93
90
  //中文全称 如:2010年12月01日 23时15分06秒
94
91
  FORMAT_YMDHMS_CN: "yyyy年MM月dd日 HH时mm分ss秒"
95
92
  };
93
+
96
94
  /**
97
95
  *
98
96
  * @param timestamp 1544580660000
99
97
  * @param formatType
100
98
  */
101
-
102
99
  exports.FORMAT = FORMAT;
103
-
104
100
  function formatDate(timestamp, formatType) {
105
101
  if (formatType == null) {
106
102
  formatType = "yyyy-MM-dd HH:mm:ss";
107
103
  }
108
-
109
104
  var stamp = parseInt(timestamp, 10);
110
-
111
105
  if (!isNaN(stamp)) {
112
106
  return formatDateByDate(new Date(stamp), formatType);
113
107
  } else {
114
108
  return formatDateByDate(timestamp, formatType);
115
109
  }
116
110
  }
117
-
118
111
  function formatDateByDate(date, formatType) {
119
112
  if (formatType === void 0) {
120
113
  formatType = FORMAT.FORMAT_YMDHMS;
121
114
  }
122
-
123
115
  if (typeof date != 'object') {
124
116
  // IOS5以下无法解析'2018-01-02'这种格式,需要替换为'2018/01/02'
125
117
  if (typeof date === 'string') {
126
118
  date = date.replace(/-/g, '/');
127
-
128
119
  if (date.length === 7) {
129
120
  // 只有月份的日期ios无法解析,例如 2021/06 , 需转换成2021/06/01
130
121
  date += "/01";
131
122
  }
132
123
  }
133
-
134
124
  date = new Date(date);
135
125
  }
136
-
137
126
  var formatResult = formatType.replace("yyyy", __formatNumber__(date.getFullYear()));
138
127
  formatResult = formatResult.replace("yy", String(date.getFullYear()).substring(2));
139
128
  formatResult = formatResult.replace("MM", __formatNumber__(date.getMonth() + 1));
@@ -144,14 +133,11 @@ function formatDateByDate(date, formatType) {
144
133
  formatResult = formatResult.replace("msms", __formatNumber__(date.getMilliseconds()));
145
134
  return formatResult;
146
135
  }
147
-
148
136
  function formatDateByDateByObject(date, formatType) {
149
137
  if (formatType === void 0) {
150
138
  formatType = FORMAT.FORMAT_YMDHMS;
151
139
  }
152
-
153
140
  var formatResult = formatType;
154
-
155
141
  if (typeof date == 'object') {
156
142
  formatResult = formatType.replace("yyyy", __formatNumber__(date.year));
157
143
  formatResult = formatResult.replace("yy", String(date.year).substring(2));
@@ -161,35 +147,26 @@ function formatDateByDateByObject(date, formatType) {
161
147
  formatResult = formatResult.replace("mm", __formatNumber__(date.minute));
162
148
  formatResult = formatResult.replace("ss", __formatNumber__(date.second));
163
149
  }
164
-
165
150
  return formatResult;
166
151
  }
167
-
168
152
  function parseDate(dateStr) {
169
153
  return new Date(Date.parse(dateStr.replace(/-/g, "/")));
170
154
  }
171
-
172
155
  function getWeek(date) {
173
156
  return weekList[date.getDay()];
174
157
  }
175
-
176
158
  function getTodayWeek() {
177
159
  return weekList[new Date().getDay()];
178
160
  }
179
-
180
161
  function getWeekNum(date) {
181
162
  var week = date.getDay();
182
-
183
163
  if (week === 0) {
184
164
  week = 7;
185
165
  }
186
-
187
166
  return week;
188
167
  }
189
-
190
168
  function getShortDateDesc(date) {
191
169
  var hours = date.getHours();
192
-
193
170
  if (hours >= 0 && hours < 6) {
194
171
  return "凌晨" + hours + "点";
195
172
  } else if (hours >= 6 && hours < 12) {
@@ -202,63 +179,54 @@ function getShortDateDesc(date) {
202
179
  return "时间错误";
203
180
  }
204
181
  }
205
-
206
182
  function getDateDesc(date) {
207
183
  var nowTimestamp = new Date().getTime();
208
184
  var timestamp = date.getTime();
209
185
  var diff = nowTimestamp - timestamp;
210
186
  var fix = "前";
211
-
212
187
  if (diff < 0) {
213
188
  fix = "后";
214
- } //月
215
-
189
+ }
216
190
 
191
+ //月
217
192
  var unit = 1000 * 60 * 60 * 24 * 30;
218
-
219
193
  if (diff / unit > 1) {
220
194
  return parseInt(diff / unit, 10) + "个月" + fix;
221
- } //周
222
-
195
+ }
223
196
 
197
+ //周
224
198
  unit = 1000 * 60 * 60 * 24 * 7;
225
-
226
199
  if (diff / unit > 1) {
227
200
  return parseInt(diff / unit, 10) + "周" + fix;
228
- } //日
229
-
201
+ }
230
202
 
203
+ //日
231
204
  unit = 1000 * 60 * 60 * 24;
232
-
233
205
  if (diff / unit > 1) {
234
206
  return parseInt(diff / unit, 10) + "天" + fix;
235
- } //小时
236
-
207
+ }
237
208
 
209
+ //小时
238
210
  unit = 1000 * 60 * 60;
239
-
240
211
  if (diff / unit > 1) {
241
212
  return parseInt(diff / unit, 10) + "个小时" + fix;
242
- } //分钟
243
-
213
+ }
244
214
 
215
+ //分钟
245
216
  unit = 1000 * 60;
246
-
247
217
  if (diff / unit > 1) {
248
218
  return parseInt(diff / unit, 10) + "分钟" + fix;
249
- } //秒
250
-
219
+ }
251
220
 
221
+ //秒
252
222
  unit = 1000;
253
-
254
223
  if (diff / unit > 1) {
255
224
  return "刚刚";
256
225
  }
257
-
258
226
  return formatDate(date.getTime(), FORMAT.FORMAT_YMDHMS);
259
- } //常规月起始日
260
-
227
+ }
261
228
 
229
+ //常规月起始日
262
230
  function getFirstDayOfNormalMonth(year, month) {
263
231
  var date = new Date();
264
232
  date.setDate(1);
@@ -266,43 +234,37 @@ function getFirstDayOfNormalMonth(year, month) {
266
234
  date.setMonth(month - 1);
267
235
  return date;
268
236
  }
269
-
270
237
  function getWeekNumDefault(date) {
271
238
  var week = date.getDay();
272
239
  return week;
273
- } //获取当年起始日期
274
-
240
+ }
275
241
 
242
+ //获取当年起始日期
276
243
  function getFirstDayOfYear(year) {
277
244
  var date = new Date();
278
245
  date.setDate(1);
279
246
  date.setYear(year);
280
247
  date.setMonth(0);
281
248
  return date;
282
- } //获取上月起始日期
283
-
284
-
249
+ }
250
+ //获取上月起始日期
285
251
  function getLastMonthStartAndEnd() {
286
252
  var nowdays = new Date();
287
253
  var year = nowdays.getFullYear();
288
254
  var month = nowdays.getMonth();
289
-
290
255
  if (month === 0) {
291
256
  month = 12;
292
257
  year = year - 1;
293
258
  }
294
-
295
259
  if (month < 10) {
296
260
  month = '0' + month;
297
261
  }
298
-
299
262
  var myDate = new Date(year, month, 0);
300
263
  var startDate = year + '-' + month + '-01';
301
264
  var endDate = year + '-' + month + '-' + myDate.getDate();
302
265
  return startDate + ',' + endDate;
303
- } //常规月结束日
304
-
305
-
266
+ }
267
+ //常规月结束日
306
268
  function getLastDayOfNormalMonth(year, month) {
307
269
  var date = new Date();
308
270
  date.setDate(1);
@@ -310,56 +272,45 @@ function getLastDayOfNormalMonth(year, month) {
310
272
  date.setMonth(month);
311
273
  return new Date(date.getTime() - 1000 * 60 * 60 * 24);
312
274
  }
313
-
314
275
  function subYears(date, years) {
315
276
  var dateYear = date.getFullYear();
316
277
  return new Date(date.setYear(dateYear - years));
317
278
  }
318
-
319
279
  function subYearsNotModify(date, years) {
320
280
  var dateYear = date.getFullYear();
321
281
  return new Date(date).setYear(dateYear - years);
322
282
  }
323
-
324
283
  function addDays(date, days) {
325
284
  return new Date(date.getTime() + days * 1000 * 60 * 60 * 24);
326
285
  }
327
-
328
286
  function subDays(date, days) {
329
287
  return new Date(date.getTime() - days * 1000 * 60 * 60 * 24);
330
288
  }
331
-
332
289
  function addSeconds(date, seconds) {
333
290
  return new Date(date.getTime() + seconds * 1000);
334
291
  }
335
-
336
292
  function getToday() {
337
293
  return formatDateByDate(new Date(), FORMAT.FORMAT_YMD);
338
294
  }
339
-
340
295
  function getTodayCN() {
341
296
  return formatDateByDate(new Date(), FORMAT.FORMAT_YMD_CN);
342
297
  }
343
-
344
298
  function getDateCN(strDate) {
345
299
  if (strDate != null) {
346
300
  var date = parseDate(strDate);
347
301
  return formatDateByDate(date, FORMAT.FORMAT_YMD_CN);
348
302
  }
349
-
350
303
  return null;
351
304
  }
352
-
353
305
  function getCurMonth() {
354
306
  return formatDateByDate(new Date(), FORMAT.FORMAT_YM);
355
- } //strdate 格式为 "2017-03" 或者 "2017-02-23" , opreation : 1 上个月 2 下个月
356
-
307
+ }
357
308
 
309
+ //strdate 格式为 "2017-03" 或者 "2017-02-23" , opreation : 1 上个月 2 下个月
358
310
  function operateMonth(strDate, operation) {
359
311
  var temp = strDate.split("-");
360
312
  var year = parseInt(temp[0], 10);
361
313
  var month = parseInt(temp[1], 10);
362
-
363
314
  if (operation === 1) {
364
315
  // 减 一个月
365
316
  if (month > 1) {
@@ -377,82 +328,65 @@ function operateMonth(strDate, operation) {
377
328
  year += 1;
378
329
  }
379
330
  }
380
-
381
331
  if (month < 10) {
382
332
  return year + "-0" + month;
383
333
  }
384
-
385
334
  return year + "-" + month;
386
335
  }
387
-
388
336
  function getLastDay(strDate, format) {
389
337
  if (format === void 0) {
390
338
  format = FORMAT.FORMAT_YMD;
391
339
  }
392
-
393
340
  if (strDate != null) {
394
341
  var date = parseDate(strDate);
395
342
  var lastDate = addDays(date, -1);
396
343
  return formatDateByDate(lastDate, format);
397
344
  }
398
-
399
345
  return null;
400
346
  }
401
-
402
347
  function getNextDay(strDate, format) {
403
348
  if (format === void 0) {
404
349
  format = FORMAT.FORMAT_YMD;
405
350
  }
406
-
407
351
  var date;
408
-
409
352
  if (typeof strDate == 'object') {
410
353
  date = strDate;
411
354
  } else {
412
355
  date = parseDate(strDate);
413
356
  }
414
-
415
357
  if (date != null) {
416
358
  var lastDate = addDays(date, 1);
417
359
  return formatDateByDate(lastDate, format);
418
360
  }
419
-
420
361
  return null;
421
362
  }
422
-
423
363
  function getYear() {
424
364
  return new Date().getFullYear();
425
365
  }
426
-
427
366
  function getMonth() {
428
367
  return new Date().getMonth() + 1;
429
368
  }
430
-
431
369
  function getPeriodDesc(milliseconds) {
432
370
  var s = parseInt(milliseconds / 1000 % 60, 10);
433
371
  var m = parseInt(milliseconds / 1000 / 60 % 60, 10);
434
372
  var h = parseInt(milliseconds / 1000 / 60 / 60 % 24, 10);
435
373
  var d = parseInt(milliseconds / 1000 / 60 / 60 / 24, 10);
436
374
  var desc = '';
437
-
438
375
  if (d > 0) {
439
376
  desc += d + '天';
440
377
  }
441
-
442
378
  if (h > 0) {
443
379
  desc += h + '小时';
444
380
  }
445
-
446
381
  if (m > 0) {
447
382
  desc += m + '分';
448
383
  }
449
-
450
384
  if (s > 0) {
451
385
  desc += s + '秒';
452
386
  }
453
-
454
387
  return desc;
455
388
  }
389
+
456
390
  /**
457
391
  * 将不规范书写的时间转为规范书写的
458
392
  * 9 09:00:00
@@ -461,47 +395,36 @@ function getPeriodDesc(milliseconds) {
461
395
  * @param rawStr
462
396
  * @returns {*}
463
397
  */
464
-
465
-
466
398
  function getTimeStrFromRaw(rawStr) {
467
399
  var items = rawStr.split(':');
468
-
469
400
  if (items === null) {
470
401
  return '00:00:00';
471
402
  }
472
-
473
403
  var threeItems = [];
474
-
475
404
  if (items.length >= 3) {
476
405
  threeItems = items.slice(0, 3);
477
406
  } else {
478
407
  var addNum = 3 - items.length;
479
408
  threeItems = items;
480
-
481
409
  for (var i = 0; i < addNum; i++) {
482
410
  threeItems.push('00');
483
411
  }
484
412
  }
485
-
486
413
  threeItems = threeItems.map(function (time) {
487
414
  var finedTime = time;
488
-
489
415
  if (time.length === 1) {
490
416
  finedTime = '0' + time;
491
417
  }
492
-
493
418
  return finedTime;
494
419
  });
495
420
  return threeItems.join(':');
496
421
  }
497
-
498
422
  function formatLeftTime(leftTime) {
499
423
  var nd = 24 * 60 * 60;
500
424
  var nh = 60 * 60;
501
425
  var nm = 60;
502
426
  var ns = 1;
503
427
  var seconds = leftTime || 0;
504
-
505
428
  if (seconds < -(3600 * 24)) {
506
429
  seconds = -seconds;
507
430
  return "\u8D85\u65F6" + parseInt(seconds / nd, 10) + "\u5929";
@@ -525,6 +448,7 @@ function formatLeftTime(leftTime) {
525
448
  return null;
526
449
  }
527
450
  }
451
+
528
452
  /**
529
453
  * get human readable time string from time result from server no matter whether it is timestamp or human readable string
530
454
  * dependent on FORMAT and formatDate, "import * as dateUtil from '***'" recommended
@@ -532,63 +456,48 @@ function formatLeftTime(leftTime) {
532
456
  * @param format
533
457
  * @returns {*}
534
458
  */
535
-
536
-
537
459
  function getTimeString(value, format) {
538
460
  if (format === void 0) {
539
461
  format = FORMAT.FORMAT_YMDHMS;
540
462
  }
541
-
542
463
  var stringifiedValue = value + '';
543
-
544
464
  if (stringifiedValue.indexOf(':') !== -1 || stringifiedValue.indexOf(':') !== -1) {
545
465
  return stringifiedValue;
546
466
  }
547
-
548
467
  if (parseInt(stringifiedValue, 10) > 999999999999) {
549
468
  return formatDate(parseInt(stringifiedValue, 10), format);
550
469
  }
551
-
552
470
  return value;
553
471
  }
554
-
555
472
  function isValidTimeStamp(val) {
556
473
  if (!val) {
557
474
  return false;
558
475
  }
559
-
560
476
  if (Object.prototype.toString.call(val) !== '[object Number]') {
561
477
  return false;
562
478
  }
563
-
564
479
  if (val <= 0 || isNaN(val)) {
565
480
  return false;
566
481
  }
567
-
568
482
  if (val < 1000000000000 || val > 10000000000000) {
569
483
  return false;
570
484
  }
571
-
572
485
  return true;
573
486
  }
487
+
574
488
  /**
575
489
  * 将当天时间显示为”X小时前“/”X分钟前“/“X秒前”
576
490
  * 当天之前显示“MM-dd HH:mm”
577
491
  *
578
492
  */
579
-
580
-
581
493
  function todaySpecialDate(time) {
582
494
  time = new Date(time);
583
-
584
495
  if (formatDateByDate(time, FORMAT.FORMAT_YMD) === formatDateByDate(new Date(), FORMAT.FORMAT_YMD)) {
585
496
  var lastHours = new Date().getHours() - new Date(time).getHours();
586
-
587
497
  if (lastHours > 0) {
588
498
  time = lastHours + "\u5C0F\u65F6\u524D";
589
499
  } else {
590
500
  var lastMinutes = new Date().getMinutes() - new Date(time).getMinutes();
591
-
592
501
  if (lastMinutes > 0) {
593
502
  time = lastMinutes + "\u5206\u949F\u524D";
594
503
  } else {
@@ -602,100 +511,84 @@ function todaySpecialDate(time) {
602
511
  time = formatDateByDate(time, FORMAT.FORMAT_YMDHM);
603
512
  }
604
513
  }
605
-
606
514
  return time;
607
- } // 获取日期之间的时间
608
-
515
+ }
609
516
 
517
+ // 获取日期之间的时间
610
518
  function getTimeDiff(firstDate, secondDate) {
611
519
  var result = '';
612
520
  var diff = Math.abs(firstDate.getTime() - secondDate.getTime());
613
521
  var hours = parseInt(diff / (1000 * 60 * 60), 10);
614
522
  var minutes = parseInt((diff - hours * 1000 * 60 * 60) / (1000 * 60), 10);
615
523
  var seconds = parseInt((diff - hours * 1000 * 60 * 60 - minutes * 1000 * 60) / 1000, 10);
616
-
617
524
  if (hours < 10) {
618
525
  result = result + '0' + hours + ':';
619
526
  } else {
620
527
  result = result + hours + ':';
621
528
  }
622
-
623
529
  if (minutes < 10) {
624
530
  result = result + '0' + minutes + ':';
625
531
  } else {
626
532
  result = result + minutes + ':';
627
533
  }
628
-
629
534
  if (seconds < 10) {
630
535
  result = result + '0' + seconds;
631
536
  } else {
632
537
  result = result + seconds;
633
538
  }
634
-
635
539
  return result;
636
540
  }
541
+
637
542
  /**
638
543
  *获取某年某月某天是一年的第几周
639
544
  *第一天为周日
640
545
  */
641
-
642
-
643
546
  function getWeekNumber(date) {
644
547
  var targetDay = new Date(date);
645
548
  var year = targetDay.getFullYear();
646
549
  var month = targetDay.getMonth();
647
- var days = targetDay.getDate(); //那一天是那一年中的第多少天
648
-
550
+ var days = targetDay.getDate();
551
+ //那一天是那一年中的第多少天
649
552
  for (var i = 1; i < month + 1; i++) {
650
553
  days += getMonthDays(year, i);
651
- } //那一年第一天是星期几
652
-
653
-
654
- var yearFirstDay = new Date(year, 0, 1).getDay(); //计算是第几周
655
-
554
+ }
555
+ //那一年第一天是星期几
556
+ var yearFirstDay = new Date(year, 0, 1).getDay();
557
+ //计算是第几周
656
558
  days += yearFirstDay;
657
559
  var week = Math.ceil(days / 7);
658
560
  return week;
659
561
  }
562
+
660
563
  /**
661
564
  *判断年份是否为润年
662
565
  */
663
-
664
-
665
566
  function isLeapYear(year) {
666
567
  return year % 400 == 0 || year % 4 == 0 && year % 100 != 0;
667
568
  }
668
569
  /**
669
570
  *获取某年某月的天数
670
571
  */
671
-
672
-
673
572
  function getMonthDays(year, month) {
674
573
  return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
675
574
  }
676
575
  /**
677
576
  * 获取本周第一天
678
577
  */
679
-
680
-
681
578
  function getFirstDayOfWeek(date) {
682
579
  var target = new Date(date);
683
580
  var weekday = target.getDay() || 7; //获取星期几,getDay()返回值是 0(周日) 到 6(周六) 之间的一个整数。0||7为7,即weekday的值为1-7
684
-
685
581
  return addDays(target, 1 - weekday);
686
582
  }
687
583
  /**
688
584
  * 加减月份
689
585
  */
690
-
691
-
692
586
  function addMonths(date, months) {
693
587
  var target = new Date(date);
694
588
  var y = target.getFullYear();
695
589
  var m = target.getMonth();
696
590
  var d = target.getDate();
697
591
  m = m + months;
698
-
699
592
  if (m < 0) {
700
593
  m = m + 12;
701
594
  y = y - 1;
@@ -703,36 +596,32 @@ function addMonths(date, months) {
703
596
  m = m - 12;
704
597
  y = y + 1;
705
598
  }
706
-
707
599
  return new Date(y, m, d);
708
- } //获取当前天是这个月的第几周
709
-
710
-
600
+ }
601
+ //获取当前天是这个月的第几周
711
602
  function getMonthWeek(date) {
712
603
  var targetDay = new Date(date);
713
604
  var w = targetDay.getDay();
714
605
  var d = targetDay.getDate();
715
-
716
606
  if (w == 0) {
717
607
  w = 7;
718
608
  }
719
-
720
609
  return Math.ceil((d + 6 - w) / 7);
721
610
  }
611
+ ;
722
612
 
723
- ; //获取一年所有周开始日期和结束日期 , 返回 12.26-01.03 01.04-01.11
724
-
613
+ //获取一年所有周开始日期和结束日期 , 返回 12.26-01.03 01.04-01.11
725
614
  function getYearWeekList(year) {
726
615
  //获取当前年份的第一天是周几
727
616
  var firstDay = new Date(year, 0, 1);
728
- var yearFirstDay = firstDay.getDay(); //获取当前年份第一天所在的周的第一天
729
-
730
- var firstWeekFirstDay = subDays(firstDay, yearFirstDay); //获取当前年份最后一天
617
+ var yearFirstDay = firstDay.getDay();
618
+ //获取当前年份第一天所在的周的第一天
619
+ var firstWeekFirstDay = subDays(firstDay, yearFirstDay);
731
620
 
621
+ //获取当前年份最后一天
732
622
  var endDay = subDays(new Date(year + 1, 0, 1), 1);
733
623
  var endWeekDay = firstWeekFirstDay;
734
624
  var weekStrList = [];
735
-
736
625
  while (endWeekDay < endDay) {
737
626
  var first = endWeekDay.getMonth() + 1 + "." + (endWeekDay.getDate() + 1);
738
627
  endWeekDay = addDays(endWeekDay, 7);
@@ -740,24 +629,23 @@ function getYearWeekList(year) {
740
629
  var str = first + "-" + end;
741
630
  weekStrList.push(str);
742
631
  }
743
-
744
632
  console.log("weekStrList :" + JSON.stringify(weekStrList));
745
633
  return weekStrList;
746
634
  }
635
+ ;
747
636
 
748
- ; //武汉环卫获取一年所有周开始日期和结束日期,需要返回上周五到这周四
749
-
637
+ //武汉环卫获取一年所有周开始日期和结束日期,需要返回上周五到这周四
750
638
  function getYearWeekListWh(year) {
751
639
  //获取当前年份的第一天是周几
752
640
  var firstDay = new Date(year, 0, 1);
753
- var yearFirstDay = firstDay.getDay(); //获取当前年份第一天所在的周的第一天
754
-
755
- var firstWeekFirstDay = addDays(subDays(firstDay, yearFirstDay), 4); //获取当前年份最后一天
641
+ var yearFirstDay = firstDay.getDay();
642
+ //获取当前年份第一天所在的周的第一天
643
+ var firstWeekFirstDay = addDays(subDays(firstDay, yearFirstDay), 4);
756
644
 
645
+ //获取当前年份最后一天
757
646
  var endDay = subDays(new Date(year + 1, 0, 1), 1);
758
647
  var endWeekDay = firstWeekFirstDay;
759
648
  var weekStrList = [];
760
-
761
649
  while (endWeekDay < endDay) {
762
650
  var first = endWeekDay.getMonth() + 1 + "." + (endWeekDay.getDate() + 1);
763
651
  endWeekDay = addDays(endWeekDay, 7);
@@ -765,23 +653,21 @@ function getYearWeekListWh(year) {
765
653
  var str = first + "-" + end;
766
654
  weekStrList.push(str);
767
655
  }
768
-
769
656
  console.log("weekStrList :" + JSON.stringify(weekStrList));
770
657
  return weekStrList;
771
658
  }
659
+ ;
772
660
 
773
- ; // 判断开始时间是否小于结束时间
774
-
661
+ // 判断开始时间是否小于结束时间
775
662
  function isLessThanDate(startDateStr, endDateStr) {
776
663
  if (new Date(startDateStr).getTime() > new Date(endDateStr).getTime()) {
777
664
  return false;
778
665
  }
779
-
780
666
  return true;
781
667
  }
668
+ ;
782
669
 
783
- ; // 获取日期之间天数
784
-
670
+ // 获取日期之间天数
785
671
  function getDateDiff(firstDate, secondDate) {
786
672
  var diff = Math.abs(firstDate.getTime() - secondDate.getTime());
787
673
  var dateNum = parseInt(diff / (1000 * 60 * 60 * 24), 10);