추가
This commit is contained in:
1
.env
1
.env
@@ -7,7 +7,6 @@ DB_PASSWORD=weeklyreport2026
|
||||
|
||||
# App
|
||||
SESSION_SECRET=dev-secret-key-change-in-production
|
||||
AUTO_START_SCHEDULER=false
|
||||
|
||||
# TODO: Google OAuth
|
||||
# GOOGLE_CLIENT_ID=
|
||||
|
||||
37
backend/api/auth/login-history.get.ts
Normal file
37
backend/api/auth/login-history.get.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 본인 로그인 이력 조회
|
||||
* GET /api/auth/login-history
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const history = await query<any>(`
|
||||
SELECT
|
||||
history_id,
|
||||
login_at,
|
||||
login_ip,
|
||||
logout_at,
|
||||
logout_ip,
|
||||
last_active_at
|
||||
FROM wr_login_history
|
||||
WHERE employee_id = $1
|
||||
ORDER BY login_at DESC
|
||||
LIMIT 50
|
||||
`, [userId])
|
||||
|
||||
return {
|
||||
history: history.map(h => ({
|
||||
historyId: h.history_id,
|
||||
loginAt: h.login_at,
|
||||
loginIp: h.login_ip,
|
||||
logoutAt: h.logout_at,
|
||||
logoutIp: h.logout_ip,
|
||||
lastActiveAt: h.last_active_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import { query, insertReturning, execute } from '../../utils/db'
|
||||
import { getClientIp } from '../../utils/ip'
|
||||
|
||||
interface LoginBody {
|
||||
email: string
|
||||
@@ -11,6 +12,7 @@ interface LoginBody {
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<LoginBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
|
||||
if (!body.email || !body.name) {
|
||||
throw createError({ statusCode: 400, message: '이메일과 이름을 입력해주세요.' })
|
||||
@@ -22,31 +24,52 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 400, message: '올바른 이메일 형식이 아닙니다.' })
|
||||
}
|
||||
|
||||
// 기존 사원 조회
|
||||
const emailLower = body.email.toLowerCase()
|
||||
const nameTrimmed = body.name.trim()
|
||||
|
||||
// 기존 직원 조회
|
||||
let employee = await query<any>(`
|
||||
SELECT * FROM wr_employee_info WHERE employee_email = $1
|
||||
`, [body.email.toLowerCase()])
|
||||
`, [emailLower])
|
||||
|
||||
let employeeData = employee[0]
|
||||
|
||||
// 없으면 자동 등록
|
||||
if (!employeeData) {
|
||||
if (employeeData) {
|
||||
// 기존 직원 - 이름이 다르면 업데이트
|
||||
if (employeeData.employee_name !== nameTrimmed) {
|
||||
await execute(`
|
||||
UPDATE wr_employee_info
|
||||
SET employee_name = $1, updated_at = NOW(), updated_ip = $2, updated_email = $3
|
||||
WHERE employee_id = $4
|
||||
`, [nameTrimmed, clientIp, emailLower, employeeData.employee_id])
|
||||
employeeData.employee_name = nameTrimmed
|
||||
}
|
||||
} else {
|
||||
// 신규 직원 자동 등록
|
||||
employeeData = await insertReturning(`
|
||||
INSERT INTO wr_employee_info (employee_name, employee_email)
|
||||
VALUES ($1, $2)
|
||||
INSERT INTO wr_employee_info (employee_name, employee_email, created_ip, created_email, updated_ip, updated_email)
|
||||
VALUES ($1, $2, $3, $2, $3, $2)
|
||||
RETURNING *
|
||||
`, [body.name, body.email.toLowerCase()])
|
||||
`, [nameTrimmed, emailLower, clientIp])
|
||||
}
|
||||
|
||||
// 로그인 이력 추가
|
||||
await execute(`
|
||||
INSERT INTO wr_login_history (employee_id) VALUES ($1)
|
||||
`, [employeeData.employee_id])
|
||||
const loginHistory = await insertReturning(`
|
||||
INSERT INTO wr_login_history (employee_id, login_ip, login_email)
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING history_id
|
||||
`, [employeeData.employee_id, clientIp, emailLower])
|
||||
|
||||
// 쿠키에 사용자 정보 저장 (간단한 임시 세션)
|
||||
// 쿠키에 사용자 정보 저장
|
||||
setCookie(event, 'user_id', String(employeeData.employee_id), {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7, // 7일
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
path: '/'
|
||||
})
|
||||
|
||||
setCookie(event, 'login_history_id', String(loginHistory.history_id), {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
path: '/'
|
||||
})
|
||||
|
||||
|
||||
@@ -1,8 +1,26 @@
|
||||
import { execute } from '../../utils/db'
|
||||
import { getClientIp } from '../../utils/ip'
|
||||
|
||||
/**
|
||||
* 로그아웃
|
||||
* POST /api/auth/logout
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const historyId = getCookie(event, 'login_history_id')
|
||||
const clientIp = getClientIp(event)
|
||||
|
||||
// 로그아웃 이력 기록
|
||||
if (historyId) {
|
||||
await execute(`
|
||||
UPDATE wr_login_history
|
||||
SET logout_at = NOW(), logout_ip = $1
|
||||
WHERE history_id = $2
|
||||
`, [clientIp, historyId])
|
||||
}
|
||||
|
||||
// 쿠키 삭제
|
||||
deleteCookie(event, 'user_id')
|
||||
deleteCookie(event, 'login_history_id')
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
|
||||
43
backend/api/auth/me.get.ts
Normal file
43
backend/api/auth/me.get.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { queryOne } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 로그인된 사용자 정보 조회
|
||||
* GET /api/auth/me
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const employee = await queryOne<any>(`
|
||||
SELECT
|
||||
employee_id,
|
||||
employee_name,
|
||||
employee_email,
|
||||
employee_phone,
|
||||
employee_position,
|
||||
company,
|
||||
join_date,
|
||||
is_active
|
||||
FROM wr_employee_info
|
||||
WHERE employee_id = $1
|
||||
`, [userId])
|
||||
|
||||
if (!employee) {
|
||||
throw createError({ statusCode: 404, message: '사용자를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
return {
|
||||
user: {
|
||||
employeeId: employee.employee_id,
|
||||
employeeName: employee.employee_name,
|
||||
employeeEmail: employee.employee_email,
|
||||
employeePhone: employee.employee_phone,
|
||||
employeePosition: employee.employee_position,
|
||||
company: employee.company,
|
||||
joinDate: employee.join_date,
|
||||
isActive: employee.is_active
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,7 +1,7 @@
|
||||
import { queryOne } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 사원 상세 조회
|
||||
* 직원 상세 조회
|
||||
* GET /api/employee/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
@@ -12,19 +12,21 @@ export default defineEventHandler(async (event) => {
|
||||
`, [employeeId])
|
||||
|
||||
if (!employee) {
|
||||
throw createError({ statusCode: 404, message: '사원을 찾을 수 없습니다.' })
|
||||
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
|
||||
employee: {
|
||||
employeeId: employee.employee_id,
|
||||
employeeName: employee.employee_name,
|
||||
employeeEmail: employee.employee_email,
|
||||
employeePhone: employee.employee_phone,
|
||||
employeePosition: employee.employee_position,
|
||||
company: employee.company,
|
||||
joinDate: employee.join_date,
|
||||
isActive: employee.is_active,
|
||||
createdAt: employee.created_at,
|
||||
updatedAt: employee.updated_at
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,47 +1,55 @@
|
||||
import { execute, queryOne } from '../../../utils/db'
|
||||
import { getClientIp } from '../../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../../utils/user'
|
||||
|
||||
interface UpdateEmployeeBody {
|
||||
employeeNumber?: string
|
||||
employeeName?: string
|
||||
employeePhone?: string
|
||||
employeePosition?: string
|
||||
company?: 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 clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
const existing = await queryOne<any>(`
|
||||
SELECT * FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [employeeId])
|
||||
|
||||
if (!existing) {
|
||||
throw createError({ statusCode: 404, message: '사원을 찾을 수 없습니다.' })
|
||||
throw createError({ statusCode: 404, message: '직원을 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_employee_info SET
|
||||
employee_number = $1,
|
||||
employee_name = $2,
|
||||
employee_phone = $3,
|
||||
employee_position = $4,
|
||||
employee_name = $1,
|
||||
employee_phone = $2,
|
||||
employee_position = $3,
|
||||
company = $4,
|
||||
join_date = $5,
|
||||
is_active = $6,
|
||||
updated_at = NOW()
|
||||
WHERE employee_id = $7
|
||||
updated_at = NOW(),
|
||||
updated_ip = $7,
|
||||
updated_email = $8
|
||||
WHERE employee_id = $9
|
||||
`, [
|
||||
body.employeeNumber ?? existing.employee_number,
|
||||
body.employeeName ?? existing.employee_name,
|
||||
body.employeePhone ?? existing.employee_phone,
|
||||
body.employeePosition ?? existing.employee_position,
|
||||
body.company ?? existing.company,
|
||||
body.joinDate ?? existing.join_date,
|
||||
body.isActive ?? existing.is_active,
|
||||
clientIp,
|
||||
userEmail,
|
||||
employeeId
|
||||
])
|
||||
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
import { insertReturning, queryOne } from '../../utils/db'
|
||||
import { getClientIp } from '../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../utils/user'
|
||||
|
||||
interface CreateEmployeeBody {
|
||||
employeeNumber?: string
|
||||
employeeName: string
|
||||
employeeEmail: string
|
||||
employeePhone?: string
|
||||
employeePosition?: string
|
||||
company?: string
|
||||
joinDate?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 등록
|
||||
* 직원 등록
|
||||
* POST /api/employee/create
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<CreateEmployeeBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
if (!body.employeeName || !body.employeeEmail) {
|
||||
throw createError({ statusCode: 400, message: '이름과 이메일은 필수입니다.' })
|
||||
@@ -31,17 +35,20 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
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)
|
||||
employee_name, employee_email, employee_phone,
|
||||
employee_position, company, join_date,
|
||||
created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $7, $8)
|
||||
RETURNING *
|
||||
`, [
|
||||
body.employeeNumber || null,
|
||||
body.employeeName,
|
||||
body.employeeEmail.toLowerCase(),
|
||||
body.employeePhone || null,
|
||||
body.employeePosition || null,
|
||||
body.joinDate || null
|
||||
body.company || '(주)터보소프트',
|
||||
body.joinDate || null,
|
||||
clientIp,
|
||||
userEmail
|
||||
])
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { query } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 사원 목록 조회
|
||||
* 직원 목록 조회
|
||||
* GET /api/employee/list
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
@@ -16,15 +16,17 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
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
|
||||
}))
|
||||
return {
|
||||
employees: employees.map((e: any) => ({
|
||||
employeeId: e.employee_id,
|
||||
employeeName: e.employee_name,
|
||||
employeeEmail: e.employee_email,
|
||||
employeePhone: e.employee_phone,
|
||||
employeePosition: e.employee_position,
|
||||
company: e.company,
|
||||
joinDate: e.join_date,
|
||||
isActive: e.is_active,
|
||||
createdAt: e.created_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -27,6 +27,7 @@ export default defineEventHandler(async (event) => {
|
||||
projectId: project.project_id,
|
||||
projectCode: project.project_code,
|
||||
projectName: project.project_name,
|
||||
projectType: project.project_type || 'SI',
|
||||
clientName: project.client_name,
|
||||
projectDescription: project.project_description,
|
||||
startDate: project.start_date,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { execute, queryOne, insertReturning } from '../../../utils/db'
|
||||
import { formatDate } from '../../../utils/week-calc'
|
||||
import { getClientIp } from '../../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../../utils/user'
|
||||
|
||||
interface AssignManagerBody {
|
||||
employeeId: number
|
||||
@@ -15,6 +17,8 @@ interface AssignManagerBody {
|
||||
export default defineEventHandler(async (event) => {
|
||||
const projectId = getRouterParam(event, 'id')
|
||||
const body = await readBody<AssignManagerBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
if (!body.employeeId || !body.roleType) {
|
||||
throw createError({ statusCode: 400, message: '담당자와 역할을 선택해주세요.' })
|
||||
@@ -31,17 +35,21 @@ export default defineEventHandler(async (event) => {
|
||||
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])
|
||||
change_reason = COALESCE(change_reason || ' / ', '') || '신규 담당자 지정으로 종료',
|
||||
updated_at = NOW(),
|
||||
updated_ip = $2,
|
||||
updated_email = $3
|
||||
WHERE project_id = $4 AND role_type = $5 AND end_date IS NULL
|
||||
`, [startDate, clientIp, userEmail, 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)
|
||||
project_id, employee_id, role_type, start_date, change_reason,
|
||||
created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $6, $7)
|
||||
RETURNING *
|
||||
`, [projectId, body.employeeId, body.roleType, startDate, body.changeReason || null])
|
||||
`, [projectId, body.employeeId, body.roleType, startDate, body.changeReason || null, clientIp, userEmail])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { execute, queryOne } from '../../../utils/db'
|
||||
import { getClientIp } from '../../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../../utils/user'
|
||||
|
||||
interface UpdateProjectBody {
|
||||
projectCode?: string
|
||||
projectName?: string
|
||||
projectType?: string
|
||||
clientName?: string
|
||||
projectDescription?: string
|
||||
startDate?: string
|
||||
@@ -18,6 +20,8 @@ interface UpdateProjectBody {
|
||||
export default defineEventHandler(async (event) => {
|
||||
const projectId = getRouterParam(event, 'id')
|
||||
const body = await readBody<UpdateProjectBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
const existing = await queryOne<any>(`
|
||||
SELECT * FROM wr_project_info WHERE project_id = $1
|
||||
@@ -27,27 +31,36 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 404, message: '프로젝트를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 프로젝트 유형 검증
|
||||
if (body.projectType && !['SI', 'SM'].includes(body.projectType)) {
|
||||
throw createError({ statusCode: 400, message: '프로젝트 유형은 SI 또는 SM이어야 합니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_project_info SET
|
||||
project_code = $1,
|
||||
project_name = $2,
|
||||
project_name = $1,
|
||||
project_type = $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
|
||||
updated_at = NOW(),
|
||||
updated_ip = $9,
|
||||
updated_email = $10
|
||||
WHERE project_id = $11
|
||||
`, [
|
||||
body.projectCode ?? existing.project_code,
|
||||
body.projectName ?? existing.project_name,
|
||||
body.projectType ?? existing.project_type ?? 'SI',
|
||||
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,
|
||||
clientIp,
|
||||
userEmail,
|
||||
projectId
|
||||
])
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { insertReturning } from '../../utils/db'
|
||||
import { query, insertReturning } from '../../utils/db'
|
||||
import { getClientIp } from '../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../utils/user'
|
||||
|
||||
interface CreateProjectBody {
|
||||
projectCode?: string
|
||||
projectName: string
|
||||
projectType?: string // SI / SM
|
||||
clientName?: string
|
||||
projectDescription?: string
|
||||
startDate?: string
|
||||
@@ -10,38 +12,80 @@ interface CreateProjectBody {
|
||||
contractAmount?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트 코드 자동 생성 (년도-일련번호)
|
||||
*/
|
||||
async function generateProjectCode(): Promise<string> {
|
||||
const year = new Date().getFullYear()
|
||||
const prefix = `${year}-`
|
||||
|
||||
// 해당 연도의 마지막 코드 조회
|
||||
const result = await query<{ project_code: string }>(`
|
||||
SELECT project_code FROM wr_project_info
|
||||
WHERE project_code LIKE $1
|
||||
ORDER BY project_code DESC
|
||||
LIMIT 1
|
||||
`, [`${prefix}%`])
|
||||
|
||||
let nextNum = 1
|
||||
if (result.length > 0 && result[0].project_code) {
|
||||
const lastCode = result[0].project_code
|
||||
const lastNum = parseInt(lastCode.split('-')[1]) || 0
|
||||
nextNum = lastNum + 1
|
||||
}
|
||||
|
||||
return `${prefix}${String(nextNum).padStart(3, '0')}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트 등록
|
||||
* POST /api/project/create
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<CreateProjectBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
if (!body.projectName) {
|
||||
throw createError({ statusCode: 400, message: '프로젝트명을 입력해주세요.' })
|
||||
}
|
||||
|
||||
// 프로젝트 유형 검증
|
||||
const projectType = body.projectType || 'SI'
|
||||
if (!['SI', 'SM'].includes(projectType)) {
|
||||
throw createError({ statusCode: 400, message: '프로젝트 유형은 SI 또는 SM이어야 합니다.' })
|
||||
}
|
||||
|
||||
// 프로젝트 코드 자동 생성
|
||||
const projectCode = await generateProjectCode()
|
||||
|
||||
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)
|
||||
project_code, project_name, project_type, client_name, project_description,
|
||||
start_date, end_date, contract_amount,
|
||||
created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $9, $10)
|
||||
RETURNING *
|
||||
`, [
|
||||
body.projectCode || null,
|
||||
projectCode,
|
||||
body.projectName,
|
||||
projectType,
|
||||
body.clientName || null,
|
||||
body.projectDescription || null,
|
||||
body.startDate || null,
|
||||
body.endDate || null,
|
||||
body.contractAmount || null
|
||||
body.contractAmount || null,
|
||||
clientIp,
|
||||
userEmail
|
||||
])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
project: {
|
||||
projectId: project.project_id,
|
||||
projectName: project.project_name
|
||||
projectCode: project.project_code,
|
||||
projectName: project.project_name,
|
||||
projectType: project.project_type
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -38,6 +38,7 @@ export default defineEventHandler(async (event) => {
|
||||
projectId: p.project_id,
|
||||
projectCode: p.project_code,
|
||||
projectName: p.project_name,
|
||||
projectType: p.project_type || 'SI',
|
||||
clientName: p.client_name,
|
||||
projectDescription: p.project_description,
|
||||
startDate: p.start_date,
|
||||
|
||||
@@ -21,12 +21,24 @@ export default defineEventHandler(async (event) => {
|
||||
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
|
||||
SELECT
|
||||
r.report_id,
|
||||
r.author_id,
|
||||
e.employee_name as author_name,
|
||||
e.employee_position,
|
||||
r.issue_description,
|
||||
r.vacation_description,
|
||||
r.remark_description,
|
||||
r.report_status,
|
||||
r.submitted_at,
|
||||
rp.work_description,
|
||||
rp.plan_description
|
||||
FROM wr_weekly_report r
|
||||
JOIN wr_weekly_report_project rp ON r.report_id = rp.report_id
|
||||
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
|
||||
WHERE rp.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])
|
||||
|
||||
@@ -41,7 +53,6 @@ export default defineEventHandler(async (event) => {
|
||||
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,
|
||||
@@ -56,8 +67,8 @@ export default defineEventHandler(async (event) => {
|
||||
workDescription: r.work_description,
|
||||
planDescription: r.plan_description,
|
||||
issueDescription: r.issue_description,
|
||||
vacationDescription: r.vacation_description,
|
||||
remarkDescription: r.remark_description,
|
||||
workHours: r.work_hours,
|
||||
reportStatus: r.report_status,
|
||||
submittedAt: r.submitted_at
|
||||
}))
|
||||
|
||||
108
backend/api/report/summary/aggregate.post.ts
Normal file
108
backend/api/report/summary/aggregate.post.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { query, queryOne, insertReturning, execute } from '../../../utils/db'
|
||||
import { getClientIp } from '../../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../../utils/user'
|
||||
|
||||
interface AggregateBody {
|
||||
projectId: number
|
||||
reportYear: number
|
||||
reportWeek: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 수동 취합 실행
|
||||
* POST /api/report/summary/aggregate
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const body = await readBody<AggregateBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
if (!body.projectId || !body.reportYear || !body.reportWeek) {
|
||||
throw createError({ statusCode: 400, message: '프로젝트, 연도, 주차를 선택해주세요.' })
|
||||
}
|
||||
|
||||
// 해당 프로젝트/주차의 제출된 보고서 조회 (새 구조)
|
||||
const reports = await query<any>(`
|
||||
SELECT
|
||||
r.report_id,
|
||||
r.author_id,
|
||||
r.week_start_date,
|
||||
r.week_end_date,
|
||||
rp.detail_id
|
||||
FROM wr_weekly_report r
|
||||
JOIN wr_weekly_report_project rp ON r.report_id = rp.report_id
|
||||
WHERE rp.project_id = $1
|
||||
AND r.report_year = $2
|
||||
AND r.report_week = $3
|
||||
AND r.report_status IN ('SUBMITTED', 'AGGREGATED')
|
||||
ORDER BY r.report_id
|
||||
`, [body.projectId, body.reportYear, body.reportWeek])
|
||||
|
||||
if (reports.length === 0) {
|
||||
throw createError({ statusCode: 400, message: '취합할 보고서가 없습니다.' })
|
||||
}
|
||||
|
||||
const reportIds = [...new Set(reports.map(r => r.report_id))]
|
||||
const weekStartDate = reports[0].week_start_date
|
||||
const weekEndDate = reports[0].week_end_date
|
||||
|
||||
// 기존 취합 보고서 확인
|
||||
const existing = await queryOne<any>(`
|
||||
SELECT summary_id FROM wr_aggregated_report_summary
|
||||
WHERE project_id = $1 AND report_year = $2 AND report_week = $3
|
||||
`, [body.projectId, body.reportYear, body.reportWeek])
|
||||
|
||||
let summaryId: number
|
||||
|
||||
if (existing) {
|
||||
// 기존 취합 업데이트
|
||||
await execute(`
|
||||
UPDATE wr_aggregated_report_summary
|
||||
SET report_ids = $1,
|
||||
member_count = $2,
|
||||
aggregated_at = NOW(),
|
||||
updated_at = NOW(),
|
||||
updated_ip = $3,
|
||||
updated_email = $4
|
||||
WHERE summary_id = $5
|
||||
`, [reportIds, reportIds.length, clientIp, userEmail, existing.summary_id])
|
||||
summaryId = existing.summary_id
|
||||
} else {
|
||||
// 새 취합 생성
|
||||
const newSummary = await insertReturning<any>(`
|
||||
INSERT INTO wr_aggregated_report_summary (
|
||||
project_id, report_year, report_week, week_start_date, week_end_date,
|
||||
report_ids, member_count,
|
||||
created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $8, $9)
|
||||
RETURNING summary_id
|
||||
`, [
|
||||
body.projectId, body.reportYear, body.reportWeek,
|
||||
weekStartDate, weekEndDate,
|
||||
reportIds, reportIds.length,
|
||||
clientIp, userEmail
|
||||
])
|
||||
summaryId = newSummary.summary_id
|
||||
}
|
||||
|
||||
// 개별 보고서 상태 업데이트
|
||||
await execute(`
|
||||
UPDATE wr_weekly_report
|
||||
SET report_status = 'AGGREGATED',
|
||||
updated_at = NOW(),
|
||||
updated_ip = $1,
|
||||
updated_email = $2
|
||||
WHERE report_id = ANY($3)
|
||||
`, [clientIp, userEmail, reportIds])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
summaryId,
|
||||
memberCount: reportIds.length
|
||||
}
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import { queryOne } from '../../../../utils/db'
|
||||
import { query, queryOne } from '../../../../utils/db'
|
||||
|
||||
/**
|
||||
* 주간보고 상세 조회
|
||||
@@ -12,10 +12,13 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
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
|
||||
SELECT
|
||||
r.*,
|
||||
e.employee_name as author_name,
|
||||
e.employee_email as author_email
|
||||
FROM wr_weekly_report r
|
||||
JOIN wr_employee_info e ON r.author_id = e.employee_id
|
||||
WHERE r.report_id = $1
|
||||
`, [reportId])
|
||||
@@ -24,25 +27,46 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 프로젝트별 실적 조회
|
||||
const projects = await query<any>(`
|
||||
SELECT
|
||||
rp.detail_id,
|
||||
rp.project_id,
|
||||
p.project_code,
|
||||
p.project_name,
|
||||
rp.work_description,
|
||||
rp.plan_description
|
||||
FROM wr_weekly_report_project rp
|
||||
JOIN wr_project_info p ON rp.project_id = p.project_id
|
||||
WHERE rp.report_id = $1
|
||||
ORDER BY rp.detail_id
|
||||
`, [reportId])
|
||||
|
||||
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
|
||||
report: {
|
||||
reportId: report.report_id,
|
||||
authorId: report.author_id,
|
||||
authorName: report.author_name,
|
||||
authorEmail: report.author_email,
|
||||
reportYear: report.report_year,
|
||||
reportWeek: report.report_week,
|
||||
weekStartDate: report.week_start_date,
|
||||
weekEndDate: report.week_end_date,
|
||||
issueDescription: report.issue_description,
|
||||
vacationDescription: report.vacation_description,
|
||||
remarkDescription: report.remark_description,
|
||||
reportStatus: report.report_status,
|
||||
submittedAt: report.submitted_at,
|
||||
createdAt: report.created_at,
|
||||
updatedAt: report.updated_at
|
||||
},
|
||||
projects: projects.map((p: any) => ({
|
||||
detailId: p.detail_id,
|
||||
projectId: p.project_id,
|
||||
projectCode: p.project_code,
|
||||
projectName: p.project_name,
|
||||
workDescription: p.work_description,
|
||||
planDescription: p.plan_description
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { execute, queryOne } from '../../../../utils/db'
|
||||
import { getClientIp } from '../../../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../../../utils/user'
|
||||
|
||||
/**
|
||||
* 주간보고 제출
|
||||
@@ -11,10 +13,12 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
const reportId = getRouterParam(event, 'id')
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
// 보고서 조회 및 권한 확인
|
||||
const report = await queryOne<any>(`
|
||||
SELECT * FROM wr_weekly_report_detail WHERE report_id = $1
|
||||
SELECT * FROM wr_weekly_report WHERE report_id = $1
|
||||
`, [reportId])
|
||||
|
||||
if (!report) {
|
||||
@@ -25,13 +29,19 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 403, message: '본인의 보고서만 제출할 수 있습니다.' })
|
||||
}
|
||||
|
||||
if (report.report_status !== 'DRAFT') {
|
||||
throw createError({ statusCode: 400, message: '이미 제출된 보고서입니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_weekly_report_detail SET
|
||||
UPDATE wr_weekly_report SET
|
||||
report_status = 'SUBMITTED',
|
||||
submitted_at = NOW(),
|
||||
updated_at = NOW()
|
||||
WHERE report_id = $1
|
||||
`, [reportId])
|
||||
updated_at = NOW(),
|
||||
updated_ip = $1,
|
||||
updated_email = $2
|
||||
WHERE report_id = $3
|
||||
`, [clientIp, userEmail, reportId])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { execute, queryOne } from '../../../../utils/db'
|
||||
import { execute, query, queryOne } from '../../../../utils/db'
|
||||
import { getClientIp } from '../../../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../../../utils/user'
|
||||
|
||||
interface UpdateReportBody {
|
||||
interface ProjectItem {
|
||||
projectId: number
|
||||
workDescription?: string
|
||||
planDescription?: string
|
||||
}
|
||||
|
||||
interface UpdateReportBody {
|
||||
projects?: ProjectItem[]
|
||||
issueDescription?: string
|
||||
vacationDescription?: string
|
||||
remarkDescription?: string
|
||||
workHours?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,10 +27,12 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const reportId = getRouterParam(event, 'id')
|
||||
const body = await readBody<UpdateReportBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
// 보고서 조회 및 권한 확인
|
||||
const report = await queryOne<any>(`
|
||||
SELECT * FROM wr_weekly_report_detail WHERE report_id = $1
|
||||
SELECT * FROM wr_weekly_report WHERE report_id = $1
|
||||
`, [reportId])
|
||||
|
||||
if (!report) {
|
||||
@@ -34,23 +43,50 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 403, message: '본인의 보고서만 수정할 수 있습니다.' })
|
||||
}
|
||||
|
||||
if (report.report_status === 'SUBMITTED' || report.report_status === 'AGGREGATED') {
|
||||
throw createError({ statusCode: 400, 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()
|
||||
UPDATE wr_weekly_report SET
|
||||
issue_description = $1,
|
||||
vacation_description = $2,
|
||||
remark_description = $3,
|
||||
updated_at = NOW(),
|
||||
updated_ip = $4,
|
||||
updated_email = $5
|
||||
WHERE report_id = $6
|
||||
`, [
|
||||
body.workDescription ?? report.work_description,
|
||||
body.planDescription ?? report.plan_description,
|
||||
body.issueDescription ?? report.issue_description,
|
||||
body.vacationDescription ?? report.vacation_description,
|
||||
body.remarkDescription ?? report.remark_description,
|
||||
body.workHours ?? report.work_hours,
|
||||
clientIp,
|
||||
userEmail,
|
||||
reportId
|
||||
])
|
||||
|
||||
// 프로젝트별 실적 업데이트
|
||||
if (body.projects && body.projects.length > 0) {
|
||||
// 기존 삭제 후 재등록
|
||||
await execute(`DELETE FROM wr_weekly_report_project WHERE report_id = $1`, [reportId])
|
||||
|
||||
for (const proj of body.projects) {
|
||||
await execute(`
|
||||
INSERT INTO wr_weekly_report_project (
|
||||
report_id, project_id, work_description, plan_description,
|
||||
created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $5, $6)
|
||||
`, [
|
||||
reportId,
|
||||
proj.projectId,
|
||||
proj.workDescription || null,
|
||||
proj.planDescription || null,
|
||||
clientIp,
|
||||
userEmail
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
import { insertReturning, queryOne } from '../../../utils/db'
|
||||
import { query, insertReturning, execute } from '../../../utils/db'
|
||||
import { getWeekInfo } from '../../../utils/week-calc'
|
||||
import { getClientIp } from '../../../utils/ip'
|
||||
import { getCurrentUserEmail } from '../../../utils/user'
|
||||
|
||||
interface CreateReportBody {
|
||||
interface ProjectItem {
|
||||
projectId: number
|
||||
reportYear?: number
|
||||
reportWeek?: number
|
||||
workDescription?: string
|
||||
planDescription?: string
|
||||
}
|
||||
|
||||
interface CreateReportBody {
|
||||
reportYear?: number
|
||||
reportWeek?: number
|
||||
projects: ProjectItem[]
|
||||
issueDescription?: string
|
||||
vacationDescription?: string
|
||||
remarkDescription?: string
|
||||
workHours?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,9 +29,11 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
const body = await readBody<CreateReportBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
const userEmail = await getCurrentUserEmail(event)
|
||||
|
||||
if (!body.projectId) {
|
||||
throw createError({ statusCode: 400, message: '프로젝트를 선택해주세요.' })
|
||||
if (!body.projects || body.projects.length === 0) {
|
||||
throw createError({ statusCode: 400, message: '최소 1개 이상의 프로젝트를 추가해주세요.' })
|
||||
}
|
||||
|
||||
// 주차 정보 (기본값: 이번 주)
|
||||
@@ -34,40 +42,57 @@ export default defineEventHandler(async (event) => {
|
||||
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])
|
||||
const existing = await query(`
|
||||
SELECT report_id FROM wr_weekly_report
|
||||
WHERE author_id = $1 AND report_year = $2 AND report_week = $3
|
||||
`, [parseInt(userId), year, week])
|
||||
|
||||
if (existing) {
|
||||
if (existing.length > 0) {
|
||||
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,
|
||||
INSERT INTO wr_weekly_report (
|
||||
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')
|
||||
issue_description, vacation_description, remark_description,
|
||||
report_status, created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, 'DRAFT', $9, $10, $9, $10)
|
||||
RETURNING *
|
||||
`, [
|
||||
body.projectId,
|
||||
parseInt(userId),
|
||||
year,
|
||||
week,
|
||||
dates.startDateStr,
|
||||
dates.endDateStr,
|
||||
body.workDescription || null,
|
||||
body.planDescription || null,
|
||||
body.issueDescription || null,
|
||||
body.vacationDescription || null,
|
||||
body.remarkDescription || null,
|
||||
body.workHours || null
|
||||
clientIp,
|
||||
userEmail
|
||||
])
|
||||
|
||||
// 프로젝트별 실적 저장
|
||||
for (const proj of body.projects) {
|
||||
await execute(`
|
||||
INSERT INTO wr_weekly_report_project (
|
||||
report_id, project_id, work_description, plan_description,
|
||||
created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $5, $6)
|
||||
`, [
|
||||
report.report_id,
|
||||
proj.projectId,
|
||||
proj.workDescription || null,
|
||||
proj.planDescription || null,
|
||||
clientIp,
|
||||
userEmail
|
||||
])
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
reportId: report.report_id
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { query } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 내 주간보고 목록
|
||||
* 주간보고 목록 조회
|
||||
* GET /api/report/weekly/list
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
@@ -11,50 +11,45 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
const queryParams = getQuery(event)
|
||||
const year = queryParams.year ? parseInt(queryParams.year as string) : null
|
||||
const projectId = queryParams.projectId ? parseInt(queryParams.projectId as string) : null
|
||||
const limit = parseInt(queryParams.limit as string) || 20
|
||||
|
||||
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
|
||||
const reports = await query<any>(`
|
||||
SELECT
|
||||
r.report_id,
|
||||
r.author_id,
|
||||
e.employee_name as author_name,
|
||||
r.report_year,
|
||||
r.report_week,
|
||||
r.week_start_date,
|
||||
r.week_end_date,
|
||||
r.issue_description,
|
||||
r.vacation_description,
|
||||
r.report_status,
|
||||
r.submitted_at,
|
||||
r.created_at,
|
||||
(SELECT COUNT(*) FROM wr_weekly_report_project WHERE report_id = r.report_id) as project_count
|
||||
FROM wr_weekly_report r
|
||||
JOIN wr_employee_info e ON r.author_id = e.employee_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)
|
||||
ORDER BY r.report_year DESC, r.report_week DESC
|
||||
LIMIT $2
|
||||
`, [userId, limit])
|
||||
|
||||
return {
|
||||
reports: reports.map((r: any) => ({
|
||||
reportId: r.report_id,
|
||||
projectId: r.project_id,
|
||||
projectName: r.project_name,
|
||||
projectCode: r.project_code,
|
||||
authorId: r.author_id,
|
||||
authorName: r.author_name,
|
||||
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,
|
||||
vacationDescription: r.vacation_description,
|
||||
reportStatus: r.report_status,
|
||||
submittedAt: r.submitted_at,
|
||||
createdAt: r.created_at,
|
||||
updatedAt: r.updated_at
|
||||
projectCount: parseInt(r.project_count)
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { getSchedulerStatus } from '../../utils/report-scheduler'
|
||||
|
||||
/**
|
||||
* 스케줄러 상태 조회
|
||||
* GET /api/scheduler/status
|
||||
*/
|
||||
export default defineEventHandler(async () => {
|
||||
return getSchedulerStatus()
|
||||
})
|
||||
@@ -1,27 +0,0 @@
|
||||
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}`
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -9,14 +9,12 @@ let pool: pg.Pool | null = null
|
||||
*/
|
||||
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,
|
||||
host: process.env.DB_HOST || 'localhost',
|
||||
port: parseInt(process.env.DB_PORT || '5432'),
|
||||
database: process.env.DB_NAME || 'weeklyreport',
|
||||
user: process.env.DB_USER || 'postgres',
|
||||
password: process.env.DB_PASSWORD || '',
|
||||
max: 10,
|
||||
idleTimeoutMillis: 30000,
|
||||
connectionTimeoutMillis: 2000,
|
||||
|
||||
33
backend/utils/ip.ts
Normal file
33
backend/utils/ip.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { H3Event } from 'h3'
|
||||
|
||||
/**
|
||||
* 클라이언트 IP 주소 가져오기
|
||||
*/
|
||||
export function getClientIp(event: H3Event): string {
|
||||
// 프록시/로드밸런서 뒤에 있을 경우
|
||||
const xForwardedFor = getHeader(event, 'x-forwarded-for')
|
||||
if (xForwardedFor) {
|
||||
return xForwardedFor.split(',')[0].trim()
|
||||
}
|
||||
|
||||
const xRealIp = getHeader(event, 'x-real-ip')
|
||||
if (xRealIp) {
|
||||
return xRealIp
|
||||
}
|
||||
|
||||
// 직접 연결
|
||||
const remoteAddress = event.node.req.socket?.remoteAddress
|
||||
if (remoteAddress) {
|
||||
// IPv6 localhost를 IPv4로 변환
|
||||
if (remoteAddress === '::1' || remoteAddress === '::ffff:127.0.0.1') {
|
||||
return '127.0.0.1'
|
||||
}
|
||||
// IPv6 매핑된 IPv4 주소 처리
|
||||
if (remoteAddress.startsWith('::ffff:')) {
|
||||
return remoteAddress.substring(7)
|
||||
}
|
||||
return remoteAddress
|
||||
}
|
||||
|
||||
return 'unknown'
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
16
backend/utils/user.ts
Normal file
16
backend/utils/user.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { H3Event } from 'h3'
|
||||
import { queryOne } from './db'
|
||||
|
||||
/**
|
||||
* 현재 로그인한 사용자의 이메일 조회
|
||||
*/
|
||||
export async function getCurrentUserEmail(event: H3Event): Promise<string | null> {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) return null
|
||||
|
||||
const user = await queryOne<{ employee_email: string }>(`
|
||||
SELECT employee_email FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [parseInt(userId)])
|
||||
|
||||
return user?.employee_email || null
|
||||
}
|
||||
@@ -34,17 +34,17 @@
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NuxtLink class="nav-link" to="/employee" active-class="active">
|
||||
<i class="bi bi-people me-1"></i> 사원관리
|
||||
<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">
|
||||
<NuxtLink to="/mypage" class="text-white text-decoration-none me-3 user-link">
|
||||
<i class="bi bi-person-circle me-1"></i>
|
||||
{{ currentUser.employeeName }}
|
||||
</span>
|
||||
</NuxtLink>
|
||||
<button class="btn btn-outline-light btn-sm" @click="handleLogout">
|
||||
<i class="bi bi-box-arrow-right"></i> 로그아웃
|
||||
</button>
|
||||
@@ -74,4 +74,13 @@ async function handleLogout() {
|
||||
.nav-link.active {
|
||||
font-weight: 500;
|
||||
}
|
||||
.user-link {
|
||||
cursor: pointer;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 0.25rem;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
.user-link:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<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>사원 정보
|
||||
<i class="bi bi-person me-2"></i>직원 정보
|
||||
</h5>
|
||||
<span :class="employee.isActive ? 'badge bg-success' : 'badge bg-secondary'">
|
||||
{{ employee.isActive ? '재직' : '퇴직' }}
|
||||
@@ -31,19 +31,33 @@
|
||||
<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" />
|
||||
<label class="form-label">소속사</label>
|
||||
<select class="form-select" v-model="form.company">
|
||||
<option value="(주)터보소프트">(주)터보소프트</option>
|
||||
<option value="(주)코쿤">(주)코쿤</option>
|
||||
<option value="(주)오솔정보기술">(주)오솔정보기술</option>
|
||||
</select>
|
||||
</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>
|
||||
<optgroup label="일반">
|
||||
<option value="사원">사원</option>
|
||||
<option value="대리">대리</option>
|
||||
<option value="과장">과장</option>
|
||||
<option value="차장">차장</option>
|
||||
<option value="부장">부장</option>
|
||||
<option value="이사">이사</option>
|
||||
</optgroup>
|
||||
<optgroup label="연구소">
|
||||
<option value="연구원">연구원</option>
|
||||
<option value="주임연구원">주임연구원</option>
|
||||
<option value="선임연구원">선임연구원</option>
|
||||
<option value="책임연구원">책임연구원</option>
|
||||
<option value="수석연구원">수석연구원</option>
|
||||
<option value="소장">소장</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
@@ -114,7 +128,7 @@ const isSubmitting = ref(false)
|
||||
const form = ref({
|
||||
employeeName: '',
|
||||
employeeEmail: '',
|
||||
employeeNumber: '',
|
||||
company: '(주)터보소프트',
|
||||
employeePosition: '',
|
||||
employeePhone: '',
|
||||
joinDate: '',
|
||||
@@ -141,14 +155,14 @@ async function loadEmployee() {
|
||||
form.value = {
|
||||
employeeName: e.employeeName || '',
|
||||
employeeEmail: e.employeeEmail || '',
|
||||
employeeNumber: e.employeeNumber || '',
|
||||
company: e.company || '(주)터보소프트',
|
||||
employeePosition: e.employeePosition || '',
|
||||
employeePhone: e.employeePhone || '',
|
||||
joinDate: e.joinDate ? e.joinDate.split('T')[0] : '',
|
||||
isActive: e.isActive
|
||||
}
|
||||
} catch (e: any) {
|
||||
alert('사원 정보를 불러오는데 실패했습니다.')
|
||||
alert('직원 정보를 불러오는데 실패했습니다.')
|
||||
router.push('/employee')
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<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>
|
||||
<h4><i class="bi bi-people me-2"></i>직원 관리</h4>
|
||||
<p class="text-muted mb-0">총 {{ employees.length }}명</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="showCreateModal = true">
|
||||
<i class="bi bi-plus-lg me-1"></i> 사원 등록
|
||||
<i class="bi bi-plus-lg me-1"></i> 직원 등록
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -23,13 +23,14 @@
|
||||
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 class="col-md-2">
|
||||
<select class="form-select" v-model="filterStatus">
|
||||
<option value="">전체</option>
|
||||
<option value="active">재직</option>
|
||||
<option value="inactive">퇴직</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,23 +42,29 @@
|
||||
<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: 150px">소속사</th>
|
||||
<th style="width: 120px">직급</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>
|
||||
<tr v-if="isLoading">
|
||||
<td colspan="6" class="text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else v-for="emp in filteredEmployees" :key="emp.employeeId">
|
||||
<td><strong>{{ emp.employeeName }}</strong></td>
|
||||
<td>{{ emp.employeeEmail }}</td>
|
||||
<td>{{ emp.company || '-' }}</td>
|
||||
<td>{{ emp.employeeEmail }}</td>
|
||||
<td>{{ emp.employeePosition || '-' }}</td>
|
||||
<td>
|
||||
<span :class="emp.isActive ? 'badge bg-success' : 'badge bg-secondary'">
|
||||
{{ emp.isActive ? '재직' : '퇴직' }}
|
||||
<span :class="emp.isActive !== false ? 'badge bg-success' : 'badge bg-secondary'">
|
||||
{{ emp.isActive !== false ? '재직' : '퇴직' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
@@ -69,10 +76,10 @@
|
||||
</NuxtLink>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="employees.length === 0">
|
||||
<tr v-if="!isLoading && filteredEmployees.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>
|
||||
<p class="mt-2 mb-0">직원 정보가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -86,7 +93,7 @@
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">사원 등록</h5>
|
||||
<h5 class="modal-title">직원 등록</h5>
|
||||
<button type="button" class="btn-close" @click="showCreateModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@@ -99,19 +106,33 @@
|
||||
<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" />
|
||||
<label class="form-label">소속사</label>
|
||||
<select class="form-select" v-model="newEmployee.company">
|
||||
<option value="(주)터보소프트">(주)터보소프트</option>
|
||||
<option value="(주)코쿤">(주)코쿤</option>
|
||||
<option value="(주)오솔정보기술">(주)오솔정보기술</option>
|
||||
</select>
|
||||
</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>
|
||||
<optgroup label="일반">
|
||||
<option value="사원">사원</option>
|
||||
<option value="대리">대리</option>
|
||||
<option value="과장">과장</option>
|
||||
<option value="차장">차장</option>
|
||||
<option value="부장">부장</option>
|
||||
<option value="이사">이사</option>
|
||||
</optgroup>
|
||||
<optgroup label="연구소">
|
||||
<option value="연구원">연구원</option>
|
||||
<option value="주임연구원">주임연구원</option>
|
||||
<option value="선임연구원">선임연구원</option>
|
||||
<option value="책임연구원">책임연구원</option>
|
||||
<option value="수석연구원">수석연구원</option>
|
||||
<option value="소장">소장</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
@@ -142,17 +163,40 @@ const router = useRouter()
|
||||
|
||||
const employees = ref<any[]>([])
|
||||
const searchKeyword = ref('')
|
||||
const filterStatus = ref('')
|
||||
const showCreateModal = ref(false)
|
||||
const isLoading = ref(true)
|
||||
|
||||
const newEmployee = ref({
|
||||
employeeName: '',
|
||||
employeeEmail: '',
|
||||
employeeNumber: '',
|
||||
company: '(주)터보소프트',
|
||||
employeePosition: '',
|
||||
employeePhone: '',
|
||||
joinDate: ''
|
||||
})
|
||||
|
||||
// 검색어/필터로 자동 필터링
|
||||
const filteredEmployees = computed(() => {
|
||||
let list = employees.value
|
||||
|
||||
if (searchKeyword.value) {
|
||||
const keyword = searchKeyword.value.toLowerCase()
|
||||
list = list.filter(e =>
|
||||
e.employeeName?.toLowerCase().includes(keyword) ||
|
||||
e.employeeEmail?.toLowerCase().includes(keyword)
|
||||
)
|
||||
}
|
||||
|
||||
if (filterStatus.value === 'active') {
|
||||
list = list.filter(e => e.isActive !== false)
|
||||
} else if (filterStatus.value === 'inactive') {
|
||||
list = list.filter(e => e.isActive === false)
|
||||
}
|
||||
|
||||
return list
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
@@ -164,14 +208,14 @@ onMounted(async () => {
|
||||
})
|
||||
|
||||
async function loadEmployees() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const query: Record<string, any> = {}
|
||||
if (searchKeyword.value) query.keyword = searchKeyword.value
|
||||
|
||||
const res = await $fetch<{ employees: any[] }>('/api/employee/list', { query })
|
||||
const res = await $fetch<{ employees: any[] }>('/api/employee/list')
|
||||
employees.value = res.employees || []
|
||||
} catch (e) {
|
||||
console.error('Load employees error:', e)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +234,7 @@ async function createEmployee() {
|
||||
newEmployee.value = {
|
||||
employeeName: '',
|
||||
employeeEmail: '',
|
||||
employeeNumber: '',
|
||||
company: '(주)터보소프트',
|
||||
employeePosition: '',
|
||||
employeePhone: '',
|
||||
joinDate: ''
|
||||
|
||||
265
frontend/mypage/index.vue
Normal file
265
frontend/mypage/index.vue
Normal file
@@ -0,0 +1,265 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container py-4">
|
||||
<h2 class="mb-4">👤 마이페이지</h2>
|
||||
|
||||
<!-- 내 정보 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<strong>내 정보</strong>
|
||||
<button v-if="!isEditing" class="btn btn-sm btn-outline-primary" @click="startEdit">
|
||||
수정
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-if="isLoading" class="text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||
</div>
|
||||
<div v-else>
|
||||
<!-- 보기 모드 -->
|
||||
<div v-if="!isEditing">
|
||||
<div class="row mb-2">
|
||||
<div class="col-3 text-muted">이름</div>
|
||||
<div class="col-9"><strong>{{ userInfo.employeeName }}</strong></div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-3 text-muted">이메일</div>
|
||||
<div class="col-9">{{ userInfo.employeeEmail }}</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-3 text-muted">소속사</div>
|
||||
<div class="col-9">{{ userInfo.company || '-' }}</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-3 text-muted">직급</div>
|
||||
<div class="col-9">{{ userInfo.employeePosition || '-' }}</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-3 text-muted">연락처</div>
|
||||
<div class="col-9">{{ userInfo.employeePhone || '-' }}</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-3 text-muted">입사일</div>
|
||||
<div class="col-9">{{ userInfo.joinDate ? userInfo.joinDate.split('T')[0] : '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 수정 모드 -->
|
||||
<form v-else @submit.prevent="saveProfile">
|
||||
<div class="row mb-3">
|
||||
<label class="col-3 col-form-label">이름</label>
|
||||
<div class="col-9">
|
||||
<input type="text" class="form-control" v-model="editForm.employeeName" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label class="col-3 col-form-label">이메일</label>
|
||||
<div class="col-9">
|
||||
<input type="email" class="form-control" :value="userInfo.employeeEmail" disabled />
|
||||
<small class="text-muted">이메일은 변경할 수 없습니다.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label class="col-3 col-form-label">소속사</label>
|
||||
<div class="col-9">
|
||||
<select class="form-select" v-model="editForm.company">
|
||||
<option value="(주)터보소프트">(주)터보소프트</option>
|
||||
<option value="(주)코쿤">(주)코쿤</option>
|
||||
<option value="(주)오솔정보기술">(주)오솔정보기술</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label class="col-3 col-form-label">직급</label>
|
||||
<div class="col-9">
|
||||
<select class="form-select" v-model="editForm.employeePosition">
|
||||
<option value="">선택</option>
|
||||
<optgroup label="일반">
|
||||
<option value="사원">사원</option>
|
||||
<option value="대리">대리</option>
|
||||
<option value="과장">과장</option>
|
||||
<option value="차장">차장</option>
|
||||
<option value="부장">부장</option>
|
||||
<option value="이사">이사</option>
|
||||
</optgroup>
|
||||
<optgroup label="연구소">
|
||||
<option value="연구원">연구원</option>
|
||||
<option value="주임연구원">주임연구원</option>
|
||||
<option value="선임연구원">선임연구원</option>
|
||||
<option value="책임연구원">책임연구원</option>
|
||||
<option value="수석연구원">수석연구원</option>
|
||||
<option value="소장">소장</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label class="col-3 col-form-label">연락처</label>
|
||||
<div class="col-9">
|
||||
<input type="tel" class="form-control" v-model="editForm.employeePhone" placeholder="010-0000-0000" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label class="col-3 col-form-label">입사일</label>
|
||||
<div class="col-9">
|
||||
<input type="date" class="form-control" v-model="editForm.joinDate" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<button type="button" class="btn btn-secondary me-2" @click="cancelEdit">취소</button>
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSaving">
|
||||
<span v-if="isSaving" class="spinner-border spinner-border-sm me-1"></span>
|
||||
저장
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 로그인 이력 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<strong>로그인 이력</strong>
|
||||
<small class="text-muted ms-2">(최근 50건)</small>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 180px">로그인 시간</th>
|
||||
<th style="width: 130px">로그인 IP</th>
|
||||
<th style="width: 180px">로그아웃 시간</th>
|
||||
<th style="width: 130px">로그아웃 IP</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="isLoadingHistory">
|
||||
<td colspan="5" class="text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else-if="loginHistory.length === 0">
|
||||
<td colspan="5" class="text-center py-4 text-muted">로그인 이력이 없습니다.</td>
|
||||
</tr>
|
||||
<tr v-else v-for="h in loginHistory" :key="h.historyId">
|
||||
<td>{{ formatDateTime(h.loginAt) }}</td>
|
||||
<td><code>{{ h.loginIp || '-' }}</code></td>
|
||||
<td>{{ h.logoutAt ? formatDateTime(h.logoutAt) : '-' }}</td>
|
||||
<td><code>{{ h.logoutIp || '-' }}</code></td>
|
||||
<td>
|
||||
<span v-if="h.logoutAt" class="badge bg-secondary">로그아웃</span>
|
||||
<span v-else class="badge bg-success">로그인 중</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
const userInfo = ref<any>({})
|
||||
const loginHistory = ref<any[]>([])
|
||||
const isLoading = ref(true)
|
||||
const isLoadingHistory = ref(true)
|
||||
const isEditing = ref(false)
|
||||
const isSaving = ref(false)
|
||||
|
||||
const editForm = ref({
|
||||
employeeName: '',
|
||||
company: '',
|
||||
employeePosition: '',
|
||||
employeePhone: '',
|
||||
joinDate: ''
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
loadUserInfo()
|
||||
loadLoginHistory()
|
||||
})
|
||||
|
||||
async function loadUserInfo() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await $fetch<any>('/api/auth/me')
|
||||
userInfo.value = res.user
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadLoginHistory() {
|
||||
isLoadingHistory.value = true
|
||||
try {
|
||||
const res = await $fetch<any>('/api/auth/login-history')
|
||||
loginHistory.value = res.history
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
isLoadingHistory.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function startEdit() {
|
||||
editForm.value = {
|
||||
employeeName: userInfo.value.employeeName || '',
|
||||
company: userInfo.value.company || '(주)터보소프트',
|
||||
employeePosition: userInfo.value.employeePosition || '',
|
||||
employeePhone: userInfo.value.employeePhone || '',
|
||||
joinDate: userInfo.value.joinDate ? userInfo.value.joinDate.split('T')[0] : ''
|
||||
}
|
||||
isEditing.value = true
|
||||
}
|
||||
|
||||
function cancelEdit() {
|
||||
isEditing.value = false
|
||||
}
|
||||
|
||||
async function saveProfile() {
|
||||
isSaving.value = true
|
||||
try {
|
||||
await $fetch(`/api/employee/${userInfo.value.employeeId}/update`, {
|
||||
method: 'PUT',
|
||||
body: editForm.value
|
||||
})
|
||||
alert('저장되었습니다.')
|
||||
isEditing.value = false
|
||||
loadUserInfo()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return '-'
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleString('ko-KR', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -17,7 +17,7 @@
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
@@ -25,6 +25,13 @@
|
||||
placeholder="프로젝트명 또는 코드 검색"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select class="form-select" v-model="filterType">
|
||||
<option value="">전체 유형</option>
|
||||
<option value="SI">SI</option>
|
||||
<option value="SM">SM</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select class="form-select" v-model="filterStatus">
|
||||
<option value="">전체 상태</option>
|
||||
@@ -48,8 +55,9 @@
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>프로젝트 코드</th>
|
||||
<th style="width: 120px">코드</th>
|
||||
<th>프로젝트명</th>
|
||||
<th style="width: 80px">유형</th>
|
||||
<th>발주처</th>
|
||||
<th style="width: 120px">기간</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
@@ -62,6 +70,11 @@
|
||||
<td>
|
||||
<strong>{{ project.projectName }}</strong>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="getTypeBadgeClass(project.projectType)">
|
||||
{{ project.projectType || 'SI' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ project.clientName || '-' }}</td>
|
||||
<td>
|
||||
<small v-if="project.startDate">
|
||||
@@ -85,7 +98,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="filteredProjects.length === 0">
|
||||
<td colspan="6" class="text-center py-5 text-muted">
|
||||
<td colspan="7" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">프로젝트가 없습니다.</p>
|
||||
</td>
|
||||
@@ -106,14 +119,17 @@
|
||||
</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-4">
|
||||
<label class="form-label">프로젝트 유형 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="newProject.projectType">
|
||||
<option value="SI">SI (시스템 구축)</option>
|
||||
<option value="SM">SM (시스템 유지보수)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">발주처</label>
|
||||
<input type="text" class="form-control" v-model="newProject.clientName" />
|
||||
@@ -135,11 +151,20 @@
|
||||
<textarea class="form-control" v-model="newProject.projectDescription" rows="3"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info mt-3 mb-0">
|
||||
<i class="bi bi-info-circle me-2"></i>
|
||||
프로젝트 코드는 자동 생성됩니다. (예: 2026-001)
|
||||
</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 type="button" class="btn btn-primary" @click="createProject" :disabled="isCreating">
|
||||
<span v-if="isCreating">
|
||||
<span class="spinner-border spinner-border-sm me-1"></span>등록 중...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-check-lg me-1"></i>등록
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -155,14 +180,16 @@ const router = useRouter()
|
||||
|
||||
const projects = ref<any[]>([])
|
||||
const searchKeyword = ref('')
|
||||
const filterType = ref('')
|
||||
const filterStatus = ref('')
|
||||
const showCreateModal = ref(false)
|
||||
const isCreating = ref(false)
|
||||
|
||||
const newProject = ref({
|
||||
projectCode: '',
|
||||
projectName: '',
|
||||
projectType: 'SI',
|
||||
clientName: '',
|
||||
contractAmount: null,
|
||||
contractAmount: null as number | null,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
projectDescription: ''
|
||||
@@ -179,6 +206,10 @@ const filteredProjects = computed(() => {
|
||||
)
|
||||
}
|
||||
|
||||
if (filterType.value) {
|
||||
list = list.filter(p => p.projectType === filterType.value)
|
||||
}
|
||||
|
||||
if (filterStatus.value) {
|
||||
list = list.filter(p => p.projectStatus === filterStatus.value)
|
||||
}
|
||||
@@ -211,27 +242,38 @@ async function createProject() {
|
||||
return
|
||||
}
|
||||
|
||||
isCreating.value = true
|
||||
try {
|
||||
await $fetch('/api/project/create', {
|
||||
method: 'POST',
|
||||
body: newProject.value
|
||||
})
|
||||
showCreateModal.value = false
|
||||
newProject.value = {
|
||||
projectCode: '',
|
||||
projectName: '',
|
||||
clientName: '',
|
||||
contractAmount: null,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
projectDescription: ''
|
||||
}
|
||||
resetNewProject()
|
||||
await loadProjects()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '등록에 실패했습니다.')
|
||||
} finally {
|
||||
isCreating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resetNewProject() {
|
||||
newProject.value = {
|
||||
projectName: '',
|
||||
projectType: 'SI',
|
||||
clientName: '',
|
||||
contractAmount: null,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
projectDescription: ''
|
||||
}
|
||||
}
|
||||
|
||||
function getTypeBadgeClass(type: string) {
|
||||
return type === 'SM' ? 'badge bg-info' : 'badge bg-primary'
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'ACTIVE': 'badge bg-success',
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
<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 class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4><i class="bi bi-collection me-2"></i>취합 보고서</h4>
|
||||
<p class="text-muted mb-0">프로젝트별 주간보고 취합 목록</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="showAggregateModal = true">
|
||||
<i class="bi bi-plus-lg me-1"></i> 취합하기
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 필터 -->
|
||||
@@ -95,14 +100,75 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 취합 모달 -->
|
||||
<div class="modal fade" :class="{ show: showAggregateModal }"
|
||||
:style="{ display: showAggregateModal ? 'block' : 'none' }"
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="bi bi-collection me-2"></i>주간보고 취합
|
||||
</h5>
|
||||
<button type="button" class="btn-close" @click="showAggregateModal = 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="aggregateForm.projectId">
|
||||
<option value="">선택하세요</option>
|
||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
||||
{{ p.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<label class="form-label">연도 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="aggregateForm.reportYear">
|
||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">주차 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="aggregateForm.reportWeek">
|
||||
<option v-for="w in 53" :key="w" :value="w">W{{ String(w).padStart(2, '0') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info mt-3 mb-0">
|
||||
<i class="bi bi-info-circle me-2"></i>
|
||||
선택한 프로젝트/주차의 제출된 보고서를 취합합니다.
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" @click="showAggregateModal = false">
|
||||
취소
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" @click="doAggregate" :disabled="isAggregating">
|
||||
<span v-if="isAggregating">
|
||||
<span class="spinner-border spinner-border-sm me-1"></span>취합 중...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-check-lg me-1"></i>취합하기
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showAggregateModal"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const { getCurrentWeekInfo } = useWeekCalc()
|
||||
const router = useRouter()
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const currentWeek = getCurrentWeekInfo()
|
||||
const years = [currentYear, currentYear - 1, currentYear - 2]
|
||||
|
||||
const filter = ref({
|
||||
@@ -113,6 +179,15 @@ const filter = ref({
|
||||
const summaries = ref<any[]>([])
|
||||
const projects = ref<any[]>([])
|
||||
|
||||
// 취합 모달
|
||||
const showAggregateModal = ref(false)
|
||||
const isAggregating = ref(false)
|
||||
const aggregateForm = ref({
|
||||
projectId: '',
|
||||
reportYear: currentYear,
|
||||
reportWeek: currentWeek.week > 1 ? currentWeek.week - 1 : 1 // 기본값: 지난주
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
@@ -145,6 +220,33 @@ async function loadSummaries() {
|
||||
}
|
||||
}
|
||||
|
||||
async function doAggregate() {
|
||||
if (!aggregateForm.value.projectId) {
|
||||
alert('프로젝트를 선택해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
isAggregating.value = true
|
||||
try {
|
||||
const res = await $fetch<{ success: boolean; memberCount: number }>('/api/report/summary/aggregate', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
projectId: parseInt(aggregateForm.value.projectId as string),
|
||||
reportYear: aggregateForm.value.reportYear,
|
||||
reportWeek: aggregateForm.value.reportWeek
|
||||
}
|
||||
})
|
||||
|
||||
alert(`취합 완료! (${res.memberCount}명의 보고서)`)
|
||||
showAggregateModal.value = false
|
||||
await loadSummaries()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '취합에 실패했습니다.')
|
||||
} finally {
|
||||
isAggregating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'AGGREGATED': 'badge bg-info',
|
||||
@@ -176,3 +278,9 @@ function formatDateTime(dateStr: string) {
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,123 +2,230 @@
|
||||
<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 class="container py-4">
|
||||
<div v-if="isLoading" class="text-center py-5">
|
||||
<span class="spinner-border"></span>
|
||||
<p class="mt-2">로딩 중...</p>
|
||||
</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 v-else-if="report">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="mb-1">
|
||||
<i class="bi bi-journal-text me-2"></i>주간보고
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)" class="ms-2">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
</h4>
|
||||
<p class="text-muted mb-0">
|
||||
{{ report.reportYear }}년 {{ report.reportWeek }}주차
|
||||
({{ formatDate(report.weekStartDate) }} ~ {{ formatDate(report.weekEndDate) }})
|
||||
</p>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<NuxtLink to="/report/weekly" class="btn btn-outline-secondary">목록</NuxtLink>
|
||||
<button v-if="canEdit" class="btn btn-primary" @click="isEditing = !isEditing">
|
||||
{{ isEditing ? '취소' : '수정' }}
|
||||
</button>
|
||||
<button v-if="canSubmit" class="btn btn-success" @click="handleSubmit" :disabled="isSubmitting">
|
||||
<span v-if="isSubmitting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
제출
|
||||
</button>
|
||||
</div>
|
||||
</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 v-if="!isEditing">
|
||||
<!-- 프로젝트별 실적 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||
<span class="badge bg-secondary ms-2">{{ projects.length }}개</span>
|
||||
</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 class="card-body">
|
||||
<div v-for="(proj, idx) in projects" :key="proj.detailId"
|
||||
:class="{ 'border-top pt-3 mt-3': idx > 0 }">
|
||||
<h6 class="mb-3">
|
||||
<i class="bi bi-folder2 me-1"></i>
|
||||
{{ proj.projectName }}
|
||||
<small class="text-muted">({{ proj.projectCode }})</small>
|
||||
</h6>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label text-muted small">금주 실적</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ proj.workDescription || '-' }}</div>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label text-muted small">차주 계획</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ proj.planDescription || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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 class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label text-muted small">이슈/리스크</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ report.issueDescription || '-' }}</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label text-muted small">휴가일정</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ report.vacationDescription || '-' }}</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label text-muted small">기타사항</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ report.remarkDescription || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
<!-- 수정 모드 -->
|
||||
<form v-else @submit.prevent="handleUpdate">
|
||||
<!-- 프로젝트별 실적 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" @click="showProjectModal = true">
|
||||
<i class="bi bi-plus"></i> 프로젝트 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-for="(proj, idx) in editForm.projects" :key="idx" class="border rounded p-3 mb-3">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<strong>{{ proj.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ proj.projectCode }})</small>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" @click="removeProject(idx)">
|
||||
<i class="bi bi-x"></i> 삭제
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">금주 실적</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.workDescription"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">차주 계획</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.planDescription"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</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 class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이슈/리스크</label>
|
||||
<textarea class="form-control" rows="3" v-model="editForm.issueDescription"></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">휴가일정</label>
|
||||
<textarea class="form-control" rows="2" v-model="editForm.vacationDescription"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">기타사항</label>
|
||||
<textarea class="form-control" rows="2" v-model="editForm.remarkDescription"></textarea>
|
||||
</div>
|
||||
</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> 삭제
|
||||
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button type="button" class="btn btn-secondary" @click="isEditing = false">취소</button>
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSaving">
|
||||
<span v-if="isSaving" class="spinner-border spinner-border-sm me-1"></span>
|
||||
저장
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 프로젝트 선택 모달 -->
|
||||
<div class="modal fade" :class="{ show: showProjectModal }" :style="{ display: showProjectModal ? 'block' : 'none' }" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">프로젝트 선택</h5>
|
||||
<button type="button" class="btn-close" @click="showProjectModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div v-if="availableProjects.length === 0" class="text-center text-muted py-4">
|
||||
추가할 수 있는 프로젝트가 없습니다.
|
||||
</div>
|
||||
<div v-else class="list-group">
|
||||
<button type="button" class="list-group-item list-group-item-action"
|
||||
v-for="p in availableProjects" :key="p.projectId"
|
||||
@click="addProject(p)">
|
||||
<strong>{{ p.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ p.projectCode }})</small>
|
||||
</button>
|
||||
</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 class="modal-backdrop fade show" v-if="showProjectModal" @click="showProjectModal = false"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const { currentUser, fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const reportId = route.params.id as string
|
||||
|
||||
const report = ref<any>(null)
|
||||
const projects = ref<any[]>([])
|
||||
const allProjects = ref<any[]>([])
|
||||
const isLoading = ref(true)
|
||||
const isEditing = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const isSubmitting = ref(false)
|
||||
const showProjectModal = ref(false)
|
||||
|
||||
interface EditProjectItem {
|
||||
projectId: number
|
||||
projectCode: string
|
||||
projectName: string
|
||||
workDescription: string
|
||||
planDescription: string
|
||||
}
|
||||
|
||||
const editForm = ref({
|
||||
projects: [] as EditProjectItem[],
|
||||
issueDescription: '',
|
||||
vacationDescription: '',
|
||||
remarkDescription: ''
|
||||
})
|
||||
|
||||
const canEdit = computed(() => {
|
||||
if (!report.value || !currentUser.value) return false
|
||||
return report.value.authorId === currentUser.value.employeeId && report.value.reportStatus === 'DRAFT'
|
||||
})
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
if (!report.value || !currentUser.value) return false
|
||||
return report.value.authorId === currentUser.value.employeeId && report.value.reportStatus === 'DRAFT'
|
||||
})
|
||||
|
||||
const availableProjects = computed(() => {
|
||||
const addedIds = editForm.value.projects.map(p => p.projectId)
|
||||
return allProjects.value.filter(p => !addedIds.includes(p.projectId))
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
@@ -126,43 +233,114 @@ onMounted(async () => {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadReport()
|
||||
await loadAllProjects()
|
||||
})
|
||||
|
||||
async function loadReport() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await $fetch<{ report: any }>(`/api/report/weekly/${route.params.id}/detail`)
|
||||
const res = await $fetch<any>(`/api/report/weekly/${reportId}/detail`)
|
||||
report.value = res.report
|
||||
projects.value = res.projects
|
||||
} catch (e: any) {
|
||||
alert('보고서를 불러오는데 실패했습니다.')
|
||||
alert(e.data?.message || '보고서를 불러올 수 없습니다.')
|
||||
router.push('/report/weekly')
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReport() {
|
||||
if (!confirm('보고서를 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
||||
|
||||
async function loadAllProjects() {
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${route.params.id}/submit`, { method: 'POST' })
|
||||
await loadReport()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '제출에 실패했습니다.')
|
||||
const res = await $fetch<any>('/api/project/list')
|
||||
allProjects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
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 || '삭제에 실패했습니다.')
|
||||
watch(isEditing, (val) => {
|
||||
if (val) {
|
||||
editForm.value = {
|
||||
projects: projects.value.map(p => ({
|
||||
projectId: p.projectId,
|
||||
projectCode: p.projectCode,
|
||||
projectName: p.projectName,
|
||||
workDescription: p.workDescription || '',
|
||||
planDescription: p.planDescription || ''
|
||||
})),
|
||||
issueDescription: report.value.issueDescription || '',
|
||||
vacationDescription: report.value.vacationDescription || '',
|
||||
remarkDescription: report.value.remarkDescription || ''
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function addProject(p: any) {
|
||||
editForm.value.projects.push({
|
||||
projectId: p.projectId,
|
||||
projectCode: p.projectCode,
|
||||
projectName: p.projectName,
|
||||
workDescription: '',
|
||||
planDescription: ''
|
||||
})
|
||||
showProjectModal.value = false
|
||||
}
|
||||
|
||||
function removeProject(idx: number) {
|
||||
editForm.value.projects.splice(idx, 1)
|
||||
}
|
||||
|
||||
async function handleUpdate() {
|
||||
if (editForm.value.projects.length === 0) {
|
||||
alert('최소 1개 이상의 프로젝트가 필요합니다.')
|
||||
return
|
||||
}
|
||||
|
||||
isSaving.value = true
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${reportId}/update`, {
|
||||
method: 'PUT',
|
||||
body: {
|
||||
projects: editForm.value.projects.map(p => ({
|
||||
projectId: p.projectId,
|
||||
workDescription: p.workDescription,
|
||||
planDescription: p.planDescription
|
||||
})),
|
||||
issueDescription: editForm.value.issueDescription,
|
||||
vacationDescription: editForm.value.vacationDescription,
|
||||
remarkDescription: editForm.value.remarkDescription
|
||||
}
|
||||
})
|
||||
alert('저장되었습니다.')
|
||||
isEditing.value = false
|
||||
await loadReport()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!confirm('제출하시겠습니까? 제출 후에는 수정할 수 없습니다.')) return
|
||||
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
||||
alert('제출되었습니다.')
|
||||
await loadReport()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '제출에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
return dateStr.split('T')[0]
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
@@ -182,9 +360,10 @@ function getStatusText(status: string) {
|
||||
}
|
||||
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>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,109 +2,61 @@
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="container 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>
|
||||
<h4 class="mb-0">
|
||||
<i class="bi bi-journal-text me-2"></i>내 주간보고
|
||||
</h4>
|
||||
<NuxtLink to="/report/weekly/write" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i> 새 보고서 작성
|
||||
<i class="bi bi-plus 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 class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 150px">주차</th>
|
||||
<th style="width: 200px">기간</th>
|
||||
<th>프로젝트</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 150px">작성일</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="isLoading">
|
||||
<td colspan="5" class="text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else-if="reports.length === 0">
|
||||
<td colspan="5" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">작성한 주간보고가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else v-for="r in reports" :key="r.reportId"
|
||||
@click="router.push(`/report/weekly/${r.reportId}`)"
|
||||
style="cursor: pointer;">
|
||||
<td>
|
||||
<strong>{{ r.reportYear }}년 {{ r.reportWeek }}주차</strong>
|
||||
</td>
|
||||
<td>{{ formatDate(r.weekStartDate) }} ~ {{ formatDate(r.weekEndDate) }}</td>
|
||||
<td>
|
||||
<span class="badge bg-primary">{{ r.projectCount }}개 프로젝트</span>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="getStatusBadgeClass(r.reportStatus)">
|
||||
{{ getStatusText(r.reportStatus) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ formatDateTime(r.createdAt) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,17 +67,8 @@
|
||||
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[]>([])
|
||||
const isLoading = ref(true)
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
@@ -133,42 +76,30 @@ onMounted(async () => {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
await loadReports()
|
||||
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() {
|
||||
isLoading.value = true
|
||||
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 })
|
||||
const res = await $fetch<any>('/api/report/weekly/list')
|
||||
reports.value = res.reports || []
|
||||
} catch (e) {
|
||||
console.error('Load reports error:', e)
|
||||
console.error(e)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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 formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
return dateStr.split('T')[0]
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleDateString('ko-KR')
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
@@ -188,18 +119,4 @@ function getStatusText(status: string) {
|
||||
}
|
||||
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>
|
||||
|
||||
@@ -2,189 +2,150 @@
|
||||
<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 class="container py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h4 class="mb-0">
|
||||
<i class="bi bi-journal-plus me-2"></i>주간보고 작성
|
||||
</h4>
|
||||
<span class="text-muted">{{ weekInfo.weekString }} ({{ weekInfo.startDateStr }} ~ {{ weekInfo.endDateStr }})</span>
|
||||
</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>
|
||||
|
||||
<form @submit.prevent="handleSubmit">
|
||||
<!-- 프로젝트별 실적 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" @click="showProjectModal = true">
|
||||
<i class="bi bi-plus"></i> 프로젝트 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-if="form.projects.length === 0" class="text-center text-muted py-4">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">프로젝트를 추가해주세요.</p>
|
||||
</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 v-for="(proj, idx) in form.projects" :key="idx" class="border rounded p-3 mb-3">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<strong>{{ proj.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ proj.projectCode }})</small>
|
||||
</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>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" @click="removeProject(idx)">
|
||||
<i class="bi bi-x"></i> 삭제
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">금주 실적</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.workDescription"
|
||||
placeholder="이번 주에 수행한 업무를 작성해주세요."></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">차주 계획</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.planDescription"
|
||||
placeholder="다음 주에 수행할 업무를 작성해주세요."></textarea>
|
||||
</div>
|
||||
</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 class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이슈/리스크</label>
|
||||
<textarea class="form-control" rows="3" v-model="form.issueDescription"
|
||||
placeholder="진행 중 발생한 이슈나 리스크를 작성해주세요."></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">휴가일정</label>
|
||||
<textarea class="form-control" rows="2" v-model="form.vacationDescription"
|
||||
placeholder="예: 1/6(월) 연차, 1/8(수) 오후 반차"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">기타사항</label>
|
||||
<textarea class="form-control" rows="2" v-model="form.remarkDescription"
|
||||
placeholder="기타 전달사항이 있으면 작성해주세요."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 버튼 -->
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<NuxtLink to="/report/weekly" class="btn btn-secondary">취소</NuxtLink>
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSubmitting || form.projects.length === 0">
|
||||
<span v-if="isSubmitting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
임시저장
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 프로젝트 선택 모달 -->
|
||||
<div class="modal fade" :class="{ show: showProjectModal }" :style="{ display: showProjectModal ? 'block' : 'none' }" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">프로젝트 선택</h5>
|
||||
<button type="button" class="btn-close" @click="showProjectModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div v-if="isLoadingProjects" class="text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||
</div>
|
||||
<div v-else-if="availableProjects.length === 0" class="text-center text-muted py-4">
|
||||
추가할 수 있는 프로젝트가 없습니다.
|
||||
</div>
|
||||
<div v-else class="list-group">
|
||||
<button type="button" class="list-group-item list-group-item-action"
|
||||
v-for="p in availableProjects" :key="p.projectId"
|
||||
@click="addProject(p)">
|
||||
<strong>{{ p.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ p.projectCode }})</small>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showProjectModal" @click="showProjectModal = false"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const { getCurrentWeekInfo, getWeekRangeText } = useWeekCalc()
|
||||
const { getCurrentWeekInfo } = useWeekCalc()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const currentWeek = getCurrentWeekInfo()
|
||||
const currentYear = new Date().getFullYear()
|
||||
const years = [currentYear, currentYear - 1]
|
||||
const weekInfo = getCurrentWeekInfo()
|
||||
|
||||
const isEdit = computed(() => !!route.query.id)
|
||||
const isSubmitting = ref(false)
|
||||
interface ProjectItem {
|
||||
projectId: number
|
||||
projectCode: string
|
||||
projectName: string
|
||||
workDescription: string
|
||||
planDescription: string
|
||||
}
|
||||
|
||||
const form = ref({
|
||||
projectId: '',
|
||||
reportYear: currentWeek.year,
|
||||
reportWeek: currentWeek.week,
|
||||
workDescription: '',
|
||||
planDescription: '',
|
||||
projects: [] as ProjectItem[],
|
||||
issueDescription: '',
|
||||
remarkDescription: '',
|
||||
workHours: null as number | null
|
||||
vacationDescription: '',
|
||||
remarkDescription: ''
|
||||
})
|
||||
|
||||
const projects = ref<any[]>([])
|
||||
const allProjects = ref<any[]>([])
|
||||
const isLoadingProjects = ref(false)
|
||||
const isSubmitting = ref(false)
|
||||
const showProjectModal = ref(false)
|
||||
|
||||
const weekRangeText = computed(() => {
|
||||
return getWeekRangeText(form.value.reportYear, form.value.reportWeek)
|
||||
// 아직 추가하지 않은 프로젝트만
|
||||
const availableProjects = computed(() => {
|
||||
const addedIds = form.value.projects.map(p => p.projectId)
|
||||
return allProjects.value.filter(p => !addedIds.includes(p.projectId))
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -193,105 +154,72 @@ onMounted(async () => {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
|
||||
if (route.query.id) {
|
||||
await loadReport(Number(route.query.id))
|
||||
}
|
||||
loadProjects()
|
||||
})
|
||||
|
||||
async function loadProjects() {
|
||||
isLoadingProjects.value = true
|
||||
try {
|
||||
const res = await $fetch<{ projects: any[] }>('/api/project/list')
|
||||
projects.value = res.projects || []
|
||||
const res = await $fetch<any>('/api/project/list')
|
||||
allProjects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error('Load projects error:', e)
|
||||
console.error(e)
|
||||
} finally {
|
||||
isLoadingProjects.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
function addProject(p: any) {
|
||||
form.value.projects.push({
|
||||
projectId: p.projectId,
|
||||
projectCode: p.projectCode,
|
||||
projectName: p.projectName,
|
||||
workDescription: '',
|
||||
planDescription: ''
|
||||
})
|
||||
showProjectModal.value = false
|
||||
}
|
||||
|
||||
function removeProject(idx: number) {
|
||||
form.value.projects.splice(idx, 1)
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!form.value.projectId || !form.value.workDescription) {
|
||||
alert('프로젝트와 금주 실적은 필수입니다.')
|
||||
if (form.value.projects.length === 0) {
|
||||
alert('최소 1개 이상의 프로젝트를 추가해주세요.')
|
||||
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
|
||||
const res = await $fetch<any>('/api/report/weekly/create', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
reportYear: weekInfo.year,
|
||||
reportWeek: weekInfo.week,
|
||||
projects: form.value.projects.map(p => ({
|
||||
projectId: p.projectId,
|
||||
workDescription: p.workDescription,
|
||||
planDescription: p.planDescription
|
||||
})),
|
||||
issueDescription: form.value.issueDescription,
|
||||
vacationDescription: form.value.vacationDescription,
|
||||
remarkDescription: form.value.remarkDescription
|
||||
}
|
||||
})
|
||||
|
||||
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')
|
||||
alert('저장되었습니다.')
|
||||
router.push(`/report/weekly/${res.reportId}`)
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '처리에 실패했습니다.')
|
||||
alert(e.data?.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,6 +3,11 @@ export default defineNuxtConfig({
|
||||
compatibilityDate: '2024-11-01',
|
||||
devtools: { enabled: true },
|
||||
|
||||
// 개발 서버 포트
|
||||
devServer: {
|
||||
port: 2026
|
||||
},
|
||||
|
||||
// 서버 설정
|
||||
nitro: {
|
||||
experimental: {
|
||||
|
||||
Reference in New Issue
Block a user