This commit is contained in:
sjl
2024-12-04 08:49:42 +08:00
parent 33004e081d
commit 741020fe79
9 changed files with 171 additions and 51 deletions

View File

@@ -126,6 +126,15 @@ const handleChange = (unit: string) => {
endDate.value = new Date()
}
timeUnit.value = unit
// 确保开始时间和结束时间不为空
if (!startDate.value) {
startDate.value = new Date()
}
if (!endDate.value) {
endDate.value = new Date()
}
emitDateChange() // 变化时也发出更新事件
updateNextButtonStatus()
}
@@ -172,7 +181,13 @@ const updateDateRange = () => {
// endDate.value.setHours(23, 59, 59, 999); // 设置结束时间为今天的23:59:59.999
// }
}
// 确保开始时间和结束时间不为空
if (!startDate.value) {
startDate.value = new Date()
}
if (!endDate.value) {
endDate.value = new Date()
}
updateNextButtonStatus()
}
@@ -285,7 +300,10 @@ const disableEndDate = (date: Date) => {
// 格式化日期yyyy-mm-dd
function formatDate(date:Date) {
function formatDate(date: Date | null): string {
if (!date) {
return '';
}
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');