Browse Source

假勤日统计时间筛选

master
巴林闲侠 2 years ago
parent
commit
bf7b9fe480
  1. 50
      api/app/lib/controllers/member/index.js
  2. 6
      api/app/lib/routes/member/index.js

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

@ -198,12 +198,39 @@ async function nativePlaceList (ctx) {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const nRes = await models.Member.findAll({ const nRes = await models.Member.findAll({
attributes: [''], attributes: ['nativePlace'],
group: '' group: 'nativePlace',
where: {
nativePlace: { $ne: null }
}
}) })
ctx.status = 200; ctx.status = 200;
ctx.body = [] ctx.body = nRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function workPlaceList (ctx) {
// 获取已有的工作地列表
try {
const { models } = ctx.fs.dc;
const wRes = await models.Member.findAll({
attributes: ['workPlace'],
group: 'workPlace',
where: {
workPlace: { $ne: null }
}
})
ctx.status = 200;
ctx.body = wRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400; ctx.status = 400;
@ -217,7 +244,10 @@ async function list (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
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 curDay = moment().format('YYYY-MM-DD')
const nowTime = moment() const nowTime = moment()
@ -366,6 +396,10 @@ async function overTimeStatistics (ctx) {
INNER JOIN overtime INNER JOIN overtime
ON overtime.id = overtime_day.overtime_id ON overtime.id = overtime_day.overtime_id
AND overtime.pep_user_id = ${pepUserId} AND overtime.pep_user_id = ${pepUserId}
${startDate && endDate ? `
WHERE overtime_day.day >= '${moment(startDate).format('YYYY-MM-DD')}'
AND overtime_day.day <= '${moment(endDate).format('YYYY-MM-DD')}'
` : ''}
GROUP BY overtime_day.day, overtime.compensate GROUP BY overtime_day.day, overtime.compensate
`).toPromise() `).toPromise()
@ -436,6 +470,10 @@ async function vacateStatistics (ctx) {
INNER JOIN vacate INNER JOIN vacate
ON vacate.id = vacate_day.vacate_id ON vacate.id = vacate_day.vacate_id
AND vacate.pep_user_id = ${pepUserId} AND vacate.pep_user_id = ${pepUserId}
${startDate && endDate ? `
WHERE vacate_day.day >= '${moment(startDate).format('YYYY-MM-DD')}'
AND vacate_day.day <= '${moment(endDate).format('YYYY-MM-DD')}'
` : ''}
GROUP BY vacate_day.day GROUP BY vacate_day.day
`).toPromise() `).toPromise()
@ -679,5 +717,7 @@ module.exports = {
overTimeStatistics, overTimeStatistics,
vacateStatistics, vacateStatistics,
exportData, exportData,
addMembersBulk addMembersBulk,
nativePlaceList,
workPlaceList,
} }

6
api/app/lib/routes/member/index.js

@ -15,6 +15,12 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/member/search'] = { content: '搜索项企用户', visible: true }; app.fs.api.logAttr['GET/member/search'] = { content: '搜索项企用户', visible: true };
router.get('/member/search', member.searchPepMember); router.get('/member/search', member.searchPepMember);
app.fs.api.logAttr['GET/member/native_place'] = { content: '查询籍贯列表', visible: true };
router.get('/member/native_place', member.nativePlaceList);
app.fs.api.logAttr['GET/member/work_place'] = { content: '查询工作地列表', visible: true };
router.get('/member/work_place', member.workPlaceList);
app.fs.api.logAttr['GET/member/list'] = { content: '查询人员列表', visible: true }; app.fs.api.logAttr['GET/member/list'] = { content: '查询人员列表', visible: true };
router.get('/member/list', member.list); router.get('/member/list', member.list);

Loading…
Cancel
Save