antd vue a-range-picker如何设置不能选择当前和之后的时间,包含时分秒

html 复制代码
<a-range-picker
              v-model:value="formState.reqTime"
              show-time
              format="YYYY-MM-DD HH:mm:ss"
              :disabledDate="disabledDate"
              :disabledTime="disabledTime"
              :placeholder="['开始时间', '结束时间']"
              style="width: 382px"
              separator="-"
            >
            </a-range-picker>
javascript 复制代码
import dayjs from 'dayjs';
setup() {
 const disabledDate = current => {
      return current && current > dayjs().endOf('day');
    };
    const range = (start, end) => {
      const result = [];
      for (let i = start; i < end; i++) {
        result.push(i);
      }
      return result;
    };
    function disabledTime(dates, partial) {
      const hours = dayjs().hour();
      const minutes = dayjs().minute();
      const seconds = dayjs().second();
      if (!dates) {
        dates = dayjs();
      }
      if (partial == 'start') {
        if (dates[0] && dayjs(dates[0]).date() === dayjs().date()) {
          if (dayjs(dates[0]).hour() === dayjs().hour()) {
            return {
              disabledHours: () => range(hours + 1, 24),
              disabledMinutes: () => range(minutes + 1, 60),
              disabledSeconds: () => range(seconds + 1, 60)
            };
          } else {
            return {
              disabledHours: () => range(hours, 24),
              disabledMinutes: () => [],
              disabledSeconds: () => []
            };
          }
        } else {
          return {
            disabledHours: () => [],
            disabledMinutes: () => [],
            disabledSeconds: () => []
          };
        }
      } else if (partial == 'end') {
        if (dates[1] && dayjs(dates[1]).date() === dayjs().date()) {
          if (dayjs(dates[1]).hour() === dayjs().hour()) {
            return {
              disabledHours: () => range(hours + 1, 24),
              disabledMinutes: () => range(minutes + 1, 60),
              disabledSeconds: () => range(seconds + 1, 60)
            };
          } else {
            return {
              disabledHours: () => range(hours, 24),
              disabledMinutes: () => [],
              disabledSeconds: () => []
            };
          }
        } else {
          return {
            disabledHours: () => [],
            disabledMinutes: () => [],
            disabledSeconds: () => []
          };
        }
      }
    }
    return {
      disabledDate,
      disabledTime
    };
   }
相关推荐
怕浪猫5 小时前
FDE 如何正确解决现场项目工程性的问题
前端·后端·ai编程
西瓜太郎12345 小时前
外层模型卡片与分组详情成功率不一致,应该怎么排查?
前端·typescript·go·软件工程·react
GreenTea5 小时前
vLLM 与 SGLang KV Cache 底层实现机制深度调研报告
前端·后端·算法
毕业设计7038 小时前
(免费领源码) 基于微信小程序的预制菜商城的设计与实现25172-java、PHP、python、C#、小程序、大数据、单片机、网络工程等)
vue.js·python·mysql·微信小程序·pycharm·微信开发者工具·推荐算法
xifangge20258 小时前
AGENTS.md 怎么写?涵盖 Java、Python、Vue、Go 的 8 套开箱即用模板
java·vue.js·python
几何心凉8 小时前
没有万能模型:我用 AiiOnly Token Plan,把多款大模型的长处拼进同一个项目
前端
kyriewen8 小时前
Claude Code 的额度今天缩水了17%——官方公告上写的是"永久提高25%"
前端·ai编程·claude
雪芽蓝域zzs9 小时前
vue解构平铺VS对象包裹
前端·javascript·vue.js
风骏时光牛马10 小时前
从零到实战,完整AI学习路线
前端
三十而立洋10 小时前
深入理解 Monorepo:子包安装依赖
前端·前端工程化