추가
This commit is contained in:
15
.env
Normal file
15
.env
Normal file
@@ -0,0 +1,15 @@
|
||||
# Database
|
||||
DB_HOST=172.25.0.79
|
||||
DB_PORT=5433
|
||||
DB_NAME=weeklyreport
|
||||
DB_USER=weeklyreport
|
||||
DB_PASSWORD=weeklyreport2026
|
||||
|
||||
# App
|
||||
SESSION_SECRET=dev-secret-key-change-in-production
|
||||
AUTO_START_SCHEDULER=false
|
||||
|
||||
# TODO: Google OAuth
|
||||
# GOOGLE_CLIENT_ID=
|
||||
# GOOGLE_CLIENT_SECRET=
|
||||
# GOOGLE_REDIRECT_URI=http://localhost:3000/api/auth/callback
|
||||
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# Dependencies
|
||||
node_modules
|
||||
|
||||
# Build
|
||||
.nuxt
|
||||
.output
|
||||
dist
|
||||
|
||||
# Environment
|
||||
# .env 는 git에 포함 (팀 공유용)
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
.vscode
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# 디폴트 무시된 파일
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 쿼리 파일을 포함한 무시된 디폴트 폴더
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# 에디터 기반 HTTP 클라이언트 요청
|
||||
/httpRequests/
|
||||
6
.idea/PMDPlugin.xml
generated
Normal file
6
.idea/PMDPlugin.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PMDPlugin">
|
||||
<option name="skipTestSources" value="false" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/misc.xml
generated
Normal file
17
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AnalysisProjectProfileManager">
|
||||
<option name="PROJECT_PROFILE" />
|
||||
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
|
||||
<list size="0" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SuppressionsComponent">
|
||||
<option name="suppComments" value="[]" />
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration>C:\Users\coziny\AppData\Roaming\Subversion</configuration>
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/weeklyreport.iml" filepath="$PROJECT_DIR$/.idea/weeklyreport.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/vcs.xml
generated
Normal file
7
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/weeklyreport.iml
generated
Normal file
9
.idea/weeklyreport.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
32
backend/api/auth/current-user.get.ts
Normal file
32
backend/api/auth/current-user.get.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { queryOne } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 현재 로그인 사용자 정보
|
||||
* GET /api/auth/current-user
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
|
||||
if (!userId) {
|
||||
return { user: null }
|
||||
}
|
||||
|
||||
const employee = await queryOne<any>(`
|
||||
SELECT * FROM wr_employee_info
|
||||
WHERE employee_id = $1 AND is_active = true
|
||||
`, [parseInt(userId)])
|
||||
|
||||
if (!employee) {
|
||||
deleteCookie(event, 'user_id')
|
||||
return { user: null }
|
||||
}
|
||||
|
||||
return {
|
||||
user: {
|
||||
employeeId: employee.employee_id,
|
||||
employeeName: employee.employee_name,
|
||||
employeeEmail: employee.employee_email,
|
||||
employeePosition: employee.employee_position
|
||||
}
|
||||
}
|
||||
})
|
||||
62
backend/api/auth/login.post.ts
Normal file
62
backend/api/auth/login.post.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { query, insertReturning, execute } from '../../utils/db'
|
||||
|
||||
interface LoginBody {
|
||||
email: string
|
||||
name: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 이메일+이름 로그인 (임시)
|
||||
* POST /api/auth/login
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<LoginBody>(event)
|
||||
|
||||
if (!body.email || !body.name) {
|
||||
throw createError({ statusCode: 400, message: '이메일과 이름을 입력해주세요.' })
|
||||
}
|
||||
|
||||
// 이메일 형식 검증
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
if (!emailRegex.test(body.email)) {
|
||||
throw createError({ statusCode: 400, message: '올바른 이메일 형식이 아닙니다.' })
|
||||
}
|
||||
|
||||
// 기존 사원 조회
|
||||
let employee = await query<any>(`
|
||||
SELECT * FROM wr_employee_info WHERE employee_email = $1
|
||||
`, [body.email.toLowerCase()])
|
||||
|
||||
let employeeData = employee[0]
|
||||
|
||||
// 없으면 자동 등록
|
||||
if (!employeeData) {
|
||||
employeeData = await insertReturning(`
|
||||
INSERT INTO wr_employee_info (employee_name, employee_email)
|
||||
VALUES ($1, $2)
|
||||
RETURNING *
|
||||
`, [body.name, body.email.toLowerCase()])
|
||||
}
|
||||
|
||||
// 로그인 이력 추가
|
||||
await execute(`
|
||||
INSERT INTO wr_login_history (employee_id) VALUES ($1)
|
||||
`, [employeeData.employee_id])
|
||||
|
||||
// 쿠키에 사용자 정보 저장 (간단한 임시 세션)
|
||||
setCookie(event, 'user_id', String(employeeData.employee_id), {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7, // 7일
|
||||
path: '/'
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
user: {
|
||||
employeeId: employeeData.employee_id,
|
||||
employeeName: employeeData.employee_name,
|
||||
employeeEmail: employeeData.employee_email,
|
||||
employeePosition: employeeData.employee_position
|
||||
}
|
||||
}
|
||||
})
|
||||
8
backend/api/auth/logout.post.ts
Normal file
8
backend/api/auth/logout.post.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* 로그아웃
|
||||
* POST /api/auth/logout
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
deleteCookie(event, 'user_id')
|
||||
return { success: true }
|
||||
})
|
||||
23
backend/api/auth/recent-users.get.ts
Normal file
23
backend/api/auth/recent-users.get.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 최근 로그인 사용자 목록
|
||||
* GET /api/auth/recent-users
|
||||
*/
|
||||
export default defineEventHandler(async () => {
|
||||
const users = await query(`
|
||||
SELECT * FROM wr_recent_login_users
|
||||
ORDER BY last_active_at DESC
|
||||
LIMIT 10
|
||||
`)
|
||||
|
||||
return {
|
||||
users: users.map((u: any) => ({
|
||||
employeeId: u.employee_id,
|
||||
employeeName: u.employee_name,
|
||||
employeeEmail: u.employee_email,
|
||||
employeePosition: u.employee_position,
|
||||
lastActiveAt: u.last_active_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
49
backend/api/auth/select-user.post.ts
Normal file
49
backend/api/auth/select-user.post.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { queryOne, execute } from '../../utils/db'
|
||||
|
||||
interface SelectUserBody {
|
||||
employeeId: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 사용자 선택 로그인
|
||||
* POST /api/auth/select-user
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<SelectUserBody>(event)
|
||||
|
||||
if (!body.employeeId) {
|
||||
throw createError({ statusCode: 400, message: '사용자를 선택해주세요.' })
|
||||
}
|
||||
|
||||
// 사원 조회
|
||||
const employee = await queryOne<any>(`
|
||||
SELECT * FROM wr_employee_info
|
||||
WHERE employee_id = $1 AND is_active = true
|
||||
`, [body.employeeId])
|
||||
|
||||
if (!employee) {
|
||||
throw createError({ statusCode: 404, message: '사용자를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 로그인 이력 추가
|
||||
await execute(`
|
||||
INSERT INTO wr_login_history (employee_id) VALUES ($1)
|
||||
`, [employee.employee_id])
|
||||
|
||||
// 쿠키 설정
|
||||
setCookie(event, 'user_id', String(employee.employee_id), {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
path: '/'
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
user: {
|
||||
employeeId: employee.employee_id,
|
||||
employeeName: employee.employee_name,
|
||||
employeeEmail: employee.employee_email,
|
||||
employeePosition: employee.employee_position
|
||||
}
|
||||
}
|
||||
})
|
||||
30
backend/api/employee/[id]/detail.get.ts
Normal file
30
backend/api/employee/[id]/detail.get.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { queryOne } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 사원 상세 조회
|
||||
* GET /api/employee/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const employeeId = getRouterParam(event, 'id')
|
||||
|
||||
const employee = await queryOne<any>(`
|
||||
SELECT * FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [employeeId])
|
||||
|
||||
if (!employee) {
|
||||
throw createError({ statusCode: 404, message: '사원을 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
return {
|
||||
employeeId: employee.employee_id,
|
||||
employeeNumber: employee.employee_number,
|
||||
employeeName: employee.employee_name,
|
||||
employeeEmail: employee.employee_email,
|
||||
employeePhone: employee.employee_phone,
|
||||
employeePosition: employee.employee_position,
|
||||
joinDate: employee.join_date,
|
||||
isActive: employee.is_active,
|
||||
createdAt: employee.created_at,
|
||||
updatedAt: employee.updated_at
|
||||
}
|
||||
})
|
||||
49
backend/api/employee/[id]/update.put.ts
Normal file
49
backend/api/employee/[id]/update.put.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { execute, queryOne } from '../../../utils/db'
|
||||
|
||||
interface UpdateEmployeeBody {
|
||||
employeeNumber?: string
|
||||
employeeName?: string
|
||||
employeePhone?: string
|
||||
employeePosition?: string
|
||||
joinDate?: string
|
||||
isActive?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 정보 수정
|
||||
* PUT /api/employee/[id]/update
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const employeeId = getRouterParam(event, 'id')
|
||||
const body = await readBody<UpdateEmployeeBody>(event)
|
||||
|
||||
const existing = await queryOne<any>(`
|
||||
SELECT * FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [employeeId])
|
||||
|
||||
if (!existing) {
|
||||
throw createError({ statusCode: 404, message: '사원을 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_employee_info SET
|
||||
employee_number = $1,
|
||||
employee_name = $2,
|
||||
employee_phone = $3,
|
||||
employee_position = $4,
|
||||
join_date = $5,
|
||||
is_active = $6,
|
||||
updated_at = NOW()
|
||||
WHERE employee_id = $7
|
||||
`, [
|
||||
body.employeeNumber ?? existing.employee_number,
|
||||
body.employeeName ?? existing.employee_name,
|
||||
body.employeePhone ?? existing.employee_phone,
|
||||
body.employeePosition ?? existing.employee_position,
|
||||
body.joinDate ?? existing.join_date,
|
||||
body.isActive ?? existing.is_active,
|
||||
employeeId
|
||||
])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
55
backend/api/employee/create.post.ts
Normal file
55
backend/api/employee/create.post.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { insertReturning, queryOne } from '../../utils/db'
|
||||
|
||||
interface CreateEmployeeBody {
|
||||
employeeNumber?: string
|
||||
employeeName: string
|
||||
employeeEmail: string
|
||||
employeePhone?: string
|
||||
employeePosition?: string
|
||||
joinDate?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 등록
|
||||
* POST /api/employee/create
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<CreateEmployeeBody>(event)
|
||||
|
||||
if (!body.employeeName || !body.employeeEmail) {
|
||||
throw createError({ statusCode: 400, message: '이름과 이메일은 필수입니다.' })
|
||||
}
|
||||
|
||||
// 이메일 중복 체크
|
||||
const existing = await queryOne(`
|
||||
SELECT employee_id FROM wr_employee_info WHERE employee_email = $1
|
||||
`, [body.employeeEmail.toLowerCase()])
|
||||
|
||||
if (existing) {
|
||||
throw createError({ statusCode: 409, message: '이미 등록된 이메일입니다.' })
|
||||
}
|
||||
|
||||
const employee = await insertReturning(`
|
||||
INSERT INTO wr_employee_info (
|
||||
employee_number, employee_name, employee_email,
|
||||
employee_phone, employee_position, join_date
|
||||
) VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING *
|
||||
`, [
|
||||
body.employeeNumber || null,
|
||||
body.employeeName,
|
||||
body.employeeEmail.toLowerCase(),
|
||||
body.employeePhone || null,
|
||||
body.employeePosition || null,
|
||||
body.joinDate || null
|
||||
])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
employee: {
|
||||
employeeId: employee.employee_id,
|
||||
employeeName: employee.employee_name,
|
||||
employeeEmail: employee.employee_email
|
||||
}
|
||||
}
|
||||
})
|
||||
30
backend/api/employee/list.get.ts
Normal file
30
backend/api/employee/list.get.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 사원 목록 조회
|
||||
* GET /api/employee/list
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const queryParams = getQuery(event)
|
||||
const activeOnly = queryParams.activeOnly !== 'false'
|
||||
|
||||
let sql = `
|
||||
SELECT * FROM wr_employee_info
|
||||
${activeOnly ? 'WHERE is_active = true' : ''}
|
||||
ORDER BY employee_name
|
||||
`
|
||||
|
||||
const employees = await query(sql)
|
||||
|
||||
return employees.map((e: any) => ({
|
||||
employeeId: e.employee_id,
|
||||
employeeNumber: e.employee_number,
|
||||
employeeName: e.employee_name,
|
||||
employeeEmail: e.employee_email,
|
||||
employeePhone: e.employee_phone,
|
||||
employeePosition: e.employee_position,
|
||||
joinDate: e.join_date,
|
||||
isActive: e.is_active,
|
||||
createdAt: e.created_at
|
||||
}))
|
||||
})
|
||||
29
backend/api/employee/search.get.ts
Normal file
29
backend/api/employee/search.get.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 사원 검색 (이름/이메일)
|
||||
* GET /api/employee/search?q=keyword
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const queryParams = getQuery(event)
|
||||
const keyword = queryParams.q as string
|
||||
|
||||
if (!keyword || keyword.length < 1) {
|
||||
return []
|
||||
}
|
||||
|
||||
const employees = await query(`
|
||||
SELECT * FROM wr_employee_info
|
||||
WHERE is_active = true
|
||||
AND (employee_name ILIKE $1 OR employee_email ILIKE $1)
|
||||
ORDER BY employee_name
|
||||
LIMIT 20
|
||||
`, [`%${keyword}%`])
|
||||
|
||||
return employees.map((e: any) => ({
|
||||
employeeId: e.employee_id,
|
||||
employeeName: e.employee_name,
|
||||
employeeEmail: e.employee_email,
|
||||
employeePosition: e.employee_position
|
||||
}))
|
||||
})
|
||||
41
backend/api/project/[id]/detail.get.ts
Normal file
41
backend/api/project/[id]/detail.get.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { queryOne, query } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 프로젝트 상세 조회
|
||||
* GET /api/project/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const projectId = getRouterParam(event, 'id')
|
||||
|
||||
const project = await queryOne<any>(`
|
||||
SELECT * FROM wr_project_info WHERE project_id = $1
|
||||
`, [projectId])
|
||||
|
||||
if (!project) {
|
||||
throw createError({ statusCode: 404, message: '프로젝트를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 현재 PM/PL
|
||||
const managers = await query(`
|
||||
SELECT * FROM wr_project_manager_current WHERE project_id = $1
|
||||
`, [projectId])
|
||||
|
||||
const pm = managers.find((m: any) => m.role_type === 'PM')
|
||||
const pl = managers.find((m: any) => m.role_type === 'PL')
|
||||
|
||||
return {
|
||||
projectId: project.project_id,
|
||||
projectCode: project.project_code,
|
||||
projectName: project.project_name,
|
||||
clientName: project.client_name,
|
||||
projectDescription: project.project_description,
|
||||
startDate: project.start_date,
|
||||
endDate: project.end_date,
|
||||
contractAmount: project.contract_amount,
|
||||
projectStatus: project.project_status,
|
||||
createdAt: project.created_at,
|
||||
updatedAt: project.updated_at,
|
||||
currentPm: pm ? { employeeId: pm.employee_id, employeeName: pm.employee_name } : null,
|
||||
currentPl: pl ? { employeeId: pl.employee_id, employeeName: pl.employee_name } : null
|
||||
}
|
||||
})
|
||||
50
backend/api/project/[id]/manager-assign.post.ts
Normal file
50
backend/api/project/[id]/manager-assign.post.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { execute, queryOne, insertReturning } from '../../../utils/db'
|
||||
import { formatDate } from '../../../utils/week-calc'
|
||||
|
||||
interface AssignManagerBody {
|
||||
employeeId: number
|
||||
roleType: 'PM' | 'PL'
|
||||
startDate?: string
|
||||
changeReason?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* PM/PL 지정 (기존 담당자 종료 + 신규 등록)
|
||||
* POST /api/project/[id]/manager-assign
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const projectId = getRouterParam(event, 'id')
|
||||
const body = await readBody<AssignManagerBody>(event)
|
||||
|
||||
if (!body.employeeId || !body.roleType) {
|
||||
throw createError({ statusCode: 400, message: '담당자와 역할을 선택해주세요.' })
|
||||
}
|
||||
|
||||
if (!['PM', 'PL'].includes(body.roleType)) {
|
||||
throw createError({ statusCode: 400, message: '역할은 PM 또는 PL만 가능합니다.' })
|
||||
}
|
||||
|
||||
const today = formatDate(new Date())
|
||||
const startDate = body.startDate || today
|
||||
|
||||
// 기존 담당자 종료 (end_date가 NULL인 경우)
|
||||
await execute(`
|
||||
UPDATE wr_project_manager_history SET
|
||||
end_date = $1,
|
||||
change_reason = COALESCE(change_reason || ' / ', '') || '신규 담당자 지정으로 종료'
|
||||
WHERE project_id = $2 AND role_type = $3 AND end_date IS NULL
|
||||
`, [startDate, projectId, body.roleType])
|
||||
|
||||
// 신규 담당자 등록
|
||||
const history = await insertReturning(`
|
||||
INSERT INTO wr_project_manager_history (
|
||||
project_id, employee_id, role_type, start_date, change_reason
|
||||
) VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING *
|
||||
`, [projectId, body.employeeId, body.roleType, startDate, body.changeReason || null])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
historyId: history.history_id
|
||||
}
|
||||
})
|
||||
30
backend/api/project/[id]/manager-history.get.ts
Normal file
30
backend/api/project/[id]/manager-history.get.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { query } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 프로젝트 PM/PL 이력 조회
|
||||
* GET /api/project/[id]/manager-history
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const projectId = getRouterParam(event, 'id')
|
||||
|
||||
const history = await query(`
|
||||
SELECT h.*, e.employee_name, e.employee_email
|
||||
FROM wr_project_manager_history h
|
||||
JOIN wr_employee_info e ON h.employee_id = e.employee_id
|
||||
WHERE h.project_id = $1
|
||||
ORDER BY h.role_type, h.start_date DESC
|
||||
`, [projectId])
|
||||
|
||||
return history.map((h: any) => ({
|
||||
historyId: h.history_id,
|
||||
projectId: h.project_id,
|
||||
employeeId: h.employee_id,
|
||||
employeeName: h.employee_name,
|
||||
employeeEmail: h.employee_email,
|
||||
roleType: h.role_type,
|
||||
startDate: h.start_date,
|
||||
endDate: h.end_date,
|
||||
changeReason: h.change_reason,
|
||||
createdAt: h.created_at
|
||||
}))
|
||||
})
|
||||
55
backend/api/project/[id]/update.put.ts
Normal file
55
backend/api/project/[id]/update.put.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { execute, queryOne } from '../../../utils/db'
|
||||
|
||||
interface UpdateProjectBody {
|
||||
projectCode?: string
|
||||
projectName?: string
|
||||
clientName?: string
|
||||
projectDescription?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
contractAmount?: number
|
||||
projectStatus?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트 정보 수정
|
||||
* PUT /api/project/[id]/update
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const projectId = getRouterParam(event, 'id')
|
||||
const body = await readBody<UpdateProjectBody>(event)
|
||||
|
||||
const existing = await queryOne<any>(`
|
||||
SELECT * FROM wr_project_info WHERE project_id = $1
|
||||
`, [projectId])
|
||||
|
||||
if (!existing) {
|
||||
throw createError({ statusCode: 404, message: '프로젝트를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_project_info SET
|
||||
project_code = $1,
|
||||
project_name = $2,
|
||||
client_name = $3,
|
||||
project_description = $4,
|
||||
start_date = $5,
|
||||
end_date = $6,
|
||||
contract_amount = $7,
|
||||
project_status = $8,
|
||||
updated_at = NOW()
|
||||
WHERE project_id = $9
|
||||
`, [
|
||||
body.projectCode ?? existing.project_code,
|
||||
body.projectName ?? existing.project_name,
|
||||
body.clientName ?? existing.client_name,
|
||||
body.projectDescription ?? existing.project_description,
|
||||
body.startDate ?? existing.start_date,
|
||||
body.endDate ?? existing.end_date,
|
||||
body.contractAmount ?? existing.contract_amount,
|
||||
body.projectStatus ?? existing.project_status,
|
||||
projectId
|
||||
])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
47
backend/api/project/create.post.ts
Normal file
47
backend/api/project/create.post.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { insertReturning } from '../../utils/db'
|
||||
|
||||
interface CreateProjectBody {
|
||||
projectCode?: string
|
||||
projectName: string
|
||||
clientName?: string
|
||||
projectDescription?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
contractAmount?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트 등록
|
||||
* POST /api/project/create
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<CreateProjectBody>(event)
|
||||
|
||||
if (!body.projectName) {
|
||||
throw createError({ statusCode: 400, message: '프로젝트명을 입력해주세요.' })
|
||||
}
|
||||
|
||||
const project = await insertReturning(`
|
||||
INSERT INTO wr_project_info (
|
||||
project_code, project_name, client_name, project_description,
|
||||
start_date, end_date, contract_amount
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
RETURNING *
|
||||
`, [
|
||||
body.projectCode || null,
|
||||
body.projectName,
|
||||
body.clientName || null,
|
||||
body.projectDescription || null,
|
||||
body.startDate || null,
|
||||
body.endDate || null,
|
||||
body.contractAmount || null
|
||||
])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
project: {
|
||||
projectId: project.project_id,
|
||||
projectName: project.project_name
|
||||
}
|
||||
}
|
||||
})
|
||||
52
backend/api/project/list.get.ts
Normal file
52
backend/api/project/list.get.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 프로젝트 목록 조회
|
||||
* GET /api/project/list
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const queryParams = getQuery(event)
|
||||
const status = queryParams.status as string || null
|
||||
|
||||
let sql = `
|
||||
SELECT p.*,
|
||||
(SELECT employee_name FROM wr_employee_info e
|
||||
JOIN wr_project_manager_history pm ON e.employee_id = pm.employee_id
|
||||
WHERE pm.project_id = p.project_id AND pm.role_type = 'PM'
|
||||
AND (pm.end_date IS NULL OR pm.end_date >= CURRENT_DATE)
|
||||
LIMIT 1) as pm_name,
|
||||
(SELECT employee_name FROM wr_employee_info e
|
||||
JOIN wr_project_manager_history pm ON e.employee_id = pm.employee_id
|
||||
WHERE pm.project_id = p.project_id AND pm.role_type = 'PL'
|
||||
AND (pm.end_date IS NULL OR pm.end_date >= CURRENT_DATE)
|
||||
LIMIT 1) as pl_name
|
||||
FROM wr_project_info p
|
||||
`
|
||||
|
||||
const params: any[] = []
|
||||
if (status) {
|
||||
sql += ' WHERE p.project_status = $1'
|
||||
params.push(status)
|
||||
}
|
||||
|
||||
sql += ' ORDER BY p.created_at DESC'
|
||||
|
||||
const projects = await query(sql, params)
|
||||
|
||||
return {
|
||||
projects: projects.map((p: any) => ({
|
||||
projectId: p.project_id,
|
||||
projectCode: p.project_code,
|
||||
projectName: p.project_name,
|
||||
clientName: p.client_name,
|
||||
projectDescription: p.project_description,
|
||||
startDate: p.start_date,
|
||||
endDate: p.end_date,
|
||||
contractAmount: p.contract_amount,
|
||||
projectStatus: p.project_status,
|
||||
pmName: p.pm_name,
|
||||
plName: p.pl_name,
|
||||
createdAt: p.created_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
30
backend/api/project/my-projects.get.ts
Normal file
30
backend/api/project/my-projects.get.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 내가 보고서 작성한 프로젝트 목록
|
||||
* GET /api/project/my-projects
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
// 내가 주간보고를 작성한 프로젝트 + 전체 활성 프로젝트
|
||||
const projects = await query(`
|
||||
SELECT DISTINCT p.*,
|
||||
CASE WHEN r.author_id IS NOT NULL THEN true ELSE false END as has_my_report
|
||||
FROM wr_project_info p
|
||||
LEFT JOIN wr_weekly_report_detail r ON p.project_id = r.project_id AND r.author_id = $1
|
||||
WHERE p.project_status = 'ACTIVE'
|
||||
ORDER BY has_my_report DESC, p.project_name
|
||||
`, [parseInt(userId)])
|
||||
|
||||
return projects.map((p: any) => ({
|
||||
projectId: p.project_id,
|
||||
projectCode: p.project_code,
|
||||
projectName: p.project_name,
|
||||
clientName: p.client_name,
|
||||
hasMyReport: p.has_my_report
|
||||
}))
|
||||
})
|
||||
65
backend/api/report/summary/[id]/detail.get.ts
Normal file
65
backend/api/report/summary/[id]/detail.get.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { queryOne, query } from '../../../../utils/db'
|
||||
|
||||
/**
|
||||
* 취합 보고서 상세 (개별 보고서 포함)
|
||||
* GET /api/report/summary/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const summaryId = getRouterParam(event, 'id')
|
||||
|
||||
// 취합 보고서 조회
|
||||
const summary = await queryOne<any>(`
|
||||
SELECT s.*, p.project_name, p.project_code,
|
||||
e.employee_name as reviewer_name
|
||||
FROM wr_aggregated_report_summary s
|
||||
JOIN wr_project_info p ON s.project_id = p.project_id
|
||||
LEFT JOIN wr_employee_info e ON s.reviewer_id = e.employee_id
|
||||
WHERE s.summary_id = $1
|
||||
`, [summaryId])
|
||||
|
||||
if (!summary) {
|
||||
throw createError({ statusCode: 404, message: '취합 보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 개별 보고서 목록
|
||||
const reports = await query(`
|
||||
SELECT r.*, e.employee_name as author_name, e.employee_position
|
||||
FROM wr_weekly_report_detail r
|
||||
JOIN wr_employee_info e ON r.author_id = e.employee_id
|
||||
WHERE r.project_id = $1 AND r.report_year = $2 AND r.report_week = $3
|
||||
ORDER BY e.employee_name
|
||||
`, [summary.project_id, summary.report_year, summary.report_week])
|
||||
|
||||
return {
|
||||
summary: {
|
||||
summaryId: summary.summary_id,
|
||||
projectId: summary.project_id,
|
||||
projectName: summary.project_name,
|
||||
projectCode: summary.project_code,
|
||||
reportYear: summary.report_year,
|
||||
reportWeek: summary.report_week,
|
||||
weekStartDate: summary.week_start_date,
|
||||
weekEndDate: summary.week_end_date,
|
||||
memberCount: summary.member_count,
|
||||
totalWorkHours: summary.total_work_hours,
|
||||
reviewerId: summary.reviewer_id,
|
||||
reviewerName: summary.reviewer_name,
|
||||
reviewerComment: summary.reviewer_comment,
|
||||
reviewedAt: summary.reviewed_at,
|
||||
summaryStatus: summary.summary_status
|
||||
},
|
||||
reports: reports.map((r: any) => ({
|
||||
reportId: r.report_id,
|
||||
authorId: r.author_id,
|
||||
authorName: r.author_name,
|
||||
authorPosition: r.employee_position,
|
||||
workDescription: r.work_description,
|
||||
planDescription: r.plan_description,
|
||||
issueDescription: r.issue_description,
|
||||
remarkDescription: r.remark_description,
|
||||
workHours: r.work_hours,
|
||||
reportStatus: r.report_status,
|
||||
submittedAt: r.submitted_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
39
backend/api/report/summary/[id]/review.put.ts
Normal file
39
backend/api/report/summary/[id]/review.put.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { execute, queryOne } from '../../../../utils/db'
|
||||
|
||||
interface ReviewBody {
|
||||
reviewerComment?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* PM 검토/코멘트 작성
|
||||
* PUT /api/report/summary/[id]/review
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const summaryId = getRouterParam(event, 'id')
|
||||
const body = await readBody<ReviewBody>(event)
|
||||
|
||||
const summary = await queryOne<any>(`
|
||||
SELECT * FROM wr_aggregated_report_summary WHERE summary_id = $1
|
||||
`, [summaryId])
|
||||
|
||||
if (!summary) {
|
||||
throw createError({ statusCode: 404, message: '취합 보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_aggregated_report_summary SET
|
||||
reviewer_id = $1,
|
||||
reviewer_comment = $2,
|
||||
reviewed_at = NOW(),
|
||||
summary_status = 'REVIEWED',
|
||||
updated_at = NOW()
|
||||
WHERE summary_id = $3
|
||||
`, [parseInt(userId), body.reviewerComment || null, summaryId])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
54
backend/api/report/summary/list.get.ts
Normal file
54
backend/api/report/summary/list.get.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { query } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 취합 보고서 목록
|
||||
* GET /api/report/summary/list
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const queryParams = getQuery(event)
|
||||
const projectId = queryParams.projectId ? parseInt(queryParams.projectId as string) : null
|
||||
const year = queryParams.year ? parseInt(queryParams.year as string) : null
|
||||
|
||||
let sql = `
|
||||
SELECT s.*, p.project_name, p.project_code,
|
||||
e.employee_name as reviewer_name
|
||||
FROM wr_aggregated_report_summary s
|
||||
JOIN wr_project_info p ON s.project_id = p.project_id
|
||||
LEFT JOIN wr_employee_info e ON s.reviewer_id = e.employee_id
|
||||
WHERE 1=1
|
||||
`
|
||||
const params: any[] = []
|
||||
let paramIndex = 1
|
||||
|
||||
if (projectId) {
|
||||
sql += ` AND s.project_id = $${paramIndex++}`
|
||||
params.push(projectId)
|
||||
}
|
||||
if (year) {
|
||||
sql += ` AND s.report_year = $${paramIndex++}`
|
||||
params.push(year)
|
||||
}
|
||||
|
||||
sql += ' ORDER BY s.report_year DESC, s.report_week DESC, p.project_name'
|
||||
|
||||
const summaries = await query(sql, params)
|
||||
|
||||
return summaries.map((s: any) => ({
|
||||
summaryId: s.summary_id,
|
||||
projectId: s.project_id,
|
||||
projectName: s.project_name,
|
||||
projectCode: s.project_code,
|
||||
reportYear: s.report_year,
|
||||
reportWeek: s.report_week,
|
||||
weekStartDate: s.week_start_date,
|
||||
weekEndDate: s.week_end_date,
|
||||
memberCount: s.member_count,
|
||||
totalWorkHours: s.total_work_hours,
|
||||
reviewerId: s.reviewer_id,
|
||||
reviewerName: s.reviewer_name,
|
||||
reviewerComment: s.reviewer_comment,
|
||||
reviewedAt: s.reviewed_at,
|
||||
summaryStatus: s.summary_status,
|
||||
aggregatedAt: s.aggregated_at
|
||||
}))
|
||||
})
|
||||
48
backend/api/report/weekly/[id]/detail.get.ts
Normal file
48
backend/api/report/weekly/[id]/detail.get.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { queryOne } from '../../../../utils/db'
|
||||
|
||||
/**
|
||||
* 주간보고 상세 조회
|
||||
* GET /api/report/weekly/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const reportId = getRouterParam(event, 'id')
|
||||
|
||||
const report = await queryOne<any>(`
|
||||
SELECT r.*, p.project_name, p.project_code, e.employee_name as author_name
|
||||
FROM wr_weekly_report_detail r
|
||||
JOIN wr_project_info p ON r.project_id = p.project_id
|
||||
JOIN wr_employee_info e ON r.author_id = e.employee_id
|
||||
WHERE r.report_id = $1
|
||||
`, [reportId])
|
||||
|
||||
if (!report) {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
return {
|
||||
reportId: report.report_id,
|
||||
projectId: report.project_id,
|
||||
projectName: report.project_name,
|
||||
projectCode: report.project_code,
|
||||
authorId: report.author_id,
|
||||
authorName: report.author_name,
|
||||
reportYear: report.report_year,
|
||||
reportWeek: report.report_week,
|
||||
weekStartDate: report.week_start_date,
|
||||
weekEndDate: report.week_end_date,
|
||||
workDescription: report.work_description,
|
||||
planDescription: report.plan_description,
|
||||
issueDescription: report.issue_description,
|
||||
remarkDescription: report.remark_description,
|
||||
workHours: report.work_hours,
|
||||
reportStatus: report.report_status,
|
||||
submittedAt: report.submitted_at,
|
||||
createdAt: report.created_at,
|
||||
updatedAt: report.updated_at
|
||||
}
|
||||
})
|
||||
37
backend/api/report/weekly/[id]/submit.post.ts
Normal file
37
backend/api/report/weekly/[id]/submit.post.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { execute, queryOne } from '../../../../utils/db'
|
||||
|
||||
/**
|
||||
* 주간보고 제출
|
||||
* POST /api/report/weekly/[id]/submit
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const reportId = getRouterParam(event, 'id')
|
||||
|
||||
// 보고서 조회 및 권한 확인
|
||||
const report = await queryOne<any>(`
|
||||
SELECT * FROM wr_weekly_report_detail WHERE report_id = $1
|
||||
`, [reportId])
|
||||
|
||||
if (!report) {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
if (report.author_id !== parseInt(userId)) {
|
||||
throw createError({ statusCode: 403, message: '본인의 보고서만 제출할 수 있습니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_weekly_report_detail SET
|
||||
report_status = 'SUBMITTED',
|
||||
submitted_at = NOW(),
|
||||
updated_at = NOW()
|
||||
WHERE report_id = $1
|
||||
`, [reportId])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
56
backend/api/report/weekly/[id]/update.put.ts
Normal file
56
backend/api/report/weekly/[id]/update.put.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { execute, queryOne } from '../../../../utils/db'
|
||||
|
||||
interface UpdateReportBody {
|
||||
workDescription?: string
|
||||
planDescription?: string
|
||||
issueDescription?: string
|
||||
remarkDescription?: string
|
||||
workHours?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 주간보고 수정
|
||||
* PUT /api/report/weekly/[id]/update
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const reportId = getRouterParam(event, 'id')
|
||||
const body = await readBody<UpdateReportBody>(event)
|
||||
|
||||
// 보고서 조회 및 권한 확인
|
||||
const report = await queryOne<any>(`
|
||||
SELECT * FROM wr_weekly_report_detail WHERE report_id = $1
|
||||
`, [reportId])
|
||||
|
||||
if (!report) {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
if (report.author_id !== parseInt(userId)) {
|
||||
throw createError({ statusCode: 403, message: '본인의 보고서만 수정할 수 있습니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_weekly_report_detail SET
|
||||
work_description = $1,
|
||||
plan_description = $2,
|
||||
issue_description = $3,
|
||||
remark_description = $4,
|
||||
work_hours = $5,
|
||||
updated_at = NOW()
|
||||
WHERE report_id = $6
|
||||
`, [
|
||||
body.workDescription ?? report.work_description,
|
||||
body.planDescription ?? report.plan_description,
|
||||
body.issueDescription ?? report.issue_description,
|
||||
body.remarkDescription ?? report.remark_description,
|
||||
body.workHours ?? report.work_hours,
|
||||
reportId
|
||||
])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
75
backend/api/report/weekly/create.post.ts
Normal file
75
backend/api/report/weekly/create.post.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { insertReturning, queryOne } from '../../../utils/db'
|
||||
import { getWeekInfo } from '../../../utils/week-calc'
|
||||
|
||||
interface CreateReportBody {
|
||||
projectId: number
|
||||
reportYear?: number
|
||||
reportWeek?: number
|
||||
workDescription?: string
|
||||
planDescription?: string
|
||||
issueDescription?: string
|
||||
remarkDescription?: string
|
||||
workHours?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 주간보고 작성
|
||||
* POST /api/report/weekly/create
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const body = await readBody<CreateReportBody>(event)
|
||||
|
||||
if (!body.projectId) {
|
||||
throw createError({ statusCode: 400, message: '프로젝트를 선택해주세요.' })
|
||||
}
|
||||
|
||||
// 주차 정보 (기본값: 이번 주)
|
||||
const weekInfo = getWeekInfo()
|
||||
const year = body.reportYear || weekInfo.year
|
||||
const week = body.reportWeek || weekInfo.week
|
||||
|
||||
// 중복 체크
|
||||
const existing = await queryOne(`
|
||||
SELECT report_id FROM wr_weekly_report_detail
|
||||
WHERE project_id = $1 AND author_id = $2 AND report_year = $3 AND report_week = $4
|
||||
`, [body.projectId, parseInt(userId), year, week])
|
||||
|
||||
if (existing) {
|
||||
throw createError({ statusCode: 409, message: '이미 해당 주차 보고서가 존재합니다.' })
|
||||
}
|
||||
|
||||
// 주차 날짜 계산
|
||||
const dates = getWeekInfo(new Date(year, 0, 4 + (week - 1) * 7))
|
||||
|
||||
const report = await insertReturning(`
|
||||
INSERT INTO wr_weekly_report_detail (
|
||||
project_id, author_id, report_year, report_week,
|
||||
week_start_date, week_end_date,
|
||||
work_description, plan_description, issue_description, remark_description,
|
||||
work_hours, report_status
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, 'DRAFT')
|
||||
RETURNING *
|
||||
`, [
|
||||
body.projectId,
|
||||
parseInt(userId),
|
||||
year,
|
||||
week,
|
||||
dates.startDateStr,
|
||||
dates.endDateStr,
|
||||
body.workDescription || null,
|
||||
body.planDescription || null,
|
||||
body.issueDescription || null,
|
||||
body.remarkDescription || null,
|
||||
body.workHours || null
|
||||
])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
reportId: report.report_id
|
||||
}
|
||||
})
|
||||
46
backend/api/report/weekly/current-week.get.ts
Normal file
46
backend/api/report/weekly/current-week.get.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { query } from '../../../utils/db'
|
||||
import { getWeekInfo, formatWeekString } from '../../../utils/week-calc'
|
||||
|
||||
/**
|
||||
* 이번 주 보고서 현황 조회
|
||||
* GET /api/report/weekly/current-week
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const weekInfo = getWeekInfo()
|
||||
|
||||
// 이번 주 내 보고서 목록
|
||||
const reports = await query(`
|
||||
SELECT r.*, p.project_name, p.project_code
|
||||
FROM wr_weekly_report_detail r
|
||||
JOIN wr_project_info p ON r.project_id = p.project_id
|
||||
WHERE r.author_id = $1 AND r.report_year = $2 AND r.report_week = $3
|
||||
ORDER BY p.project_name
|
||||
`, [parseInt(userId), weekInfo.year, weekInfo.week])
|
||||
|
||||
return {
|
||||
weekInfo: {
|
||||
year: weekInfo.year,
|
||||
week: weekInfo.week,
|
||||
weekString: formatWeekString(weekInfo.year, weekInfo.week),
|
||||
startDate: weekInfo.startDateStr,
|
||||
endDate: weekInfo.endDateStr
|
||||
},
|
||||
reports: reports.map((r: any) => ({
|
||||
reportId: r.report_id,
|
||||
projectId: r.project_id,
|
||||
projectName: r.project_name,
|
||||
projectCode: r.project_code,
|
||||
reportStatus: r.report_status,
|
||||
workDescription: r.work_description,
|
||||
planDescription: r.plan_description,
|
||||
issueDescription: r.issue_description,
|
||||
workHours: r.work_hours,
|
||||
updatedAt: r.updated_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
60
backend/api/report/weekly/list.get.ts
Normal file
60
backend/api/report/weekly/list.get.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { query } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 내 주간보고 목록
|
||||
* GET /api/report/weekly/list
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const queryParams = getQuery(event)
|
||||
const year = queryParams.year ? parseInt(queryParams.year as string) : null
|
||||
const projectId = queryParams.projectId ? parseInt(queryParams.projectId as string) : null
|
||||
|
||||
let sql = `
|
||||
SELECT r.*, p.project_name, p.project_code
|
||||
FROM wr_weekly_report_detail r
|
||||
JOIN wr_project_info p ON r.project_id = p.project_id
|
||||
WHERE r.author_id = $1
|
||||
`
|
||||
const params: any[] = [parseInt(userId)]
|
||||
let paramIndex = 2
|
||||
|
||||
if (year) {
|
||||
sql += ` AND r.report_year = $${paramIndex++}`
|
||||
params.push(year)
|
||||
}
|
||||
if (projectId) {
|
||||
sql += ` AND r.project_id = $${paramIndex++}`
|
||||
params.push(projectId)
|
||||
}
|
||||
|
||||
sql += ' ORDER BY r.report_year DESC, r.report_week DESC'
|
||||
|
||||
const reports = await query(sql, params)
|
||||
|
||||
return {
|
||||
reports: reports.map((r: any) => ({
|
||||
reportId: r.report_id,
|
||||
projectId: r.project_id,
|
||||
projectName: r.project_name,
|
||||
projectCode: r.project_code,
|
||||
reportYear: r.report_year,
|
||||
reportWeek: r.report_week,
|
||||
weekStartDate: r.week_start_date,
|
||||
weekEndDate: r.week_end_date,
|
||||
workDescription: r.work_description,
|
||||
planDescription: r.plan_description,
|
||||
issueDescription: r.issue_description,
|
||||
remarkDescription: r.remark_description,
|
||||
workHours: r.work_hours,
|
||||
reportStatus: r.report_status,
|
||||
submittedAt: r.submitted_at,
|
||||
createdAt: r.created_at,
|
||||
updatedAt: r.updated_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
9
backend/api/scheduler/status.get.ts
Normal file
9
backend/api/scheduler/status.get.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { getSchedulerStatus } from '../../utils/report-scheduler'
|
||||
|
||||
/**
|
||||
* 스케줄러 상태 조회
|
||||
* GET /api/scheduler/status
|
||||
*/
|
||||
export default defineEventHandler(async () => {
|
||||
return getSchedulerStatus()
|
||||
})
|
||||
27
backend/api/scheduler/trigger-aggregate.post.ts
Normal file
27
backend/api/scheduler/trigger-aggregate.post.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { aggregateWeeklyReports } from '../../utils/report-scheduler'
|
||||
|
||||
interface TriggerBody {
|
||||
year?: number
|
||||
week?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 수동 취합 트리거
|
||||
* POST /api/scheduler/trigger-aggregate
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<TriggerBody>(event)
|
||||
|
||||
try {
|
||||
const result = await aggregateWeeklyReports(body.year, body.week)
|
||||
return {
|
||||
success: true,
|
||||
...result
|
||||
}
|
||||
} catch (error: any) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: `취합 실패: ${error.message}`
|
||||
})
|
||||
}
|
||||
})
|
||||
71
backend/utils/db.ts
Normal file
71
backend/utils/db.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import pg from 'pg'
|
||||
|
||||
const { Pool } = pg
|
||||
|
||||
let pool: pg.Pool | null = null
|
||||
|
||||
/**
|
||||
* PostgreSQL 연결 풀 가져오기
|
||||
*/
|
||||
export function getPool(): pg.Pool {
|
||||
if (!pool) {
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
const poolConfig = {
|
||||
host: config.dbHost,
|
||||
port: parseInt(config.dbPort as string),
|
||||
database: config.dbName,
|
||||
user: config.dbUser,
|
||||
password: config.dbPassword,
|
||||
max: 10,
|
||||
idleTimeoutMillis: 30000,
|
||||
connectionTimeoutMillis: 2000,
|
||||
}
|
||||
|
||||
console.log(`[DB] Connecting to ${poolConfig.host}:${poolConfig.port}/${poolConfig.database}`)
|
||||
|
||||
pool = new Pool(poolConfig)
|
||||
|
||||
pool.on('error', (err) => {
|
||||
console.error('[DB] Unexpected pool error:', err)
|
||||
})
|
||||
|
||||
console.log('[DB] PostgreSQL pool created')
|
||||
}
|
||||
return pool
|
||||
}
|
||||
|
||||
/**
|
||||
* 쿼리 실행
|
||||
*/
|
||||
export async function query<T = any>(sql: string, params?: any[]): Promise<T[]> {
|
||||
const pool = getPool()
|
||||
const result = await pool.query(sql, params)
|
||||
return result.rows as T[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 행 조회
|
||||
*/
|
||||
export async function queryOne<T = any>(sql: string, params?: any[]): Promise<T | null> {
|
||||
const rows = await query<T>(sql, params)
|
||||
return rows[0] || null
|
||||
}
|
||||
|
||||
/**
|
||||
* INSERT/UPDATE/DELETE 실행
|
||||
*/
|
||||
export async function execute(sql: string, params?: any[]): Promise<number> {
|
||||
const pool = getPool()
|
||||
const result = await pool.query(sql, params)
|
||||
return result.rowCount || 0
|
||||
}
|
||||
|
||||
/**
|
||||
* INSERT 후 반환
|
||||
*/
|
||||
export async function insertReturning<T = any>(sql: string, params?: any[]): Promise<T | null> {
|
||||
const pool = getPool()
|
||||
const result = await pool.query(sql, params)
|
||||
return result.rows[0] || null
|
||||
}
|
||||
99
backend/utils/report-scheduler.ts
Normal file
99
backend/utils/report-scheduler.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { query, execute, insertReturning } from './db'
|
||||
import { getLastWeekInfo, formatDate } from './week-calc'
|
||||
|
||||
let isRunning = false
|
||||
|
||||
/**
|
||||
* 주간보고 취합 실행
|
||||
*/
|
||||
export async function aggregateWeeklyReports(targetYear?: number, targetWeek?: number) {
|
||||
const weekInfo = targetYear && targetWeek
|
||||
? { year: targetYear, week: targetWeek }
|
||||
: getLastWeekInfo()
|
||||
|
||||
console.log(`[Aggregator] 취합 시작: ${weekInfo.year}-W${weekInfo.week}`)
|
||||
|
||||
// 해당 주차에 제출된 보고서가 있는 프로젝트 조회
|
||||
const projects = await query<any>(`
|
||||
SELECT DISTINCT project_id
|
||||
FROM wr_weekly_report_detail
|
||||
WHERE report_year = $1 AND report_week = $2 AND report_status = 'SUBMITTED'
|
||||
`, [weekInfo.year, weekInfo.week])
|
||||
|
||||
let aggregatedCount = 0
|
||||
|
||||
for (const { project_id } of projects) {
|
||||
// 해당 프로젝트의 제출된 보고서들
|
||||
const reports = await query<any>(`
|
||||
SELECT report_id, work_hours
|
||||
FROM wr_weekly_report_detail
|
||||
WHERE project_id = $1 AND report_year = $2 AND report_week = $3
|
||||
AND report_status = 'SUBMITTED'
|
||||
`, [project_id, weekInfo.year, weekInfo.week])
|
||||
|
||||
const reportIds = reports.map((r: any) => r.report_id)
|
||||
const totalHours = reports.reduce((sum: number, r: any) => sum + (parseFloat(r.work_hours) || 0), 0)
|
||||
|
||||
// 주차 날짜 계산
|
||||
const jan4 = new Date(weekInfo.year, 0, 4)
|
||||
const firstMonday = new Date(jan4)
|
||||
firstMonday.setDate(jan4.getDate() - ((jan4.getDay() + 6) % 7))
|
||||
const targetMonday = new Date(firstMonday)
|
||||
targetMonday.setDate(firstMonday.getDate() + (weekInfo.week - 1) * 7)
|
||||
const targetSunday = new Date(targetMonday)
|
||||
targetSunday.setDate(targetMonday.getDate() + 6)
|
||||
|
||||
// UPSERT 취합 보고서
|
||||
await execute(`
|
||||
INSERT INTO wr_aggregated_report_summary (
|
||||
project_id, report_year, report_week,
|
||||
week_start_date, week_end_date,
|
||||
report_ids, member_count, total_work_hours
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
ON CONFLICT (project_id, report_year, report_week)
|
||||
DO UPDATE SET
|
||||
report_ids = $6,
|
||||
member_count = $7,
|
||||
total_work_hours = $8,
|
||||
aggregated_at = NOW(),
|
||||
updated_at = NOW()
|
||||
`, [
|
||||
project_id,
|
||||
weekInfo.year,
|
||||
weekInfo.week,
|
||||
formatDate(targetMonday),
|
||||
formatDate(targetSunday),
|
||||
reportIds,
|
||||
reportIds.length,
|
||||
totalHours || null
|
||||
])
|
||||
|
||||
// 개별 보고서 상태 변경
|
||||
await execute(`
|
||||
UPDATE wr_weekly_report_detail SET
|
||||
report_status = 'AGGREGATED',
|
||||
updated_at = NOW()
|
||||
WHERE report_id = ANY($1)
|
||||
`, [reportIds])
|
||||
|
||||
aggregatedCount++
|
||||
console.log(`[Aggregator] 프로젝트 ${project_id}: ${reportIds.length}건 취합`)
|
||||
}
|
||||
|
||||
console.log(`[Aggregator] 취합 완료: ${aggregatedCount}개 프로젝트`)
|
||||
|
||||
return {
|
||||
year: weekInfo.year,
|
||||
week: weekInfo.week,
|
||||
projectCount: aggregatedCount
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 스케줄러 상태
|
||||
*/
|
||||
export function getSchedulerStatus() {
|
||||
return {
|
||||
isRunning
|
||||
}
|
||||
}
|
||||
95
backend/utils/week-calc.ts
Normal file
95
backend/utils/week-calc.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* ISO 8601 주차 계산 유틸리티
|
||||
*/
|
||||
|
||||
export interface WeekInfo {
|
||||
year: number
|
||||
week: number
|
||||
startDate: Date // 월요일
|
||||
endDate: Date // 일요일
|
||||
startDateStr: string // YYYY-MM-DD
|
||||
endDateStr: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 날짜를 YYYY-MM-DD 문자열로 변환
|
||||
*/
|
||||
export function formatDate(date: Date): string {
|
||||
const y = date.getFullYear()
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const d = String(date.getDate()).padStart(2, '0')
|
||||
return `${y}-${m}-${d}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 날짜의 ISO 주차 정보 반환
|
||||
*/
|
||||
export function getWeekInfo(date: Date = new Date()): WeekInfo {
|
||||
const target = new Date(date)
|
||||
target.setHours(0, 0, 0, 0)
|
||||
|
||||
// 목요일 기준으로 연도 판단 (ISO 규칙)
|
||||
const thursday = new Date(target)
|
||||
thursday.setDate(target.getDate() - ((target.getDay() + 6) % 7) + 3)
|
||||
|
||||
const year = thursday.getFullYear()
|
||||
const firstThursday = new Date(year, 0, 4)
|
||||
firstThursday.setDate(firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3)
|
||||
|
||||
const week = Math.ceil((thursday.getTime() - firstThursday.getTime()) / (7 * 24 * 60 * 60 * 1000)) + 1
|
||||
|
||||
// 해당 주의 월요일
|
||||
const monday = new Date(target)
|
||||
monday.setDate(target.getDate() - ((target.getDay() + 6) % 7))
|
||||
|
||||
// 해당 주의 일요일
|
||||
const sunday = new Date(monday)
|
||||
sunday.setDate(monday.getDate() + 6)
|
||||
|
||||
return {
|
||||
year,
|
||||
week,
|
||||
startDate: monday,
|
||||
endDate: sunday,
|
||||
startDateStr: formatDate(monday),
|
||||
endDateStr: formatDate(sunday)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ISO 주차 문자열 반환 (예: "2026-W01")
|
||||
*/
|
||||
export function formatWeekString(year: number, week: number): string {
|
||||
return `${year}-W${week.toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 지난 주 정보
|
||||
*/
|
||||
export function getLastWeekInfo(): WeekInfo {
|
||||
const lastWeek = new Date()
|
||||
lastWeek.setDate(lastWeek.getDate() - 7)
|
||||
return getWeekInfo(lastWeek)
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 연도/주차의 날짜 범위 반환
|
||||
*/
|
||||
export function getWeekDates(year: number, week: number): { startDate: Date, endDate: Date } {
|
||||
// 해당 연도의 1월 4일 (1주차에 반드시 포함)
|
||||
const jan4 = new Date(year, 0, 4)
|
||||
|
||||
// 1월 4일이 포함된 주의 월요일
|
||||
const firstMonday = new Date(jan4)
|
||||
firstMonday.setDate(jan4.getDate() - ((jan4.getDay() + 6) % 7))
|
||||
|
||||
// 원하는 주차의 월요일
|
||||
const targetMonday = new Date(firstMonday)
|
||||
targetMonday.setDate(firstMonday.getDate() + (week - 1) * 7)
|
||||
|
||||
// 일요일
|
||||
const targetSunday = new Date(targetMonday)
|
||||
targetSunday.setDate(targetMonday.getDate() + 6)
|
||||
|
||||
return { startDate: targetMonday, endDate: targetSunday }
|
||||
}
|
||||
77
frontend/components/layout/AppHeader.vue
Normal file
77
frontend/components/layout/AppHeader.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container-fluid">
|
||||
<NuxtLink class="navbar-brand" to="/">
|
||||
<i class="bi bi-clipboard-check me-2"></i>
|
||||
주간업무보고
|
||||
</NuxtLink>
|
||||
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<NuxtLink class="nav-link" to="/" active-class="active">
|
||||
<i class="bi bi-house me-1"></i> 대시보드
|
||||
</NuxtLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NuxtLink class="nav-link" to="/report/weekly" active-class="active">
|
||||
<i class="bi bi-journal-text me-1"></i> 주간보고
|
||||
</NuxtLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NuxtLink class="nav-link" to="/report/summary" active-class="active">
|
||||
<i class="bi bi-collection me-1"></i> 취합보고
|
||||
</NuxtLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NuxtLink class="nav-link" to="/project" active-class="active">
|
||||
<i class="bi bi-folder me-1"></i> 프로젝트
|
||||
</NuxtLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NuxtLink class="nav-link" to="/employee" active-class="active">
|
||||
<i class="bi bi-people me-1"></i> 사원관리
|
||||
</NuxtLink>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- 사용자 정보 -->
|
||||
<div class="d-flex align-items-center" v-if="currentUser">
|
||||
<span class="text-white me-3">
|
||||
<i class="bi bi-person-circle me-1"></i>
|
||||
{{ currentUser.employeeName }}
|
||||
</span>
|
||||
<button class="btn btn-outline-light btn-sm" @click="handleLogout">
|
||||
<i class="bi bi-box-arrow-right"></i> 로그아웃
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { currentUser, logout } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
async function handleLogout() {
|
||||
await logout()
|
||||
router.push('/login')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.navbar-brand {
|
||||
font-weight: 600;
|
||||
}
|
||||
.nav-link {
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
.nav-link.active {
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
60
frontend/composables/useApi.ts
Normal file
60
frontend/composables/useApi.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* API 호출 유틸리티 composable
|
||||
*/
|
||||
|
||||
interface ApiOptions {
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'DELETE'
|
||||
body?: any
|
||||
query?: Record<string, any>
|
||||
}
|
||||
|
||||
export function useApi() {
|
||||
const isLoading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
/**
|
||||
* API 호출 래퍼
|
||||
*/
|
||||
async function call<T>(url: string, options: ApiOptions = {}): Promise<T> {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
|
||||
try {
|
||||
const response = await $fetch<T>(url, {
|
||||
method: options.method || 'GET',
|
||||
body: options.body,
|
||||
query: options.query
|
||||
})
|
||||
return response
|
||||
} catch (err: any) {
|
||||
const message = err.data?.message || err.message || '요청 처리 중 오류가 발생했습니다.'
|
||||
error.value = message
|
||||
throw new Error(message)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 편의 메서드들
|
||||
const get = <T>(url: string, query?: Record<string, any>) =>
|
||||
call<T>(url, { method: 'GET', query })
|
||||
|
||||
const post = <T>(url: string, body?: any) =>
|
||||
call<T>(url, { method: 'POST', body })
|
||||
|
||||
const put = <T>(url: string, body?: any) =>
|
||||
call<T>(url, { method: 'PUT', body })
|
||||
|
||||
const del = <T>(url: string) =>
|
||||
call<T>(url, { method: 'DELETE' })
|
||||
|
||||
return {
|
||||
isLoading: readonly(isLoading),
|
||||
error: readonly(error),
|
||||
call,
|
||||
get,
|
||||
post,
|
||||
put,
|
||||
del
|
||||
}
|
||||
}
|
||||
89
frontend/composables/useAuth.ts
Normal file
89
frontend/composables/useAuth.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 인증 상태 관리 composable
|
||||
*/
|
||||
|
||||
interface User {
|
||||
employeeId: number
|
||||
employeeName: string
|
||||
employeeEmail: string
|
||||
employeePosition: string | null
|
||||
}
|
||||
|
||||
// 전역 상태
|
||||
const currentUser = ref<User | null>(null)
|
||||
const isLoading = ref(false)
|
||||
|
||||
export function useAuth() {
|
||||
/**
|
||||
* 현재 로그인 사용자 조회
|
||||
*/
|
||||
async function fetchCurrentUser(): Promise<User | null> {
|
||||
try {
|
||||
isLoading.value = true
|
||||
const response = await $fetch<{ user: User | null }>('/api/auth/current-user')
|
||||
currentUser.value = response.user
|
||||
return response.user
|
||||
} catch (error) {
|
||||
currentUser.value = null
|
||||
return null
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 이메일+이름으로 로그인
|
||||
*/
|
||||
async function login(email: string, name: string): Promise<User> {
|
||||
const response = await $fetch<{ user: User }>('/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: { email, name }
|
||||
})
|
||||
currentUser.value = response.user
|
||||
return response.user
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 사용자 선택 로그인
|
||||
*/
|
||||
async function selectUser(employeeId: number): Promise<User> {
|
||||
const response = await $fetch<{ user: User }>('/api/auth/select-user', {
|
||||
method: 'POST',
|
||||
body: { employeeId }
|
||||
})
|
||||
currentUser.value = response.user
|
||||
return response.user
|
||||
}
|
||||
|
||||
/**
|
||||
* 최근 로그인 사용자 목록
|
||||
*/
|
||||
async function getRecentUsers(): Promise<User[]> {
|
||||
const response = await $fetch<{ users: User[] }>('/api/auth/recent-users')
|
||||
return response.users
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그아웃
|
||||
*/
|
||||
async function logout(): Promise<void> {
|
||||
await $fetch('/api/auth/logout', { method: 'POST' })
|
||||
currentUser.value = null
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그인 여부 확인
|
||||
*/
|
||||
const isLoggedIn = computed(() => currentUser.value !== null)
|
||||
|
||||
return {
|
||||
currentUser: readonly(currentUser),
|
||||
isLoading: readonly(isLoading),
|
||||
isLoggedIn,
|
||||
fetchCurrentUser,
|
||||
login,
|
||||
selectUser,
|
||||
getRecentUsers,
|
||||
logout
|
||||
}
|
||||
}
|
||||
119
frontend/composables/useWeekCalc.ts
Normal file
119
frontend/composables/useWeekCalc.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* ISO 8601 주차 계산 composable
|
||||
*/
|
||||
|
||||
interface WeekInfo {
|
||||
year: number
|
||||
week: number
|
||||
startDate: Date
|
||||
endDate: Date
|
||||
startDateStr: string
|
||||
endDateStr: string
|
||||
weekString: string // "2026-W01" 형식
|
||||
}
|
||||
|
||||
export function useWeekCalc() {
|
||||
/**
|
||||
* 특정 날짜의 ISO 주차 정보 반환
|
||||
*/
|
||||
function getWeekInfo(date: Date = new Date()): WeekInfo {
|
||||
const target = new Date(date)
|
||||
target.setHours(0, 0, 0, 0)
|
||||
|
||||
// 목요일 기준으로 연도 판단 (ISO 규칙)
|
||||
const thursday = new Date(target)
|
||||
thursday.setDate(target.getDate() - ((target.getDay() + 6) % 7) + 3)
|
||||
|
||||
const year = thursday.getFullYear()
|
||||
const firstThursday = new Date(year, 0, 4)
|
||||
firstThursday.setDate(firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3)
|
||||
|
||||
const week = Math.ceil((thursday.getTime() - firstThursday.getTime()) / (7 * 24 * 60 * 60 * 1000)) + 1
|
||||
|
||||
// 해당 주의 월요일
|
||||
const monday = new Date(target)
|
||||
monday.setDate(target.getDate() - ((target.getDay() + 6) % 7))
|
||||
|
||||
// 해당 주의 일요일
|
||||
const sunday = new Date(monday)
|
||||
sunday.setDate(monday.getDate() + 6)
|
||||
|
||||
return {
|
||||
year,
|
||||
week,
|
||||
startDate: monday,
|
||||
endDate: sunday,
|
||||
startDateStr: formatDate(monday),
|
||||
endDateStr: formatDate(sunday),
|
||||
weekString: `${year}-W${week.toString().padStart(2, '0')}`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 이번 주 정보
|
||||
*/
|
||||
function getCurrentWeekInfo(): WeekInfo {
|
||||
return getWeekInfo(new Date())
|
||||
}
|
||||
|
||||
/**
|
||||
* 지난 주 정보
|
||||
*/
|
||||
function getLastWeekInfo(): WeekInfo {
|
||||
const lastWeek = new Date()
|
||||
lastWeek.setDate(lastWeek.getDate() - 7)
|
||||
return getWeekInfo(lastWeek)
|
||||
}
|
||||
|
||||
/**
|
||||
* 날짜 포맷 (YYYY-MM-DD)
|
||||
*/
|
||||
function formatDate(date: Date): string {
|
||||
return date.toISOString().split('T')[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* 주차 문자열 파싱
|
||||
*/
|
||||
function parseWeekString(weekStr: string): { year: number; week: number } | null {
|
||||
const match = weekStr.match(/^(\d{4})-W(\d{2})$/)
|
||||
if (!match) return null
|
||||
return { year: parseInt(match[1]), week: parseInt(match[2]) }
|
||||
}
|
||||
|
||||
/**
|
||||
* 주차별 날짜 범위 텍스트
|
||||
*/
|
||||
function getWeekRangeText(year: number, week: number): string {
|
||||
// 해당 연도 첫 번째 목요일 찾기
|
||||
const jan4 = new Date(year, 0, 4)
|
||||
const firstThursday = new Date(jan4)
|
||||
firstThursday.setDate(jan4.getDate() - ((jan4.getDay() + 6) % 7) + 3)
|
||||
|
||||
// 해당 주차의 월요일
|
||||
const monday = new Date(firstThursday)
|
||||
monday.setDate(firstThursday.getDate() - 3 + (week - 1) * 7)
|
||||
|
||||
const sunday = new Date(monday)
|
||||
sunday.setDate(monday.getDate() + 6)
|
||||
|
||||
return `${formatDateKr(monday)} ~ ${formatDateKr(sunday)}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 한국어 날짜 포맷 (M월 D일)
|
||||
*/
|
||||
function formatDateKr(date: Date): string {
|
||||
return `${date.getMonth() + 1}월 ${date.getDate()}일`
|
||||
}
|
||||
|
||||
return {
|
||||
getWeekInfo,
|
||||
getCurrentWeekInfo,
|
||||
getLastWeekInfo,
|
||||
formatDate,
|
||||
parseWeekString,
|
||||
getWeekRangeText,
|
||||
formatDateKr
|
||||
}
|
||||
}
|
||||
184
frontend/employee/[id].vue
Normal file
184
frontend/employee/[id].vue
Normal file
@@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<NuxtLink to="/employee" class="text-decoration-none">
|
||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<div class="row" v-if="employee">
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-person me-2"></i>사원 정보
|
||||
</h5>
|
||||
<span :class="employee.isActive ? 'badge bg-success' : 'badge bg-secondary'">
|
||||
{{ employee.isActive ? '재직' : '퇴직' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form @submit.prevent="updateEmployee">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이름 <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" v-model="form.employeeName" required />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이메일 <span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" v-model="form.employeeEmail" required />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">사번</label>
|
||||
<input type="text" class="form-control" v-model="form.employeeNumber" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">직급</label>
|
||||
<select class="form-select" v-model="form.employeePosition">
|
||||
<option value="">선택</option>
|
||||
<option value="사원">사원</option>
|
||||
<option value="대리">대리</option>
|
||||
<option value="과장">과장</option>
|
||||
<option value="차장">차장</option>
|
||||
<option value="부장">부장</option>
|
||||
<option value="이사">이사</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">연락처</label>
|
||||
<input type="text" class="form-control" v-model="form.employeePhone" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">입사일</label>
|
||||
<input type="date" class="form-control" v-model="form.joinDate" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="isActive" v-model="form.isActive" />
|
||||
<label class="form-check-label" for="isActive">재직중</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSubmitting">
|
||||
<i class="bi bi-save me-1"></i> 저장
|
||||
</button>
|
||||
<NuxtLink to="/employee" class="btn btn-outline-secondary">취소</NuxtLink>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="bi bi-clock-history me-2"></i>활동 이력
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-4">
|
||||
<h6 class="text-muted">최근 로그인</h6>
|
||||
<p class="mb-0">{{ employee.lastLoginAt ? formatDateTime(employee.lastLoginAt) : '-' }}</p>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<h6 class="text-muted">등록일</h6>
|
||||
<p class="mb-0">{{ formatDateTime(employee.createdAt) }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="text-muted">최종 수정</h6>
|
||||
<p class="mb-0">{{ formatDateTime(employee.updatedAt) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center py-5" v-else-if="isLoading">
|
||||
<div class="spinner-border text-primary"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const employee = ref<any>(null)
|
||||
const isLoading = ref(true)
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
const form = ref({
|
||||
employeeName: '',
|
||||
employeeEmail: '',
|
||||
employeeNumber: '',
|
||||
employeePosition: '',
|
||||
employeePhone: '',
|
||||
joinDate: '',
|
||||
isActive: true
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadEmployee()
|
||||
})
|
||||
|
||||
async function loadEmployee() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await $fetch<{ employee: any }>(`/api/employee/${route.params.id}/detail`)
|
||||
employee.value = res.employee
|
||||
|
||||
const e = res.employee
|
||||
form.value = {
|
||||
employeeName: e.employeeName || '',
|
||||
employeeEmail: e.employeeEmail || '',
|
||||
employeeNumber: e.employeeNumber || '',
|
||||
employeePosition: e.employeePosition || '',
|
||||
employeePhone: e.employeePhone || '',
|
||||
joinDate: e.joinDate ? e.joinDate.split('T')[0] : '',
|
||||
isActive: e.isActive
|
||||
}
|
||||
} catch (e: any) {
|
||||
alert('사원 정보를 불러오는데 실패했습니다.')
|
||||
router.push('/employee')
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function updateEmployee() {
|
||||
if (!form.value.employeeName || !form.value.employeeEmail) {
|
||||
alert('이름과 이메일은 필수입니다.')
|
||||
return
|
||||
}
|
||||
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
await $fetch(`/api/employee/${route.params.id}/update`, {
|
||||
method: 'PUT',
|
||||
body: form.value
|
||||
})
|
||||
alert('저장되었습니다.')
|
||||
await loadEmployee()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return '-'
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleString('ko-KR')
|
||||
}
|
||||
</script>
|
||||
209
frontend/employee/index.vue
Normal file
209
frontend/employee/index.vue
Normal file
@@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4><i class="bi bi-people me-2"></i>사원 관리</h4>
|
||||
<p class="text-muted mb-0">직원 정보 관리</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="showCreateModal = true">
|
||||
<i class="bi bi-plus-lg me-1"></i> 사원 등록
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 검색 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
v-model="searchKeyword"
|
||||
placeholder="이름 또는 이메일 검색"
|
||||
@keyup.enter="loadEmployees"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex align-items-end">
|
||||
<button class="btn btn-outline-secondary" @click="loadEmployees">
|
||||
<i class="bi bi-search me-1"></i> 조회
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 사원 목록 -->
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 100px">사번</th>
|
||||
<th>이름</th>
|
||||
<th>이메일</th>
|
||||
<th style="width: 100px">직급</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 80px">상세</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="emp in employees" :key="emp.employeeId">
|
||||
<td><code>{{ emp.employeeNumber || '-' }}</code></td>
|
||||
<td><strong>{{ emp.employeeName }}</strong></td>
|
||||
<td>{{ emp.employeeEmail }}</td>
|
||||
<td>{{ emp.employeePosition || '-' }}</td>
|
||||
<td>
|
||||
<span :class="emp.isActive ? 'badge bg-success' : 'badge bg-secondary'">
|
||||
{{ emp.isActive ? '재직' : '퇴직' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<NuxtLink
|
||||
:to="`/employee/${emp.employeeId}`"
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
>
|
||||
<i class="bi bi-eye"></i>
|
||||
</NuxtLink>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="employees.length === 0">
|
||||
<td colspan="6" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">사원 정보가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 사원 등록 모달 -->
|
||||
<div class="modal fade" :class="{ show: showCreateModal }" :style="{ display: showCreateModal ? 'block' : 'none' }">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">사원 등록</h5>
|
||||
<button type="button" class="btn-close" @click="showCreateModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이름 <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" v-model="newEmployee.employeeName" required />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이메일 <span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" v-model="newEmployee.employeeEmail" required />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">사번</label>
|
||||
<input type="text" class="form-control" v-model="newEmployee.employeeNumber" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">직급</label>
|
||||
<select class="form-select" v-model="newEmployee.employeePosition">
|
||||
<option value="">선택</option>
|
||||
<option value="사원">사원</option>
|
||||
<option value="대리">대리</option>
|
||||
<option value="과장">과장</option>
|
||||
<option value="차장">차장</option>
|
||||
<option value="부장">부장</option>
|
||||
<option value="이사">이사</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">연락처</label>
|
||||
<input type="text" class="form-control" v-model="newEmployee.employeePhone" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">입사일</label>
|
||||
<input type="date" class="form-control" v-model="newEmployee.joinDate" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" @click="showCreateModal = false">취소</button>
|
||||
<button type="button" class="btn btn-primary" @click="createEmployee">
|
||||
<i class="bi bi-check-lg me-1"></i> 등록
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showCreateModal"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
const employees = ref<any[]>([])
|
||||
const searchKeyword = ref('')
|
||||
const showCreateModal = ref(false)
|
||||
|
||||
const newEmployee = ref({
|
||||
employeeName: '',
|
||||
employeeEmail: '',
|
||||
employeeNumber: '',
|
||||
employeePosition: '',
|
||||
employeePhone: '',
|
||||
joinDate: ''
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadEmployees()
|
||||
})
|
||||
|
||||
async function loadEmployees() {
|
||||
try {
|
||||
const query: Record<string, any> = {}
|
||||
if (searchKeyword.value) query.keyword = searchKeyword.value
|
||||
|
||||
const res = await $fetch<{ employees: any[] }>('/api/employee/list', { query })
|
||||
employees.value = res.employees || []
|
||||
} catch (e) {
|
||||
console.error('Load employees error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEmployee() {
|
||||
if (!newEmployee.value.employeeName || !newEmployee.value.employeeEmail) {
|
||||
alert('이름과 이메일은 필수입니다.')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await $fetch('/api/employee/create', {
|
||||
method: 'POST',
|
||||
body: newEmployee.value
|
||||
})
|
||||
showCreateModal.value = false
|
||||
newEmployee.value = {
|
||||
employeeName: '',
|
||||
employeeEmail: '',
|
||||
employeeNumber: '',
|
||||
employeePosition: '',
|
||||
employeePhone: '',
|
||||
joinDate: ''
|
||||
}
|
||||
await loadEmployees()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '등록에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
275
frontend/index.vue
Normal file
275
frontend/index.vue
Normal file
@@ -0,0 +1,275 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h4>
|
||||
<i class="bi bi-speedometer2 me-2"></i>대시보드
|
||||
</h4>
|
||||
<p class="text-muted mb-0">
|
||||
{{ currentWeek.weekString }} ({{ currentWeek.startDateStr }} ~ {{ currentWeek.endDateStr }})
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 요약 카드 -->
|
||||
<div class="row g-4 mb-4">
|
||||
<div class="col-md-3">
|
||||
<div class="card border-primary h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h6 class="text-muted">이번 주 내 보고서</h6>
|
||||
<h2 class="mb-0">{{ stats.myReportsThisWeek }}</h2>
|
||||
</div>
|
||||
<div class="text-primary">
|
||||
<i class="bi bi-journal-text display-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card border-success h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h6 class="text-muted">참여 프로젝트</h6>
|
||||
<h2 class="mb-0">{{ stats.myProjects }}</h2>
|
||||
</div>
|
||||
<div class="text-success">
|
||||
<i class="bi bi-folder-check display-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card border-info h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h6 class="text-muted">이번 주 취합</h6>
|
||||
<h2 class="mb-0">{{ stats.summariesThisWeek }}</h2>
|
||||
</div>
|
||||
<div class="text-info">
|
||||
<i class="bi bi-collection display-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card border-warning h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h6 class="text-muted">전체 프로젝트</h6>
|
||||
<h2 class="mb-0">{{ stats.totalProjects }}</h2>
|
||||
</div>
|
||||
<div class="text-warning">
|
||||
<i class="bi bi-briefcase display-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
<!-- 내 주간보고 -->
|
||||
<div class="col-lg-6">
|
||||
<div class="card h-100">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span><i class="bi bi-journal-text me-2"></i>내 주간보고</span>
|
||||
<NuxtLink to="/report/weekly/write" class="btn btn-primary btn-sm">
|
||||
<i class="bi bi-plus"></i> 작성
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="list-group list-group-flush" v-if="myReports.length > 0">
|
||||
<NuxtLink
|
||||
v-for="report in myReports"
|
||||
:key="report.reportId"
|
||||
:to="`/report/weekly/${report.reportId}`"
|
||||
class="list-group-item list-group-item-action"
|
||||
>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<strong>{{ report.projectName }}</strong>
|
||||
<br />
|
||||
<small class="text-muted">
|
||||
{{ report.reportYear }}-W{{ String(report.reportWeek).padStart(2, '0') }}
|
||||
</small>
|
||||
</div>
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="p-4 text-center text-muted" v-else>
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">작성한 보고서가 없습니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 최근 취합 보고서 -->
|
||||
<div class="col-lg-6">
|
||||
<div class="card h-100">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span><i class="bi bi-collection me-2"></i>최근 취합 보고서</span>
|
||||
<NuxtLink to="/report/summary" class="btn btn-outline-secondary btn-sm">
|
||||
전체보기
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="list-group list-group-flush" v-if="summaries.length > 0">
|
||||
<NuxtLink
|
||||
v-for="summary in summaries"
|
||||
:key="summary.summaryId"
|
||||
:to="`/report/summary/${summary.summaryId}`"
|
||||
class="list-group-item list-group-item-action"
|
||||
>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<strong>{{ summary.projectName }}</strong>
|
||||
<br />
|
||||
<small class="text-muted">
|
||||
{{ summary.reportYear }}-W{{ String(summary.reportWeek).padStart(2, '0') }}
|
||||
· {{ summary.memberCount }}명 참여
|
||||
</small>
|
||||
</div>
|
||||
<span :class="getSummaryBadgeClass(summary.summaryStatus)">
|
||||
{{ getSummaryStatusText(summary.summaryStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="p-4 text-center text-muted" v-else>
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">취합된 보고서가 없습니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { currentUser, fetchCurrentUser } = useAuth()
|
||||
const { getCurrentWeekInfo } = useWeekCalc()
|
||||
const router = useRouter()
|
||||
|
||||
const currentWeek = getCurrentWeekInfo()
|
||||
|
||||
const stats = ref({
|
||||
myReportsThisWeek: 0,
|
||||
myProjects: 0,
|
||||
summariesThisWeek: 0,
|
||||
totalProjects: 0
|
||||
})
|
||||
|
||||
const myReports = ref<any[]>([])
|
||||
const summaries = ref<any[]>([])
|
||||
|
||||
// 로그인 체크 및 데이터 로드
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadDashboardData()
|
||||
})
|
||||
|
||||
async function loadDashboardData() {
|
||||
try {
|
||||
// 내 주간보고 목록
|
||||
const reportsRes = await $fetch<{ reports: any[] }>('/api/report/weekly/list', {
|
||||
query: { limit: 5 }
|
||||
})
|
||||
myReports.value = reportsRes.reports || []
|
||||
|
||||
// 취합 보고서 목록
|
||||
const summariesRes = await $fetch<{ summaries: any[] }>('/api/report/summary/list', {
|
||||
query: { limit: 5 }
|
||||
})
|
||||
summaries.value = summariesRes.summaries || []
|
||||
|
||||
// 내 프로젝트
|
||||
const projectsRes = await $fetch<{ projects: any[] }>('/api/project/my-projects')
|
||||
|
||||
// 전체 프로젝트
|
||||
const allProjectsRes = await $fetch<{ projects: any[] }>('/api/project/list')
|
||||
|
||||
// 통계 계산
|
||||
stats.value = {
|
||||
myReportsThisWeek: myReports.value.filter(r =>
|
||||
r.reportYear === currentWeek.year && r.reportWeek === currentWeek.week
|
||||
).length,
|
||||
myProjects: projectsRes.projects?.length || 0,
|
||||
summariesThisWeek: summaries.value.filter(s =>
|
||||
s.reportYear === currentWeek.year && s.reportWeek === currentWeek.week
|
||||
).length,
|
||||
totalProjects: allProjectsRes.projects?.length || 0
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Dashboard data load error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'DRAFT': 'badge bg-secondary',
|
||||
'SUBMITTED': 'badge bg-success',
|
||||
'AGGREGATED': 'badge bg-info'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'DRAFT': '작성중',
|
||||
'SUBMITTED': '제출완료',
|
||||
'AGGREGATED': '취합완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function getSummaryBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'AGGREGATED': 'badge bg-info',
|
||||
'REVIEWED': 'badge bg-success'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getSummaryStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'AGGREGATED': '취합완료',
|
||||
'REVIEWED': '검토완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.card {
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.card-header {
|
||||
background-color: #f8f9fa;
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
158
frontend/login.vue
Normal file
158
frontend/login.vue
Normal file
@@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<div class="login-card">
|
||||
<div class="text-center mb-4">
|
||||
<i class="bi bi-clipboard-check display-1 text-primary"></i>
|
||||
<h2 class="mt-3">주간업무보고</h2>
|
||||
<p class="text-muted">로그인하여 시작하세요</p>
|
||||
</div>
|
||||
|
||||
<!-- 새 사용자 로그인 폼 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<i class="bi bi-person-plus me-2"></i>이메일로 로그인
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form @submit.prevent="handleLogin">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Gmail 주소</label>
|
||||
<input
|
||||
type="email"
|
||||
class="form-control"
|
||||
v-model="email"
|
||||
placeholder="example@gmail.com"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이름</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
v-model="name"
|
||||
placeholder="홍길동"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100" :disabled="isSubmitting">
|
||||
<span v-if="isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로그인 중...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-box-arrow-in-right me-2"></i>로그인
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 기존 사용자 선택 -->
|
||||
<div class="card" v-if="recentUsers.length > 0">
|
||||
<div class="card-header">
|
||||
<i class="bi bi-clock-history me-2"></i>최근 로그인 사용자
|
||||
</div>
|
||||
<div class="list-group list-group-flush">
|
||||
<button
|
||||
v-for="user in recentUsers"
|
||||
:key="user.employeeId"
|
||||
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"
|
||||
@click="handleSelectUser(user.employeeId)"
|
||||
:disabled="isSubmitting"
|
||||
>
|
||||
<div>
|
||||
<i class="bi bi-person-circle me-2 text-primary"></i>
|
||||
<strong>{{ user.employeeName }}</strong>
|
||||
<small class="text-muted ms-2">{{ user.employeeEmail }}</small>
|
||||
</div>
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 에러 메시지 -->
|
||||
<div class="alert alert-danger mt-3" v-if="errorMessage">
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>{{ errorMessage }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
layout: false
|
||||
})
|
||||
|
||||
const { login, selectUser, getRecentUsers } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
const email = ref('')
|
||||
const name = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const recentUsers = ref<any[]>([])
|
||||
|
||||
// 최근 로그인 사용자 불러오기
|
||||
onMounted(async () => {
|
||||
try {
|
||||
recentUsers.value = await getRecentUsers()
|
||||
} catch (e) {
|
||||
// 무시
|
||||
}
|
||||
})
|
||||
|
||||
// 이메일+이름 로그인
|
||||
async function handleLogin() {
|
||||
if (!email.value || !name.value) return
|
||||
|
||||
isSubmitting.value = true
|
||||
errorMessage.value = ''
|
||||
|
||||
try {
|
||||
await login(email.value, name.value)
|
||||
router.push('/')
|
||||
} catch (e: any) {
|
||||
errorMessage.value = e.message || '로그인에 실패했습니다.'
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 기존 사용자 선택
|
||||
async function handleSelectUser(employeeId: number) {
|
||||
isSubmitting.value = true
|
||||
errorMessage.value = ''
|
||||
|
||||
try {
|
||||
await selectUser(employeeId)
|
||||
router.push('/')
|
||||
} catch (e: any) {
|
||||
errorMessage.value = e.message || '로그인에 실패했습니다.'
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background: white;
|
||||
border-radius: 1rem;
|
||||
padding: 2rem;
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.list-group-item-action:hover {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
</style>
|
||||
285
frontend/project/[id].vue
Normal file
285
frontend/project/[id].vue
Normal file
@@ -0,0 +1,285 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<NuxtLink to="/project" class="text-decoration-none">
|
||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<div v-if="project">
|
||||
<!-- 프로젝트 기본 정보 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-folder me-2"></i>{{ project.projectName }}
|
||||
</h5>
|
||||
<span :class="getStatusBadgeClass(project.projectStatus)">
|
||||
{{ getStatusText(project.projectStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-4">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label text-muted">프로젝트 코드</label>
|
||||
<p class="mb-0"><code>{{ project.projectCode || '-' }}</code></p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label text-muted">발주처</label>
|
||||
<p class="mb-0">{{ project.clientName || '-' }}</p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label text-muted">계약금액</label>
|
||||
<p class="mb-0">{{ formatMoney(project.contractAmount) }}</p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label text-muted">기간</label>
|
||||
<p class="mb-0">
|
||||
{{ project.startDate ? formatDate(project.startDate) : '-' }} ~
|
||||
{{ project.endDate ? formatDate(project.endDate) : '진행중' }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-12" v-if="project.projectDescription">
|
||||
<label class="form-label text-muted">설명</label>
|
||||
<p class="mb-0">{{ project.projectDescription }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PM/PL 이력 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span><i class="bi bi-person-badge me-2"></i>PM/PL 담당 이력</span>
|
||||
<button class="btn btn-sm btn-primary" @click="showAssignModal = true">
|
||||
<i class="bi bi-plus"></i> 담당자 지정
|
||||
</button>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 80px">역할</th>
|
||||
<th>담당자</th>
|
||||
<th style="width: 200px">기간</th>
|
||||
<th>비고</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="m in managers" :key="m.historyId">
|
||||
<td>
|
||||
<span :class="m.roleType === 'PM' ? 'badge bg-primary' : 'badge bg-info'">
|
||||
{{ m.roleType }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ m.employeeName }}</td>
|
||||
<td>
|
||||
{{ formatDate(m.startDate) }} ~
|
||||
{{ m.endDate ? formatDate(m.endDate) : '현재' }}
|
||||
</td>
|
||||
<td>{{ m.changeReason || '-' }}</td>
|
||||
</tr>
|
||||
<tr v-if="managers.length === 0">
|
||||
<td colspan="4" class="text-center text-muted py-3">
|
||||
담당자 이력이 없습니다.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 참여자 통계 (주간보고 작성 기준) -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="bi bi-people me-2"></i>참여자 현황
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3" v-for="member in members" :key="member.employeeId">
|
||||
<div class="p-3 border rounded">
|
||||
<strong>{{ member.employeeName }}</strong>
|
||||
<br />
|
||||
<small class="text-muted">{{ member.reportCount }}건 보고</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 text-center text-muted py-3" v-if="members.length === 0">
|
||||
아직 주간보고를 작성한 참여자가 없습니다.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center py-5" v-else-if="isLoading">
|
||||
<div class="spinner-border text-primary"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 담당자 지정 모달 -->
|
||||
<div class="modal fade" :class="{ show: showAssignModal }" :style="{ display: showAssignModal ? 'block' : 'none' }">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">PM/PL 담당자 지정</h5>
|
||||
<button type="button" class="btn-close" @click="showAssignModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">역할 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="assignForm.roleType">
|
||||
<option value="PM">PM</option>
|
||||
<option value="PL">PL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">담당자 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="assignForm.employeeId">
|
||||
<option value="">선택하세요</option>
|
||||
<option v-for="e in employees" :key="e.employeeId" :value="e.employeeId">
|
||||
{{ e.employeeName }} ({{ e.employeeEmail }})
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">시작일 <span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" v-model="assignForm.startDate" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">변경 사유</label>
|
||||
<input type="text" class="form-control" v-model="assignForm.changeReason" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" @click="showAssignModal = false">취소</button>
|
||||
<button type="button" class="btn btn-primary" @click="assignManager">
|
||||
<i class="bi bi-check-lg me-1"></i> 지정
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showAssignModal"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const project = ref<any>(null)
|
||||
const managers = ref<any[]>([])
|
||||
const members = ref<any[]>([])
|
||||
const employees = ref<any[]>([])
|
||||
const isLoading = ref(true)
|
||||
const showAssignModal = ref(false)
|
||||
|
||||
const assignForm = ref({
|
||||
roleType: 'PM',
|
||||
employeeId: '',
|
||||
startDate: new Date().toISOString().split('T')[0],
|
||||
changeReason: ''
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await Promise.all([loadProject(), loadEmployees()])
|
||||
})
|
||||
|
||||
async function loadProject() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await $fetch<{ project: any }>(`/api/project/${route.params.id}/detail`)
|
||||
project.value = res.project
|
||||
|
||||
// PM/PL 이력 로드
|
||||
const mgRes = await $fetch<{ managers: any[] }>(`/api/project/${route.params.id}/manager-history`)
|
||||
managers.value = mgRes.managers || []
|
||||
|
||||
// 참여자 현황 (주간보고 기준) - 별도 API 필요하면 추가
|
||||
// 임시로 빈 배열
|
||||
members.value = []
|
||||
} catch (e: any) {
|
||||
alert('프로젝트를 불러오는데 실패했습니다.')
|
||||
router.push('/project')
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadEmployees() {
|
||||
try {
|
||||
const res = await $fetch<{ employees: any[] }>('/api/employee/list')
|
||||
employees.value = res.employees || []
|
||||
} catch (e) {
|
||||
console.error('Load employees error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function assignManager() {
|
||||
if (!assignForm.value.employeeId || !assignForm.value.startDate) {
|
||||
alert('담당자와 시작일은 필수입니다.')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await $fetch(`/api/project/${route.params.id}/manager-assign`, {
|
||||
method: 'POST',
|
||||
body: assignForm.value
|
||||
})
|
||||
showAssignModal.value = false
|
||||
assignForm.value = {
|
||||
roleType: 'PM',
|
||||
employeeId: '',
|
||||
startDate: new Date().toISOString().split('T')[0],
|
||||
changeReason: ''
|
||||
}
|
||||
await loadProject()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '지정에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'ACTIVE': 'badge bg-success',
|
||||
'COMPLETED': 'badge bg-secondary',
|
||||
'HOLD': 'badge bg-warning'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'ACTIVE': '진행중',
|
||||
'COMPLETED': '완료',
|
||||
'HOLD': '보류'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
const d = new Date(dateStr)
|
||||
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`
|
||||
}
|
||||
|
||||
function formatMoney(amount: number | null) {
|
||||
if (!amount) return '-'
|
||||
return new Intl.NumberFormat('ko-KR').format(amount) + '원'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
266
frontend/project/index.vue
Normal file
266
frontend/project/index.vue
Normal file
@@ -0,0 +1,266 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4><i class="bi bi-folder me-2"></i>프로젝트 관리</h4>
|
||||
<p class="text-muted mb-0">프로젝트(사업) 정보 관리</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="showCreateModal = true">
|
||||
<i class="bi bi-plus-lg me-1"></i> 새 프로젝트
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 필터 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
v-model="searchKeyword"
|
||||
placeholder="프로젝트명 또는 코드 검색"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select class="form-select" v-model="filterStatus">
|
||||
<option value="">전체 상태</option>
|
||||
<option value="ACTIVE">진행중</option>
|
||||
<option value="COMPLETED">완료</option>
|
||||
<option value="HOLD">보류</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex align-items-end">
|
||||
<button class="btn btn-outline-secondary" @click="loadProjects">
|
||||
<i class="bi bi-search me-1"></i> 조회
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 프로젝트 목록 -->
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>프로젝트 코드</th>
|
||||
<th>프로젝트명</th>
|
||||
<th>발주처</th>
|
||||
<th style="width: 120px">기간</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 80px">상세</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="project in filteredProjects" :key="project.projectId">
|
||||
<td><code>{{ project.projectCode || '-' }}</code></td>
|
||||
<td>
|
||||
<strong>{{ project.projectName }}</strong>
|
||||
</td>
|
||||
<td>{{ project.clientName || '-' }}</td>
|
||||
<td>
|
||||
<small v-if="project.startDate">
|
||||
{{ formatDate(project.startDate) }} ~
|
||||
<br />{{ formatDate(project.endDate) || '진행중' }}
|
||||
</small>
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="getStatusBadgeClass(project.projectStatus)">
|
||||
{{ getStatusText(project.projectStatus) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<NuxtLink
|
||||
:to="`/project/${project.projectId}`"
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
>
|
||||
<i class="bi bi-eye"></i>
|
||||
</NuxtLink>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="filteredProjects.length === 0">
|
||||
<td colspan="6" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">프로젝트가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 프로젝트 생성 모달 -->
|
||||
<div class="modal fade" :class="{ show: showCreateModal }" :style="{ display: showCreateModal ? 'block' : 'none' }">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">새 프로젝트 등록</h5>
|
||||
<button type="button" class="btn-close" @click="showCreateModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">프로젝트 코드</label>
|
||||
<input type="text" class="form-control" v-model="newProject.projectCode" placeholder="예: 2026-KDCA-001" />
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<label class="form-label">프로젝트명 <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" v-model="newProject.projectName" required />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">발주처</label>
|
||||
<input type="text" class="form-control" v-model="newProject.clientName" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">계약금액 (원)</label>
|
||||
<input type="number" class="form-control" v-model="newProject.contractAmount" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">시작일</label>
|
||||
<input type="date" class="form-control" v-model="newProject.startDate" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">종료일</label>
|
||||
<input type="date" class="form-control" v-model="newProject.endDate" />
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">설명</label>
|
||||
<textarea class="form-control" v-model="newProject.projectDescription" rows="3"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" @click="showCreateModal = false">취소</button>
|
||||
<button type="button" class="btn btn-primary" @click="createProject">
|
||||
<i class="bi bi-check-lg me-1"></i> 등록
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showCreateModal"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
const projects = ref<any[]>([])
|
||||
const searchKeyword = ref('')
|
||||
const filterStatus = ref('')
|
||||
const showCreateModal = ref(false)
|
||||
|
||||
const newProject = ref({
|
||||
projectCode: '',
|
||||
projectName: '',
|
||||
clientName: '',
|
||||
contractAmount: null,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
projectDescription: ''
|
||||
})
|
||||
|
||||
const filteredProjects = computed(() => {
|
||||
let list = projects.value
|
||||
|
||||
if (searchKeyword.value) {
|
||||
const keyword = searchKeyword.value.toLowerCase()
|
||||
list = list.filter(p =>
|
||||
p.projectName?.toLowerCase().includes(keyword) ||
|
||||
p.projectCode?.toLowerCase().includes(keyword)
|
||||
)
|
||||
}
|
||||
|
||||
if (filterStatus.value) {
|
||||
list = list.filter(p => p.projectStatus === filterStatus.value)
|
||||
}
|
||||
|
||||
return list
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
})
|
||||
|
||||
async function loadProjects() {
|
||||
try {
|
||||
const res = await $fetch<{ projects: any[] }>('/api/project/list')
|
||||
projects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error('Load projects error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function createProject() {
|
||||
if (!newProject.value.projectName) {
|
||||
alert('프로젝트명은 필수입니다.')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await $fetch('/api/project/create', {
|
||||
method: 'POST',
|
||||
body: newProject.value
|
||||
})
|
||||
showCreateModal.value = false
|
||||
newProject.value = {
|
||||
projectCode: '',
|
||||
projectName: '',
|
||||
clientName: '',
|
||||
contractAmount: null,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
projectDescription: ''
|
||||
}
|
||||
await loadProjects()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '등록에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'ACTIVE': 'badge bg-success',
|
||||
'COMPLETED': 'badge bg-secondary',
|
||||
'HOLD': 'badge bg-warning',
|
||||
'CANCELLED': 'badge bg-danger'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'ACTIVE': '진행중',
|
||||
'COMPLETED': '완료',
|
||||
'HOLD': '보류',
|
||||
'CANCELLED': '취소'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
const d = new Date(dateStr)
|
||||
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
240
frontend/report/summary/[id].vue
Normal file
240
frontend/report/summary/[id].vue
Normal file
@@ -0,0 +1,240 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<NuxtLink to="/report/summary" class="text-decoration-none">
|
||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<div v-if="summary">
|
||||
<!-- 취합 보고서 헤더 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-collection me-2"></i>
|
||||
{{ summary.projectName }} - {{ summary.reportYear }}-W{{ String(summary.reportWeek).padStart(2, '0') }}
|
||||
</h5>
|
||||
<span :class="getStatusBadgeClass(summary.summaryStatus)">
|
||||
{{ getStatusText(summary.summaryStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label text-muted">기간</label>
|
||||
<p class="mb-0">{{ formatDate(summary.weekStartDate) }} ~ {{ formatDate(summary.weekEndDate) }}</p>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label text-muted">참여 인원</label>
|
||||
<p class="mb-0">{{ summary.memberCount }}명</p>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label text-muted">총 투입시간</label>
|
||||
<p class="mb-0">{{ summary.totalWorkHours ? summary.totalWorkHours + '시간' : '-' }}</p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label text-muted">취합일시</label>
|
||||
<p class="mb-0">{{ formatDateTime(summary.aggregatedAt) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PM 검토 영역 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<i class="bi bi-chat-square-text me-2"></i>PM 검토
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-if="summary.reviewerComment" class="mb-3">
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span class="text-muted">
|
||||
<i class="bi bi-person me-1"></i>{{ summary.reviewerName || '검토자' }}
|
||||
</span>
|
||||
<small class="text-muted">{{ formatDateTime(summary.reviewedAt) }}</small>
|
||||
</div>
|
||||
<div class="p-3 bg-success bg-opacity-10 rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ summary.reviewerComment }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label class="form-label">코멘트 작성</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="reviewComment"
|
||||
rows="3"
|
||||
placeholder="PM 코멘트를 입력하세요..."
|
||||
></textarea>
|
||||
<button
|
||||
class="btn btn-primary mt-2"
|
||||
@click="submitReview"
|
||||
:disabled="isSubmitting"
|
||||
>
|
||||
<i class="bi bi-check-lg me-1"></i> 검토 완료
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 개별 보고서 목록 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="bi bi-list-ul me-2"></i>개별 보고서 ({{ reports.length }}건)
|
||||
</div>
|
||||
<div class="accordion accordion-flush" id="reportsAccordion">
|
||||
<div
|
||||
v-for="(report, index) in reports"
|
||||
:key="report.reportId"
|
||||
class="accordion-item"
|
||||
>
|
||||
<h2 class="accordion-header">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
:data-bs-toggle="'collapse'"
|
||||
:data-bs-target="`#report-${report.reportId}`"
|
||||
>
|
||||
<div class="d-flex justify-content-between w-100 me-3">
|
||||
<span>
|
||||
<i class="bi bi-person me-2"></i>
|
||||
<strong>{{ report.authorName }}</strong>
|
||||
</span>
|
||||
<small class="text-muted">
|
||||
{{ report.workHours ? report.workHours + 'h' : '' }}
|
||||
</small>
|
||||
</div>
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
:id="`report-${report.reportId}`"
|
||||
class="accordion-collapse collapse"
|
||||
data-bs-parent="#reportsAccordion"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<!-- 금주 실적 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label text-muted small">
|
||||
<i class="bi bi-check-circle me-1"></i>금주 실적
|
||||
</label>
|
||||
<div class="p-2 bg-light rounded">
|
||||
<pre class="mb-0 small" style="white-space: pre-wrap;">{{ report.workDescription || '-' }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 차주 계획 -->
|
||||
<div class="mb-3" v-if="report.planDescription">
|
||||
<label class="form-label text-muted small">
|
||||
<i class="bi bi-calendar-event me-1"></i>차주 계획
|
||||
</label>
|
||||
<div class="p-2 bg-light rounded">
|
||||
<pre class="mb-0 small" style="white-space: pre-wrap;">{{ report.planDescription }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 이슈 -->
|
||||
<div class="mb-3" v-if="report.issueDescription">
|
||||
<label class="form-label text-muted small">
|
||||
<i class="bi bi-exclamation-triangle me-1"></i>이슈/리스크
|
||||
</label>
|
||||
<div class="p-2 bg-warning bg-opacity-10 rounded">
|
||||
<pre class="mb-0 small" style="white-space: pre-wrap;">{{ report.issueDescription }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center py-5" v-else-if="isLoading">
|
||||
<div class="spinner-border text-primary"></div>
|
||||
<p class="mt-2 text-muted">로딩중...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser, currentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const summary = ref<any>(null)
|
||||
const reports = ref<any[]>([])
|
||||
const reviewComment = ref('')
|
||||
const isLoading = ref(true)
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadSummary()
|
||||
})
|
||||
|
||||
async function loadSummary() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await $fetch<{ summary: any; reports: any[] }>(`/api/report/summary/${route.params.id}/detail`)
|
||||
summary.value = res.summary
|
||||
reports.value = res.reports || []
|
||||
reviewComment.value = res.summary?.reviewerComment || ''
|
||||
} catch (e: any) {
|
||||
alert('취합 보고서를 불러오는데 실패했습니다.')
|
||||
router.push('/report/summary')
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReview() {
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
await $fetch(`/api/report/summary/${route.params.id}/review`, {
|
||||
method: 'PUT',
|
||||
body: { comment: reviewComment.value }
|
||||
})
|
||||
await loadSummary()
|
||||
alert('검토가 완료되었습니다.')
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '검토 저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'AGGREGATED': 'badge bg-info',
|
||||
'REVIEWED': 'badge bg-success'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'AGGREGATED': '취합완료',
|
||||
'REVIEWED': '검토완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
const d = new Date(dateStr)
|
||||
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return '-'
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleString('ko-KR')
|
||||
}
|
||||
</script>
|
||||
178
frontend/report/summary/index.vue
Normal file
178
frontend/report/summary/index.vue
Normal file
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<h4><i class="bi bi-collection me-2"></i>취합 보고서</h4>
|
||||
<p class="text-muted mb-0">프로젝트별 주간보고 취합 목록</p>
|
||||
</div>
|
||||
|
||||
<!-- 필터 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">프로젝트</label>
|
||||
<select class="form-select" v-model="filter.projectId">
|
||||
<option value="">전체</option>
|
||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
||||
{{ p.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">연도</label>
|
||||
<select class="form-select" v-model="filter.year">
|
||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex align-items-end">
|
||||
<button class="btn btn-outline-secondary" @click="loadSummaries">
|
||||
<i class="bi bi-search me-1"></i> 조회
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 취합 목록 -->
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 80px">주차</th>
|
||||
<th>프로젝트</th>
|
||||
<th style="width: 150px">기간</th>
|
||||
<th style="width: 100px">참여인원</th>
|
||||
<th style="width: 100px">총 시간</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 150px">취합일시</th>
|
||||
<th style="width: 80px">상세</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="summary in summaries" :key="summary.summaryId">
|
||||
<td>
|
||||
<strong>W{{ String(summary.reportWeek).padStart(2, '0') }}</strong>
|
||||
</td>
|
||||
<td>{{ summary.projectName }}</td>
|
||||
<td>
|
||||
<small>{{ formatDateRange(summary.weekStartDate, summary.weekEndDate) }}</small>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-primary">{{ summary.memberCount }}명</span>
|
||||
</td>
|
||||
<td>
|
||||
{{ summary.totalWorkHours ? summary.totalWorkHours + 'h' : '-' }}
|
||||
</td>
|
||||
<td>
|
||||
<span :class="getStatusBadgeClass(summary.summaryStatus)">
|
||||
{{ getStatusText(summary.summaryStatus) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<small>{{ formatDateTime(summary.aggregatedAt) }}</small>
|
||||
</td>
|
||||
<td>
|
||||
<NuxtLink
|
||||
:to="`/report/summary/${summary.summaryId}`"
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
>
|
||||
<i class="bi bi-eye"></i>
|
||||
</NuxtLink>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="summaries.length === 0">
|
||||
<td colspan="8" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">취합된 보고서가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const years = [currentYear, currentYear - 1, currentYear - 2]
|
||||
|
||||
const filter = ref({
|
||||
projectId: '',
|
||||
year: currentYear
|
||||
})
|
||||
|
||||
const summaries = ref<any[]>([])
|
||||
const projects = ref<any[]>([])
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
await loadSummaries()
|
||||
})
|
||||
|
||||
async function loadProjects() {
|
||||
try {
|
||||
const res = await $fetch<{ projects: any[] }>('/api/project/list')
|
||||
projects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error('Load projects error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSummaries() {
|
||||
try {
|
||||
const query: Record<string, any> = { year: filter.value.year }
|
||||
if (filter.value.projectId) query.projectId = filter.value.projectId
|
||||
|
||||
const res = await $fetch<{ summaries: any[] }>('/api/report/summary/list', { query })
|
||||
summaries.value = res.summaries || []
|
||||
} catch (e) {
|
||||
console.error('Load summaries error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'AGGREGATED': 'badge bg-info',
|
||||
'REVIEWED': 'badge bg-success'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'AGGREGATED': '취합완료',
|
||||
'REVIEWED': '검토완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDateRange(start: string, end: string) {
|
||||
const s = new Date(start)
|
||||
const e = new Date(end)
|
||||
return `${s.getMonth()+1}/${s.getDate()} ~ ${e.getMonth()+1}/${e.getDate()}`
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return '-'
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleString('ko-KR', {
|
||||
month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
190
frontend/report/weekly/[id].vue
Normal file
190
frontend/report/weekly/[id].vue
Normal file
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<NuxtLink to="/report/weekly" class="text-decoration-none">
|
||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<div class="card" v-if="report">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-journal-text me-2"></i>
|
||||
{{ report.projectName }} - {{ report.reportYear }}-W{{ String(report.reportWeek).padStart(2, '0') }}
|
||||
</h5>
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<!-- 기본 정보 -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label text-muted">작성자</label>
|
||||
<p class="mb-0">{{ report.authorName }}</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label text-muted">기간</label>
|
||||
<p class="mb-0">{{ formatDate(report.weekStartDate) }} ~ {{ formatDate(report.weekEndDate) }}</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label text-muted">투입시간</label>
|
||||
<p class="mb-0">{{ report.workHours ? report.workHours + '시간' : '-' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 금주 실적 -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-check-circle me-1"></i>금주 실적
|
||||
</label>
|
||||
<div class="p-3 bg-light rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.workDescription || '-' }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 차주 계획 -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-calendar-event me-1"></i>차주 계획
|
||||
</label>
|
||||
<div class="p-3 bg-light rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.planDescription || '-' }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 이슈사항 -->
|
||||
<div class="mb-4" v-if="report.issueDescription">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-exclamation-triangle me-1"></i>이슈/리스크
|
||||
</label>
|
||||
<div class="p-3 bg-warning bg-opacity-10 rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.issueDescription }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 비고 -->
|
||||
<div class="mb-4" v-if="report.remarkDescription">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-chat-text me-1"></i>비고
|
||||
</label>
|
||||
<div class="p-3 bg-light rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.remarkDescription }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 작업 버튼 -->
|
||||
<div class="d-flex gap-2 mt-4 pt-3 border-top">
|
||||
<NuxtLink
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
:to="`/report/weekly/write?id=${report.reportId}`"
|
||||
class="btn btn-primary"
|
||||
>
|
||||
<i class="bi bi-pencil me-1"></i> 수정
|
||||
</NuxtLink>
|
||||
<button
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
class="btn btn-success"
|
||||
@click="submitReport"
|
||||
>
|
||||
<i class="bi bi-send me-1"></i> 제출
|
||||
</button>
|
||||
<button
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
class="btn btn-outline-danger"
|
||||
@click="deleteReport"
|
||||
>
|
||||
<i class="bi bi-trash me-1"></i> 삭제
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center py-5" v-else-if="isLoading">
|
||||
<div class="spinner-border text-primary"></div>
|
||||
<p class="mt-2 text-muted">로딩중...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const report = ref<any>(null)
|
||||
const isLoading = ref(true)
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadReport()
|
||||
})
|
||||
|
||||
async function loadReport() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await $fetch<{ report: any }>(`/api/report/weekly/${route.params.id}/detail`)
|
||||
report.value = res.report
|
||||
} catch (e: any) {
|
||||
alert('보고서를 불러오는데 실패했습니다.')
|
||||
router.push('/report/weekly')
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReport() {
|
||||
if (!confirm('보고서를 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
||||
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${route.params.id}/submit`, { method: 'POST' })
|
||||
await loadReport()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '제출에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteReport() {
|
||||
if (!confirm('보고서를 삭제하시겠습니까?')) return
|
||||
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${route.params.id}/detail`, { method: 'DELETE' })
|
||||
router.push('/report/weekly')
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '삭제에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'DRAFT': 'badge bg-secondary',
|
||||
'SUBMITTED': 'badge bg-success',
|
||||
'AGGREGATED': 'badge bg-info'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'DRAFT': '작성중',
|
||||
'SUBMITTED': '제출완료',
|
||||
'AGGREGATED': '취합완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
const d = new Date(dateStr)
|
||||
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`
|
||||
}
|
||||
</script>
|
||||
205
frontend/report/weekly/index.vue
Normal file
205
frontend/report/weekly/index.vue
Normal file
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4><i class="bi bi-journal-text me-2"></i>주간보고</h4>
|
||||
<p class="text-muted mb-0">내가 작성한 주간보고 목록</p>
|
||||
</div>
|
||||
<NuxtLink to="/report/weekly/write" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i> 새 보고서 작성
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 필터 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">프로젝트</label>
|
||||
<select class="form-select" v-model="filter.projectId">
|
||||
<option value="">전체</option>
|
||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
||||
{{ p.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">연도</label>
|
||||
<select class="form-select" v-model="filter.year">
|
||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">상태</label>
|
||||
<select class="form-select" v-model="filter.status">
|
||||
<option value="">전체</option>
|
||||
<option value="DRAFT">작성중</option>
|
||||
<option value="SUBMITTED">제출완료</option>
|
||||
<option value="AGGREGATED">취합완료</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex align-items-end">
|
||||
<button class="btn btn-outline-secondary" @click="loadReports">
|
||||
<i class="bi bi-search me-1"></i> 조회
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 보고서 목록 -->
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 80px">주차</th>
|
||||
<th>프로젝트</th>
|
||||
<th style="width: 120px">기간</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 150px">작성일</th>
|
||||
<th style="width: 100px">작업</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="report in reports" :key="report.reportId">
|
||||
<td>
|
||||
<strong>W{{ String(report.reportWeek).padStart(2, '0') }}</strong>
|
||||
</td>
|
||||
<td>{{ report.projectName }}</td>
|
||||
<td>
|
||||
<small>{{ formatDateRange(report.weekStartDate, report.weekEndDate) }}</small>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<small>{{ formatDateTime(report.createdAt) }}</small>
|
||||
</td>
|
||||
<td>
|
||||
<NuxtLink
|
||||
:to="`/report/weekly/${report.reportId}`"
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
>
|
||||
<i class="bi bi-eye"></i>
|
||||
</NuxtLink>
|
||||
<button
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
class="btn btn-sm btn-outline-success ms-1"
|
||||
@click="submitReport(report.reportId)"
|
||||
>
|
||||
<i class="bi bi-send"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="reports.length === 0">
|
||||
<td colspan="6" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">보고서가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const years = [currentYear, currentYear - 1, currentYear - 2]
|
||||
|
||||
const filter = ref({
|
||||
projectId: '',
|
||||
year: currentYear,
|
||||
status: ''
|
||||
})
|
||||
|
||||
const reports = ref<any[]>([])
|
||||
const projects = ref<any[]>([])
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
await loadReports()
|
||||
})
|
||||
|
||||
async function loadProjects() {
|
||||
try {
|
||||
const res = await $fetch<{ projects: any[] }>('/api/project/my-projects')
|
||||
projects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error('Load projects error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadReports() {
|
||||
try {
|
||||
const query: Record<string, any> = { year: filter.value.year }
|
||||
if (filter.value.projectId) query.projectId = filter.value.projectId
|
||||
if (filter.value.status) query.status = filter.value.status
|
||||
|
||||
const res = await $fetch<{ reports: any[] }>('/api/report/weekly/list', { query })
|
||||
reports.value = res.reports || []
|
||||
} catch (e) {
|
||||
console.error('Load reports error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReport(reportId: number) {
|
||||
if (!confirm('보고서를 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
||||
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
||||
await loadReports()
|
||||
} catch (e: any) {
|
||||
alert(e.message || '제출에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'DRAFT': 'badge bg-secondary',
|
||||
'SUBMITTED': 'badge bg-success',
|
||||
'AGGREGATED': 'badge bg-info'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'DRAFT': '작성중',
|
||||
'SUBMITTED': '제출완료',
|
||||
'AGGREGATED': '취합완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDateRange(start: string, end: string) {
|
||||
const s = new Date(start)
|
||||
const e = new Date(end)
|
||||
return `${s.getMonth()+1}/${s.getDate()} ~ ${e.getMonth()+1}/${e.getDate()}`
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleString('ko-KR', {
|
||||
month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
297
frontend/report/weekly/write.vue
Normal file
297
frontend/report/weekly/write.vue
Normal file
@@ -0,0 +1,297 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<NuxtLink to="/report/weekly" class="text-decoration-none">
|
||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-pencil-square me-2"></i>
|
||||
{{ isEdit ? '주간보고 수정' : '주간보고 작성' }}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form @submit.prevent="handleSubmit">
|
||||
<!-- 프로젝트 선택 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">프로젝트 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="form.projectId" required :disabled="isEdit">
|
||||
<option value="">프로젝트를 선택하세요</option>
|
||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
||||
{{ p.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 주차 선택 -->
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">연도</label>
|
||||
<select class="form-select" v-model="form.reportYear" :disabled="isEdit">
|
||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">주차</label>
|
||||
<select class="form-select" v-model="form.reportWeek" :disabled="isEdit">
|
||||
<option v-for="w in 53" :key="w" :value="w">
|
||||
W{{ String(w).padStart(2, '0') }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">기간</label>
|
||||
<input type="text" class="form-control" :value="weekRangeText" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 금주 실적 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">금주 실적 <span class="text-danger">*</span></label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.workDescription"
|
||||
rows="5"
|
||||
placeholder="이번 주에 수행한 업무 내용을 작성해주세요."
|
||||
required
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 차주 계획 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">차주 계획</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.planDescription"
|
||||
rows="4"
|
||||
placeholder="다음 주에 수행할 업무 계획을 작성해주세요."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 이슈사항 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이슈/리스크</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.issueDescription"
|
||||
rows="3"
|
||||
placeholder="업무 진행 중 발생한 이슈나 리스크를 작성해주세요."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 비고 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">비고</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.remarkDescription"
|
||||
rows="2"
|
||||
placeholder="기타 참고사항"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 투입시간 -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label">투입 시간 (선택)</label>
|
||||
<div class="input-group" style="max-width: 200px;">
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
v-model="form.workHours"
|
||||
min="0"
|
||||
max="100"
|
||||
step="0.5"
|
||||
/>
|
||||
<span class="input-group-text">시간</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 버튼 -->
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSubmitting">
|
||||
<span v-if="isSubmitting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
<i class="bi bi-save me-1" v-else></i>
|
||||
{{ isEdit ? '수정' : '저장' }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success"
|
||||
@click="handleSaveAndSubmit"
|
||||
:disabled="isSubmitting"
|
||||
>
|
||||
<i class="bi bi-send me-1"></i> 저장 후 제출
|
||||
</button>
|
||||
<NuxtLink to="/report/weekly" class="btn btn-outline-secondary">
|
||||
취소
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 사이드 안내 -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<h6><i class="bi bi-info-circle me-1"></i> 작성 안내</h6>
|
||||
<ul class="mb-0 ps-3">
|
||||
<li>금주 실적은 필수 항목입니다.</li>
|
||||
<li>같은 프로젝트, 같은 주차에 하나의 보고서만 작성 가능합니다.</li>
|
||||
<li>제출 후에는 수정이 제한됩니다.</li>
|
||||
<li>취합은 매주 자동으로 진행됩니다.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const { getCurrentWeekInfo, getWeekRangeText } = useWeekCalc()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const currentWeek = getCurrentWeekInfo()
|
||||
const currentYear = new Date().getFullYear()
|
||||
const years = [currentYear, currentYear - 1]
|
||||
|
||||
const isEdit = computed(() => !!route.query.id)
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
const form = ref({
|
||||
projectId: '',
|
||||
reportYear: currentWeek.year,
|
||||
reportWeek: currentWeek.week,
|
||||
workDescription: '',
|
||||
planDescription: '',
|
||||
issueDescription: '',
|
||||
remarkDescription: '',
|
||||
workHours: null as number | null
|
||||
})
|
||||
|
||||
const projects = ref<any[]>([])
|
||||
|
||||
const weekRangeText = computed(() => {
|
||||
return getWeekRangeText(form.value.reportYear, form.value.reportWeek)
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
|
||||
if (route.query.id) {
|
||||
await loadReport(Number(route.query.id))
|
||||
}
|
||||
})
|
||||
|
||||
async function loadProjects() {
|
||||
try {
|
||||
const res = await $fetch<{ projects: any[] }>('/api/project/list')
|
||||
projects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error('Load projects error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadReport(reportId: number) {
|
||||
try {
|
||||
const res = await $fetch<{ report: any }>(`/api/report/weekly/${reportId}/detail`)
|
||||
const r = res.report
|
||||
form.value = {
|
||||
projectId: r.projectId,
|
||||
reportYear: r.reportYear,
|
||||
reportWeek: r.reportWeek,
|
||||
workDescription: r.workDescription || '',
|
||||
planDescription: r.planDescription || '',
|
||||
issueDescription: r.issueDescription || '',
|
||||
remarkDescription: r.remarkDescription || '',
|
||||
workHours: r.workHours
|
||||
}
|
||||
} catch (e: any) {
|
||||
alert('보고서를 불러오는데 실패했습니다.')
|
||||
router.push('/report/weekly')
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!form.value.projectId || !form.value.workDescription) {
|
||||
alert('프로젝트와 금주 실적은 필수입니다.')
|
||||
return
|
||||
}
|
||||
|
||||
isSubmitting.value = true
|
||||
|
||||
try {
|
||||
if (isEdit.value) {
|
||||
await $fetch(`/api/report/weekly/${route.query.id}/update`, {
|
||||
method: 'PUT',
|
||||
body: form.value
|
||||
})
|
||||
} else {
|
||||
await $fetch('/api/report/weekly/create', {
|
||||
method: 'POST',
|
||||
body: form.value
|
||||
})
|
||||
}
|
||||
router.push('/report/weekly')
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSaveAndSubmit() {
|
||||
if (!form.value.projectId || !form.value.workDescription) {
|
||||
alert('프로젝트와 금주 실적은 필수입니다.')
|
||||
return
|
||||
}
|
||||
|
||||
if (!confirm('저장 후 바로 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
||||
|
||||
isSubmitting.value = true
|
||||
|
||||
try {
|
||||
let reportId: number
|
||||
|
||||
if (isEdit.value) {
|
||||
await $fetch(`/api/report/weekly/${route.query.id}/update`, {
|
||||
method: 'PUT',
|
||||
body: form.value
|
||||
})
|
||||
reportId = Number(route.query.id)
|
||||
} else {
|
||||
const res = await $fetch<{ report: any }>('/api/report/weekly/create', {
|
||||
method: 'POST',
|
||||
body: form.value
|
||||
})
|
||||
reportId = res.report.reportId
|
||||
}
|
||||
|
||||
// 제출
|
||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
||||
router.push('/report/weekly')
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '처리에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
61
nuxt.config.ts
Normal file
61
nuxt.config.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: '2024-11-01',
|
||||
devtools: { enabled: true },
|
||||
|
||||
// 서버 설정
|
||||
nitro: {
|
||||
experimental: {
|
||||
websocket: true
|
||||
}
|
||||
},
|
||||
|
||||
// 라우트 설정
|
||||
dir: {
|
||||
pages: 'frontend',
|
||||
},
|
||||
|
||||
// 서버 API 디렉토리
|
||||
serverDir: 'backend',
|
||||
|
||||
// 컴포넌트 자동 import
|
||||
components: [
|
||||
{ path: '~/frontend/components', pathPrefix: false }
|
||||
],
|
||||
|
||||
// composables 경로
|
||||
imports: {
|
||||
dirs: ['frontend/composables']
|
||||
},
|
||||
|
||||
// 앱 설정
|
||||
app: {
|
||||
head: {
|
||||
title: '주간업무보고',
|
||||
meta: [
|
||||
{ charset: 'utf-8' },
|
||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
|
||||
],
|
||||
link: [
|
||||
{ rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css' },
|
||||
{ rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css' }
|
||||
],
|
||||
script: [
|
||||
{ src: 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js', defer: true }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// 런타임 설정
|
||||
runtimeConfig: {
|
||||
dbHost: process.env.DB_HOST || 'localhost',
|
||||
dbPort: process.env.DB_PORT || '5432',
|
||||
dbName: process.env.DB_NAME || 'weeklyreport',
|
||||
dbUser: process.env.DB_USER || 'postgres',
|
||||
dbPassword: process.env.DB_PASSWORD || '',
|
||||
sessionSecret: process.env.SESSION_SECRET || 'dev-secret-key',
|
||||
public: {
|
||||
appName: '주간업무보고'
|
||||
}
|
||||
}
|
||||
})
|
||||
10585
package-lock.json
generated
Normal file
10585
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
Normal file
25
package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "weekly-report",
|
||||
"version": "1.0.0",
|
||||
"description": "주간업무보고 시스템",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "nuxt dev",
|
||||
"build": "nuxt build",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt": "^3.15.4",
|
||||
"pg": "^8.13.1",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/devtools": "^2.3.1",
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/pg": "^8.11.10",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
}
|
||||
3
tsconfig.json
Normal file
3
tsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "./.nuxt/tsconfig.json"
|
||||
}
|
||||
Reference in New Issue
Block a user