Browse Source

人员状态

master
巴林闲侠 3 years ago
parent
commit
772edd2628
  1. 20
      api/app/lib/controllers/member/index.js
  2. 6
      api/app/lib/utils/member.js

20
api/app/lib/controllers/member/index.js

@ -190,6 +190,22 @@ async function list (ctx) {
const { judgeHoliday, memberList } = ctx.app.fs.utils const { judgeHoliday, memberList } = ctx.app.fs.utils
const { keywordTarget, keyword, limit, page, state } = ctx.query const { keywordTarget, keyword, limit, page, state } = ctx.query
const curDay = moment().format('YYYY-MM-DD')
const nowTime = moment()
const holidayJudge = await judgeHoliday(curDay)
let workTime = false
let dayoffTime = false
if (holidayJudge) {
if (
holidayJudge.workday
&& nowTime.isAfter(moment(curDay + ' 08:30'))
&& nowTime.isBefore(moment(curDay + ' 17:30'))
) {
workTime = true
} else if (holidayJudge.dayoff || holidayJudge.festivals) {
dayoffTime = true
}
}
const userRes = await memberList({ keywordTarget, keyword, limit, page, state }) const userRes = await memberList({ keywordTarget, keyword, limit, page, state })
let returnD = [] let returnD = []
@ -233,6 +249,10 @@ async function list (ctx) {
id: u.roleId, id: u.roleId,
name: u.roleName name: u.roleName
}] : [], }] : [],
state: obj['dimissionDate'] ? 'dimission' :
obj['vacateStartTime'] ? 'vacate' :
workTime ? 'inOffice' :
dayoffTime ? 'dayoff' : 'rest',
del: undefined, del: undefined,
pepuserid: undefined, pepuserid: undefined,
}) })

6
api/app/lib/utils/member.js

@ -23,7 +23,7 @@ module.exports = function (app, opts) {
&& nowTime.isBefore(moment(curDay + ' 17:30')) && nowTime.isBefore(moment(curDay + ' 17:30'))
) { ) {
// 在工作日的工作时间范围 无请假记录 // 在工作日的工作时间范围 无请假记录
whereFromSelectOption.push(`vacateStartTime IS NULL`) whereFromSelectOption.push(`vacateStartTime = '1970-01-01 00:00:00.000000'`)
} else { } else {
return [] return []
} }
@ -39,7 +39,7 @@ module.exports = function (app, opts) {
holidayJudge.dayoff || holidayJudge.festivals holidayJudge.dayoff || holidayJudge.festivals
) { ) {
// 在休息日范围内且无加班申请 // 在休息日范围内且无加班申请
whereFromSelectOption.push(`overtimeStartTime IS NULL`) whereFromSelectOption.push(`overtimeStartTime = '1970-01-01 00:00:00.000000'`)
} else { } else {
return [] return []
} }
@ -88,7 +88,7 @@ module.exports = function (app, opts) {
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
pep_user_id, pep_user_id,
any(start_time) AS overtimeStartTime, any(toString(start_time)) AS overtimeStartTime,
any(end_time) AS overtimeEndTime any(end_time) AS overtimeEndTime
FROM overtime FROM overtime
WHERE WHERE

Loading…
Cancel
Save