55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import dayjs from 'dayjs'
|
|
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
|
|
dayjs.extend(isSameOrAfter)
|
|
// dayjs.extend(isBefore)
|
|
|
|
function isNotOneWeekAgo(date: any) {
|
|
if (!date) return false
|
|
const oneWeekAgo = dayjs().subtract(1, 'week')
|
|
// console.log('🚀 ~ oneWeekAgo:', oneWeekAgo.format('YYYY-MM-DD'))
|
|
return dayjs(date).isSameOrAfter(oneWeekAgo, 'day')
|
|
}
|
|
|
|
const pickerOptions = {
|
|
disabledDate(time) {
|
|
return time.getTime() < Date.now()
|
|
},
|
|
valueFormat: 'YYYY-MM-dd HH:mm:ss',
|
|
shortcuts: [
|
|
{
|
|
text: '3天后',
|
|
value: () => {
|
|
const date = new Date()
|
|
date.setTime(date.getTime() + 3600 * 1000 * 24 * 3)
|
|
return date
|
|
}
|
|
},
|
|
{
|
|
text: '5天后',
|
|
value: () => {
|
|
const date = new Date()
|
|
date.setTime(date.getTime() + 3600 * 1000 * 24 * 5)
|
|
return date
|
|
}
|
|
},
|
|
{
|
|
text: '7天后',
|
|
value: () => {
|
|
const date = new Date()
|
|
date.setTime(date.getTime() + 3600 * 1000 * 24 * 7)
|
|
return date
|
|
}
|
|
},
|
|
{
|
|
text: '10天后',
|
|
value: () => {
|
|
const date = new Date()
|
|
date.setTime(date.getTime() + 3600 * 1000 * 24 * 10)
|
|
return date
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
export { isNotOneWeekAgo, pickerOptions }
|