feat(mes): 新增假期设置列表支持日期范围过滤功能

更新假期设置列表接口,支持可选的开始和结束日期参数,优化前端日历组件的数据获取逻辑,提升用户体验。
pull/871/MERGE
YunaiV 2026-04-02 10:03:50 +08:00
parent fc21347c59
commit f8553abcdd
2 changed files with 19 additions and 5 deletions

View File

@ -11,9 +11,9 @@ export interface CalHolidayVO {
// MES 假期设置 API // MES 假期设置 API
export const CalHolidayApi = { export const CalHolidayApi = {
// 查询所有假期设置列表 // 查询假期设置列表(支持可选日期范围过滤)
getHolidayList: async () => { getHolidayList: async (params?: { startDay?: string; endDay?: string }) => {
return await request.get({ url: `/mes/cal/holiday/list` }) return await request.get({ url: `/mes/cal/holiday/list`, params })
}, },
// 根据日期查询假期设置 // 根据日期查询假期设置

View File

@ -47,11 +47,16 @@ const message = useMessage()
const currentDate = ref(new Date()) const currentDate = ref(new Date())
const holidaySet = ref(new Set<string>()) // const holidaySet = ref(new Set<string>()) //
const formRef = ref() const formRef = ref()
const lastFetchedMonth = ref('') //
/** 获取假期列表 */ /** 获取假期列表(按当前日历可见范围过滤) */
const getList = async () => { const getList = async () => {
holidaySet.value.clear() holidaySet.value.clear()
const list = await CalHolidayApi.getHolidayList() // ± 1 el-calendar
const current = dayjs(currentDate.value)
const startDay = current.subtract(1, 'month').startOf('month').format('YYYY-MM-DD 00:00:00')
const endDay = current.add(1, 'month').endOf('month').format('YYYY-MM-DD 23:59:59')
const list = await CalHolidayApi.getHolidayList({ startDay, endDay })
if (list) { if (list) {
list.forEach((item: CalHolidayVO) => { list.forEach((item: CalHolidayVO) => {
// day long yyyy-MM-dd // day long yyyy-MM-dd
@ -61,8 +66,17 @@ const getList = async () => {
} }
}) })
} }
lastFetchedMonth.value = current.format('YYYY-MM')
} }
/** 监听月份切换,重新加载可见范围内的数据 */
watch(currentDate, (newDate) => {
const newMonth = dayjs(newDate).format('YYYY-MM')
if (newMonth !== lastFetchedMonth.value) {
getList()
}
})
/** 点击日期 */ /** 点击日期 */
const onClickDay = (data: { type: string; day: string }) => { const onClickDay = (data: { type: string; day: string }) => {
// //