diff --git a/api/app/lib/controllers/member/index.js b/api/app/lib/controllers/member/index.js index 6b381f7..39ad529 100644 --- a/api/app/lib/controllers/member/index.js +++ b/api/app/lib/controllers/member/index.js @@ -176,14 +176,32 @@ async function del (ctx) { async function list (ctx) { try { const { models } = ctx.fs.dc; + const { judgeHoliday } = ctx.app.fs.utils const { clickHouse } = ctx.app.fs const { database: pepEmis } = clickHouse.pepEmis.opts.config const { keywordTarget, keyword, limit, page, state } = ctx.query + let nowTime = moment() let whereOption = [] if (state == 'dimission') { whereOption.push(`member.dimission_date IS NOT null`) } + if (state == 'inOffice') { + const curDay = moment().format('YYYY-MM-DD') + const holidayJudge = await judgeHoliday(curDay) + if (holidayJudge) { + if ( + holidayJudge.workday + && nowTime.isAfter(moment(curDay + ' 08:30')) + && nowTime.isBefore(moment(curDay + ' 17:30')) + ) { + // 在工作日的工作时间范围 + } + } else { + ctx.body = [] + return + } + } const userRes = await clickHouse.hr.query(` SELECT member.pep_user_id AS pepUserId, @@ -192,7 +210,8 @@ async function list (ctx) { role.name AS roleName, role.id AS roleId, department.name AS depName, - department.id AS depId + department.id AS depId, + vacate.id AS vacateId FROM member LEFT JOIN ${pepEmis}.user AS user ON member.pep_user_id = user.id @@ -209,6 +228,7 @@ async function list (ctx) { AND vacate.start_time <= '${moment().format('YYYY-MM-DD HH:mm:ss')}' AND vacate.end_time > '${moment().format('YYYY-MM-DD HH:mm:ss')}' ${whereOption.length ? `WHERE ${whereOption.join(' AND ')}` : ''} + ${/** limit 错啦*/''} ${limit ? `LIMIT ${limit}` : ''} ${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} `).toPromise() diff --git a/web/client/src/layout/actions/webSocket.js b/web/client/src/layout/actions/webSocket.js index e91971e..605748e 100644 --- a/web/client/src/layout/actions/webSocket.js +++ b/web/client/src/layout/actions/webSocket.js @@ -2,19 +2,19 @@ import io from 'socket.io-client'; export const INIT_WEB_SOCKET = 'INIT_WEB_SOCKET' -export function initWebSocket ({ ioUrl, token, pomsUserId }) { +export function initWebSocket ({ ioUrl, token, hrUserId }) { if (!ioUrl) { ioUrl = localStorage.getItem('apiRoot') ioUrl = JSON.parse(ioUrl).root } if (!token) { - let user = sessionStorage.getItem('pomsUser') + let user = sessionStorage.getItem('hrUser') if (user) { user = JSON.parse(user) token = user.token } } - if (!ioUrl || !token || !pomsUserId) { + if (!ioUrl || !token || !hrUserId) { return { type: '', } diff --git a/web/client/src/sections/auth/actions/auth.js b/web/client/src/sections/auth/actions/auth.js index c3e4a5d..ce6a8d3 100644 --- a/web/client/src/sections/auth/actions/auth.js +++ b/web/client/src/sections/auth/actions/auth.js @@ -5,10 +5,10 @@ import { Request } from '@peace/utils'; export const INIT_AUTH = 'INIT_AUTH'; export function initAuth (userData) { - const sessionUser = JSON.parse(sessionStorage.getItem('pomsUser')) + const sessionUser = JSON.parse(sessionStorage.getItem('hrUser')) const user = userData || sessionUser || {}; if (user.authorized && !sessionUser) { - sessionStorage.setItem('pomsUser', JSON.stringify(user)) + sessionStorage.setItem('hrUser', JSON.stringify(user)) } return { type: INIT_AUTH, @@ -45,7 +45,7 @@ export function login (username, password) { return Request.post(ApiTable.login, { username, password, code: 'POMS' }) .then(user => { - sessionStorage.setItem('pomsUser', JSON.stringify(user)); + sessionStorage.setItem('hrUser', JSON.stringify(user)); return dispatch({ type: LOGIN_SUCCESS, payload: { user: user }, @@ -64,13 +64,13 @@ export function login (username, password) { export const LOGOUT = 'LOGOUT'; export function logout () { - const user = JSON.parse(sessionStorage.getItem('pomsUser')) + const user = JSON.parse(sessionStorage.getItem('hrUser')) user && user.token ? Request.put(ApiTable.logout, { token: user.token, code: 'POMS' }) : null; - sessionStorage.removeItem('pomsUser'); + sessionStorage.removeItem('hrUser'); return { type: LOGOUT }; diff --git a/web/client/src/sections/auth/containers/login.jsx b/web/client/src/sections/auth/containers/login.jsx index 531cce9..949e12e 100644 --- a/web/client/src/sections/auth/containers/login.jsx +++ b/web/client/src/sections/auth/containers/login.jsx @@ -66,7 +66,7 @@ const Login = props => { onSubmit={values => { dispatch(login(values.username, values.password)).then(res => { const data = res.payload.user - dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, pomsUserId: data.pomsUserInfo.id })) + dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo.id })) }) }} getFormApi={formApi => form.current = formApi} diff --git a/web/client/src/utils/func.js b/web/client/src/utils/func.js index c77199e..9783a9f 100644 --- a/web/client/src/utils/func.js +++ b/web/client/src/utils/func.js @@ -2,7 +2,7 @@ export const isAuthorized = (authcode) => { if (JSON.parse(sessionStorage.getItem('user'))) { - const { resources } = JSON.parse(sessionStorage.getItem('pomsUser')); + const { resources } = JSON.parse(sessionStorage.getItem('hrUser')); return resources.includes(authcode); } else { return false;