Pārlūkot izejas kodu

feat: 在考勤服务中新增日期信息计算功能,并在打卡请求中包含考勤组信息。更新打卡页面以传递考勤组ID和名称,提升考勤数据的完整性。

master
lizhuang pirms 4 dienas
vecāks
revīzija
ccbf2413d3

+ 35
- 1
src/utils/attendance/AttendanceService.js Parādīt failu

return time ? parseTime(time, '{h}:{i}:{s}') : '' return time ? parseTime(time, '{h}:{i}:{s}') : ''
} }


/**
* 计算日期信息
* @param {Date} date 日期对象
* @returns {Object} 包含月、周、日的对象
*/
static calculateDateInfo(date) {
// 获取月份(1-12)
const month = date.getMonth() + 1

// 获取日期(1-31)
const day = date.getDate()

// 计算是一年中的第几周
const week = date.getDay()

return { month, week, day }
}

/** /**
* 构建打卡请求数据 * 构建打卡请求数据
* @param {Object} params 参数对象 * @param {Object} params 参数对象
* @returns {Object} 打卡数据 * @returns {Object} 打卡数据
*/ */
static buildPunchData(params) { static buildPunchData(params) {
const { type, userInfo, userLocation, remark } = params
const {
type,
userInfo,
userLocation,
remark,
attendanceGroupId,
attendanceGroupName
} = params


const statusMap = { const statusMap = {
morning: PUNCH_STATUS.CHECKED_IN, morning: PUNCH_STATUS.CHECKED_IN,
const isClockIn = type.includes('morning') const isClockIn = type.includes('morning')
const currentTime = this.formatDateTime(new Date()) const currentTime = this.formatDateTime(new Date())


// 获取当前日期的年月日信息
const currentDate = new Date(currentTime)
const { month, week, day } = this.calculateDateInfo(currentDate)

return { return {
userId: userInfo.userId, userId: userInfo.userId,
userName: userInfo.nickName, userName: userInfo.nickName,
checkInStatus: statusMap[type], checkInStatus: statusMap[type],
checkInType: isClockIn ? PUNCH_TYPE.CLOCK_IN : PUNCH_TYPE.CLOCK_OUT, checkInType: isClockIn ? PUNCH_TYPE.CLOCK_IN : PUNCH_TYPE.CLOCK_OUT,
[isClockIn ? 'clockIn' : 'clockOut']: currentTime, [isClockIn ? 'clockIn' : 'clockOut']: currentTime,
attendanceGroupId,
attendanceGroupName,
month,
week,
day,
description: remark || '' description: remark || ''
} }
} }

+ 2
- 0
src/views/m/checkin/index.vue Parādīt failu

type, type,
userInfo: this.userinfo, userInfo: this.userinfo,
userLocation: this.userLocation, userLocation: this.userLocation,
attendanceGroupId: this.attendanceGroup.id,
attendanceGroupName: this.attendanceGroup.attendanceGroupName,
remark: this.remarkForm.remark remark: this.remarkForm.remark
}) })



Notiek ielāde…
Atcelt
Saglabāt