@vtj/materials 0.10.6 → 0.10.7
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.
- package/dist/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +3 -3
- package/dist/assets/uni-ui/index.umd.js +3 -3
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +3 -3
- package/dist/deps/@vtj/utils/index.umd.js +20 -20
- package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/package.json +7 -7
- package/src/uni-h5/components/input.ts +2 -2
- package/src/uni-h5/components/scrollView.ts +3 -3
- package/src/uni-h5/components/video.ts +1 -1
- package/src/uni-ui/components/badge.ts +1 -5
- package/src/uni-ui/components/breadcrumb.ts +1 -20
- package/src/uni-ui/components/collapse.ts +22 -23
- package/src/uni-ui/components/grid.ts +0 -9
- package/src/uni-ui/components/group.ts +1 -10
- package/src/uni-ui/components/index.ts +4 -4
- package/src/uni-ui/components/popup.ts +10 -2
- package/src/uni-ui/components/swiperDot.ts +21 -7
- package/src/uni-ui/components/table.ts +9 -3
- package/src/uni-ui/components/transition.ts +10 -1
- package/src/uni-ui/index.ts +19 -44
- package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +153 -0
- package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +425 -0
- package/src/uni-ui/lib/uni-data-picker/keypress.js +45 -0
- package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +604 -0
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +622 -0
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +76 -0
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +335 -0
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +181 -170
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +977 -939
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +1024 -932
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +15 -17
- package/src/uni-ui/lib/uni-datetime-picker/util.js +419 -392
- package/src/uni-ui/lib/uni-fav/i18n/en.json +4 -0
- package/src/uni-ui/lib/uni-fav/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +4 -0
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +4 -0
- package/src/uni-ui/lib/uni-fav/uni-fav.vue +170 -0
- package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +280 -0
- package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +668 -0
- package/src/uni-ui/lib/uni-file-picker/upload-file.vue +325 -0
- package/src/uni-ui/lib/uni-file-picker/upload-image.vue +292 -0
- package/src/uni-ui/lib/uni-file-picker/utils.js +110 -0
- package/src/uni-ui/lib/uni-grid/uni-grid.vue +148 -0
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +152 -128
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +50 -50
- package/src/uni-ui/lib/uni-load-more/i18n/en.json +5 -0
- package/src/uni-ui/lib/uni-load-more/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +5 -0
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +5 -0
- package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +456 -0
- package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +484 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +4 -4
- package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +149 -0
- package/src/uni-ui/lib/uni-rate/uni-rate.vue +362 -343
- package/src/uni-ui/lib/uni-row/uni-row.vue +193 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/en.json +4 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +339 -0
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +294 -285
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +8 -9
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +551 -503
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +165 -163
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +6 -6
- package/src/uni-ui/lib/uni-transition/createAnimation.js +131 -0
- package/src/uni-ui/lib/uni-transition/uni-transition.vue +310 -0
- package/src/version.ts +2 -2
@@ -1,421 +1,448 @@
|
|
1
1
|
class Calendar {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
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
|
-
|
383
|
+
return `${getDate(date)} ${getTime(date, hideSecond)}`;
|
360
384
|
}
|
361
385
|
|
362
386
|
function getDate(date) {
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
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
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
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
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
407
|
+
if (num < 10) {
|
408
|
+
num = `0${num}`;
|
409
|
+
}
|
410
|
+
return num;
|
385
411
|
}
|
386
412
|
|
387
413
|
function getDefaultSecond(hideSecond) {
|
388
|
-
|
414
|
+
return hideSecond ? '00:00' : '00:00:00';
|
389
415
|
}
|
390
416
|
|
391
417
|
function dateCompare(startDate, endDate) {
|
392
|
-
|
393
|
-
|
394
|
-
|
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
|
-
|
399
|
-
|
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 =
|
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
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
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
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
}
|
439
|
+
Calendar,
|
440
|
+
getDateTime,
|
441
|
+
getDate,
|
442
|
+
getTime,
|
443
|
+
addZero,
|
444
|
+
getDefaultSecond,
|
445
|
+
dateCompare,
|
446
|
+
checkDate,
|
447
|
+
fixIosDateFormat
|
448
|
+
};
|