fix(admin): 日期组件进入界面后应滚动到当前日期/选中项居中
构建并部署 BYW VoiceHub / Preflight 语法与构建检查 (push) Successful in 2m51s
构建并部署 BYW VoiceHub / 镜像构建·预热(与 Preflight 并发:系统/镜像源/Builder 初始化) (push) Successful in 4m50s
构建并部署 BYW VoiceHub / 构建并推送容器镜像 (push) Failing after 1s
构建并部署 BYW VoiceHub / 部署到生产服务器 (push) Skipped

AdminDatePicker:
- scrollToDateElement 在 props.modelValue 为空时回退到今天
- onMounted: 空值时走 smooth(有滚动感),有值走 auto(无声定位),不再直接 return 停在最左

AdminMultiDatePicker:
- 新增 scrollToDateElement 通用 + watch(modelValue)
- onMounted 分两支: 有选中值时跳到首个 >= 今天的选中项 否则跳今天
- 目标超出 dateRange 时先扩 range 再滚 (避免定位不到元素)
This commit is contained in:
2026-09-13 10:29:12 +08:00
parent 456bc39e3e
commit 27d718bf01
2 changed files with 42 additions and 12 deletions
+7 -5
View File
@@ -239,10 +239,12 @@ const selectDate = (dateValue) => {
emit('change', dateValue)
}
const scrollToDateElement = (behavior = 'smooth') => {
if (!dateSelector.value || !props.modelValue) return
const el = dateSelector.value.querySelector(`[data-date="${props.modelValue}"]`)
if (el) el.scrollIntoView({ behavior, block: 'nearest', inline: 'center' })
const scrollToDateElement = (behavior = 'smooth', targetDate = props.modelValue) => {
if (!dateSelector.value) return
const dateKey = targetDate || formatDateStr(today)
const el = dateSelector.value.querySelector(`[data-date="${dateKey}"]`)
if (!el) return
el.scrollIntoView({ behavior, block: 'nearest', inline: 'center' })
}
const handleWheel = (event) => {
@@ -324,7 +326,7 @@ watch(() => props.modelValue, () => {
})
onMounted(() => {
nextTick(() => scrollToDateElement('auto'))
nextTick(() => scrollToDateElement(props.modelValue ? 'auto' : 'smooth'))
})
</script>