Ver código fonte

chore(utils): 添加禁止选择超过今天的日期的函数

wangcong 1 semana atrás
pai
commit
b72dec41a4
1 arquivos alterados com 5 adições e 0 exclusões
  1. 5 0
      src/utils/index.ts

+ 5 - 0
src/utils/index.ts

@@ -8,6 +8,7 @@ import { fetchWithTimeout } from './fetch';
 
 import type { SorterResult } from 'ant-design-vue/es/table/interface';
 import type { GlobalToken } from 'ant-design-vue/es/theme';
+import type { Dayjs } from 'dayjs';
 import type { ApiResponse, PageSorts } from '@/types';
 
 export const request = async <T>(url: string, init: RequestInit = {}, timeout?: number): Promise<T> => {
@@ -272,3 +273,7 @@ export const isEmptyVal = (value: unknown) => {
 export const isNotEmptyVal = (value: unknown) => {
   return value !== undefined && value !== null;
 };
+
+export const disabledDate = (current: Dayjs) => {
+  return current > dayjs().endOf('day');
+};