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
| import { ref } from "vue";
export function dateDisabled() { const firstSelectDate = ref(0); const countDay = 7;
function disabledDateRange(date) { if (firstSelectDate.value) { const timeRange = 24 * 60 * 60 * 1000; const currentTime = new Date().getTime(); const minTime = firstSelectDate.value - timeRange * countDay; let maxTime = firstSelectDate.value + timeRange * (countDay - 1); if (maxTime > currentTime) maxTime = currentTime; return date.getTime() <= minTime || date.getTime() > maxTime; } else { return date.getTime() > new Date().getTime(); } }
function calendarChange(dates) { firstSelectDate.value = dates[0].getTime(); if (dates[1]) firstSelectDate.value = 0; } return { disabledDateRange, calendarChange, }; }
|