@vtj/materials 0.10.6 → 0.10.8

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 (77) hide show
  1. package/dist/assets/antdv/index.umd.js +2 -2
  2. package/dist/assets/charts/index.umd.js +2 -2
  3. package/dist/assets/element/index.umd.js +2 -2
  4. package/dist/assets/ui/index.umd.js +2 -2
  5. package/dist/assets/uni-h5/index.umd.js +3 -3
  6. package/dist/assets/uni-ui/index.umd.js +3 -3
  7. package/dist/assets/vant/index.umd.js +2 -2
  8. package/dist/deps/@vtj/charts/index.umd.js +2 -2
  9. package/dist/deps/@vtj/icons/index.umd.js +2 -2
  10. package/dist/deps/@vtj/ui/index.umd.js +3 -3
  11. package/dist/deps/@vtj/utils/index.umd.js +20 -20
  12. package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
  13. package/dist/deps/uni-ui/index.umd.js +1 -1
  14. package/dist/deps/uni-ui/style.css +1 -1
  15. package/package.json +7 -7
  16. package/src/uni-h5/components/input.ts +2 -2
  17. package/src/uni-h5/components/scrollView.ts +3 -3
  18. package/src/uni-h5/components/video.ts +1 -1
  19. package/src/uni-ui/components/badge.ts +1 -5
  20. package/src/uni-ui/components/breadcrumb.ts +1 -20
  21. package/src/uni-ui/components/collapse.ts +22 -23
  22. package/src/uni-ui/components/grid.ts +0 -9
  23. package/src/uni-ui/components/group.ts +1 -10
  24. package/src/uni-ui/components/index.ts +4 -4
  25. package/src/uni-ui/components/popup.ts +10 -2
  26. package/src/uni-ui/components/swiperDot.ts +21 -7
  27. package/src/uni-ui/components/table.ts +9 -3
  28. package/src/uni-ui/components/transition.ts +10 -1
  29. package/src/uni-ui/index.ts +19 -44
  30. package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +153 -0
  31. package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +425 -0
  32. package/src/uni-ui/lib/uni-data-picker/keypress.js +45 -0
  33. package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +604 -0
  34. package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +622 -0
  35. package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +76 -0
  36. package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +335 -0
  37. package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +181 -170
  38. package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +977 -939
  39. package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +1024 -932
  40. package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +15 -17
  41. package/src/uni-ui/lib/uni-datetime-picker/util.js +419 -392
  42. package/src/uni-ui/lib/uni-fav/i18n/en.json +4 -0
  43. package/src/uni-ui/lib/uni-fav/i18n/index.js +8 -0
  44. package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +4 -0
  45. package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +4 -0
  46. package/src/uni-ui/lib/uni-fav/uni-fav.vue +170 -0
  47. package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +280 -0
  48. package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +668 -0
  49. package/src/uni-ui/lib/uni-file-picker/upload-file.vue +325 -0
  50. package/src/uni-ui/lib/uni-file-picker/upload-image.vue +292 -0
  51. package/src/uni-ui/lib/uni-file-picker/utils.js +110 -0
  52. package/src/uni-ui/lib/uni-grid/uni-grid.vue +148 -0
  53. package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +152 -128
  54. package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +50 -50
  55. package/src/uni-ui/lib/uni-load-more/i18n/en.json +5 -0
  56. package/src/uni-ui/lib/uni-load-more/i18n/index.js +8 -0
  57. package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +5 -0
  58. package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +5 -0
  59. package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +456 -0
  60. package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +484 -0
  61. package/src/uni-ui/lib/uni-popup/uni-popup.vue +4 -4
  62. package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +149 -0
  63. package/src/uni-ui/lib/uni-rate/uni-rate.vue +362 -343
  64. package/src/uni-ui/lib/uni-row/uni-row.vue +193 -0
  65. package/src/uni-ui/lib/uni-search-bar/i18n/en.json +4 -0
  66. package/src/uni-ui/lib/uni-search-bar/i18n/index.js +8 -0
  67. package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +4 -0
  68. package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +4 -0
  69. package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +339 -0
  70. package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +294 -285
  71. package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +8 -9
  72. package/src/uni-ui/lib/uni-th/filter-dropdown.vue +551 -503
  73. package/src/uni-ui/lib/uni-tr/table-checkbox.vue +165 -163
  74. package/src/uni-ui/lib/uni-tr/uni-tr.vue +6 -6
  75. package/src/uni-ui/lib/uni-transition/createAnimation.js +131 -0
  76. package/src/uni-ui/lib/uni-transition/uni-transition.vue +310 -0
  77. package/src/version.ts +2 -2
@@ -1,421 +1,448 @@
1
1
  class Calendar {
2
- constructor({
3
- selected,
4
- startDate,
5
- endDate,
6
- range,
7
- } = {}) {
8
- // 当前日期
9
- this.date = this.getDateObj(new Date()) // 当前初入日期
10
- // 打点信息
11
- this.selected = selected || [];
12
- // 起始时间
13
- this.startDate = startDate
14
- // 终止时间
15
- this.endDate = endDate
16
- // 是否范围选择
17
- this.range = range
18
- // 多选状态
19
- this.cleanMultipleStatus()
20
- // 每周日期
21
- this.weeks = {}
22
- this.lastHover = false
23
- }
24
- /**
25
- * 设置日期
26
- * @param {Object} date
27
- */
28
- setDate(date) {
29
- const selectDate = this.getDateObj(date)
30
- this.getWeeks(selectDate.fullDate)
31
- }
32
-
33
- /**
34
- * 清理多选状态
35
- */
36
- cleanMultipleStatus() {
37
- this.multipleStatus = {
38
- before: '',
39
- after: '',
40
- data: []
41
- }
42
- }
43
-
44
- setStartDate(startDate) {
45
- this.startDate = startDate
46
- }
47
-
48
- setEndDate(endDate) {
49
- this.endDate = endDate
50
- }
51
-
52
- getPreMonthObj(date) {
53
- date = fixIosDateFormat(date)
54
- date = new Date(date)
55
-
56
- const oldMonth = date.getMonth()
57
- date.setMonth(oldMonth - 1)
58
- const newMonth = date.getMonth()
59
- if (oldMonth !== 0 && newMonth - oldMonth === 0) {
60
- date.setMonth(newMonth - 1)
61
- }
62
- return this.getDateObj(date)
63
- }
64
- getNextMonthObj(date) {
65
- date = fixIosDateFormat(date)
66
- date = new Date(date)
67
-
68
- const oldMonth = date.getMonth()
69
- date.setMonth(oldMonth + 1)
70
- const newMonth = date.getMonth()
71
- if (newMonth - oldMonth > 1) {
72
- date.setMonth(newMonth - 1)
73
- }
74
- return this.getDateObj(date)
75
- }
76
-
77
- /**
78
- * 获取指定格式Date对象
79
- */
80
- getDateObj(date) {
81
- date = fixIosDateFormat(date)
82
- date = new Date(date)
83
-
84
- return {
85
- fullDate: getDate(date),
86
- year: date.getFullYear(),
87
- month: addZero(date.getMonth() + 1),
88
- date: addZero(date.getDate()),
89
- day: date.getDay()
90
- }
91
- }
92
-
93
- /**
94
- * 获取上一个月日期集合
95
- */
96
- getPreMonthDays(amount, dateObj) {
97
- const result = []
98
- for (let i = amount - 1; i >= 0; i--) {
99
- const month = dateObj.month - 1
100
- result.push({
101
- date: new Date(dateObj.year, month, -i).getDate(),
102
- month,
103
- disable: true
104
- })
105
- }
106
- return result
107
- }
108
- /**
109
- * 获取本月日期集合
110
- */
111
- getCurrentMonthDays(amount, dateObj) {
112
- const result = []
113
- const fullDate = this.date.fullDate
114
- for (let i = 1; i <= amount; i++) {
115
- const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
116
- const isToday = fullDate === currentDate
117
- // 获取打点信息
118
- const info = this.selected && this.selected.find((item) => {
119
- if (this.dateEqual(currentDate, item.date)) {
120
- return item
121
- }
122
- })
123
-
124
- // 日期禁用
125
- let disableBefore = true
126
- let disableAfter = true
127
- if (this.startDate) {
128
- disableBefore = dateCompare(this.startDate, currentDate)
129
- }
130
-
131
- if (this.endDate) {
132
- disableAfter = dateCompare(currentDate, this.endDate)
133
- }
134
-
135
- let multiples = this.multipleStatus.data
136
- let multiplesStatus = -1
137
- if (this.range && multiples) {
138
- multiplesStatus = multiples.findIndex((item) => {
139
- return this.dateEqual(item, currentDate)
140
- })
141
- }
142
- const checked = multiplesStatus !== -1
143
-
144
- result.push({
145
- fullDate: currentDate,
146
- year: dateObj.year,
147
- date: i,
148
- multiple: this.range ? checked : false,
149
- beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
150
- afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
151
- month: dateObj.month,
152
- disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(
153
- currentDate, this.endDate)),
154
- isToday,
155
- userChecked: false,
156
- extraInfo: info
157
- })
158
- }
159
- return result
160
- }
161
- /**
162
- * 获取下一个月日期集合
163
- */
164
- _getNextMonthDays(amount, dateObj) {
165
- const result = []
166
- const month = dateObj.month + 1
167
- for (let i = 1; i <= amount; i++) {
168
- result.push({
169
- date: i,
170
- month,
171
- disable: true
172
- })
173
- }
174
- return result
175
- }
176
-
177
- /**
178
- * 获取当前日期详情
179
- * @param {Object} date
180
- */
181
- getInfo(date) {
182
- if (!date) {
183
- date = new Date()
184
- }
185
- const res = this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
186
- return res ? res : this.getDateObj(date)
187
- }
188
-
189
- /**
190
- * 比较时间是否相等
191
- */
192
- dateEqual(before, after) {
193
- before = new Date(fixIosDateFormat(before))
194
- after = new Date(fixIosDateFormat(after))
195
- return before.valueOf() === after.valueOf()
196
- }
197
-
198
- /**
199
- * 比较真实起始日期
200
- */
201
-
202
- isLogicBefore(currentDate, before, after) {
203
- let logicBefore = before
204
- if (before && after) {
205
- logicBefore = dateCompare(before, after) ? before : after
206
- }
207
- return this.dateEqual(logicBefore, currentDate)
208
- }
209
-
210
- isLogicAfter(currentDate, before, after) {
211
- let logicAfter = after
212
- if (before && after) {
213
- logicAfter = dateCompare(before, after) ? after : before
214
- }
215
- return this.dateEqual(logicAfter, currentDate)
216
- }
217
-
218
- /**
219
- * 获取日期范围内所有日期
220
- * @param {Object} begin
221
- * @param {Object} end
222
- */
223
- geDateAll(begin, end) {
224
- var arr = []
225
- var ab = begin.split('-')
226
- var ae = end.split('-')
227
- var db = new Date()
228
- db.setFullYear(ab[0], ab[1] - 1, ab[2])
229
- var de = new Date()
230
- de.setFullYear(ae[0], ae[1] - 1, ae[2])
231
- var unixDb = db.getTime() - 24 * 60 * 60 * 1000
232
- var unixDe = de.getTime() - 24 * 60 * 60 * 1000
233
- for (var k = unixDb; k <= unixDe;) {
234
- k = k + 24 * 60 * 60 * 1000
235
- arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
236
- }
237
- return arr
238
- }
239
-
240
- /**
241
- * 获取多选状态
242
- */
243
- setMultiple(fullDate) {
244
- if (!this.range) return
245
-
246
- let {
247
- before,
248
- after
249
- } = this.multipleStatus
250
- if (before && after) {
251
- if (!this.lastHover) {
252
- this.lastHover = true
253
- return
254
- }
255
- this.multipleStatus.before = fullDate
256
- this.multipleStatus.after = ''
257
- this.multipleStatus.data = []
258
- this.multipleStatus.fulldate = ''
259
- this.lastHover = false
260
- } else {
261
- if (!before) {
262
- this.multipleStatus.before = fullDate
263
- this.multipleStatus.after = undefined;
264
- this.lastHover = false
265
- } else {
266
- this.multipleStatus.after = fullDate
267
- if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
268
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
269
- .after);
270
- } else {
271
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
272
- .before);
273
- }
274
- this.lastHover = true
275
- }
276
- }
277
- this.getWeeks(fullDate)
278
- }
279
-
280
- /**
281
- * 鼠标 hover 更新多选状态
282
- */
283
- setHoverMultiple(fullDate) {
284
- //抖音小程序点击会触发hover事件,需要避免一下
285
- // #ifndef MP-TOUTIAO
286
- if (!this.range || this.lastHover) return
287
- const {
288
- before
289
- } = this.multipleStatus
290
-
291
- if (!before) {
292
- this.multipleStatus.before = fullDate
293
- } else {
294
- this.multipleStatus.after = fullDate
295
- if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
296
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
297
- } else {
298
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
299
- }
300
- }
301
- this.getWeeks(fullDate)
302
- // #endif
303
-
304
- }
305
-
306
- /**
307
- * 更新默认值多选状态
308
- */
309
- setDefaultMultiple(before, after) {
310
- this.multipleStatus.before = before
311
- this.multipleStatus.after = after
312
- if (before && after) {
313
- if (dateCompare(before, after)) {
314
- this.multipleStatus.data = this.geDateAll(before, after);
315
- this.getWeeks(after)
316
- } else {
317
- this.multipleStatus.data = this.geDateAll(after, before);
318
- this.getWeeks(before)
319
- }
320
- }
321
- }
322
-
323
- /**
324
- * 获取每周数据
325
- * @param {Object} dateData
326
- */
327
- getWeeks(dateData) {
328
- const {
329
- year,
330
- month,
331
- } = this.getDateObj(dateData)
332
-
333
- const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
334
- const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
335
-
336
- const currentMonthDayAmount = new Date(year, month, 0).getDate()
337
- const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
338
-
339
- const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
340
- const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
341
-
342
- const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
343
-
344
- const weeks = new Array(6)
345
- for (let i = 0; i < calendarDays.length; i++) {
346
- const index = Math.floor(i / 7)
347
- if (!weeks[index]) {
348
- weeks[index] = new Array(7)
349
- }
350
- weeks[index][i % 7] = calendarDays[i]
351
- }
352
-
353
- this.calendar = calendarDays
354
- this.weeks = weeks
355
- }
2
+ constructor({ selected, startDate, endDate, range } = {}) {
3
+ // 当前日期
4
+ this.date = this.getDateObj(new Date()); // 当前初入日期
5
+ // 打点信息
6
+ this.selected = selected || [];
7
+ // 起始时间
8
+ this.startDate = startDate;
9
+ // 终止时间
10
+ this.endDate = endDate;
11
+ // 是否范围选择
12
+ this.range = range;
13
+ // 多选状态
14
+ this.cleanMultipleStatus();
15
+ // 每周日期
16
+ this.weeks = {};
17
+ this.lastHover = false;
18
+ }
19
+ /**
20
+ * 设置日期
21
+ * @param {Object} date
22
+ */
23
+ setDate(date) {
24
+ const selectDate = this.getDateObj(date);
25
+ this.getWeeks(selectDate.fullDate);
26
+ }
27
+
28
+ /**
29
+ * 清理多选状态
30
+ */
31
+ cleanMultipleStatus() {
32
+ this.multipleStatus = {
33
+ before: '',
34
+ after: '',
35
+ data: []
36
+ };
37
+ }
38
+
39
+ setStartDate(startDate) {
40
+ this.startDate = startDate;
41
+ }
42
+
43
+ setEndDate(endDate) {
44
+ this.endDate = endDate;
45
+ }
46
+
47
+ getPreMonthObj(date) {
48
+ date = fixIosDateFormat(date);
49
+ date = new Date(date);
50
+
51
+ const oldMonth = date.getMonth();
52
+ date.setMonth(oldMonth - 1);
53
+ const newMonth = date.getMonth();
54
+ if (oldMonth !== 0 && newMonth - oldMonth === 0) {
55
+ date.setMonth(newMonth - 1);
56
+ }
57
+ return this.getDateObj(date);
58
+ }
59
+ getNextMonthObj(date) {
60
+ date = fixIosDateFormat(date);
61
+ date = new Date(date);
62
+
63
+ const oldMonth = date.getMonth();
64
+ date.setMonth(oldMonth + 1);
65
+ const newMonth = date.getMonth();
66
+ if (newMonth - oldMonth > 1) {
67
+ date.setMonth(newMonth - 1);
68
+ }
69
+ return this.getDateObj(date);
70
+ }
71
+
72
+ /**
73
+ * 获取指定格式Date对象
74
+ */
75
+ getDateObj(date) {
76
+ date = fixIosDateFormat(date);
77
+ date = new Date(date);
78
+
79
+ return {
80
+ fullDate: getDate(date),
81
+ year: date.getFullYear(),
82
+ month: addZero(date.getMonth() + 1),
83
+ date: addZero(date.getDate()),
84
+ day: date.getDay()
85
+ };
86
+ }
87
+
88
+ /**
89
+ * 获取上一个月日期集合
90
+ */
91
+ getPreMonthDays(amount, dateObj) {
92
+ const result = [];
93
+ for (let i = amount - 1; i >= 0; i--) {
94
+ const month = dateObj.month - 1;
95
+ result.push({
96
+ date: new Date(dateObj.year, month, -i).getDate(),
97
+ month,
98
+ disable: true
99
+ });
100
+ }
101
+ return result;
102
+ }
103
+ /**
104
+ * 获取本月日期集合
105
+ */
106
+ getCurrentMonthDays(amount, dateObj) {
107
+ const result = [];
108
+ const fullDate = this.date.fullDate;
109
+ for (let i = 1; i <= amount; i++) {
110
+ const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`;
111
+ const isToday = fullDate === currentDate;
112
+ // 获取打点信息
113
+ const info =
114
+ this.selected &&
115
+ this.selected.find((item) => {
116
+ if (this.dateEqual(currentDate, item.date)) {
117
+ return item;
118
+ }
119
+ });
120
+
121
+ // 日期禁用
122
+ let disableBefore = true;
123
+ let disableAfter = true;
124
+ if (this.startDate) {
125
+ disableBefore = dateCompare(this.startDate, currentDate);
126
+ }
127
+
128
+ if (this.endDate) {
129
+ disableAfter = dateCompare(currentDate, this.endDate);
130
+ }
131
+
132
+ let multiples = this.multipleStatus.data;
133
+ let multiplesStatus = -1;
134
+ if (this.range && multiples) {
135
+ multiplesStatus = multiples.findIndex((item) => {
136
+ return this.dateEqual(item, currentDate);
137
+ });
138
+ }
139
+ const checked = multiplesStatus !== -1;
140
+
141
+ result.push({
142
+ fullDate: currentDate,
143
+ year: dateObj.year,
144
+ date: i,
145
+ multiple: this.range ? checked : false,
146
+ beforeMultiple: this.isLogicBefore(
147
+ currentDate,
148
+ this.multipleStatus.before,
149
+ this.multipleStatus.after
150
+ ),
151
+ afterMultiple: this.isLogicAfter(
152
+ currentDate,
153
+ this.multipleStatus.before,
154
+ this.multipleStatus.after
155
+ ),
156
+ month: dateObj.month,
157
+ disable:
158
+ (this.startDate && !dateCompare(this.startDate, currentDate)) ||
159
+ (this.endDate && !dateCompare(currentDate, this.endDate)),
160
+ isToday,
161
+ userChecked: false,
162
+ extraInfo: info
163
+ });
164
+ }
165
+ return result;
166
+ }
167
+ /**
168
+ * 获取下一个月日期集合
169
+ */
170
+ _getNextMonthDays(amount, dateObj) {
171
+ const result = [];
172
+ const month = dateObj.month + 1;
173
+ for (let i = 1; i <= amount; i++) {
174
+ result.push({
175
+ date: i,
176
+ month,
177
+ disable: true
178
+ });
179
+ }
180
+ return result;
181
+ }
182
+
183
+ /**
184
+ * 获取当前日期详情
185
+ * @param {Object} date
186
+ */
187
+ getInfo(date) {
188
+ if (!date) {
189
+ date = new Date();
190
+ }
191
+ const res = this.calendar.find(
192
+ (item) => item.fullDate === this.getDateObj(date).fullDate
193
+ );
194
+ return res ? res : this.getDateObj(date);
195
+ }
196
+
197
+ /**
198
+ * 比较时间是否相等
199
+ */
200
+ dateEqual(before, after) {
201
+ before = new Date(fixIosDateFormat(before));
202
+ after = new Date(fixIosDateFormat(after));
203
+ return before.valueOf() === after.valueOf();
204
+ }
205
+
206
+ /**
207
+ * 比较真实起始日期
208
+ */
209
+
210
+ isLogicBefore(currentDate, before, after) {
211
+ let logicBefore = before;
212
+ if (before && after) {
213
+ logicBefore = dateCompare(before, after) ? before : after;
214
+ }
215
+ return this.dateEqual(logicBefore, currentDate);
216
+ }
217
+
218
+ isLogicAfter(currentDate, before, after) {
219
+ let logicAfter = after;
220
+ if (before && after) {
221
+ logicAfter = dateCompare(before, after) ? after : before;
222
+ }
223
+ return this.dateEqual(logicAfter, currentDate);
224
+ }
225
+
226
+ /**
227
+ * 获取日期范围内所有日期
228
+ * @param {Object} begin
229
+ * @param {Object} end
230
+ */
231
+ geDateAll(begin, end) {
232
+ var arr = [];
233
+ var ab = begin.split('-');
234
+ var ae = end.split('-');
235
+ var db = new Date();
236
+ db.setFullYear(ab[0], ab[1] - 1, ab[2]);
237
+ var de = new Date();
238
+ de.setFullYear(ae[0], ae[1] - 1, ae[2]);
239
+ var unixDb = db.getTime() - 24 * 60 * 60 * 1000;
240
+ var unixDe = de.getTime() - 24 * 60 * 60 * 1000;
241
+ for (var k = unixDb; k <= unixDe; ) {
242
+ k = k + 24 * 60 * 60 * 1000;
243
+ arr.push(this.getDateObj(new Date(parseInt(k))).fullDate);
244
+ }
245
+ return arr;
246
+ }
247
+
248
+ /**
249
+ * 获取多选状态
250
+ */
251
+ setMultiple(fullDate) {
252
+ if (!this.range) return;
253
+
254
+ let { before, after } = this.multipleStatus;
255
+ if (before && after) {
256
+ if (!this.lastHover) {
257
+ this.lastHover = true;
258
+ return;
259
+ }
260
+ this.multipleStatus.before = fullDate;
261
+ this.multipleStatus.after = '';
262
+ this.multipleStatus.data = [];
263
+ this.multipleStatus.fulldate = '';
264
+ this.lastHover = false;
265
+ } else {
266
+ if (!before) {
267
+ this.multipleStatus.before = fullDate;
268
+ this.multipleStatus.after = undefined;
269
+ this.lastHover = false;
270
+ } else {
271
+ this.multipleStatus.after = fullDate;
272
+ if (
273
+ dateCompare(this.multipleStatus.before, this.multipleStatus.after)
274
+ ) {
275
+ this.multipleStatus.data = this.geDateAll(
276
+ this.multipleStatus.before,
277
+ this.multipleStatus.after
278
+ );
279
+ } else {
280
+ this.multipleStatus.data = this.geDateAll(
281
+ this.multipleStatus.after,
282
+ this.multipleStatus.before
283
+ );
284
+ }
285
+ this.lastHover = true;
286
+ }
287
+ }
288
+ this.getWeeks(fullDate);
289
+ }
290
+
291
+ /**
292
+ * 鼠标 hover 更新多选状态
293
+ */
294
+ setHoverMultiple(fullDate) {
295
+ //抖音小程序点击会触发hover事件,需要避免一下
296
+ // #ifndef MP-TOUTIAO
297
+ if (!this.range || this.lastHover) return;
298
+ const { before } = this.multipleStatus;
299
+
300
+ if (!before) {
301
+ this.multipleStatus.before = fullDate;
302
+ } else {
303
+ this.multipleStatus.after = fullDate;
304
+ if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
305
+ this.multipleStatus.data = this.geDateAll(
306
+ this.multipleStatus.before,
307
+ this.multipleStatus.after
308
+ );
309
+ } else {
310
+ this.multipleStatus.data = this.geDateAll(
311
+ this.multipleStatus.after,
312
+ this.multipleStatus.before
313
+ );
314
+ }
315
+ }
316
+ this.getWeeks(fullDate);
317
+ // #endif
318
+ }
319
+
320
+ /**
321
+ * 更新默认值多选状态
322
+ */
323
+ setDefaultMultiple(before, after) {
324
+ this.multipleStatus.before = before;
325
+ this.multipleStatus.after = after;
326
+ if (before && after) {
327
+ if (dateCompare(before, after)) {
328
+ this.multipleStatus.data = this.geDateAll(before, after);
329
+ this.getWeeks(after);
330
+ } else {
331
+ this.multipleStatus.data = this.geDateAll(after, before);
332
+ this.getWeeks(before);
333
+ }
334
+ }
335
+ }
336
+
337
+ /**
338
+ * 获取每周数据
339
+ * @param {Object} dateData
340
+ */
341
+ getWeeks(dateData) {
342
+ const { year, month } = this.getDateObj(dateData);
343
+
344
+ const preMonthDayAmount = new Date(year, month - 1, 1).getDay();
345
+ const preMonthDays = this.getPreMonthDays(
346
+ preMonthDayAmount,
347
+ this.getDateObj(dateData)
348
+ );
349
+
350
+ const currentMonthDayAmount = new Date(year, month, 0).getDate();
351
+ const currentMonthDays = this.getCurrentMonthDays(
352
+ currentMonthDayAmount,
353
+ this.getDateObj(dateData)
354
+ );
355
+
356
+ const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount;
357
+ const nextMonthDays = this._getNextMonthDays(
358
+ nextMonthDayAmount,
359
+ this.getDateObj(dateData)
360
+ );
361
+
362
+ const calendarDays = [
363
+ ...preMonthDays,
364
+ ...currentMonthDays,
365
+ ...nextMonthDays
366
+ ];
367
+
368
+ const weeks = new Array(6);
369
+ for (let i = 0; i < calendarDays.length; i++) {
370
+ const index = Math.floor(i / 7);
371
+ if (!weeks[index]) {
372
+ weeks[index] = new Array(7);
373
+ }
374
+ weeks[index][i % 7] = calendarDays[i];
375
+ }
376
+
377
+ this.calendar = calendarDays;
378
+ this.weeks = weeks;
379
+ }
356
380
  }
357
381
 
358
382
  function getDateTime(date, hideSecond) {
359
- return `${getDate(date)} ${getTime(date, hideSecond)}`
383
+ return `${getDate(date)} ${getTime(date, hideSecond)}`;
360
384
  }
361
385
 
362
386
  function getDate(date) {
363
- date = fixIosDateFormat(date)
364
- date = new Date(date)
365
- const year = date.getFullYear()
366
- const month = date.getMonth() + 1
367
- const day = date.getDate()
368
- return `${year}-${addZero(month)}-${addZero(day)}`
387
+ date = fixIosDateFormat(date);
388
+ date = new Date(date);
389
+ const year = date.getFullYear();
390
+ const month = date.getMonth() + 1;
391
+ const day = date.getDate();
392
+ return `${year}-${addZero(month)}-${addZero(day)}`;
369
393
  }
370
394
 
371
395
  function getTime(date, hideSecond) {
372
- date = fixIosDateFormat(date)
373
- date = new Date(date)
374
- const hour = date.getHours()
375
- const minute = date.getMinutes()
376
- const second = date.getSeconds()
377
- return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
396
+ date = fixIosDateFormat(date);
397
+ date = new Date(date);
398
+ const hour = date.getHours();
399
+ const minute = date.getMinutes();
400
+ const second = date.getSeconds();
401
+ return hideSecond
402
+ ? `${addZero(hour)}:${addZero(minute)}`
403
+ : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`;
378
404
  }
379
405
 
380
406
  function addZero(num) {
381
- if (num < 10) {
382
- num = `0${num}`
383
- }
384
- return num
407
+ if (num < 10) {
408
+ num = `0${num}`;
409
+ }
410
+ return num;
385
411
  }
386
412
 
387
413
  function getDefaultSecond(hideSecond) {
388
- return hideSecond ? '00:00' : '00:00:00'
414
+ return hideSecond ? '00:00' : '00:00:00';
389
415
  }
390
416
 
391
417
  function dateCompare(startDate, endDate) {
392
- startDate = new Date(fixIosDateFormat(startDate))
393
- endDate = new Date(fixIosDateFormat(endDate))
394
- return startDate <= endDate
418
+ startDate = new Date(fixIosDateFormat(startDate));
419
+ endDate = new Date(fixIosDateFormat(endDate));
420
+ return startDate <= endDate;
395
421
  }
396
422
 
397
423
  function checkDate(date) {
398
- const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
399
- return date.match(dateReg)
424
+ const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g;
425
+ return date.match(dateReg);
400
426
  }
401
427
  //ios低版本15及以下,无法匹配 没有 ’秒‘ 时的情况,所以需要在末尾 秒 加上 问号
402
- const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9](:[0-5]?[0-9])?)?$/;
428
+ const dateTimeReg =
429
+ /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9](:[0-5]?[0-9])?)?$/;
403
430
 
404
431
  function fixIosDateFormat(value) {
405
- if (typeof value === 'string' && dateTimeReg.test(value)) {
406
- value = value.replace(/-/g, '/')
407
- }
408
- return value
432
+ if (typeof value === 'string' && dateTimeReg.test(value)) {
433
+ value = value.replace(/-/g, '/');
434
+ }
435
+ return value;
409
436
  }
410
437
 
411
438
  export {
412
- Calendar,
413
- getDateTime,
414
- getDate,
415
- getTime,
416
- addZero,
417
- getDefaultSecond,
418
- dateCompare,
419
- checkDate,
420
- fixIosDateFormat
421
- }
439
+ Calendar,
440
+ getDateTime,
441
+ getDate,
442
+ getTime,
443
+ addZero,
444
+ getDefaultSecond,
445
+ dateCompare,
446
+ checkDate,
447
+ fixIosDateFormat
448
+ };