封装日期时间限制控件,文件放在interface/index.ts文件夹里;
// 封装的日期禁用控件。interface/index.ts
import {toRefs} 'vue';
export interface ClassifyDate {
startDate:any;
}
/**
@description: 判断今年是闰年还是平年。闰年366天 平年365天
@return {*}
**/
const getDay = () => {
const years = new Date().getFullYear();
if ((years % 4 === 0 && years % 100 === 0) || years % 400 === 0) {
return 366;
} else {
return 365;
}
};
/**
@description: 日期控件的封装
@param {number} day // 日期控件限制时间跨度,非必穿,默认一年
@return {*}
**/
export const useDatePicker = (day:number = getDay()) => {
const state = reactive<ClassifyDate>({
startDate: null, // 日期选择的开始时间
});
//获取点击开始的时间
const calendarChange = (dates:any) => {
const hasSelectDate = dates !== null &&