huiyi-time 0.1.1 → 0.1.2
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/huiyi-time.es.js +613 -0
- package/dist/huiyi-time.umd.js +1 -0
- package/dist/index.html +17 -1
- package/dist/style.css +1 -0
- package/huiyi-time/package.json +2 -2
- package/package.json +10 -31
- package/vite.config.js +33 -0
- package/dist/js/chunk-vendors.887ff85c.js +0 -46
- package/dist/js/chunk-vendors.887ff85c.js.map +0 -1
- package/dist/js/index.c8d1f43d.js +0 -2
- package/dist/js/index.c8d1f43d.js.map +0 -1
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import { resolveComponent as I, openBlock as h, createElementBlock as p, createElementVNode as i, createVNode as Y, normalizeClass as v, normalizeStyle as F, withModifiers as D, Fragment as f, renderList as m, toDisplayString as g } from "vue";
|
|
2
|
+
const S = (t, e) => {
|
|
3
|
+
const n = t.__vccOpts || t;
|
|
4
|
+
for (const [r, l] of e)
|
|
5
|
+
n[r] = l;
|
|
6
|
+
return n;
|
|
7
|
+
}, _ = {
|
|
8
|
+
name: "TimeComponentsUp",
|
|
9
|
+
props: {
|
|
10
|
+
initTime: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: ""
|
|
13
|
+
// 默认返回空对象
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
// 这里是你的数据
|
|
19
|
+
showPanel: !1,
|
|
20
|
+
startDate: /* @__PURE__ */ new Date(),
|
|
21
|
+
endDate: /* @__PURE__ */ new Date(),
|
|
22
|
+
activeControl: "startYear",
|
|
23
|
+
selectedRange: null,
|
|
24
|
+
inputValue: "",
|
|
25
|
+
isInvalid: !1,
|
|
26
|
+
inputSelection: {
|
|
27
|
+
start: 0,
|
|
28
|
+
end: 0
|
|
29
|
+
},
|
|
30
|
+
mouseOver: !1,
|
|
31
|
+
startCalendarViewDate: /* @__PURE__ */ new Date(),
|
|
32
|
+
endCalendarViewDate: /* @__PURE__ */ new Date(),
|
|
33
|
+
quickOptions: {
|
|
34
|
+
common: [
|
|
35
|
+
{ name: "近3月", type: "months", value: 3, active: !1 },
|
|
36
|
+
{ name: "近1年", type: "years", value: 1, active: !1 }
|
|
37
|
+
],
|
|
38
|
+
today: [],
|
|
39
|
+
yesterday: [
|
|
40
|
+
{ name: "昨天", type: "yesterday", value: "full", active: !1 }
|
|
41
|
+
],
|
|
42
|
+
thisWeek: [
|
|
43
|
+
{ name: "本周", type: "thisWeek", value: "full", active: !1 }
|
|
44
|
+
],
|
|
45
|
+
thisMonth: [
|
|
46
|
+
{ name: "本月", type: "thisMonth", value: "full", active: !1 }
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
dateFormatter: new Intl.DateTimeFormat("en-US", { year: "numeric", month: "long", day: "2-digit" })
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
computed: {
|
|
53
|
+
startDateMonthYear() {
|
|
54
|
+
const t = this.startCalendarViewDate.getFullYear(), e = this.startCalendarViewDate.getMonth() + 1;
|
|
55
|
+
return `${t}年${e}月`;
|
|
56
|
+
},
|
|
57
|
+
endDateMonthYear() {
|
|
58
|
+
const t = this.endCalendarViewDate.getFullYear(), e = this.endCalendarViewDate.getMonth() + 1;
|
|
59
|
+
return `${t}年${e}月`;
|
|
60
|
+
},
|
|
61
|
+
startCalendarDays() {
|
|
62
|
+
return this.generateCalendarDays(this.startCalendarViewDate, this.startDate, this.endDate, "start");
|
|
63
|
+
},
|
|
64
|
+
endCalendarDays() {
|
|
65
|
+
return this.generateCalendarDays(this.endCalendarViewDate, this.startDate, this.endDate, "end");
|
|
66
|
+
},
|
|
67
|
+
// 定义输入框中各个时间字段的位置范围
|
|
68
|
+
fieldPositions() {
|
|
69
|
+
return [
|
|
70
|
+
{ name: "startYear", start: 0, end: 4, length: 4 },
|
|
71
|
+
{ name: "startMonth", start: 5, end: 7, length: 2 },
|
|
72
|
+
{ name: "startDay", start: 8, end: 10, length: 2 },
|
|
73
|
+
{ name: "endYear", start: 13, end: 17, length: 4 },
|
|
74
|
+
{ name: "endMonth", start: 18, end: 20, length: 2 },
|
|
75
|
+
{ name: "endDay", start: 21, end: 23, length: 2 }
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
mounted() {
|
|
80
|
+
console.log(this.initTime, "this.initTime"), this.inputValue = this.initTime, this.updateQuickOptionsActiveState();
|
|
81
|
+
},
|
|
82
|
+
methods: {
|
|
83
|
+
setActiveControl(t) {
|
|
84
|
+
this.activeControl = t;
|
|
85
|
+
},
|
|
86
|
+
// 更新输入框的值
|
|
87
|
+
updateInputValue() {
|
|
88
|
+
const t = (e) => {
|
|
89
|
+
const n = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), l = String(e.getDate()).padStart(2, "0");
|
|
90
|
+
return `${n}-${r}-${l}`;
|
|
91
|
+
};
|
|
92
|
+
this.inputValue = `${t(this.startDate)} ~ ${t(this.endDate)}`, this.modelClick();
|
|
93
|
+
},
|
|
94
|
+
// 输入框获得焦点时
|
|
95
|
+
onInputFocus(t) {
|
|
96
|
+
console.log(t), setTimeout(() => {
|
|
97
|
+
this.inputSelection = {
|
|
98
|
+
start: t.target.selectionStart,
|
|
99
|
+
end: t.target.selectionEnd
|
|
100
|
+
}, console.log(t.target.selectionStart, this.inputSelection.start, "this.inputSelection.start"), this.selectCurrentField(this.inputSelection.start);
|
|
101
|
+
}, 0);
|
|
102
|
+
},
|
|
103
|
+
// 输入框失去焦点时
|
|
104
|
+
onInputBlur() {
|
|
105
|
+
this.validateInput();
|
|
106
|
+
},
|
|
107
|
+
// 输入框内容变化时
|
|
108
|
+
onInputChange() {
|
|
109
|
+
this.validateInput();
|
|
110
|
+
},
|
|
111
|
+
// 输入框键盘事件
|
|
112
|
+
onInputKeydown(t) {
|
|
113
|
+
const e = t.key;
|
|
114
|
+
["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(e) && (t.preventDefault(), e === "ArrowLeft" ? this.navigateLeft() : e === "ArrowRight" ? this.navigateRight() : e === "ArrowUp" ? this.incrementValue() : e === "ArrowDown" && this.decrementValue()), e === "Tab" && (t.preventDefault(), t.shiftKey ? this.navigateLeft() : this.navigateRight()), e === "Enter" && (t.preventDefault(), this.showPanel = !1);
|
|
115
|
+
},
|
|
116
|
+
// 向左导航
|
|
117
|
+
navigateLeft() {
|
|
118
|
+
const t = this.inputSelection.start;
|
|
119
|
+
let e = null;
|
|
120
|
+
for (let n = 0; n < this.fieldPositions.length; n++)
|
|
121
|
+
if (t >= this.fieldPositions[n].start && t <= this.fieldPositions[n].end) {
|
|
122
|
+
n > 0 ? e = this.fieldPositions[n - 1] : e = this.fieldPositions[this.fieldPositions.length - 1];
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
e || (e = this.fieldPositions[0]), this.selectField(e);
|
|
126
|
+
},
|
|
127
|
+
// 向右导航
|
|
128
|
+
navigateRight() {
|
|
129
|
+
const t = this.inputSelection.start;
|
|
130
|
+
let e = null;
|
|
131
|
+
console.log(this.fieldPositions, "this.fieldPositions");
|
|
132
|
+
for (let n = 0; n < this.fieldPositions.length; n++)
|
|
133
|
+
if (t >= this.fieldPositions[n].start && t <= this.fieldPositions[n].end) {
|
|
134
|
+
n < this.fieldPositions.length - 1 ? e = this.fieldPositions[n + 1] : e = this.fieldPositions[0];
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
e || (e = this.fieldPositions[0]), this.selectField(e);
|
|
138
|
+
},
|
|
139
|
+
// 选择当前字段
|
|
140
|
+
selectCurrentField(t) {
|
|
141
|
+
console.log(this.fieldPositions, t, "this.fieldPositions");
|
|
142
|
+
for (const e of this.fieldPositions)
|
|
143
|
+
if (t >= e.start && t <= e.end) {
|
|
144
|
+
console.log(e, "this.field"), this.selectField(e);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this.selectField(this.fieldPositions[0]);
|
|
148
|
+
},
|
|
149
|
+
// 选择指定字段
|
|
150
|
+
selectField(t) {
|
|
151
|
+
document.getElementById("datetime-input").setSelectionRange(t.start, t.end), this.inputSelection = {
|
|
152
|
+
start: t.start,
|
|
153
|
+
end: t.end
|
|
154
|
+
}, this.activeControl = t.name;
|
|
155
|
+
},
|
|
156
|
+
// 增加当前字段的值
|
|
157
|
+
incrementValue() {
|
|
158
|
+
const t = this.getCurrentField();
|
|
159
|
+
if (!t)
|
|
160
|
+
return;
|
|
161
|
+
let n = parseInt(this.inputValue.substring(t.start, t.end)) + 1;
|
|
162
|
+
switch (t.name) {
|
|
163
|
+
case "startYear":
|
|
164
|
+
case "endYear":
|
|
165
|
+
break;
|
|
166
|
+
case "startMonth":
|
|
167
|
+
case "endMonth":
|
|
168
|
+
n > 12 && (n = 1);
|
|
169
|
+
break;
|
|
170
|
+
case "startDay":
|
|
171
|
+
case "endDay":
|
|
172
|
+
n > 31 && (n = 1);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
this.updateFieldValue(t, n);
|
|
176
|
+
},
|
|
177
|
+
// 减少当前字段的值
|
|
178
|
+
decrementValue() {
|
|
179
|
+
const t = this.getCurrentField();
|
|
180
|
+
if (!t)
|
|
181
|
+
return;
|
|
182
|
+
let n = parseInt(this.inputValue.substring(t.start, t.end)) - 1;
|
|
183
|
+
switch (t.name) {
|
|
184
|
+
case "startYear":
|
|
185
|
+
case "endYear":
|
|
186
|
+
n < 1 && (n = 9999);
|
|
187
|
+
break;
|
|
188
|
+
case "startMonth":
|
|
189
|
+
case "endMonth":
|
|
190
|
+
n < 1 && (n = 12);
|
|
191
|
+
break;
|
|
192
|
+
case "startDay":
|
|
193
|
+
case "endDay":
|
|
194
|
+
n < 1 && (n = 31);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
this.updateFieldValue(t, n);
|
|
198
|
+
},
|
|
199
|
+
// 获取当前字段
|
|
200
|
+
getCurrentField() {
|
|
201
|
+
for (const t of this.fieldPositions)
|
|
202
|
+
if (this.inputSelection.start >= t.start && this.inputSelection.start <= t.end)
|
|
203
|
+
return t;
|
|
204
|
+
return null;
|
|
205
|
+
},
|
|
206
|
+
// 更新字段值
|
|
207
|
+
updateFieldValue(t, e) {
|
|
208
|
+
console.log(e, " value");
|
|
209
|
+
const n = String(e).padStart(t.length, "0"), r = this.inputValue.substring(0, t.start) + n + this.inputValue.substring(t.end);
|
|
210
|
+
this.inputValue = r, this.$nextTick(() => {
|
|
211
|
+
this.selectField(t);
|
|
212
|
+
}), this.updateDateFromInput();
|
|
213
|
+
},
|
|
214
|
+
// 从输入框更新日期对象
|
|
215
|
+
updateDateFromInput() {
|
|
216
|
+
if (!this.validateInputFormat())
|
|
217
|
+
return;
|
|
218
|
+
console.log("pplh");
|
|
219
|
+
const t = this.inputValue.split(/[''~-]/);
|
|
220
|
+
if (console.log(t, "pphu"), t.length !== 6)
|
|
221
|
+
return;
|
|
222
|
+
console.log("pph");
|
|
223
|
+
const e = parseInt(t[0]), n = parseInt(t[1]) - 1, r = parseInt(t[2]), l = parseInt(t[3]), s = parseInt(t[4]) - 1, d = parseInt(t[5]);
|
|
224
|
+
console.log("pp");
|
|
225
|
+
const a = new Date(e, n, r), c = new Date(l, s, d);
|
|
226
|
+
if (isNaN(a.getTime()) || isNaN(c.getTime())) {
|
|
227
|
+
this.isInvalid = !0;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.startDate = a, this.endDate = c, this.isInvalid = !1, this.updateQuickOptionsActiveState(), this.startCalendarViewDate = new Date(this.startDate), this.endCalendarViewDate = new Date(this.endDate), console.log(this.startCalendarViewDate, this.startCalendarViewDate, "ddd");
|
|
231
|
+
},
|
|
232
|
+
// 验证输入格式
|
|
233
|
+
validateInputFormat() {
|
|
234
|
+
return /^\d{4}-\d{2}-\d{2} ~ \d{4}-\d{2}-\d{2}$/.test(this.inputValue);
|
|
235
|
+
},
|
|
236
|
+
// 验证输入内容
|
|
237
|
+
validateInput() {
|
|
238
|
+
if (!this.validateInputFormat()) {
|
|
239
|
+
this.isInvalid = !0;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const t = this.inputValue.split(/[ ~-]/), e = parseInt(t[0]), n = parseInt(t[1]), r = parseInt(t[2]), l = parseInt(t[3]), s = parseInt(t[4]), d = parseInt(t[5]);
|
|
243
|
+
if (n < 1 || n > 12 || s < 1 || s > 12) {
|
|
244
|
+
this.isInvalid = !0;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (r < 1 || r > 31 || d < 1 || d > 31) {
|
|
248
|
+
this.isInvalid = !0;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const a = new Date(e, n - 1, r), c = new Date(l, s - 1, d);
|
|
252
|
+
if (a.getMonth() !== n - 1 || a.getDate() !== r || c.getMonth() !== s - 1 || c.getDate() !== d) {
|
|
253
|
+
this.isInvalid = !0;
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
this.isInvalid = !1;
|
|
257
|
+
},
|
|
258
|
+
// 前一年
|
|
259
|
+
prevYear(t) {
|
|
260
|
+
if (t === "start") {
|
|
261
|
+
const e = new Date(this.startCalendarViewDate);
|
|
262
|
+
e.setFullYear(e.getFullYear() - 1), this.startCalendarViewDate = e;
|
|
263
|
+
} else {
|
|
264
|
+
const e = new Date(this.endCalendarViewDate);
|
|
265
|
+
e.setFullYear(e.getFullYear() - 1), this.endCalendarViewDate = e;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
// 后一年
|
|
269
|
+
nextYear(t) {
|
|
270
|
+
if (t === "start") {
|
|
271
|
+
const e = new Date(this.startCalendarViewDate);
|
|
272
|
+
e.setFullYear(e.getFullYear() + 1), this.startCalendarViewDate = e;
|
|
273
|
+
} else {
|
|
274
|
+
const e = new Date(this.endCalendarViewDate);
|
|
275
|
+
e.setFullYear(e.getFullYear() + 1), this.endCalendarViewDate = e;
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
prevMonth(t) {
|
|
279
|
+
if (t === "start") {
|
|
280
|
+
const e = new Date(this.startCalendarViewDate);
|
|
281
|
+
e.setMonth(e.getMonth() - 1), this.startCalendarViewDate = e;
|
|
282
|
+
} else {
|
|
283
|
+
const e = new Date(this.endCalendarViewDate);
|
|
284
|
+
e.setMonth(e.getMonth() - 1), this.endCalendarViewDate = e;
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
nextMonth(t) {
|
|
288
|
+
if (t === "start") {
|
|
289
|
+
const e = new Date(this.startCalendarViewDate);
|
|
290
|
+
e.setMonth(e.getMonth() + 1), this.startCalendarViewDate = e;
|
|
291
|
+
} else {
|
|
292
|
+
const e = new Date(this.endCalendarViewDate);
|
|
293
|
+
e.setMonth(e.getMonth() + 1), this.endCalendarViewDate = e;
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
selectDate(t, e) {
|
|
297
|
+
t === "start" ? this.startDate = e : this.endDate = e, this.updateInputValue(), this.updateQuickOptionsActiveState();
|
|
298
|
+
},
|
|
299
|
+
generateCalendarDays(t, e, n, r) {
|
|
300
|
+
const l = t.getFullYear(), s = t.getMonth(), d = new Date(l, s, 1), a = new Date(l, s + 1, 0), c = d.getDay(), C = new Date(l, s, 0).getDate(), w = [], k = /* @__PURE__ */ new Date();
|
|
301
|
+
for (let o = c - 1; o >= 0; o--) {
|
|
302
|
+
const u = new Date(l, s - 1, C - o);
|
|
303
|
+
w.push({
|
|
304
|
+
id: `prev-${o}-${r}`,
|
|
305
|
+
day: C - o,
|
|
306
|
+
date: u,
|
|
307
|
+
isCurrentMonth: !1,
|
|
308
|
+
isSelected: this.isSameDay(u, r === "start" ? e : n),
|
|
309
|
+
isToday: this.isSameDay(u, k),
|
|
310
|
+
isInRange: this.isDateInRange(u, e, n)
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
for (let o = 1; o <= a.getDate(); o++) {
|
|
314
|
+
const u = new Date(l, s, o);
|
|
315
|
+
w.push({
|
|
316
|
+
id: `current-${o}-${r}`,
|
|
317
|
+
day: o,
|
|
318
|
+
date: u,
|
|
319
|
+
isCurrentMonth: !0,
|
|
320
|
+
isSelected: this.isSameDay(u, r === "start" ? e : n),
|
|
321
|
+
isToday: this.isSameDay(u, k),
|
|
322
|
+
isInRange: this.isDateInRange(u, e, n)
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
const V = 42 - w.length;
|
|
326
|
+
for (let o = 1; o <= V; o++) {
|
|
327
|
+
const u = new Date(l, s + 1, o);
|
|
328
|
+
w.push({
|
|
329
|
+
id: `next-${o}-${r}`,
|
|
330
|
+
day: o,
|
|
331
|
+
date: u,
|
|
332
|
+
isCurrentMonth: !1,
|
|
333
|
+
isSelected: this.isSameDay(u, r === "start" ? e : n),
|
|
334
|
+
isToday: this.isSameDay(u, k),
|
|
335
|
+
isInRange: this.isDateInRange(u, e, n)
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return w;
|
|
339
|
+
},
|
|
340
|
+
isSameDay(t, e) {
|
|
341
|
+
return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate();
|
|
342
|
+
},
|
|
343
|
+
isDateInRange(t, e, n) {
|
|
344
|
+
return t >= e && t <= n;
|
|
345
|
+
},
|
|
346
|
+
applyQuickOption(t) {
|
|
347
|
+
console.log(t, "option");
|
|
348
|
+
const e = /* @__PURE__ */ new Date();
|
|
349
|
+
let n = /* @__PURE__ */ new Date(), r = /* @__PURE__ */ new Date();
|
|
350
|
+
switch (t.type) {
|
|
351
|
+
case "days":
|
|
352
|
+
n = new Date(e.getTime() - t.value * 24 * 60 * 60 * 1e3);
|
|
353
|
+
break;
|
|
354
|
+
case "months":
|
|
355
|
+
n = new Date(e.getFullYear(), e.getMonth() - t.value, e.getDate());
|
|
356
|
+
break;
|
|
357
|
+
case "years":
|
|
358
|
+
n = new Date(e.getFullYear() - t.value, e.getMonth(), e.getDate());
|
|
359
|
+
break;
|
|
360
|
+
case "today":
|
|
361
|
+
t.value === "full" && (n = new Date(e.getFullYear(), e.getMonth(), e.getDate()), r = new Date(e.getFullYear(), e.getMonth(), e.getDate()));
|
|
362
|
+
break;
|
|
363
|
+
case "yesterday":
|
|
364
|
+
if (t.value === "full") {
|
|
365
|
+
const l = new Date(e.getTime() - 864e5);
|
|
366
|
+
n = new Date(l.getFullYear(), l.getMonth(), l.getDate()), r = new Date(l.getFullYear(), l.getMonth(), l.getDate());
|
|
367
|
+
}
|
|
368
|
+
break;
|
|
369
|
+
case "thisWeek": {
|
|
370
|
+
const l = e.getDay(), s = new Date(e.getTime() - l * 24 * 60 * 60 * 1e3);
|
|
371
|
+
if (t.value === "full") {
|
|
372
|
+
n = new Date(s.getFullYear(), s.getMonth(), s.getDate());
|
|
373
|
+
const d = new Date(s.getTime() + 6 * 24 * 60 * 60 * 1e3);
|
|
374
|
+
r = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
375
|
+
}
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
case "thisMonth":
|
|
379
|
+
t.value === "full" && (n = new Date(e.getFullYear(), e.getMonth(), 1), r = new Date(e.getFullYear(), e.getMonth() + 1, 0));
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
this.startDate = n, this.endDate = r, this.updateInputValue(), this.updateQuickOptionsActiveState(), this.startCalendarViewDate = new Date(this.startDate), this.endCalendarViewDate = new Date(this.endDate);
|
|
383
|
+
},
|
|
384
|
+
updateQuickOptionsActiveState() {
|
|
385
|
+
Object.keys(this.quickOptions).forEach((t) => {
|
|
386
|
+
this.quickOptions[t].forEach((e) => {
|
|
387
|
+
e.active = !1;
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
formatRangeDisplay() {
|
|
392
|
+
const t = (e) => {
|
|
393
|
+
const n = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), l = String(e.getDate()).padStart(2, "0");
|
|
394
|
+
return `${n}-${r}-${l}`;
|
|
395
|
+
};
|
|
396
|
+
return `${t(this.startDate)} ~ ${t(this.endDate)}`;
|
|
397
|
+
},
|
|
398
|
+
clickStop(t) {
|
|
399
|
+
t.stopPropagation();
|
|
400
|
+
},
|
|
401
|
+
confirmSelection() {
|
|
402
|
+
this.selectedRange = this.formatRangeDisplay(), this.inputValue = this.selectedRange, this.showPanel = !1;
|
|
403
|
+
},
|
|
404
|
+
blurInput() {
|
|
405
|
+
this.mouseOver == !1 && (this.showPanel = !1);
|
|
406
|
+
},
|
|
407
|
+
handleMouseOver() {
|
|
408
|
+
console.log("lll"), this.mouseOver = !0;
|
|
409
|
+
},
|
|
410
|
+
handleMouseOut() {
|
|
411
|
+
this.mouseOver = !1;
|
|
412
|
+
},
|
|
413
|
+
modelClick() {
|
|
414
|
+
this.showPanel = !1;
|
|
415
|
+
const e = this.inputValue.split("~").map((n) => n.trim());
|
|
416
|
+
this.$emit("changeTime", e);
|
|
417
|
+
},
|
|
418
|
+
handleListener() {
|
|
419
|
+
const t = document.getElementById("content"), e = document.getElementById("timePanel");
|
|
420
|
+
document.addEventListener("click", (n) => {
|
|
421
|
+
const r = t.contains(n.target), l = e.contains(n.target);
|
|
422
|
+
r || l ? console.log("") : this.modelClick();
|
|
423
|
+
});
|
|
424
|
+
},
|
|
425
|
+
openShowPanel() {
|
|
426
|
+
this.showPanel = !0, this.handleListener();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}, P = {
|
|
430
|
+
class: "container",
|
|
431
|
+
id: "content"
|
|
432
|
+
}, O = { class: "content" }, b = { class: "input-section" }, T = { class: "input-field" }, R = { class: "panel-body" }, A = { class: "quick-options" }, E = { class: "option-group" }, q = { class: "option-group" }, x = ["onClick"], Q = { class: "option-group" }, L = ["onClick"], B = { class: "option-group" }, W = ["onClick"], U = { class: "option-group" }, N = ["onClick"], K = { class: "panels-container" }, $ = { class: "date-panel" }, z = { class: "calendar-section" }, j = { class: "calendar-header" }, G = { class: "current-month" }, H = { class: "calendar-days" }, J = ["onClick"], X = { class: "date-panel" }, Z = { class: "calendar-section" }, ee = { class: "calendar-header" }, te = { class: "current-month" }, ne = { class: "calendar-days" }, ae = ["onClick"];
|
|
433
|
+
function se(t, e, n, r, l, s) {
|
|
434
|
+
const d = I("el-input");
|
|
435
|
+
return h(), p("div", {
|
|
436
|
+
id: "app-time",
|
|
437
|
+
onMouseover: e[12] || (e[12] = (...a) => s.handleMouseOver && s.handleMouseOver(...a)),
|
|
438
|
+
onMouseleave: e[13] || (e[13] = (...a) => s.handleMouseOut && s.handleMouseOut(...a))
|
|
439
|
+
}, [
|
|
440
|
+
i("div", P, [
|
|
441
|
+
i("div", O, [
|
|
442
|
+
i("div", b, [
|
|
443
|
+
i("div", T, [
|
|
444
|
+
Y(d, {
|
|
445
|
+
type: "text",
|
|
446
|
+
id: "datetime-input",
|
|
447
|
+
class: v(["datetime-input", { invalid: l.isInvalid }]),
|
|
448
|
+
modelValue: l.inputValue,
|
|
449
|
+
"onUpdate:modelValue": e[0] || (e[0] = (a) => l.inputValue = a),
|
|
450
|
+
placeholder: "YYYY-MM-DD ~ YYYY-MM-DD",
|
|
451
|
+
onMouseup: s.onInputFocus,
|
|
452
|
+
onBlur: s.onInputBlur,
|
|
453
|
+
onKeydown: s.onInputKeydown,
|
|
454
|
+
onInput: s.onInputChange,
|
|
455
|
+
onClick: e[1] || (e[1] = (a) => s.openShowPanel())
|
|
456
|
+
}, null, 8, ["class", "modelValue", "onMouseup", "onBlur", "onKeydown", "onInput"])
|
|
457
|
+
])
|
|
458
|
+
])
|
|
459
|
+
])
|
|
460
|
+
]),
|
|
461
|
+
i("div", {
|
|
462
|
+
class: "time-panel",
|
|
463
|
+
style: F(l.showPanel ? "display:visible" : "display:none"),
|
|
464
|
+
id: "timePanel"
|
|
465
|
+
}, [
|
|
466
|
+
i("div", {
|
|
467
|
+
class: "panel-container",
|
|
468
|
+
onClick: e[11] || (e[11] = D((...a) => s.clickStop && s.clickStop(...a), ["stop"]))
|
|
469
|
+
}, [
|
|
470
|
+
i("div", R, [
|
|
471
|
+
i("div", A, [
|
|
472
|
+
i("div", E, [
|
|
473
|
+
i("div", {
|
|
474
|
+
class: "quick-option",
|
|
475
|
+
onClick: e[2] || (e[2] = D((a) => s.applyQuickOption({ name: "今天", type: "today", value: "full", active: !1 }), ["stop"]))
|
|
476
|
+
}, " 今天 ")
|
|
477
|
+
]),
|
|
478
|
+
i("div", q, [
|
|
479
|
+
(h(!0), p(f, null, m(l.quickOptions.yesterday, (a) => (h(), p("div", {
|
|
480
|
+
key: a.name,
|
|
481
|
+
class: v(["quick-option", { active: a.active }]),
|
|
482
|
+
onClick: D((c) => s.applyQuickOption(a), ["stop"])
|
|
483
|
+
}, g(a.name), 11, x))), 128))
|
|
484
|
+
]),
|
|
485
|
+
i("div", Q, [
|
|
486
|
+
(h(!0), p(f, null, m(l.quickOptions.thisWeek, (a) => (h(), p("div", {
|
|
487
|
+
key: a.name,
|
|
488
|
+
class: v(["quick-option", { active: a.active }]),
|
|
489
|
+
onClick: D((c) => s.applyQuickOption(a), ["stop"])
|
|
490
|
+
}, g(a.name), 11, L))), 128))
|
|
491
|
+
]),
|
|
492
|
+
i("div", B, [
|
|
493
|
+
(h(!0), p(f, null, m(l.quickOptions.thisMonth, (a) => (h(), p("div", {
|
|
494
|
+
key: a.name,
|
|
495
|
+
class: v(["quick-option", { active: a.active }]),
|
|
496
|
+
onClick: D((c) => s.applyQuickOption(a), ["stop"])
|
|
497
|
+
}, g(a.name), 11, W))), 128))
|
|
498
|
+
]),
|
|
499
|
+
i("div", U, [
|
|
500
|
+
(h(!0), p(f, null, m(l.quickOptions.common, (a) => (h(), p("div", {
|
|
501
|
+
key: a.name,
|
|
502
|
+
class: v(["quick-option", { active: a.active }]),
|
|
503
|
+
onClick: D((c) => s.applyQuickOption(a), ["stop"])
|
|
504
|
+
}, g(a.name), 11, N))), 128))
|
|
505
|
+
])
|
|
506
|
+
]),
|
|
507
|
+
i("div", K, [
|
|
508
|
+
i("div", $, [
|
|
509
|
+
i("div", z, [
|
|
510
|
+
i("div", j, [
|
|
511
|
+
i("div", {
|
|
512
|
+
class: "year-nav",
|
|
513
|
+
onClick: e[3] || (e[3] = (a) => s.prevYear("start"))
|
|
514
|
+
}, "<<"),
|
|
515
|
+
i("div", {
|
|
516
|
+
class: "month-nav",
|
|
517
|
+
onClick: e[4] || (e[4] = (a) => s.prevMonth("start"))
|
|
518
|
+
}, "<"),
|
|
519
|
+
i("div", G, g(s.startDateMonthYear), 1),
|
|
520
|
+
i("div", {
|
|
521
|
+
class: "month-nav",
|
|
522
|
+
onClick: e[5] || (e[5] = (a) => s.nextMonth("start"))
|
|
523
|
+
}, ">"),
|
|
524
|
+
i("div", {
|
|
525
|
+
class: "year-nav",
|
|
526
|
+
onClick: e[6] || (e[6] = (a) => s.nextYear("start"))
|
|
527
|
+
}, ">>")
|
|
528
|
+
]),
|
|
529
|
+
e[14] || (e[14] = i("div", { class: "week-days" }, [
|
|
530
|
+
i("div", null, "日"),
|
|
531
|
+
i("div", null, "一"),
|
|
532
|
+
i("div", null, "二"),
|
|
533
|
+
i("div", null, "三"),
|
|
534
|
+
i("div", null, "四"),
|
|
535
|
+
i("div", null, "五"),
|
|
536
|
+
i("div", null, "六")
|
|
537
|
+
], -1)),
|
|
538
|
+
i("div", H, [
|
|
539
|
+
(h(!0), p(f, null, m(s.startCalendarDays, (a) => (h(), p("div", {
|
|
540
|
+
key: a.id,
|
|
541
|
+
class: v(["calendar-day", {
|
|
542
|
+
"other-month": !a.isCurrentMonth,
|
|
543
|
+
selected: a.isSelected,
|
|
544
|
+
today: a.isToday,
|
|
545
|
+
"in-range": a.isInRange
|
|
546
|
+
}]),
|
|
547
|
+
onClick: D((c) => s.selectDate("start", a.date), ["stop"])
|
|
548
|
+
}, g(a.day), 11, J))), 128))
|
|
549
|
+
])
|
|
550
|
+
])
|
|
551
|
+
]),
|
|
552
|
+
i("div", X, [
|
|
553
|
+
i("div", Z, [
|
|
554
|
+
i("div", ee, [
|
|
555
|
+
i("div", {
|
|
556
|
+
class: "year-nav",
|
|
557
|
+
onClick: e[7] || (e[7] = (a) => s.prevYear("end"))
|
|
558
|
+
}, "<<"),
|
|
559
|
+
i("div", {
|
|
560
|
+
class: "month-nav",
|
|
561
|
+
onClick: e[8] || (e[8] = D((a) => s.prevMonth("end"), ["stop"]))
|
|
562
|
+
}, "<"),
|
|
563
|
+
i("div", te, g(s.endDateMonthYear), 1),
|
|
564
|
+
i("div", {
|
|
565
|
+
class: "month-nav",
|
|
566
|
+
onClick: e[9] || (e[9] = D((a) => s.nextMonth("end"), ["stop"]))
|
|
567
|
+
}, ">"),
|
|
568
|
+
i("div", {
|
|
569
|
+
class: "year-nav",
|
|
570
|
+
onClick: e[10] || (e[10] = (a) => s.nextYear("end"))
|
|
571
|
+
}, ">>")
|
|
572
|
+
]),
|
|
573
|
+
e[15] || (e[15] = i("div", { class: "week-days" }, [
|
|
574
|
+
i("div", null, "日"),
|
|
575
|
+
i("div", null, "一"),
|
|
576
|
+
i("div", null, "二"),
|
|
577
|
+
i("div", null, "三"),
|
|
578
|
+
i("div", null, "四"),
|
|
579
|
+
i("div", null, "五"),
|
|
580
|
+
i("div", null, "六")
|
|
581
|
+
], -1)),
|
|
582
|
+
i("div", ne, [
|
|
583
|
+
(h(!0), p(f, null, m(s.endCalendarDays, (a) => (h(), p("div", {
|
|
584
|
+
key: a.id,
|
|
585
|
+
class: v(["calendar-day", {
|
|
586
|
+
"other-month": !a.isCurrentMonth,
|
|
587
|
+
selected: a.isSelected,
|
|
588
|
+
today: a.isToday,
|
|
589
|
+
"in-range": a.isInRange
|
|
590
|
+
}]),
|
|
591
|
+
onClick: D((c) => s.selectDate("end", a.date), ["stop"])
|
|
592
|
+
}, g(a.day), 11, ae))), 128))
|
|
593
|
+
])
|
|
594
|
+
])
|
|
595
|
+
])
|
|
596
|
+
])
|
|
597
|
+
])
|
|
598
|
+
])
|
|
599
|
+
], 4)
|
|
600
|
+
], 32);
|
|
601
|
+
}
|
|
602
|
+
const y = /* @__PURE__ */ S(_, [["render", se], ["__scopeId", "data-v-adeefd27"]]);
|
|
603
|
+
y.install = (t) => {
|
|
604
|
+
t.component(y.name, y);
|
|
605
|
+
};
|
|
606
|
+
const ie = [
|
|
607
|
+
y
|
|
608
|
+
], M = function(t) {
|
|
609
|
+
M.installed || ie.forEach((e) => {
|
|
610
|
+
t.component(e.name, e);
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
typeof window < "u" && window.Vue && M(window.Vue);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(n,m){typeof exports=="object"&&typeof module<"u"?m(require("vue")):typeof define=="function"&&define.amd?define(["vue"],m):(n=typeof globalThis<"u"?globalThis:n||self,m(n.Vue))})(this,function(n){"use strict";const m="",w=(t,e)=>{const a=t.__vccOpts||t;for(const[o,l]of e)a[o]=l;return a},y={name:"TimeComponentsUp",props:{initTime:{type:String,default:""}},data(){return{showPanel:!1,startDate:new Date,endDate:new Date,activeControl:"startYear",selectedRange:null,inputValue:"",isInvalid:!1,inputSelection:{start:0,end:0},mouseOver:!1,startCalendarViewDate:new Date,endCalendarViewDate:new Date,quickOptions:{common:[{name:"近3月",type:"months",value:3,active:!1},{name:"近1年",type:"years",value:1,active:!1}],today:[],yesterday:[{name:"昨天",type:"yesterday",value:"full",active:!1}],thisWeek:[{name:"本周",type:"thisWeek",value:"full",active:!1}],thisMonth:[{name:"本月",type:"thisMonth",value:"full",active:!1}]},dateFormatter:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"2-digit"})}},computed:{startDateMonthYear(){const t=this.startCalendarViewDate.getFullYear(),e=this.startCalendarViewDate.getMonth()+1;return`${t}年${e}月`},endDateMonthYear(){const t=this.endCalendarViewDate.getFullYear(),e=this.endCalendarViewDate.getMonth()+1;return`${t}年${e}月`},startCalendarDays(){return this.generateCalendarDays(this.startCalendarViewDate,this.startDate,this.endDate,"start")},endCalendarDays(){return this.generateCalendarDays(this.endCalendarViewDate,this.startDate,this.endDate,"end")},fieldPositions(){return[{name:"startYear",start:0,end:4,length:4},{name:"startMonth",start:5,end:7,length:2},{name:"startDay",start:8,end:10,length:2},{name:"endYear",start:13,end:17,length:4},{name:"endMonth",start:18,end:20,length:2},{name:"endDay",start:21,end:23,length:2}]}},mounted(){console.log(this.initTime,"this.initTime"),this.inputValue=this.initTime,this.updateQuickOptionsActiveState()},methods:{setActiveControl(t){this.activeControl=t},updateInputValue(){const t=e=>{const a=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${o}-${l}`};this.inputValue=`${t(this.startDate)} ~ ${t(this.endDate)}`,this.modelClick()},onInputFocus(t){console.log(t),setTimeout(()=>{this.inputSelection={start:t.target.selectionStart,end:t.target.selectionEnd},console.log(t.target.selectionStart,this.inputSelection.start,"this.inputSelection.start"),this.selectCurrentField(this.inputSelection.start)},0)},onInputBlur(){this.validateInput()},onInputChange(){this.validateInput()},onInputKeydown(t){const e=t.key;["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e)&&(t.preventDefault(),e==="ArrowLeft"?this.navigateLeft():e==="ArrowRight"?this.navigateRight():e==="ArrowUp"?this.incrementValue():e==="ArrowDown"&&this.decrementValue()),e==="Tab"&&(t.preventDefault(),t.shiftKey?this.navigateLeft():this.navigateRight()),e==="Enter"&&(t.preventDefault(),this.showPanel=!1)},navigateLeft(){const t=this.inputSelection.start;let e=null;for(let a=0;a<this.fieldPositions.length;a++)if(t>=this.fieldPositions[a].start&&t<=this.fieldPositions[a].end){a>0?e=this.fieldPositions[a-1]:e=this.fieldPositions[this.fieldPositions.length-1];break}e||(e=this.fieldPositions[0]),this.selectField(e)},navigateRight(){const t=this.inputSelection.start;let e=null;console.log(this.fieldPositions,"this.fieldPositions");for(let a=0;a<this.fieldPositions.length;a++)if(t>=this.fieldPositions[a].start&&t<=this.fieldPositions[a].end){a<this.fieldPositions.length-1?e=this.fieldPositions[a+1]:e=this.fieldPositions[0];break}e||(e=this.fieldPositions[0]),this.selectField(e)},selectCurrentField(t){console.log(this.fieldPositions,t,"this.fieldPositions");for(const e of this.fieldPositions)if(t>=e.start&&t<=e.end){console.log(e,"this.field"),this.selectField(e);return}this.selectField(this.fieldPositions[0])},selectField(t){document.getElementById("datetime-input").setSelectionRange(t.start,t.end),this.inputSelection={start:t.start,end:t.end},this.activeControl=t.name},incrementValue(){const t=this.getCurrentField();if(!t)return;let a=parseInt(this.inputValue.substring(t.start,t.end))+1;switch(t.name){case"startYear":case"endYear":break;case"startMonth":case"endMonth":a>12&&(a=1);break;case"startDay":case"endDay":a>31&&(a=1);break}this.updateFieldValue(t,a)},decrementValue(){const t=this.getCurrentField();if(!t)return;let a=parseInt(this.inputValue.substring(t.start,t.end))-1;switch(t.name){case"startYear":case"endYear":a<1&&(a=9999);break;case"startMonth":case"endMonth":a<1&&(a=12);break;case"startDay":case"endDay":a<1&&(a=31);break}this.updateFieldValue(t,a)},getCurrentField(){for(const t of this.fieldPositions)if(this.inputSelection.start>=t.start&&this.inputSelection.start<=t.end)return t;return null},updateFieldValue(t,e){console.log(e," value");const a=String(e).padStart(t.length,"0"),o=this.inputValue.substring(0,t.start)+a+this.inputValue.substring(t.end);this.inputValue=o,this.$nextTick(()=>{this.selectField(t)}),this.updateDateFromInput()},updateDateFromInput(){if(!this.validateInputFormat())return;console.log("pplh");const t=this.inputValue.split(/[''~-]/);if(console.log(t,"pphu"),t.length!==6)return;console.log("pph");const e=parseInt(t[0]),a=parseInt(t[1])-1,o=parseInt(t[2]),l=parseInt(t[3]),i=parseInt(t[4])-1,d=parseInt(t[5]);console.log("pp");const s=new Date(e,a,o),h=new Date(l,i,d);if(isNaN(s.getTime())||isNaN(h.getTime())){this.isInvalid=!0;return}this.startDate=s,this.endDate=h,this.isInvalid=!1,this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate),console.log(this.startCalendarViewDate,this.startCalendarViewDate,"ddd")},validateInputFormat(){return/^\d{4}-\d{2}-\d{2} ~ \d{4}-\d{2}-\d{2}$/.test(this.inputValue)},validateInput(){if(!this.validateInputFormat()){this.isInvalid=!0;return}const t=this.inputValue.split(/[ ~-]/),e=parseInt(t[0]),a=parseInt(t[1]),o=parseInt(t[2]),l=parseInt(t[3]),i=parseInt(t[4]),d=parseInt(t[5]);if(a<1||a>12||i<1||i>12){this.isInvalid=!0;return}if(o<1||o>31||d<1||d>31){this.isInvalid=!0;return}const s=new Date(e,a-1,o),h=new Date(l,i-1,d);if(s.getMonth()!==a-1||s.getDate()!==o||h.getMonth()!==i-1||h.getDate()!==d){this.isInvalid=!0;return}this.isInvalid=!1},prevYear(t){if(t==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.endCalendarViewDate=e}},nextYear(t){if(t==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.endCalendarViewDate=e}},prevMonth(t){if(t==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()-1),this.endCalendarViewDate=e}},nextMonth(t){if(t==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()+1),this.endCalendarViewDate=e}},selectDate(t,e){t==="start"?this.startDate=e:this.endDate=e,this.updateInputValue(),this.updateQuickOptionsActiveState()},generateCalendarDays(t,e,a,o){const l=t.getFullYear(),i=t.getMonth(),d=new Date(l,i,1),s=new Date(l,i+1,0),h=d.getDay(),f=new Date(l,i,0).getDate(),u=[],D=new Date;for(let r=h-1;r>=0;r--){const c=new Date(l,i-1,f-r);u.push({id:`prev-${r}-${o}`,day:f-r,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,o==="start"?e:a),isToday:this.isSameDay(c,D),isInRange:this.isDateInRange(c,e,a)})}for(let r=1;r<=s.getDate();r++){const c=new Date(l,i,r);u.push({id:`current-${r}-${o}`,day:r,date:c,isCurrentMonth:!0,isSelected:this.isSameDay(c,o==="start"?e:a),isToday:this.isSameDay(c,D),isInRange:this.isDateInRange(c,e,a)})}const H=42-u.length;for(let r=1;r<=H;r++){const c=new Date(l,i+1,r);u.push({id:`next-${r}-${o}`,day:r,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,o==="start"?e:a),isToday:this.isSameDay(c,D),isInRange:this.isDateInRange(c,e,a)})}return u},isSameDay(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()},isDateInRange(t,e,a){return t>=e&&t<=a},applyQuickOption(t){console.log(t,"option");const e=new Date;let a=new Date,o=new Date;switch(t.type){case"days":a=new Date(e.getTime()-t.value*24*60*60*1e3);break;case"months":a=new Date(e.getFullYear(),e.getMonth()-t.value,e.getDate());break;case"years":a=new Date(e.getFullYear()-t.value,e.getMonth(),e.getDate());break;case"today":t.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),o=new Date(e.getFullYear(),e.getMonth(),e.getDate()));break;case"yesterday":if(t.value==="full"){const l=new Date(e.getTime()-864e5);a=new Date(l.getFullYear(),l.getMonth(),l.getDate()),o=new Date(l.getFullYear(),l.getMonth(),l.getDate())}break;case"thisWeek":{const l=e.getDay(),i=new Date(e.getTime()-l*24*60*60*1e3);if(t.value==="full"){a=new Date(i.getFullYear(),i.getMonth(),i.getDate());const d=new Date(i.getTime()+6*24*60*60*1e3);o=new Date(d.getFullYear(),d.getMonth(),d.getDate())}break}case"thisMonth":t.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),1),o=new Date(e.getFullYear(),e.getMonth()+1,0));break}this.startDate=a,this.endDate=o,this.updateInputValue(),this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate)},updateQuickOptionsActiveState(){Object.keys(this.quickOptions).forEach(t=>{this.quickOptions[t].forEach(e=>{e.active=!1})})},formatRangeDisplay(){const t=e=>{const a=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${o}-${l}`};return`${t(this.startDate)} ~ ${t(this.endDate)}`},clickStop(t){t.stopPropagation()},confirmSelection(){this.selectedRange=this.formatRangeDisplay(),this.inputValue=this.selectedRange,this.showPanel=!1},blurInput(){this.mouseOver==!1&&(this.showPanel=!1)},handleMouseOver(){console.log("lll"),this.mouseOver=!0},handleMouseOut(){this.mouseOver=!1},modelClick(){this.showPanel=!1;const e=this.inputValue.split("~").map(a=>a.trim());this.$emit("changeTime",e)},handleListener(){const t=document.getElementById("content"),e=document.getElementById("timePanel");document.addEventListener("click",a=>{const o=t.contains(a.target),l=e.contains(a.target);o||l?console.log(""):this.modelClick()})},openShowPanel(){this.showPanel=!0,this.handleListener()}}},V={class:"container",id:"content"},k={class:"content"},C={class:"input-section"},M={class:"input-field"},E={class:"panel-body"},I={class:"quick-options"},S={class:"option-group"},F={class:"option-group"},N=["onClick"],Y={class:"option-group"},_=["onClick"],v={class:"option-group"},P=["onClick"],O={class:"option-group"},B=["onClick"],b={class:"panels-container"},T={class:"date-panel"},R={class:"calendar-section"},L={class:"calendar-header"},q={class:"current-month"},x={class:"calendar-days"},A=["onClick"],Q={class:"date-panel"},z={class:"calendar-section"},W={class:"calendar-header"},U={class:"current-month"},K={class:"calendar-days"},$=["onClick"];function j(t,e,a,o,l,i){const d=n.resolveComponent("el-input");return n.openBlock(),n.createElementBlock("div",{id:"app-time",onMouseover:e[12]||(e[12]=(...s)=>i.handleMouseOver&&i.handleMouseOver(...s)),onMouseleave:e[13]||(e[13]=(...s)=>i.handleMouseOut&&i.handleMouseOut(...s))},[n.createElementVNode("div",V,[n.createElementVNode("div",k,[n.createElementVNode("div",C,[n.createElementVNode("div",M,[n.createVNode(d,{type:"text",id:"datetime-input",class:n.normalizeClass(["datetime-input",{invalid:l.isInvalid}]),modelValue:l.inputValue,"onUpdate:modelValue":e[0]||(e[0]=s=>l.inputValue=s),placeholder:"YYYY-MM-DD ~ YYYY-MM-DD",onMouseup:i.onInputFocus,onBlur:i.onInputBlur,onKeydown:i.onInputKeydown,onInput:i.onInputChange,onClick:e[1]||(e[1]=s=>i.openShowPanel())},null,8,["class","modelValue","onMouseup","onBlur","onKeydown","onInput"])])])])]),n.createElementVNode("div",{class:"time-panel",style:n.normalizeStyle(l.showPanel?"display:visible":"display:none"),id:"timePanel"},[n.createElementVNode("div",{class:"panel-container",onClick:e[11]||(e[11]=n.withModifiers((...s)=>i.clickStop&&i.clickStop(...s),["stop"]))},[n.createElementVNode("div",E,[n.createElementVNode("div",I,[n.createElementVNode("div",S,[n.createElementVNode("div",{class:"quick-option",onClick:e[2]||(e[2]=n.withModifiers(s=>i.applyQuickOption({name:"今天",type:"today",value:"full",active:!1}),["stop"]))}," 今天 ")]),n.createElementVNode("div",F,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(l.quickOptions.yesterday,s=>(n.openBlock(),n.createElementBlock("div",{key:s.name,class:n.normalizeClass(["quick-option",{active:s.active}]),onClick:n.withModifiers(h=>i.applyQuickOption(s),["stop"])},n.toDisplayString(s.name),11,N))),128))]),n.createElementVNode("div",Y,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(l.quickOptions.thisWeek,s=>(n.openBlock(),n.createElementBlock("div",{key:s.name,class:n.normalizeClass(["quick-option",{active:s.active}]),onClick:n.withModifiers(h=>i.applyQuickOption(s),["stop"])},n.toDisplayString(s.name),11,_))),128))]),n.createElementVNode("div",v,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(l.quickOptions.thisMonth,s=>(n.openBlock(),n.createElementBlock("div",{key:s.name,class:n.normalizeClass(["quick-option",{active:s.active}]),onClick:n.withModifiers(h=>i.applyQuickOption(s),["stop"])},n.toDisplayString(s.name),11,P))),128))]),n.createElementVNode("div",O,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(l.quickOptions.common,s=>(n.openBlock(),n.createElementBlock("div",{key:s.name,class:n.normalizeClass(["quick-option",{active:s.active}]),onClick:n.withModifiers(h=>i.applyQuickOption(s),["stop"])},n.toDisplayString(s.name),11,B))),128))])]),n.createElementVNode("div",b,[n.createElementVNode("div",T,[n.createElementVNode("div",R,[n.createElementVNode("div",L,[n.createElementVNode("div",{class:"year-nav",onClick:e[3]||(e[3]=s=>i.prevYear("start"))},"<<"),n.createElementVNode("div",{class:"month-nav",onClick:e[4]||(e[4]=s=>i.prevMonth("start"))},"<"),n.createElementVNode("div",q,n.toDisplayString(i.startDateMonthYear),1),n.createElementVNode("div",{class:"month-nav",onClick:e[5]||(e[5]=s=>i.nextMonth("start"))},">"),n.createElementVNode("div",{class:"year-nav",onClick:e[6]||(e[6]=s=>i.nextYear("start"))},">>")]),e[14]||(e[14]=n.createElementVNode("div",{class:"week-days"},[n.createElementVNode("div",null,"日"),n.createElementVNode("div",null,"一"),n.createElementVNode("div",null,"二"),n.createElementVNode("div",null,"三"),n.createElementVNode("div",null,"四"),n.createElementVNode("div",null,"五"),n.createElementVNode("div",null,"六")],-1)),n.createElementVNode("div",x,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(i.startCalendarDays,s=>(n.openBlock(),n.createElementBlock("div",{key:s.id,class:n.normalizeClass(["calendar-day",{"other-month":!s.isCurrentMonth,selected:s.isSelected,today:s.isToday,"in-range":s.isInRange}]),onClick:n.withModifiers(h=>i.selectDate("start",s.date),["stop"])},n.toDisplayString(s.day),11,A))),128))])])]),n.createElementVNode("div",Q,[n.createElementVNode("div",z,[n.createElementVNode("div",W,[n.createElementVNode("div",{class:"year-nav",onClick:e[7]||(e[7]=s=>i.prevYear("end"))},"<<"),n.createElementVNode("div",{class:"month-nav",onClick:e[8]||(e[8]=n.withModifiers(s=>i.prevMonth("end"),["stop"]))},"<"),n.createElementVNode("div",U,n.toDisplayString(i.endDateMonthYear),1),n.createElementVNode("div",{class:"month-nav",onClick:e[9]||(e[9]=n.withModifiers(s=>i.nextMonth("end"),["stop"]))},">"),n.createElementVNode("div",{class:"year-nav",onClick:e[10]||(e[10]=s=>i.nextYear("end"))},">>")]),e[15]||(e[15]=n.createElementVNode("div",{class:"week-days"},[n.createElementVNode("div",null,"日"),n.createElementVNode("div",null,"一"),n.createElementVNode("div",null,"二"),n.createElementVNode("div",null,"三"),n.createElementVNode("div",null,"四"),n.createElementVNode("div",null,"五"),n.createElementVNode("div",null,"六")],-1)),n.createElementVNode("div",K,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(i.endCalendarDays,s=>(n.openBlock(),n.createElementBlock("div",{key:s.id,class:n.normalizeClass(["calendar-day",{"other-month":!s.isCurrentMonth,selected:s.isSelected,today:s.isToday,"in-range":s.isInRange}]),onClick:n.withModifiers(h=>i.selectDate("end",s.date),["stop"])},n.toDisplayString(s.day),11,$))),128))])])])])])])],4)],32)}const p=w(y,[["render",j],["__scopeId","data-v-adeefd27"]]);p.install=t=>{t.component(p.name,p)};const G=[p],g=function(t){g.installed||G.forEach(e=>{t.component(e.name,e)})};typeof window<"u"&&window.Vue&&g(window.Vue)});
|
package/dist/index.html
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
8
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<noscript>
|
|
12
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
13
|
+
</noscript>
|
|
14
|
+
<div id="app"></div>
|
|
15
|
+
<!-- built files will be auto injected -->
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|