|
|
|
|
|
|
|
|
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 || '' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |