Tencent / tdesign-vue-next

A Vue3.x UI components lib for TDesign.
https://tdesign.tencent.com/vue-next
MIT License
1.42k stars 458 forks source link

[DatePicker] 是否可以支持在enableTimePicker使用disabledDate时,自动处理传给TimePicker的disableTime #3305

Open ngyyuusora opened 1 year ago

ngyyuusora commented 1 year ago

这个功能解决了什么问题

内置计算方法,使用起来更方便,不需要手动维护disableTime 可能解决这个问题更方便 https://github.com/Tencent/tdesign-vue-next/issues/3304

你建议的方案是什么

在DatePicker组件内部维护一个传给内置TimePicker的disableTime的方法,如果外部传入的disableDate格式为时间戳、HH、HH:mm、HH:mm:ss(意味着用户希望禁用到某一具体的时分秒),就激活该方法自动计算disableTime。

如果用户依然使用了timePickerProps.disableTime手动控制,就不使用该自动计算方法。

处理#3304的问题时,可判断如传入了{before: '2023-08-31 09:00'}时,如从20230901 0700从左侧日期选择面板切换到20230831时,自动将时分秒部分修改为09:00(如果是after禁用,如已选择after的前一日的时,该时间晚于after设定的时分秒,切到换after的当日时,因晚于after的时分秒,自动调整为after的时分秒)

如果处理#3304的问题,只在切换日期时判断新日期保留当前日期的时分秒,是否符合用户的disableTime规则,可能比较麻烦,不好计算如何跳转到最近的可用日期

github-actions[bot] commented 1 year ago

👋 @ngyyuusora,感谢给 TDesign 提出了 issue。 请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

github-actions[bot] commented 1 year ago

♥️ 有劳 @xkelvinx666 @xiaosansiji @honkinglin 尽快确认问题。 确认有效后将下一步计划和可能需要的时间回复给 @ngyyuusora 。

ngyyuusora commented 1 year ago

但是antd5也没有提供这样的功能,blazor的fluentui、angular的md组件库甚至都没有提供日期选择器内置时间选择器的功能,不知道这种自动处理是否适合内置在组件库中

ngyyuusora commented 1 year ago

因禁用时间范围指定的是一个(before或after)或两个(before和after),故disableTime也只有一或两天需要进行时分秒禁用。同理在切换日期时也是这一或两个日期需要判断时分秒是否符合before/after的时分秒

ngyyuusora commented 1 year ago

但是antd5也没有提供这样的功能,blazor的fluentui、angular的md组件库甚至都没有提供日期选择器内置时间选择器的功能,不知道这种自动处理是否适合内置在组件库中

Screenshot_2023-09-01-14-17-30-648_com tencent mm