대시보드와 주간보고 기능 업데이트

This commit is contained in:
2026-01-10 14:40:01 +09:00
parent 0dd4b561f0
commit e4627caa4c
26 changed files with 3329 additions and 1720 deletions

View File

@@ -32,26 +32,14 @@ export default defineEventHandler(async (event) => {
const q = getQuery(event)
const limit = parseInt(q.limit as string) || 100
const viewAll = q.viewAll === 'true'
// 필터 조건 구성
const conditions: string[] = []
const params: any[] = []
let paramIndex = 1
// 관리자가 viewAll이면 전체 조회, 아니면 본인 것만
if (!isAdmin || !viewAll) {
// 작성자 필터 (본인 또는 지정된 작성자)
if (q.authorId) {
conditions.push(`r.author_id = $${paramIndex++}`)
params.push(q.authorId)
} else if (!isAdmin) {
// 관리자가 아니면 본인 것만
conditions.push(`r.author_id = $${paramIndex++}`)
params.push(userId)
}
} else if (q.authorId) {
// 관리자가 viewAll이어도 작성자 필터가 있으면 적용
// 작성자 필터 (선택된 경우에만 적용)
if (q.authorId) {
conditions.push(`r.author_id = $${paramIndex++}`)
params.push(q.authorId)
}
@@ -77,6 +65,15 @@ export default defineEventHandler(async (event) => {
params.push(q.week)
}
// 특정 주차 이전 필터 (beforeYear, beforeWeek)
if (q.beforeYear && q.beforeWeek) {
conditions.push(`(r.report_year < $${paramIndex} OR (r.report_year = $${paramIndex} AND r.report_week < $${paramIndex + 1}))`)
params.push(q.beforeYear)
paramIndex++
params.push(q.beforeWeek)
paramIndex++
}
// 주차 범위 필터
if (q.weekFrom) {
conditions.push(`r.report_week >= $${paramIndex++}`)
@@ -122,6 +119,8 @@ export default defineEventHandler(async (event) => {
r.report_status,
r.submitted_at,
r.created_at,
r.updated_at,
r.ai_review,
(SELECT COUNT(DISTINCT project_id) FROM wr_weekly_report_task WHERE report_id = r.report_id) as project_count,
(SELECT string_agg(DISTINCT p.project_name, ', ')
FROM wr_weekly_report_task t
@@ -152,6 +151,8 @@ export default defineEventHandler(async (event) => {
reportStatus: r.report_status,
submittedAt: r.submitted_at,
createdAt: r.created_at,
updatedAt: r.updated_at,
aiReview: r.ai_review,
projectCount: parseInt(r.project_count),
projectNames: r.project_names,
totalWorkHours: parseFloat(r.total_work_hours) || 0,