✨ feat(mes): 新增假期设置列表支持日期范围过滤功能
更新假期设置列表接口,支持可选的开始和结束日期参数,优化前端日历组件的数据获取逻辑,提升用户体验。pull/871/MERGE
parent
fc21347c59
commit
f8553abcdd
|
|
@ -11,9 +11,9 @@ export interface CalHolidayVO {
|
|||
|
||||
// MES 假期设置 API
|
||||
export const CalHolidayApi = {
|
||||
// 查询所有假期设置列表
|
||||
getHolidayList: async () => {
|
||||
return await request.get({ url: `/mes/cal/holiday/list` })
|
||||
// 查询假期设置列表(支持可选日期范围过滤)
|
||||
getHolidayList: async (params?: { startDay?: string; endDay?: string }) => {
|
||||
return await request.get({ url: `/mes/cal/holiday/list`, params })
|
||||
},
|
||||
|
||||
// 根据日期查询假期设置
|
||||
|
|
|
|||
|
|
@ -47,11 +47,16 @@ const message = useMessage()
|
|||
const currentDate = ref(new Date())
|
||||
const holidaySet = ref(new Set<string>()) // 节假日日期集合
|
||||
const formRef = ref()
|
||||
const lastFetchedMonth = ref('') // 用于避免同月重复请求
|
||||
|
||||
/** 获取假期列表 */
|
||||
/** 获取假期列表(按当前日历可见范围过滤) */
|
||||
const getList = async () => {
|
||||
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) {
|
||||
list.forEach((item: CalHolidayVO) => {
|
||||
// 后端返回的 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 }) => {
|
||||
// 非当前月日期,不处理(避免切换月份)
|
||||
|
|
|
|||
Loading…
Reference in New Issue