Repository navigation
Expand file tree
/
Copy pathshortcuts.js
More file actions
96 lines (93 loc) · 2.27 KB
/
Copy pathshortcuts.js
File metadata and controls
96 lines (93 loc) · 2.27 KB
1
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
import Date from './datetime.js'
export const calendarBaseShortcuts = [{
text: '今天',
onClick(picker) {
const start = new Date()
picker.$emit('pick', [start, start])
}
}, {
text: '昨天',
onClick(picker) {
const start = new Date().daysAgo(1)
picker.$emit('pick', [start, start])
}
}, {
text: '最近一周',
onClick(picker) {
const start = new Date().daysAgo(7)
picker.$emit('pick', [start, new Date()])
}
}, {
text: '最近30天',
onClick(picker) {
const start = new Date().daysAgo(30)
picker.$emit('pick', [start, new Date()])
}
}, {
text: '这个月',
onClick(picker) {
const start = new Date().monthBegin()
picker.$emit('pick', [start, new Date()])
}
}, {
text: '本季度',
onClick(picker) {
const start = new Date().quarterBegin()
picker.$emit('pick', [start, new Date()])
}
}]
export const calendarMoveShortcuts = [{
text: '‹ 往前一天 ',
onClick(picker) {
if (picker.value.length === 0) {
picker.value = [new Date(), new Date()]
}
const start = picker.value[0].daysAgo(1)
const end = picker.value[1].daysAgo(1)
picker.$emit('pick', [start, end])
}
}, {
text: ' 往后一天 ›',
onClick(picker) {
let start = new Date()
let end = new Date()
if (picker.value.length > 0) {
if (end - picker.value[1] > 8.64E7) {
start = picker.value[0].daysAgo(-1)
end = picker.value[1].daysAgo(-1)
} else {
start = picker.value[0]
}
}
picker.$emit('pick', [start, end])
}
}, {
text: '« 往前一周 ',
onClick(picker) {
if (picker.value.length === 0) {
picker.value = [new Date().daysAgo(7), new Date()]
}
const start = picker.value[0].daysAgo(7)
const end = picker.value[1].daysAgo(7)
picker.$emit('pick', [start, end])
}
}, {
text: ' 往后一周 »',
onClick(picker) {
let start = new Date().daysAgo(7)
let end = new Date()
if (picker.value.length > 0) {
if (end - picker.value[1] > 8.64E7) {
start = picker.value[0].daysAgo(-7)
end = picker.value[1].daysAgo(-7)
} else {
start = picker.value[0]
}
}
picker.$emit('pick', [start, end])
}
}]
export const calendarShortcuts = [
...calendarBaseShortcuts,
...calendarMoveShortcuts
]