排班管理接口对接

This commit is contained in:
re-JZzzz
2025-09-23 20:15:50 +08:00
parent 07c5dcde11
commit 30f5941202
6 changed files with 828 additions and 327 deletions

70
src/utils/getDate.ts Normal file
View File

@ -0,0 +1,70 @@
// 获取指定月份的日期信息
export interface DateInfo {
date: number;
weekDay: string;
fullDate: string;
}
/**
* 获取当前月份的日期信息
* @returns 包含当月所有日期信息的数组
*/
export const getCurrentMonthDates = (): DateInfo[] => {
const today = new Date();
const year = today.getFullYear();
const month = today.getMonth(); // 0-11
// 获取当月第一天
const firstDay = new Date(year, month, 1);
// 获取当月最后一天
const lastDay = new Date(year, month + 1, 0);
// 当月总天数
const daysInMonth = lastDay.getDate();
const weekdays = ['日', '一', '二', '三', '四', '五', '六'];
const dates: DateInfo[] = [];
// 生成当月所有日期信息
for (let i = 1; i <= daysInMonth; i++) {
const date = new Date(year, month, i);
const weekDayIndex = date.getDay(); // 0-60表示星期日
dates.push({
date: i,
weekDay: weekdays[weekDayIndex],
fullDate: `${year}-${String(month + 1).padStart(2, '0')}-${String(i).padStart(2, '0')}`
});
}
return dates;
};
/**
* 获取指定月份的日期信息
* @param year 年份
* @param month 月份0-11
* @returns 包含指定月份所有日期信息的数组
*/
export const getMonthDates = (year: number, month: number): DateInfo[] => {
// 获取当月第一天
const firstDay = new Date(year, month, 1);
// 获取当月最后一天
const lastDay = new Date(year, month + 1, 0);
// 当月总天数
const daysInMonth = lastDay.getDate();
const weekdays = ['日', '一', '二', '三', '四', '五', '六'];
const dates: DateInfo[] = [];
// 生成当月所有日期信息
for (let i = 1; i <= daysInMonth; i++) {
const date = new Date(year, month, i);
const weekDayIndex = date.getDay(); // 0-60表示星期日
dates.push({
date: i,
weekDay: weekdays[weekDayIndex],
fullDate: `${year}-${String(month + 1).padStart(2, '0')}-${String(i).padStart(2, '0')}`
});
}
return dates;
};