| | |
| | | syncAttendanceRecord |
| | | } from '@/api/performance/attendance' |
| | | import {getDicts} from "@/api/system/dict/data"; |
| | | import dayjs from 'dayjs'; |
| | | import {getTimeRange} from "@/utils/date"; |
| | | export default { |
| | | name: "Attendance", |
| | | components: { |
| | |
| | | this.selectEnumByCategory() |
| | | this.getUserList() |
| | | this.getTableHeight(); |
| | | this.dateRange = this.getTimeRange() |
| | | this.dateRange = getTimeRange() |
| | | this.resizeHandler = this.debounce(() => { |
| | | this.getTableHeight(); |
| | | }, 200); |
| | |
| | | this.dailyTypeList = response.data; |
| | | }); |
| | | }, |
| | | /** |
| | | * 初始化默认日期范围:近一个月(当前日期 - 30天 至 当前日期) |
| | | */ |
| | | getTimeRange(format = 'YYYY-MM-DD HH:mm:ss') { |
| | | // 获取当前时间 |
| | | const now = dayjs(); |
| | | // 获取当前日期的「日」(1-31) |
| | | const currentDate = now.date(); |
| | | |
| | | let startTime, endTime; |
| | | |
| | | // 核心逻辑:判断当前日期是否大于25号 |
| | | if (currentDate > 25) { |
| | | // ✅ 情况1:当前日>25 → 当月26号 ~ 次月25号 |
| | | startTime = now.startOf('month').add(25, 'day'); // 当月1号 +25天 = 26号 |
| | | endTime = startTime.add(1, 'month').date(25).hour(23) |
| | | .minute(59) |
| | | .second(59); // 次月25号(dayjs自动处理跨年) |
| | | } else { |
| | | // ✅ 情况2:当前日≤25 → 上月26号 ~ 当月25号 |
| | | startTime = now.subtract(1, 'month').startOf('month').add(25, 'day'); // 上月26号 |
| | | endTime = now.date(25).hour(23) |
| | | .minute(59) |
| | | .second(59); // 当月25号 |
| | | } |
| | | |
| | | // 返回格式化后的时间数组 |
| | | return [startTime.format(format), endTime.format(format)]; |
| | | }, |
| | | //同步考勤记录 |
| | | confirmSyncAttendance(){ |
| | | if(!this.syncDateRange || this.syncDateRange.length<2){ |
| | |
| | | }, |
| | | //打开同步考勤记录弹框 |
| | | openSyncAttendanceDialog(){ |
| | | this.syncAttendanceVisible = true |
| | | this.syncDateRange = getTimeRange() |
| | | this.$nextTick(()=>{ |
| | | this.syncAttendanceVisible = true |
| | | }) |
| | | }, |
| | | //删除考勤记录 |
| | | confirmRemoveRecord(row){ |
| | |
| | | }, |
| | | //重置按钮 |
| | | resetQuery() { |
| | | this.dateRange = this.getTimeRange(); |
| | | this.dateRange = getTimeRange(); |
| | | this.queryParams = { |
| | | startDate: "", |
| | | endDate: "", |