时间控件

This commit is contained in:
sjl
2024-11-07 10:24:33 +08:00
parent dc7e9d40e7
commit 9de2c874f0
4 changed files with 29 additions and 25 deletions

View File

@@ -85,16 +85,16 @@ const props = defineProps({
},
default: {
type: String,
default: '',
default: '',
},
})
// 定义事件
const emit = defineEmits<{
(e: 'update-dates', startDate: Date, endDate: Date): void;
(e: 'update-dates', startDate: string, endDate: string): void;
}>()
const timeUnit = ref<string>(props.default) // 默认选择
const startDate = ref<Date>(new Date()) // 起始日期
const startDate = ref<Date>(new Date(0)) // 起始日期
const endDate = ref<Date>(new Date()) // 结束日期
const isNextDisabled = ref<boolean>(false) // 控制下一周期按钮的禁用状态
const today = ref<Date>(new Date()) // 当前日期
@@ -109,7 +109,7 @@ const timeUnits = ref<TimeUnit[]>(
// 发出日期变化事件
const emitDateChange = () => {
emit('update-dates', formatDate(startDate.value), formatDate(endDate.value))
//console.log('emitDateChange', startDate.value, endDate.value);
console.log('emitDateChange', startDate.value, endDate.value)
}
// 在组件挂载时更新日期范围