추가
This commit is contained in:
1
.env
1
.env
@@ -7,7 +7,6 @@ DB_PASSWORD=weeklyreport2026
|
|||||||
|
|
||||||
# App
|
# App
|
||||||
SESSION_SECRET=dev-secret-key-change-in-production
|
SESSION_SECRET=dev-secret-key-change-in-production
|
||||||
AUTO_START_SCHEDULER=false
|
|
||||||
|
|
||||||
# TODO: Google OAuth
|
# TODO: Google OAuth
|
||||||
# GOOGLE_CLIENT_ID=
|
# 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 { query, insertReturning, execute } from '../../utils/db'
|
||||||
|
import { getClientIp } from '../../utils/ip'
|
||||||
|
|
||||||
interface LoginBody {
|
interface LoginBody {
|
||||||
email: string
|
email: string
|
||||||
@@ -11,6 +12,7 @@ interface LoginBody {
|
|||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const body = await readBody<LoginBody>(event)
|
const body = await readBody<LoginBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
|
||||||
if (!body.email || !body.name) {
|
if (!body.email || !body.name) {
|
||||||
throw createError({ statusCode: 400, message: '이메일과 이름을 입력해주세요.' })
|
throw createError({ statusCode: 400, message: '이메일과 이름을 입력해주세요.' })
|
||||||
@@ -22,31 +24,52 @@ export default defineEventHandler(async (event) => {
|
|||||||
throw createError({ statusCode: 400, message: '올바른 이메일 형식이 아닙니다.' })
|
throw createError({ statusCode: 400, message: '올바른 이메일 형식이 아닙니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 기존 사원 조회
|
const emailLower = body.email.toLowerCase()
|
||||||
|
const nameTrimmed = body.name.trim()
|
||||||
|
|
||||||
|
// 기존 직원 조회
|
||||||
let employee = await query<any>(`
|
let employee = await query<any>(`
|
||||||
SELECT * FROM wr_employee_info WHERE employee_email = $1
|
SELECT * FROM wr_employee_info WHERE employee_email = $1
|
||||||
`, [body.email.toLowerCase()])
|
`, [emailLower])
|
||||||
|
|
||||||
let employeeData = employee[0]
|
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(`
|
employeeData = await insertReturning(`
|
||||||
INSERT INTO wr_employee_info (employee_name, employee_email)
|
INSERT INTO wr_employee_info (employee_name, employee_email, created_ip, created_email, updated_ip, updated_email)
|
||||||
VALUES ($1, $2)
|
VALUES ($1, $2, $3, $2, $3, $2)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
`, [body.name, body.email.toLowerCase()])
|
`, [nameTrimmed, emailLower, clientIp])
|
||||||
}
|
}
|
||||||
|
|
||||||
// 로그인 이력 추가
|
// 로그인 이력 추가
|
||||||
await execute(`
|
const loginHistory = await insertReturning(`
|
||||||
INSERT INTO wr_login_history (employee_id) VALUES ($1)
|
INSERT INTO wr_login_history (employee_id, login_ip, login_email)
|
||||||
`, [employeeData.employee_id])
|
VALUES ($1, $2, $3)
|
||||||
|
RETURNING history_id
|
||||||
|
`, [employeeData.employee_id, clientIp, emailLower])
|
||||||
|
|
||||||
// 쿠키에 사용자 정보 저장 (간단한 임시 세션)
|
// 쿠키에 사용자 정보 저장
|
||||||
setCookie(event, 'user_id', String(employeeData.employee_id), {
|
setCookie(event, 'user_id', String(employeeData.employee_id), {
|
||||||
httpOnly: true,
|
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: '/'
|
path: '/'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
|
import { execute } from '../../utils/db'
|
||||||
|
import { getClientIp } from '../../utils/ip'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 로그아웃
|
* 로그아웃
|
||||||
* POST /api/auth/logout
|
* POST /api/auth/logout
|
||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
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, 'user_id')
|
||||||
|
deleteCookie(event, 'login_history_id')
|
||||||
|
|
||||||
return { success: true }
|
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'
|
import { queryOne } from '../../../utils/db'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 사원 상세 조회
|
* 직원 상세 조회
|
||||||
* GET /api/employee/[id]/detail
|
* GET /api/employee/[id]/detail
|
||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
@@ -12,19 +12,21 @@ export default defineEventHandler(async (event) => {
|
|||||||
`, [employeeId])
|
`, [employeeId])
|
||||||
|
|
||||||
if (!employee) {
|
if (!employee) {
|
||||||
throw createError({ statusCode: 404, message: '사원을 찾을 수 없습니다.' })
|
throw createError({ statusCode: 404, message: '직원을 찾을 수 없습니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
employeeId: employee.employee_id,
|
employee: {
|
||||||
employeeNumber: employee.employee_number,
|
employeeId: employee.employee_id,
|
||||||
employeeName: employee.employee_name,
|
employeeName: employee.employee_name,
|
||||||
employeeEmail: employee.employee_email,
|
employeeEmail: employee.employee_email,
|
||||||
employeePhone: employee.employee_phone,
|
employeePhone: employee.employee_phone,
|
||||||
employeePosition: employee.employee_position,
|
employeePosition: employee.employee_position,
|
||||||
joinDate: employee.join_date,
|
company: employee.company,
|
||||||
isActive: employee.is_active,
|
joinDate: employee.join_date,
|
||||||
createdAt: employee.created_at,
|
isActive: employee.is_active,
|
||||||
updatedAt: employee.updated_at
|
createdAt: employee.created_at,
|
||||||
|
updatedAt: employee.updated_at
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,47 +1,55 @@
|
|||||||
import { execute, queryOne } from '../../../utils/db'
|
import { execute, queryOne } from '../../../utils/db'
|
||||||
|
import { getClientIp } from '../../../utils/ip'
|
||||||
|
import { getCurrentUserEmail } from '../../../utils/user'
|
||||||
|
|
||||||
interface UpdateEmployeeBody {
|
interface UpdateEmployeeBody {
|
||||||
employeeNumber?: string
|
|
||||||
employeeName?: string
|
employeeName?: string
|
||||||
employeePhone?: string
|
employeePhone?: string
|
||||||
employeePosition?: string
|
employeePosition?: string
|
||||||
|
company?: string
|
||||||
joinDate?: string
|
joinDate?: string
|
||||||
isActive?: boolean
|
isActive?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 사원 정보 수정
|
* 직원 정보 수정
|
||||||
* PUT /api/employee/[id]/update
|
* PUT /api/employee/[id]/update
|
||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const employeeId = getRouterParam(event, 'id')
|
const employeeId = getRouterParam(event, 'id')
|
||||||
const body = await readBody<UpdateEmployeeBody>(event)
|
const body = await readBody<UpdateEmployeeBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
const existing = await queryOne<any>(`
|
const existing = await queryOne<any>(`
|
||||||
SELECT * FROM wr_employee_info WHERE employee_id = $1
|
SELECT * FROM wr_employee_info WHERE employee_id = $1
|
||||||
`, [employeeId])
|
`, [employeeId])
|
||||||
|
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
throw createError({ statusCode: 404, message: '사원을 찾을 수 없습니다.' })
|
throw createError({ statusCode: 404, message: '직원을 찾을 수 없습니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
await execute(`
|
await execute(`
|
||||||
UPDATE wr_employee_info SET
|
UPDATE wr_employee_info SET
|
||||||
employee_number = $1,
|
employee_name = $1,
|
||||||
employee_name = $2,
|
employee_phone = $2,
|
||||||
employee_phone = $3,
|
employee_position = $3,
|
||||||
employee_position = $4,
|
company = $4,
|
||||||
join_date = $5,
|
join_date = $5,
|
||||||
is_active = $6,
|
is_active = $6,
|
||||||
updated_at = NOW()
|
updated_at = NOW(),
|
||||||
WHERE employee_id = $7
|
updated_ip = $7,
|
||||||
|
updated_email = $8
|
||||||
|
WHERE employee_id = $9
|
||||||
`, [
|
`, [
|
||||||
body.employeeNumber ?? existing.employee_number,
|
|
||||||
body.employeeName ?? existing.employee_name,
|
body.employeeName ?? existing.employee_name,
|
||||||
body.employeePhone ?? existing.employee_phone,
|
body.employeePhone ?? existing.employee_phone,
|
||||||
body.employeePosition ?? existing.employee_position,
|
body.employeePosition ?? existing.employee_position,
|
||||||
|
body.company ?? existing.company,
|
||||||
body.joinDate ?? existing.join_date,
|
body.joinDate ?? existing.join_date,
|
||||||
body.isActive ?? existing.is_active,
|
body.isActive ?? existing.is_active,
|
||||||
|
clientIp,
|
||||||
|
userEmail,
|
||||||
employeeId
|
employeeId
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
import { insertReturning, queryOne } from '../../utils/db'
|
import { insertReturning, queryOne } from '../../utils/db'
|
||||||
|
import { getClientIp } from '../../utils/ip'
|
||||||
|
import { getCurrentUserEmail } from '../../utils/user'
|
||||||
|
|
||||||
interface CreateEmployeeBody {
|
interface CreateEmployeeBody {
|
||||||
employeeNumber?: string
|
|
||||||
employeeName: string
|
employeeName: string
|
||||||
employeeEmail: string
|
employeeEmail: string
|
||||||
employeePhone?: string
|
employeePhone?: string
|
||||||
employeePosition?: string
|
employeePosition?: string
|
||||||
|
company?: string
|
||||||
joinDate?: string
|
joinDate?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 사원 등록
|
* 직원 등록
|
||||||
* POST /api/employee/create
|
* POST /api/employee/create
|
||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const body = await readBody<CreateEmployeeBody>(event)
|
const body = await readBody<CreateEmployeeBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
if (!body.employeeName || !body.employeeEmail) {
|
if (!body.employeeName || !body.employeeEmail) {
|
||||||
throw createError({ statusCode: 400, message: '이름과 이메일은 필수입니다.' })
|
throw createError({ statusCode: 400, message: '이름과 이메일은 필수입니다.' })
|
||||||
@@ -31,17 +35,20 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const employee = await insertReturning(`
|
const employee = await insertReturning(`
|
||||||
INSERT INTO wr_employee_info (
|
INSERT INTO wr_employee_info (
|
||||||
employee_number, employee_name, employee_email,
|
employee_name, employee_email, employee_phone,
|
||||||
employee_phone, employee_position, join_date
|
employee_position, company, join_date,
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6)
|
created_ip, created_email, updated_ip, updated_email
|
||||||
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $7, $8)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
`, [
|
`, [
|
||||||
body.employeeNumber || null,
|
|
||||||
body.employeeName,
|
body.employeeName,
|
||||||
body.employeeEmail.toLowerCase(),
|
body.employeeEmail.toLowerCase(),
|
||||||
body.employeePhone || null,
|
body.employeePhone || null,
|
||||||
body.employeePosition || null,
|
body.employeePosition || null,
|
||||||
body.joinDate || null
|
body.company || '(주)터보소프트',
|
||||||
|
body.joinDate || null,
|
||||||
|
clientIp,
|
||||||
|
userEmail
|
||||||
])
|
])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { query } from '../../utils/db'
|
import { query } from '../../utils/db'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 사원 목록 조회
|
* 직원 목록 조회
|
||||||
* GET /api/employee/list
|
* GET /api/employee/list
|
||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
@@ -16,15 +16,17 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const employees = await query(sql)
|
const employees = await query(sql)
|
||||||
|
|
||||||
return employees.map((e: any) => ({
|
return {
|
||||||
employeeId: e.employee_id,
|
employees: employees.map((e: any) => ({
|
||||||
employeeNumber: e.employee_number,
|
employeeId: e.employee_id,
|
||||||
employeeName: e.employee_name,
|
employeeName: e.employee_name,
|
||||||
employeeEmail: e.employee_email,
|
employeeEmail: e.employee_email,
|
||||||
employeePhone: e.employee_phone,
|
employeePhone: e.employee_phone,
|
||||||
employeePosition: e.employee_position,
|
employeePosition: e.employee_position,
|
||||||
joinDate: e.join_date,
|
company: e.company,
|
||||||
isActive: e.is_active,
|
joinDate: e.join_date,
|
||||||
createdAt: e.created_at
|
isActive: e.is_active,
|
||||||
}))
|
createdAt: e.created_at
|
||||||
|
}))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
projectId: project.project_id,
|
projectId: project.project_id,
|
||||||
projectCode: project.project_code,
|
projectCode: project.project_code,
|
||||||
projectName: project.project_name,
|
projectName: project.project_name,
|
||||||
|
projectType: project.project_type || 'SI',
|
||||||
clientName: project.client_name,
|
clientName: project.client_name,
|
||||||
projectDescription: project.project_description,
|
projectDescription: project.project_description,
|
||||||
startDate: project.start_date,
|
startDate: project.start_date,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { execute, queryOne, insertReturning } from '../../../utils/db'
|
import { execute, queryOne, insertReturning } from '../../../utils/db'
|
||||||
import { formatDate } from '../../../utils/week-calc'
|
import { formatDate } from '../../../utils/week-calc'
|
||||||
|
import { getClientIp } from '../../../utils/ip'
|
||||||
|
import { getCurrentUserEmail } from '../../../utils/user'
|
||||||
|
|
||||||
interface AssignManagerBody {
|
interface AssignManagerBody {
|
||||||
employeeId: number
|
employeeId: number
|
||||||
@@ -15,6 +17,8 @@ interface AssignManagerBody {
|
|||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const projectId = getRouterParam(event, 'id')
|
const projectId = getRouterParam(event, 'id')
|
||||||
const body = await readBody<AssignManagerBody>(event)
|
const body = await readBody<AssignManagerBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
if (!body.employeeId || !body.roleType) {
|
if (!body.employeeId || !body.roleType) {
|
||||||
throw createError({ statusCode: 400, message: '담당자와 역할을 선택해주세요.' })
|
throw createError({ statusCode: 400, message: '담당자와 역할을 선택해주세요.' })
|
||||||
@@ -31,17 +35,21 @@ export default defineEventHandler(async (event) => {
|
|||||||
await execute(`
|
await execute(`
|
||||||
UPDATE wr_project_manager_history SET
|
UPDATE wr_project_manager_history SET
|
||||||
end_date = $1,
|
end_date = $1,
|
||||||
change_reason = COALESCE(change_reason || ' / ', '') || '신규 담당자 지정으로 종료'
|
change_reason = COALESCE(change_reason || ' / ', '') || '신규 담당자 지정으로 종료',
|
||||||
WHERE project_id = $2 AND role_type = $3 AND end_date IS NULL
|
updated_at = NOW(),
|
||||||
`, [startDate, projectId, body.roleType])
|
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(`
|
const history = await insertReturning(`
|
||||||
INSERT INTO wr_project_manager_history (
|
INSERT INTO wr_project_manager_history (
|
||||||
project_id, employee_id, role_type, start_date, change_reason
|
project_id, employee_id, role_type, start_date, change_reason,
|
||||||
) VALUES ($1, $2, $3, $4, $5)
|
created_ip, created_email, updated_ip, updated_email
|
||||||
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $6, $7)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
`, [projectId, body.employeeId, body.roleType, startDate, body.changeReason || null])
|
`, [projectId, body.employeeId, body.roleType, startDate, body.changeReason || null, clientIp, userEmail])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { execute, queryOne } from '../../../utils/db'
|
import { execute, queryOne } from '../../../utils/db'
|
||||||
|
import { getClientIp } from '../../../utils/ip'
|
||||||
|
import { getCurrentUserEmail } from '../../../utils/user'
|
||||||
|
|
||||||
interface UpdateProjectBody {
|
interface UpdateProjectBody {
|
||||||
projectCode?: string
|
|
||||||
projectName?: string
|
projectName?: string
|
||||||
|
projectType?: string
|
||||||
clientName?: string
|
clientName?: string
|
||||||
projectDescription?: string
|
projectDescription?: string
|
||||||
startDate?: string
|
startDate?: string
|
||||||
@@ -18,6 +20,8 @@ interface UpdateProjectBody {
|
|||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const projectId = getRouterParam(event, 'id')
|
const projectId = getRouterParam(event, 'id')
|
||||||
const body = await readBody<UpdateProjectBody>(event)
|
const body = await readBody<UpdateProjectBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
const existing = await queryOne<any>(`
|
const existing = await queryOne<any>(`
|
||||||
SELECT * FROM wr_project_info WHERE project_id = $1
|
SELECT * FROM wr_project_info WHERE project_id = $1
|
||||||
@@ -27,27 +31,36 @@ export default defineEventHandler(async (event) => {
|
|||||||
throw createError({ statusCode: 404, message: '프로젝트를 찾을 수 없습니다.' })
|
throw createError({ statusCode: 404, message: '프로젝트를 찾을 수 없습니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 프로젝트 유형 검증
|
||||||
|
if (body.projectType && !['SI', 'SM'].includes(body.projectType)) {
|
||||||
|
throw createError({ statusCode: 400, message: '프로젝트 유형은 SI 또는 SM이어야 합니다.' })
|
||||||
|
}
|
||||||
|
|
||||||
await execute(`
|
await execute(`
|
||||||
UPDATE wr_project_info SET
|
UPDATE wr_project_info SET
|
||||||
project_code = $1,
|
project_name = $1,
|
||||||
project_name = $2,
|
project_type = $2,
|
||||||
client_name = $3,
|
client_name = $3,
|
||||||
project_description = $4,
|
project_description = $4,
|
||||||
start_date = $5,
|
start_date = $5,
|
||||||
end_date = $6,
|
end_date = $6,
|
||||||
contract_amount = $7,
|
contract_amount = $7,
|
||||||
project_status = $8,
|
project_status = $8,
|
||||||
updated_at = NOW()
|
updated_at = NOW(),
|
||||||
WHERE project_id = $9
|
updated_ip = $9,
|
||||||
|
updated_email = $10
|
||||||
|
WHERE project_id = $11
|
||||||
`, [
|
`, [
|
||||||
body.projectCode ?? existing.project_code,
|
|
||||||
body.projectName ?? existing.project_name,
|
body.projectName ?? existing.project_name,
|
||||||
|
body.projectType ?? existing.project_type ?? 'SI',
|
||||||
body.clientName ?? existing.client_name,
|
body.clientName ?? existing.client_name,
|
||||||
body.projectDescription ?? existing.project_description,
|
body.projectDescription ?? existing.project_description,
|
||||||
body.startDate ?? existing.start_date,
|
body.startDate ?? existing.start_date,
|
||||||
body.endDate ?? existing.end_date,
|
body.endDate ?? existing.end_date,
|
||||||
body.contractAmount ?? existing.contract_amount,
|
body.contractAmount ?? existing.contract_amount,
|
||||||
body.projectStatus ?? existing.project_status,
|
body.projectStatus ?? existing.project_status,
|
||||||
|
clientIp,
|
||||||
|
userEmail,
|
||||||
projectId
|
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 {
|
interface CreateProjectBody {
|
||||||
projectCode?: string
|
|
||||||
projectName: string
|
projectName: string
|
||||||
|
projectType?: string // SI / SM
|
||||||
clientName?: string
|
clientName?: string
|
||||||
projectDescription?: string
|
projectDescription?: string
|
||||||
startDate?: string
|
startDate?: string
|
||||||
@@ -10,38 +12,80 @@ interface CreateProjectBody {
|
|||||||
contractAmount?: number
|
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
|
* POST /api/project/create
|
||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const body = await readBody<CreateProjectBody>(event)
|
const body = await readBody<CreateProjectBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
if (!body.projectName) {
|
if (!body.projectName) {
|
||||||
throw createError({ statusCode: 400, message: '프로젝트명을 입력해주세요.' })
|
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(`
|
const project = await insertReturning(`
|
||||||
INSERT INTO wr_project_info (
|
INSERT INTO wr_project_info (
|
||||||
project_code, project_name, client_name, project_description,
|
project_code, project_name, project_type, client_name, project_description,
|
||||||
start_date, end_date, contract_amount
|
start_date, end_date, contract_amount,
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
created_ip, created_email, updated_ip, updated_email
|
||||||
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $9, $10)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
`, [
|
`, [
|
||||||
body.projectCode || null,
|
projectCode,
|
||||||
body.projectName,
|
body.projectName,
|
||||||
|
projectType,
|
||||||
body.clientName || null,
|
body.clientName || null,
|
||||||
body.projectDescription || null,
|
body.projectDescription || null,
|
||||||
body.startDate || null,
|
body.startDate || null,
|
||||||
body.endDate || null,
|
body.endDate || null,
|
||||||
body.contractAmount || null
|
body.contractAmount || null,
|
||||||
|
clientIp,
|
||||||
|
userEmail
|
||||||
])
|
])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
project: {
|
project: {
|
||||||
projectId: project.project_id,
|
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,
|
projectId: p.project_id,
|
||||||
projectCode: p.project_code,
|
projectCode: p.project_code,
|
||||||
projectName: p.project_name,
|
projectName: p.project_name,
|
||||||
|
projectType: p.project_type || 'SI',
|
||||||
clientName: p.client_name,
|
clientName: p.client_name,
|
||||||
projectDescription: p.project_description,
|
projectDescription: p.project_description,
|
||||||
startDate: p.start_date,
|
startDate: p.start_date,
|
||||||
|
|||||||
@@ -21,12 +21,24 @@ export default defineEventHandler(async (event) => {
|
|||||||
throw createError({ statusCode: 404, message: '취합 보고서를 찾을 수 없습니다.' })
|
throw createError({ statusCode: 404, message: '취합 보고서를 찾을 수 없습니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 개별 보고서 목록
|
// 개별 보고서 목록 (새 구조: 마스터 + 프로젝트별 실적 조인)
|
||||||
const reports = await query(`
|
const reports = await query(`
|
||||||
SELECT r.*, e.employee_name as author_name, e.employee_position
|
SELECT
|
||||||
FROM wr_weekly_report_detail r
|
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
|
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
|
ORDER BY e.employee_name
|
||||||
`, [summary.project_id, summary.report_year, summary.report_week])
|
`, [summary.project_id, summary.report_year, summary.report_week])
|
||||||
|
|
||||||
@@ -41,7 +53,6 @@ export default defineEventHandler(async (event) => {
|
|||||||
weekStartDate: summary.week_start_date,
|
weekStartDate: summary.week_start_date,
|
||||||
weekEndDate: summary.week_end_date,
|
weekEndDate: summary.week_end_date,
|
||||||
memberCount: summary.member_count,
|
memberCount: summary.member_count,
|
||||||
totalWorkHours: summary.total_work_hours,
|
|
||||||
reviewerId: summary.reviewer_id,
|
reviewerId: summary.reviewer_id,
|
||||||
reviewerName: summary.reviewer_name,
|
reviewerName: summary.reviewer_name,
|
||||||
reviewerComment: summary.reviewer_comment,
|
reviewerComment: summary.reviewer_comment,
|
||||||
@@ -56,8 +67,8 @@ export default defineEventHandler(async (event) => {
|
|||||||
workDescription: r.work_description,
|
workDescription: r.work_description,
|
||||||
planDescription: r.plan_description,
|
planDescription: r.plan_description,
|
||||||
issueDescription: r.issue_description,
|
issueDescription: r.issue_description,
|
||||||
|
vacationDescription: r.vacation_description,
|
||||||
remarkDescription: r.remark_description,
|
remarkDescription: r.remark_description,
|
||||||
workHours: r.work_hours,
|
|
||||||
reportStatus: r.report_status,
|
reportStatus: r.report_status,
|
||||||
submittedAt: r.submitted_at
|
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 reportId = getRouterParam(event, 'id')
|
||||||
|
|
||||||
|
// 마스터 조회
|
||||||
const report = await queryOne<any>(`
|
const report = await queryOne<any>(`
|
||||||
SELECT r.*, p.project_name, p.project_code, e.employee_name as author_name
|
SELECT
|
||||||
FROM wr_weekly_report_detail r
|
r.*,
|
||||||
JOIN wr_project_info p ON r.project_id = p.project_id
|
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
|
JOIN wr_employee_info e ON r.author_id = e.employee_id
|
||||||
WHERE r.report_id = $1
|
WHERE r.report_id = $1
|
||||||
`, [reportId])
|
`, [reportId])
|
||||||
@@ -24,25 +27,46 @@ export default defineEventHandler(async (event) => {
|
|||||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
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 {
|
return {
|
||||||
reportId: report.report_id,
|
report: {
|
||||||
projectId: report.project_id,
|
reportId: report.report_id,
|
||||||
projectName: report.project_name,
|
authorId: report.author_id,
|
||||||
projectCode: report.project_code,
|
authorName: report.author_name,
|
||||||
authorId: report.author_id,
|
authorEmail: report.author_email,
|
||||||
authorName: report.author_name,
|
reportYear: report.report_year,
|
||||||
reportYear: report.report_year,
|
reportWeek: report.report_week,
|
||||||
reportWeek: report.report_week,
|
weekStartDate: report.week_start_date,
|
||||||
weekStartDate: report.week_start_date,
|
weekEndDate: report.week_end_date,
|
||||||
weekEndDate: report.week_end_date,
|
issueDescription: report.issue_description,
|
||||||
workDescription: report.work_description,
|
vacationDescription: report.vacation_description,
|
||||||
planDescription: report.plan_description,
|
remarkDescription: report.remark_description,
|
||||||
issueDescription: report.issue_description,
|
reportStatus: report.report_status,
|
||||||
remarkDescription: report.remark_description,
|
submittedAt: report.submitted_at,
|
||||||
workHours: report.work_hours,
|
createdAt: report.created_at,
|
||||||
reportStatus: report.report_status,
|
updatedAt: report.updated_at
|
||||||
submittedAt: report.submitted_at,
|
},
|
||||||
createdAt: report.created_at,
|
projects: projects.map((p: any) => ({
|
||||||
updatedAt: report.updated_at
|
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 { 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 reportId = getRouterParam(event, 'id')
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
// 보고서 조회 및 권한 확인
|
// 보고서 조회 및 권한 확인
|
||||||
const report = await queryOne<any>(`
|
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])
|
`, [reportId])
|
||||||
|
|
||||||
if (!report) {
|
if (!report) {
|
||||||
@@ -25,13 +29,19 @@ export default defineEventHandler(async (event) => {
|
|||||||
throw createError({ statusCode: 403, message: '본인의 보고서만 제출할 수 있습니다.' })
|
throw createError({ statusCode: 403, message: '본인의 보고서만 제출할 수 있습니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (report.report_status !== 'DRAFT') {
|
||||||
|
throw createError({ statusCode: 400, message: '이미 제출된 보고서입니다.' })
|
||||||
|
}
|
||||||
|
|
||||||
await execute(`
|
await execute(`
|
||||||
UPDATE wr_weekly_report_detail SET
|
UPDATE wr_weekly_report SET
|
||||||
report_status = 'SUBMITTED',
|
report_status = 'SUBMITTED',
|
||||||
submitted_at = NOW(),
|
submitted_at = NOW(),
|
||||||
updated_at = NOW()
|
updated_at = NOW(),
|
||||||
WHERE report_id = $1
|
updated_ip = $1,
|
||||||
`, [reportId])
|
updated_email = $2
|
||||||
|
WHERE report_id = $3
|
||||||
|
`, [clientIp, userEmail, reportId])
|
||||||
|
|
||||||
return { success: true }
|
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
|
workDescription?: string
|
||||||
planDescription?: string
|
planDescription?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UpdateReportBody {
|
||||||
|
projects?: ProjectItem[]
|
||||||
issueDescription?: string
|
issueDescription?: string
|
||||||
|
vacationDescription?: string
|
||||||
remarkDescription?: string
|
remarkDescription?: string
|
||||||
workHours?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,10 +27,12 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const reportId = getRouterParam(event, 'id')
|
const reportId = getRouterParam(event, 'id')
|
||||||
const body = await readBody<UpdateReportBody>(event)
|
const body = await readBody<UpdateReportBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
// 보고서 조회 및 권한 확인
|
// 보고서 조회 및 권한 확인
|
||||||
const report = await queryOne<any>(`
|
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])
|
`, [reportId])
|
||||||
|
|
||||||
if (!report) {
|
if (!report) {
|
||||||
@@ -34,23 +43,50 @@ export default defineEventHandler(async (event) => {
|
|||||||
throw createError({ statusCode: 403, message: '본인의 보고서만 수정할 수 있습니다.' })
|
throw createError({ statusCode: 403, message: '본인의 보고서만 수정할 수 있습니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (report.report_status === 'SUBMITTED' || report.report_status === 'AGGREGATED') {
|
||||||
|
throw createError({ statusCode: 400, message: '제출된 보고서는 수정할 수 없습니다.' })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 마스터 업데이트
|
||||||
await execute(`
|
await execute(`
|
||||||
UPDATE wr_weekly_report_detail SET
|
UPDATE wr_weekly_report SET
|
||||||
work_description = $1,
|
issue_description = $1,
|
||||||
plan_description = $2,
|
vacation_description = $2,
|
||||||
issue_description = $3,
|
remark_description = $3,
|
||||||
remark_description = $4,
|
updated_at = NOW(),
|
||||||
work_hours = $5,
|
updated_ip = $4,
|
||||||
updated_at = NOW()
|
updated_email = $5
|
||||||
WHERE report_id = $6
|
WHERE report_id = $6
|
||||||
`, [
|
`, [
|
||||||
body.workDescription ?? report.work_description,
|
|
||||||
body.planDescription ?? report.plan_description,
|
|
||||||
body.issueDescription ?? report.issue_description,
|
body.issueDescription ?? report.issue_description,
|
||||||
|
body.vacationDescription ?? report.vacation_description,
|
||||||
body.remarkDescription ?? report.remark_description,
|
body.remarkDescription ?? report.remark_description,
|
||||||
body.workHours ?? report.work_hours,
|
clientIp,
|
||||||
|
userEmail,
|
||||||
reportId
|
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 }
|
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 { getWeekInfo } from '../../../utils/week-calc'
|
||||||
|
import { getClientIp } from '../../../utils/ip'
|
||||||
|
import { getCurrentUserEmail } from '../../../utils/user'
|
||||||
|
|
||||||
interface CreateReportBody {
|
interface ProjectItem {
|
||||||
projectId: number
|
projectId: number
|
||||||
reportYear?: number
|
|
||||||
reportWeek?: number
|
|
||||||
workDescription?: string
|
workDescription?: string
|
||||||
planDescription?: string
|
planDescription?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CreateReportBody {
|
||||||
|
reportYear?: number
|
||||||
|
reportWeek?: number
|
||||||
|
projects: ProjectItem[]
|
||||||
issueDescription?: string
|
issueDescription?: string
|
||||||
|
vacationDescription?: string
|
||||||
remarkDescription?: string
|
remarkDescription?: string
|
||||||
workHours?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,9 +29,11 @@ export default defineEventHandler(async (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const body = await readBody<CreateReportBody>(event)
|
const body = await readBody<CreateReportBody>(event)
|
||||||
|
const clientIp = getClientIp(event)
|
||||||
|
const userEmail = await getCurrentUserEmail(event)
|
||||||
|
|
||||||
if (!body.projectId) {
|
if (!body.projects || body.projects.length === 0) {
|
||||||
throw createError({ statusCode: 400, message: '프로젝트를 선택해주세요.' })
|
throw createError({ statusCode: 400, message: '최소 1개 이상의 프로젝트를 추가해주세요.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 주차 정보 (기본값: 이번 주)
|
// 주차 정보 (기본값: 이번 주)
|
||||||
@@ -34,40 +42,57 @@ export default defineEventHandler(async (event) => {
|
|||||||
const week = body.reportWeek || weekInfo.week
|
const week = body.reportWeek || weekInfo.week
|
||||||
|
|
||||||
// 중복 체크
|
// 중복 체크
|
||||||
const existing = await queryOne(`
|
const existing = await query(`
|
||||||
SELECT report_id FROM wr_weekly_report_detail
|
SELECT report_id FROM wr_weekly_report
|
||||||
WHERE project_id = $1 AND author_id = $2 AND report_year = $3 AND report_week = $4
|
WHERE author_id = $1 AND report_year = $2 AND report_week = $3
|
||||||
`, [body.projectId, parseInt(userId), year, week])
|
`, [parseInt(userId), year, week])
|
||||||
|
|
||||||
if (existing) {
|
if (existing.length > 0) {
|
||||||
throw createError({ statusCode: 409, message: '이미 해당 주차 보고서가 존재합니다.' })
|
throw createError({ statusCode: 409, message: '이미 해당 주차 보고서가 존재합니다.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 주차 날짜 계산
|
// 주차 날짜 계산
|
||||||
const dates = getWeekInfo(new Date(year, 0, 4 + (week - 1) * 7))
|
const dates = getWeekInfo(new Date(year, 0, 4 + (week - 1) * 7))
|
||||||
|
|
||||||
|
// 마스터 생성
|
||||||
const report = await insertReturning(`
|
const report = await insertReturning(`
|
||||||
INSERT INTO wr_weekly_report_detail (
|
INSERT INTO wr_weekly_report (
|
||||||
project_id, author_id, report_year, report_week,
|
author_id, report_year, report_week,
|
||||||
week_start_date, week_end_date,
|
week_start_date, week_end_date,
|
||||||
work_description, plan_description, issue_description, remark_description,
|
issue_description, vacation_description, remark_description,
|
||||||
work_hours, report_status
|
report_status, created_ip, created_email, updated_ip, updated_email
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, 'DRAFT')
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, 'DRAFT', $9, $10, $9, $10)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
`, [
|
`, [
|
||||||
body.projectId,
|
|
||||||
parseInt(userId),
|
parseInt(userId),
|
||||||
year,
|
year,
|
||||||
week,
|
week,
|
||||||
dates.startDateStr,
|
dates.startDateStr,
|
||||||
dates.endDateStr,
|
dates.endDateStr,
|
||||||
body.workDescription || null,
|
|
||||||
body.planDescription || null,
|
|
||||||
body.issueDescription || null,
|
body.issueDescription || null,
|
||||||
|
body.vacationDescription || null,
|
||||||
body.remarkDescription || 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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
reportId: report.report_id
|
reportId: report.report_id
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { query } from '../../../utils/db'
|
import { query } from '../../../utils/db'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 내 주간보고 목록
|
* 주간보고 목록 조회
|
||||||
* GET /api/report/weekly/list
|
* GET /api/report/weekly/list
|
||||||
*/
|
*/
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
@@ -11,50 +11,45 @@ export default defineEventHandler(async (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const queryParams = getQuery(event)
|
const queryParams = getQuery(event)
|
||||||
const year = queryParams.year ? parseInt(queryParams.year as string) : null
|
const limit = parseInt(queryParams.limit as string) || 20
|
||||||
const projectId = queryParams.projectId ? parseInt(queryParams.projectId as string) : null
|
|
||||||
|
|
||||||
let sql = `
|
const reports = await query<any>(`
|
||||||
SELECT r.*, p.project_name, p.project_code
|
SELECT
|
||||||
FROM wr_weekly_report_detail r
|
r.report_id,
|
||||||
JOIN wr_project_info p ON r.project_id = p.project_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
|
WHERE r.author_id = $1
|
||||||
`
|
ORDER BY r.report_year DESC, r.report_week DESC
|
||||||
const params: any[] = [parseInt(userId)]
|
LIMIT $2
|
||||||
let paramIndex = 2
|
`, [userId, limit])
|
||||||
|
|
||||||
if (year) {
|
|
||||||
sql += ` AND r.report_year = $${paramIndex++}`
|
|
||||||
params.push(year)
|
|
||||||
}
|
|
||||||
if (projectId) {
|
|
||||||
sql += ` AND r.project_id = $${paramIndex++}`
|
|
||||||
params.push(projectId)
|
|
||||||
}
|
|
||||||
|
|
||||||
sql += ' ORDER BY r.report_year DESC, r.report_week DESC'
|
|
||||||
|
|
||||||
const reports = await query(sql, params)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
reports: reports.map((r: any) => ({
|
reports: reports.map((r: any) => ({
|
||||||
reportId: r.report_id,
|
reportId: r.report_id,
|
||||||
projectId: r.project_id,
|
authorId: r.author_id,
|
||||||
projectName: r.project_name,
|
authorName: r.author_name,
|
||||||
projectCode: r.project_code,
|
|
||||||
reportYear: r.report_year,
|
reportYear: r.report_year,
|
||||||
reportWeek: r.report_week,
|
reportWeek: r.report_week,
|
||||||
weekStartDate: r.week_start_date,
|
weekStartDate: r.week_start_date,
|
||||||
weekEndDate: r.week_end_date,
|
weekEndDate: r.week_end_date,
|
||||||
workDescription: r.work_description,
|
|
||||||
planDescription: r.plan_description,
|
|
||||||
issueDescription: r.issue_description,
|
issueDescription: r.issue_description,
|
||||||
remarkDescription: r.remark_description,
|
vacationDescription: r.vacation_description,
|
||||||
workHours: r.work_hours,
|
|
||||||
reportStatus: r.report_status,
|
reportStatus: r.report_status,
|
||||||
submittedAt: r.submitted_at,
|
submittedAt: r.submitted_at,
|
||||||
createdAt: r.created_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 {
|
export function getPool(): pg.Pool {
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
const config = useRuntimeConfig()
|
|
||||||
|
|
||||||
const poolConfig = {
|
const poolConfig = {
|
||||||
host: config.dbHost,
|
host: process.env.DB_HOST || 'localhost',
|
||||||
port: parseInt(config.dbPort as string),
|
port: parseInt(process.env.DB_PORT || '5432'),
|
||||||
database: config.dbName,
|
database: process.env.DB_NAME || 'weeklyreport',
|
||||||
user: config.dbUser,
|
user: process.env.DB_USER || 'postgres',
|
||||||
password: config.dbPassword,
|
password: process.env.DB_PASSWORD || '',
|
||||||
max: 10,
|
max: 10,
|
||||||
idleTimeoutMillis: 30000,
|
idleTimeoutMillis: 30000,
|
||||||
connectionTimeoutMillis: 2000,
|
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>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<NuxtLink class="nav-link" to="/employee" active-class="active">
|
<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>
|
</NuxtLink>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- 사용자 정보 -->
|
<!-- 사용자 정보 -->
|
||||||
<div class="d-flex align-items-center" v-if="currentUser">
|
<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>
|
<i class="bi bi-person-circle me-1"></i>
|
||||||
{{ currentUser.employeeName }}
|
{{ currentUser.employeeName }}
|
||||||
</span>
|
</NuxtLink>
|
||||||
<button class="btn btn-outline-light btn-sm" @click="handleLogout">
|
<button class="btn btn-outline-light btn-sm" @click="handleLogout">
|
||||||
<i class="bi bi-box-arrow-right"></i> 로그아웃
|
<i class="bi bi-box-arrow-right"></i> 로그아웃
|
||||||
</button>
|
</button>
|
||||||
@@ -74,4 +74,13 @@ async function handleLogout() {
|
|||||||
.nav-link.active {
|
.nav-link.active {
|
||||||
font-weight: 500;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0">
|
<h5 class="mb-0">
|
||||||
<i class="bi bi-person me-2"></i>사원 정보
|
<i class="bi bi-person me-2"></i>직원 정보
|
||||||
</h5>
|
</h5>
|
||||||
<span :class="employee.isActive ? 'badge bg-success' : 'badge bg-secondary'">
|
<span :class="employee.isActive ? 'badge bg-success' : 'badge bg-secondary'">
|
||||||
{{ employee.isActive ? '재직' : '퇴직' }}
|
{{ employee.isActive ? '재직' : '퇴직' }}
|
||||||
@@ -31,19 +31,33 @@
|
|||||||
<input type="email" class="form-control" v-model="form.employeeEmail" required />
|
<input type="email" class="form-control" v-model="form.employeeEmail" required />
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">사번</label>
|
<label class="form-label">소속사</label>
|
||||||
<input type="text" class="form-control" v-model="form.employeeNumber" />
|
<select class="form-select" v-model="form.company">
|
||||||
|
<option value="(주)터보소프트">(주)터보소프트</option>
|
||||||
|
<option value="(주)코쿤">(주)코쿤</option>
|
||||||
|
<option value="(주)오솔정보기술">(주)오솔정보기술</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">직급</label>
|
<label class="form-label">직급</label>
|
||||||
<select class="form-select" v-model="form.employeePosition">
|
<select class="form-select" v-model="form.employeePosition">
|
||||||
<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>
|
||||||
<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>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
@@ -114,7 +128,7 @@ const isSubmitting = ref(false)
|
|||||||
const form = ref({
|
const form = ref({
|
||||||
employeeName: '',
|
employeeName: '',
|
||||||
employeeEmail: '',
|
employeeEmail: '',
|
||||||
employeeNumber: '',
|
company: '(주)터보소프트',
|
||||||
employeePosition: '',
|
employeePosition: '',
|
||||||
employeePhone: '',
|
employeePhone: '',
|
||||||
joinDate: '',
|
joinDate: '',
|
||||||
@@ -141,14 +155,14 @@ async function loadEmployee() {
|
|||||||
form.value = {
|
form.value = {
|
||||||
employeeName: e.employeeName || '',
|
employeeName: e.employeeName || '',
|
||||||
employeeEmail: e.employeeEmail || '',
|
employeeEmail: e.employeeEmail || '',
|
||||||
employeeNumber: e.employeeNumber || '',
|
company: e.company || '(주)터보소프트',
|
||||||
employeePosition: e.employeePosition || '',
|
employeePosition: e.employeePosition || '',
|
||||||
employeePhone: e.employeePhone || '',
|
employeePhone: e.employeePhone || '',
|
||||||
joinDate: e.joinDate ? e.joinDate.split('T')[0] : '',
|
joinDate: e.joinDate ? e.joinDate.split('T')[0] : '',
|
||||||
isActive: e.isActive
|
isActive: e.isActive
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
alert('사원 정보를 불러오는데 실패했습니다.')
|
alert('직원 정보를 불러오는데 실패했습니다.')
|
||||||
router.push('/employee')
|
router.push('/employee')
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
<div class="container-fluid py-4">
|
<div class="container-fluid py-4">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<div>
|
<div>
|
||||||
<h4><i class="bi bi-people me-2"></i>사원 관리</h4>
|
<h4><i class="bi bi-people me-2"></i>직원 관리</h4>
|
||||||
<p class="text-muted mb-0">직원 정보 관리</p>
|
<p class="text-muted mb-0">총 {{ employees.length }}명</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary" @click="showCreateModal = true">
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -23,13 +23,14 @@
|
|||||||
class="form-control"
|
class="form-control"
|
||||||
v-model="searchKeyword"
|
v-model="searchKeyword"
|
||||||
placeholder="이름 또는 이메일 검색"
|
placeholder="이름 또는 이메일 검색"
|
||||||
@keyup.enter="loadEmployees"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 d-flex align-items-end">
|
<div class="col-md-2">
|
||||||
<button class="btn btn-outline-secondary" @click="loadEmployees">
|
<select class="form-select" v-model="filterStatus">
|
||||||
<i class="bi bi-search me-1"></i> 조회
|
<option value="">전체</option>
|
||||||
</button>
|
<option value="active">재직</option>
|
||||||
|
<option value="inactive">퇴직</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,23 +42,29 @@
|
|||||||
<table class="table table-hover mb-0">
|
<table class="table table-hover mb-0">
|
||||||
<thead class="table-light">
|
<thead class="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 100px">사번</th>
|
|
||||||
<th>이름</th>
|
<th>이름</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: 100px">상태</th>
|
||||||
<th style="width: 80px">상세</th>
|
<th style="width: 80px">상세</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="emp in employees" :key="emp.employeeId">
|
<tr v-if="isLoading">
|
||||||
<td><code>{{ emp.employeeNumber || '-' }}</code></td>
|
<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><strong>{{ emp.employeeName }}</strong></td>
|
||||||
<td>{{ emp.employeeEmail }}</td>
|
<td>{{ emp.employeeEmail }}</td>
|
||||||
|
<td>{{ emp.company || '-' }}</td>
|
||||||
|
<td>{{ emp.employeeEmail }}</td>
|
||||||
<td>{{ emp.employeePosition || '-' }}</td>
|
<td>{{ emp.employeePosition || '-' }}</td>
|
||||||
<td>
|
<td>
|
||||||
<span :class="emp.isActive ? 'badge bg-success' : 'badge bg-secondary'">
|
<span :class="emp.isActive !== false ? 'badge bg-success' : 'badge bg-secondary'">
|
||||||
{{ emp.isActive ? '재직' : '퇴직' }}
|
{{ emp.isActive !== false ? '재직' : '퇴직' }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -69,10 +76,10 @@
|
|||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="employees.length === 0">
|
<tr v-if="!isLoading && filteredEmployees.length === 0">
|
||||||
<td colspan="6" class="text-center py-5 text-muted">
|
<td colspan="6" class="text-center py-5 text-muted">
|
||||||
<i class="bi bi-inbox display-4"></i>
|
<i class="bi bi-inbox display-4"></i>
|
||||||
<p class="mt-2 mb-0">사원 정보가 없습니다.</p>
|
<p class="mt-2 mb-0">직원 정보가 없습니다.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -86,7 +93,7 @@
|
|||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">사원 등록</h5>
|
<h5 class="modal-title">직원 등록</h5>
|
||||||
<button type="button" class="btn-close" @click="showCreateModal = false"></button>
|
<button type="button" class="btn-close" @click="showCreateModal = false"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@@ -99,19 +106,33 @@
|
|||||||
<input type="email" class="form-control" v-model="newEmployee.employeeEmail" required />
|
<input type="email" class="form-control" v-model="newEmployee.employeeEmail" required />
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">사번</label>
|
<label class="form-label">소속사</label>
|
||||||
<input type="text" class="form-control" v-model="newEmployee.employeeNumber" />
|
<select class="form-select" v-model="newEmployee.company">
|
||||||
|
<option value="(주)터보소프트">(주)터보소프트</option>
|
||||||
|
<option value="(주)코쿤">(주)코쿤</option>
|
||||||
|
<option value="(주)오솔정보기술">(주)오솔정보기술</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">직급</label>
|
<label class="form-label">직급</label>
|
||||||
<select class="form-select" v-model="newEmployee.employeePosition">
|
<select class="form-select" v-model="newEmployee.employeePosition">
|
||||||
<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>
|
||||||
<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>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
@@ -142,17 +163,40 @@ const router = useRouter()
|
|||||||
|
|
||||||
const employees = ref<any[]>([])
|
const employees = ref<any[]>([])
|
||||||
const searchKeyword = ref('')
|
const searchKeyword = ref('')
|
||||||
|
const filterStatus = ref('')
|
||||||
const showCreateModal = ref(false)
|
const showCreateModal = ref(false)
|
||||||
|
const isLoading = ref(true)
|
||||||
|
|
||||||
const newEmployee = ref({
|
const newEmployee = ref({
|
||||||
employeeName: '',
|
employeeName: '',
|
||||||
employeeEmail: '',
|
employeeEmail: '',
|
||||||
employeeNumber: '',
|
company: '(주)터보소프트',
|
||||||
employeePosition: '',
|
employeePosition: '',
|
||||||
employeePhone: '',
|
employeePhone: '',
|
||||||
joinDate: ''
|
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 () => {
|
onMounted(async () => {
|
||||||
const user = await fetchCurrentUser()
|
const user = await fetchCurrentUser()
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@@ -164,14 +208,14 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function loadEmployees() {
|
async function loadEmployees() {
|
||||||
|
isLoading.value = true
|
||||||
try {
|
try {
|
||||||
const query: Record<string, any> = {}
|
const res = await $fetch<{ employees: any[] }>('/api/employee/list')
|
||||||
if (searchKeyword.value) query.keyword = searchKeyword.value
|
|
||||||
|
|
||||||
const res = await $fetch<{ employees: any[] }>('/api/employee/list', { query })
|
|
||||||
employees.value = res.employees || []
|
employees.value = res.employees || []
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Load employees error:', e)
|
console.error('Load employees error:', e)
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +234,7 @@ async function createEmployee() {
|
|||||||
newEmployee.value = {
|
newEmployee.value = {
|
||||||
employeeName: '',
|
employeeName: '',
|
||||||
employeeEmail: '',
|
employeeEmail: '',
|
||||||
employeeNumber: '',
|
company: '(주)터보소프트',
|
||||||
employeePosition: '',
|
employeePosition: '',
|
||||||
employeePhone: '',
|
employeePhone: '',
|
||||||
joinDate: ''
|
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 mb-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-md-4">
|
<div class="col-md-3">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@@ -25,6 +25,13 @@
|
|||||||
placeholder="프로젝트명 또는 코드 검색"
|
placeholder="프로젝트명 또는 코드 검색"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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">
|
<div class="col-md-2">
|
||||||
<select class="form-select" v-model="filterStatus">
|
<select class="form-select" v-model="filterStatus">
|
||||||
<option value="">전체 상태</option>
|
<option value="">전체 상태</option>
|
||||||
@@ -48,8 +55,9 @@
|
|||||||
<table class="table table-hover mb-0">
|
<table class="table table-hover mb-0">
|
||||||
<thead class="table-light">
|
<thead class="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>프로젝트 코드</th>
|
<th style="width: 120px">코드</th>
|
||||||
<th>프로젝트명</th>
|
<th>프로젝트명</th>
|
||||||
|
<th style="width: 80px">유형</th>
|
||||||
<th>발주처</th>
|
<th>발주처</th>
|
||||||
<th style="width: 120px">기간</th>
|
<th style="width: 120px">기간</th>
|
||||||
<th style="width: 100px">상태</th>
|
<th style="width: 100px">상태</th>
|
||||||
@@ -62,6 +70,11 @@
|
|||||||
<td>
|
<td>
|
||||||
<strong>{{ project.projectName }}</strong>
|
<strong>{{ project.projectName }}</strong>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<span :class="getTypeBadgeClass(project.projectType)">
|
||||||
|
{{ project.projectType || 'SI' }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
<td>{{ project.clientName || '-' }}</td>
|
<td>{{ project.clientName || '-' }}</td>
|
||||||
<td>
|
<td>
|
||||||
<small v-if="project.startDate">
|
<small v-if="project.startDate">
|
||||||
@@ -85,7 +98,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="filteredProjects.length === 0">
|
<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>
|
<i class="bi bi-inbox display-4"></i>
|
||||||
<p class="mt-2 mb-0">프로젝트가 없습니다.</p>
|
<p class="mt-2 mb-0">프로젝트가 없습니다.</p>
|
||||||
</td>
|
</td>
|
||||||
@@ -106,14 +119,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="row g-3">
|
<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">
|
<div class="col-md-8">
|
||||||
<label class="form-label">프로젝트명 <span class="text-danger">*</span></label>
|
<label class="form-label">프로젝트명 <span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" v-model="newProject.projectName" required />
|
<input type="text" class="form-control" v-model="newProject.projectName" required />
|
||||||
</div>
|
</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">
|
<div class="col-md-6">
|
||||||
<label class="form-label">발주처</label>
|
<label class="form-label">발주처</label>
|
||||||
<input type="text" class="form-control" v-model="newProject.clientName" />
|
<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>
|
<textarea class="form-control" v-model="newProject.projectDescription" rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" @click="showCreateModal = false">취소</button>
|
<button type="button" class="btn btn-secondary" @click="showCreateModal = false">취소</button>
|
||||||
<button type="button" class="btn btn-primary" @click="createProject">
|
<button type="button" class="btn btn-primary" @click="createProject" :disabled="isCreating">
|
||||||
<i class="bi bi-check-lg me-1"></i> 등록
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -155,14 +180,16 @@ const router = useRouter()
|
|||||||
|
|
||||||
const projects = ref<any[]>([])
|
const projects = ref<any[]>([])
|
||||||
const searchKeyword = ref('')
|
const searchKeyword = ref('')
|
||||||
|
const filterType = ref('')
|
||||||
const filterStatus = ref('')
|
const filterStatus = ref('')
|
||||||
const showCreateModal = ref(false)
|
const showCreateModal = ref(false)
|
||||||
|
const isCreating = ref(false)
|
||||||
|
|
||||||
const newProject = ref({
|
const newProject = ref({
|
||||||
projectCode: '',
|
|
||||||
projectName: '',
|
projectName: '',
|
||||||
|
projectType: 'SI',
|
||||||
clientName: '',
|
clientName: '',
|
||||||
contractAmount: null,
|
contractAmount: null as number | null,
|
||||||
startDate: '',
|
startDate: '',
|
||||||
endDate: '',
|
endDate: '',
|
||||||
projectDescription: ''
|
projectDescription: ''
|
||||||
@@ -179,6 +206,10 @@ const filteredProjects = computed(() => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filterType.value) {
|
||||||
|
list = list.filter(p => p.projectType === filterType.value)
|
||||||
|
}
|
||||||
|
|
||||||
if (filterStatus.value) {
|
if (filterStatus.value) {
|
||||||
list = list.filter(p => p.projectStatus === filterStatus.value)
|
list = list.filter(p => p.projectStatus === filterStatus.value)
|
||||||
}
|
}
|
||||||
@@ -211,27 +242,38 @@ async function createProject() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCreating.value = true
|
||||||
try {
|
try {
|
||||||
await $fetch('/api/project/create', {
|
await $fetch('/api/project/create', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: newProject.value
|
body: newProject.value
|
||||||
})
|
})
|
||||||
showCreateModal.value = false
|
showCreateModal.value = false
|
||||||
newProject.value = {
|
resetNewProject()
|
||||||
projectCode: '',
|
|
||||||
projectName: '',
|
|
||||||
clientName: '',
|
|
||||||
contractAmount: null,
|
|
||||||
startDate: '',
|
|
||||||
endDate: '',
|
|
||||||
projectDescription: ''
|
|
||||||
}
|
|
||||||
await loadProjects()
|
await loadProjects()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
alert(e.data?.message || e.message || '등록에 실패했습니다.')
|
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) {
|
function getStatusBadgeClass(status: string) {
|
||||||
const classes: Record<string, string> = {
|
const classes: Record<string, string> = {
|
||||||
'ACTIVE': 'badge bg-success',
|
'ACTIVE': 'badge bg-success',
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
<AppHeader />
|
<AppHeader />
|
||||||
|
|
||||||
<div class="container-fluid py-4">
|
<div class="container-fluid py-4">
|
||||||
<div class="mb-4">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<h4><i class="bi bi-collection me-2"></i>취합 보고서</h4>
|
<div>
|
||||||
<p class="text-muted mb-0">프로젝트별 주간보고 취합 목록</p>
|
<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>
|
</div>
|
||||||
|
|
||||||
<!-- 필터 -->
|
<!-- 필터 -->
|
||||||
@@ -95,14 +100,75 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { fetchCurrentUser } = useAuth()
|
const { fetchCurrentUser } = useAuth()
|
||||||
|
const { getCurrentWeekInfo } = useWeekCalc()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const currentYear = new Date().getFullYear()
|
const currentYear = new Date().getFullYear()
|
||||||
|
const currentWeek = getCurrentWeekInfo()
|
||||||
const years = [currentYear, currentYear - 1, currentYear - 2]
|
const years = [currentYear, currentYear - 1, currentYear - 2]
|
||||||
|
|
||||||
const filter = ref({
|
const filter = ref({
|
||||||
@@ -113,6 +179,15 @@ const filter = ref({
|
|||||||
const summaries = ref<any[]>([])
|
const summaries = ref<any[]>([])
|
||||||
const projects = 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 () => {
|
onMounted(async () => {
|
||||||
const user = await fetchCurrentUser()
|
const user = await fetchCurrentUser()
|
||||||
if (!user) {
|
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) {
|
function getStatusBadgeClass(status: string) {
|
||||||
const classes: Record<string, string> = {
|
const classes: Record<string, string> = {
|
||||||
'AGGREGATED': 'badge bg-info',
|
'AGGREGATED': 'badge bg-info',
|
||||||
@@ -176,3 +278,9 @@ function formatDateTime(dateStr: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.modal.show {
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -2,123 +2,230 @@
|
|||||||
<div>
|
<div>
|
||||||
<AppHeader />
|
<AppHeader />
|
||||||
|
|
||||||
<div class="container-fluid py-4">
|
<div class="container py-4">
|
||||||
<div class="mb-4">
|
<div v-if="isLoading" class="text-center py-5">
|
||||||
<NuxtLink to="/report/weekly" class="text-decoration-none">
|
<span class="spinner-border"></span>
|
||||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
<p class="mt-2">로딩 중...</p>
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card" v-if="report">
|
<div v-else-if="report">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<h5 class="mb-0">
|
<div>
|
||||||
<i class="bi bi-journal-text me-2"></i>
|
<h4 class="mb-1">
|
||||||
{{ report.projectName }} - {{ report.reportYear }}-W{{ String(report.reportWeek).padStart(2, '0') }}
|
<i class="bi bi-journal-text me-2"></i>주간보고
|
||||||
</h5>
|
<span :class="getStatusBadgeClass(report.reportStatus)" class="ms-2">
|
||||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
{{ getStatusText(report.reportStatus) }}
|
||||||
{{ getStatusText(report.reportStatus) }}
|
</span>
|
||||||
</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>
|
||||||
|
|
||||||
<div class="card-body">
|
<!-- 보기 모드 -->
|
||||||
<!-- 기본 정보 -->
|
<div v-if="!isEditing">
|
||||||
<div class="row mb-4">
|
<!-- 프로젝트별 실적 -->
|
||||||
<div class="col-md-4">
|
<div class="card mb-4">
|
||||||
<label class="form-label text-muted">작성자</label>
|
<div class="card-header">
|
||||||
<p class="mb-0">{{ report.authorName }}</p>
|
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||||
|
<span class="badge bg-secondary ms-2">{{ projects.length }}개</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="card-body">
|
||||||
<label class="form-label text-muted">기간</label>
|
<div v-for="(proj, idx) in projects" :key="proj.detailId"
|
||||||
<p class="mb-0">{{ formatDate(report.weekStartDate) }} ~ {{ formatDate(report.weekEndDate) }}</p>
|
:class="{ 'border-top pt-3 mt-3': idx > 0 }">
|
||||||
</div>
|
<h6 class="mb-3">
|
||||||
<div class="col-md-4">
|
<i class="bi bi-folder2 me-1"></i>
|
||||||
<label class="form-label text-muted">투입시간</label>
|
{{ proj.projectName }}
|
||||||
<p class="mb-0">{{ report.workHours ? report.workHours + '시간' : '-' }}</p>
|
<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>
|
</div>
|
||||||
|
|
||||||
<!-- 금주 실적 -->
|
<!-- 공통 사항 -->
|
||||||
<div class="mb-4">
|
<div class="card mb-4">
|
||||||
<label class="form-label text-muted">
|
<div class="card-header">
|
||||||
<i class="bi bi-check-circle me-1"></i>금주 실적
|
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||||
</label>
|
</div>
|
||||||
<div class="p-3 bg-light rounded">
|
<div class="card-body">
|
||||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.workDescription || '-' }}</pre>
|
<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>
|
</div>
|
||||||
|
</div>
|
||||||
<!-- 차주 계획 -->
|
|
||||||
<div class="mb-4">
|
<!-- 수정 모드 -->
|
||||||
<label class="form-label text-muted">
|
<form v-else @submit.prevent="handleUpdate">
|
||||||
<i class="bi bi-calendar-event me-1"></i>차주 계획
|
<!-- 프로젝트별 실적 -->
|
||||||
</label>
|
<div class="card mb-4">
|
||||||
<div class="p-3 bg-light rounded">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.planDescription || '-' }}</pre>
|
<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>
|
</div>
|
||||||
|
|
||||||
<!-- 이슈사항 -->
|
<!-- 공통 사항 -->
|
||||||
<div class="mb-4" v-if="report.issueDescription">
|
<div class="card mb-4">
|
||||||
<label class="form-label text-muted">
|
<div class="card-header">
|
||||||
<i class="bi bi-exclamation-triangle me-1"></i>이슈/리스크
|
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||||
</label>
|
</div>
|
||||||
<div class="p-3 bg-warning bg-opacity-10 rounded">
|
<div class="card-body">
|
||||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.issueDescription }}</pre>
|
<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>
|
</div>
|
||||||
|
|
||||||
<!-- 비고 -->
|
<div class="d-flex justify-content-end gap-2">
|
||||||
<div class="mb-4" v-if="report.remarkDescription">
|
<button type="button" class="btn btn-secondary" @click="isEditing = false">취소</button>
|
||||||
<label class="form-label text-muted">
|
<button type="submit" class="btn btn-primary" :disabled="isSaving">
|
||||||
<i class="bi bi-chat-text me-1"></i>비고
|
<span v-if="isSaving" class="spinner-border spinner-border-sm me-1"></span>
|
||||||
</label>
|
저장
|
||||||
<div class="p-3 bg-light rounded">
|
|
||||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.remarkDescription }}</pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 작업 버튼 -->
|
|
||||||
<div class="d-flex gap-2 mt-4 pt-3 border-top">
|
|
||||||
<NuxtLink
|
|
||||||
v-if="report.reportStatus === 'DRAFT'"
|
|
||||||
:to="`/report/weekly/write?id=${report.reportId}`"
|
|
||||||
class="btn btn-primary"
|
|
||||||
>
|
|
||||||
<i class="bi bi-pencil me-1"></i> 수정
|
|
||||||
</NuxtLink>
|
|
||||||
<button
|
|
||||||
v-if="report.reportStatus === 'DRAFT'"
|
|
||||||
class="btn btn-success"
|
|
||||||
@click="submitReport"
|
|
||||||
>
|
|
||||||
<i class="bi bi-send me-1"></i> 제출
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-if="report.reportStatus === 'DRAFT'"
|
|
||||||
class="btn btn-outline-danger"
|
|
||||||
@click="deleteReport"
|
|
||||||
>
|
|
||||||
<i class="bi bi-trash me-1"></i> 삭제
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
</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>
|
||||||
|
<div class="modal-backdrop fade show" v-if="showProjectModal" @click="showProjectModal = false"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { fetchCurrentUser } = useAuth()
|
const { currentUser, fetchCurrentUser } = useAuth()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
|
const reportId = route.params.id as string
|
||||||
|
|
||||||
const report = ref<any>(null)
|
const report = ref<any>(null)
|
||||||
|
const projects = ref<any[]>([])
|
||||||
|
const allProjects = ref<any[]>([])
|
||||||
const isLoading = ref(true)
|
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 () => {
|
onMounted(async () => {
|
||||||
const user = await fetchCurrentUser()
|
const user = await fetchCurrentUser()
|
||||||
@@ -126,43 +233,114 @@ onMounted(async () => {
|
|||||||
router.push('/login')
|
router.push('/login')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await loadReport()
|
await loadReport()
|
||||||
|
await loadAllProjects()
|
||||||
})
|
})
|
||||||
|
|
||||||
async function loadReport() {
|
async function loadReport() {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
try {
|
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
|
report.value = res.report
|
||||||
|
projects.value = res.projects
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
alert('보고서를 불러오는데 실패했습니다.')
|
alert(e.data?.message || '보고서를 불러올 수 없습니다.')
|
||||||
router.push('/report/weekly')
|
router.push('/report/weekly')
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitReport() {
|
async function loadAllProjects() {
|
||||||
if (!confirm('보고서를 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await $fetch(`/api/report/weekly/${route.params.id}/submit`, { method: 'POST' })
|
const res = await $fetch<any>('/api/project/list')
|
||||||
await loadReport()
|
allProjects.value = res.projects || []
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
alert(e.data?.message || e.message || '제출에 실패했습니다.')
|
console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteReport() {
|
watch(isEditing, (val) => {
|
||||||
if (!confirm('보고서를 삭제하시겠습니까?')) return
|
if (val) {
|
||||||
|
editForm.value = {
|
||||||
try {
|
projects: projects.value.map(p => ({
|
||||||
await $fetch(`/api/report/weekly/${route.params.id}/detail`, { method: 'DELETE' })
|
projectId: p.projectId,
|
||||||
router.push('/report/weekly')
|
projectCode: p.projectCode,
|
||||||
} catch (e: any) {
|
projectName: p.projectName,
|
||||||
alert(e.data?.message || e.message || '삭제에 실패했습니다.')
|
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) {
|
function getStatusBadgeClass(status: string) {
|
||||||
@@ -182,9 +360,10 @@ function getStatusText(status: string) {
|
|||||||
}
|
}
|
||||||
return texts[status] || status
|
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>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.modal.show {
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -2,109 +2,61 @@
|
|||||||
<div>
|
<div>
|
||||||
<AppHeader />
|
<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 class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<div>
|
<h4 class="mb-0">
|
||||||
<h4><i class="bi bi-journal-text me-2"></i>주간보고</h4>
|
<i class="bi bi-journal-text me-2"></i>내 주간보고
|
||||||
<p class="text-muted mb-0">내가 작성한 주간보고 목록</p>
|
</h4>
|
||||||
</div>
|
|
||||||
<NuxtLink to="/report/weekly/write" class="btn btn-primary">
|
<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>
|
</NuxtLink>
|
||||||
</div>
|
</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="card">
|
||||||
<div class="table-responsive">
|
<div class="card-body p-0">
|
||||||
<table class="table table-hover mb-0">
|
<div class="table-responsive">
|
||||||
<thead class="table-light">
|
<table class="table table-hover mb-0">
|
||||||
<tr>
|
<thead class="table-light">
|
||||||
<th style="width: 80px">주차</th>
|
<tr>
|
||||||
<th>프로젝트</th>
|
<th style="width: 150px">주차</th>
|
||||||
<th style="width: 120px">기간</th>
|
<th style="width: 200px">기간</th>
|
||||||
<th style="width: 100px">상태</th>
|
<th>프로젝트</th>
|
||||||
<th style="width: 150px">작성일</th>
|
<th style="width: 100px">상태</th>
|
||||||
<th style="width: 100px">작업</th>
|
<th style="width: 150px">작성일</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="report in reports" :key="report.reportId">
|
<tr v-if="isLoading">
|
||||||
<td>
|
<td colspan="5" class="text-center py-4">
|
||||||
<strong>W{{ String(report.reportWeek).padStart(2, '0') }}</strong>
|
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||||
</td>
|
</td>
|
||||||
<td>{{ report.projectName }}</td>
|
</tr>
|
||||||
<td>
|
<tr v-else-if="reports.length === 0">
|
||||||
<small>{{ formatDateRange(report.weekStartDate, report.weekEndDate) }}</small>
|
<td colspan="5" class="text-center py-5 text-muted">
|
||||||
</td>
|
<i class="bi bi-inbox display-4"></i>
|
||||||
<td>
|
<p class="mt-2 mb-0">작성한 주간보고가 없습니다.</p>
|
||||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
</td>
|
||||||
{{ getStatusText(report.reportStatus) }}
|
</tr>
|
||||||
</span>
|
<tr v-else v-for="r in reports" :key="r.reportId"
|
||||||
</td>
|
@click="router.push(`/report/weekly/${r.reportId}`)"
|
||||||
<td>
|
style="cursor: pointer;">
|
||||||
<small>{{ formatDateTime(report.createdAt) }}</small>
|
<td>
|
||||||
</td>
|
<strong>{{ r.reportYear }}년 {{ r.reportWeek }}주차</strong>
|
||||||
<td>
|
</td>
|
||||||
<NuxtLink
|
<td>{{ formatDate(r.weekStartDate) }} ~ {{ formatDate(r.weekEndDate) }}</td>
|
||||||
:to="`/report/weekly/${report.reportId}`"
|
<td>
|
||||||
class="btn btn-sm btn-outline-primary"
|
<span class="badge bg-primary">{{ r.projectCount }}개 프로젝트</span>
|
||||||
>
|
</td>
|
||||||
<i class="bi bi-eye"></i>
|
<td>
|
||||||
</NuxtLink>
|
<span :class="getStatusBadgeClass(r.reportStatus)">
|
||||||
<button
|
{{ getStatusText(r.reportStatus) }}
|
||||||
v-if="report.reportStatus === 'DRAFT'"
|
</span>
|
||||||
class="btn btn-sm btn-outline-success ms-1"
|
</td>
|
||||||
@click="submitReport(report.reportId)"
|
<td>{{ formatDateTime(r.createdAt) }}</td>
|
||||||
>
|
</tr>
|
||||||
<i class="bi bi-send"></i>
|
</tbody>
|
||||||
</button>
|
</table>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
|
||||||
<tr v-if="reports.length === 0">
|
|
||||||
<td colspan="6" class="text-center py-5 text-muted">
|
|
||||||
<i class="bi bi-inbox display-4"></i>
|
|
||||||
<p class="mt-2 mb-0">보고서가 없습니다.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -115,17 +67,8 @@
|
|||||||
const { fetchCurrentUser } = useAuth()
|
const { fetchCurrentUser } = useAuth()
|
||||||
const router = useRouter()
|
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 reports = ref<any[]>([])
|
||||||
const projects = ref<any[]>([])
|
const isLoading = ref(true)
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const user = await fetchCurrentUser()
|
const user = await fetchCurrentUser()
|
||||||
@@ -133,42 +76,30 @@ onMounted(async () => {
|
|||||||
router.push('/login')
|
router.push('/login')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
loadReports()
|
||||||
await loadProjects()
|
|
||||||
await loadReports()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
async function loadProjects() {
|
|
||||||
try {
|
|
||||||
const res = await $fetch<{ projects: any[] }>('/api/project/my-projects')
|
|
||||||
projects.value = res.projects || []
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Load projects error:', e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadReports() {
|
async function loadReports() {
|
||||||
|
isLoading.value = true
|
||||||
try {
|
try {
|
||||||
const query: Record<string, any> = { year: filter.value.year }
|
const res = await $fetch<any>('/api/report/weekly/list')
|
||||||
if (filter.value.projectId) query.projectId = filter.value.projectId
|
|
||||||
if (filter.value.status) query.status = filter.value.status
|
|
||||||
|
|
||||||
const res = await $fetch<{ reports: any[] }>('/api/report/weekly/list', { query })
|
|
||||||
reports.value = res.reports || []
|
reports.value = res.reports || []
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Load reports error:', e)
|
console.error(e)
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitReport(reportId: number) {
|
function formatDate(dateStr: string) {
|
||||||
if (!confirm('보고서를 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
if (!dateStr) return ''
|
||||||
|
return dateStr.split('T')[0]
|
||||||
try {
|
}
|
||||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
|
||||||
await loadReports()
|
function formatDateTime(dateStr: string) {
|
||||||
} catch (e: any) {
|
if (!dateStr) return ''
|
||||||
alert(e.message || '제출에 실패했습니다.')
|
const d = new Date(dateStr)
|
||||||
}
|
return d.toLocaleDateString('ko-KR')
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatusBadgeClass(status: string) {
|
function getStatusBadgeClass(status: string) {
|
||||||
@@ -188,18 +119,4 @@ function getStatusText(status: string) {
|
|||||||
}
|
}
|
||||||
return texts[status] || status
|
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>
|
</script>
|
||||||
|
|||||||
@@ -2,189 +2,150 @@
|
|||||||
<div>
|
<div>
|
||||||
<AppHeader />
|
<AppHeader />
|
||||||
|
|
||||||
<div class="container-fluid py-4">
|
<div class="container py-4">
|
||||||
<div class="mb-4">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<NuxtLink to="/report/weekly" class="text-decoration-none">
|
<h4 class="mb-0">
|
||||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
<i class="bi bi-journal-plus me-2"></i>주간보고 작성
|
||||||
</NuxtLink>
|
</h4>
|
||||||
|
<span class="text-muted">{{ weekInfo.weekString }} ({{ weekInfo.startDateStr }} ~ {{ weekInfo.endDateStr }})</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<form @submit.prevent="handleSubmit">
|
||||||
<div class="col-lg-8">
|
<!-- 프로젝트별 실적 -->
|
||||||
<div class="card">
|
<div class="card mb-4">
|
||||||
<div class="card-header">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0">
|
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||||
<i class="bi bi-pencil-square me-2"></i>
|
<button type="button" class="btn btn-sm btn-outline-primary" @click="showProjectModal = true">
|
||||||
{{ isEdit ? '주간보고 수정' : '주간보고 작성' }}
|
<i class="bi bi-plus"></i> 프로젝트 추가
|
||||||
</h5>
|
</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>
|
||||||
<div class="card-body">
|
|
||||||
<form @submit.prevent="handleSubmit">
|
<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 class="mb-3">
|
<div>
|
||||||
<label class="form-label">프로젝트 <span class="text-danger">*</span></label>
|
<strong>{{ proj.projectName }}</strong>
|
||||||
<select class="form-select" v-model="form.projectId" required :disabled="isEdit">
|
<small class="text-muted ms-2">({{ proj.projectCode }})</small>
|
||||||
<option value="">프로젝트를 선택하세요</option>
|
|
||||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
|
||||||
{{ p.projectName }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
<button type="button" class="btn btn-sm btn-outline-danger" @click="removeProject(idx)">
|
||||||
<!-- 주차 선택 -->
|
<i class="bi bi-x"></i> 삭제
|
||||||
<div class="row mb-3">
|
</button>
|
||||||
<div class="col-md-4">
|
</div>
|
||||||
<label class="form-label">연도</label>
|
<div class="mb-3">
|
||||||
<select class="form-select" v-model="form.reportYear" :disabled="isEdit">
|
<label class="form-label">금주 실적</label>
|
||||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
<textarea class="form-control" rows="3" v-model="proj.workDescription"
|
||||||
</select>
|
placeholder="이번 주에 수행한 업무를 작성해주세요."></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div>
|
||||||
<label class="form-label">주차</label>
|
<label class="form-label">차주 계획</label>
|
||||||
<select class="form-select" v-model="form.reportWeek" :disabled="isEdit">
|
<textarea class="form-control" rows="3" v-model="proj.planDescription"
|
||||||
<option v-for="w in 53" :key="w" :value="w">
|
placeholder="다음 주에 수행할 업무를 작성해주세요."></textarea>
|
||||||
W{{ String(w).padStart(2, '0') }}
|
</div>
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label class="form-label">기간</label>
|
|
||||||
<input type="text" class="form-control" :value="weekRangeText" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 금주 실적 -->
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">금주 실적 <span class="text-danger">*</span></label>
|
|
||||||
<textarea
|
|
||||||
class="form-control"
|
|
||||||
v-model="form.workDescription"
|
|
||||||
rows="5"
|
|
||||||
placeholder="이번 주에 수행한 업무 내용을 작성해주세요."
|
|
||||||
required
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 차주 계획 -->
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">차주 계획</label>
|
|
||||||
<textarea
|
|
||||||
class="form-control"
|
|
||||||
v-model="form.planDescription"
|
|
||||||
rows="4"
|
|
||||||
placeholder="다음 주에 수행할 업무 계획을 작성해주세요."
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 이슈사항 -->
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">이슈/리스크</label>
|
|
||||||
<textarea
|
|
||||||
class="form-control"
|
|
||||||
v-model="form.issueDescription"
|
|
||||||
rows="3"
|
|
||||||
placeholder="업무 진행 중 발생한 이슈나 리스크를 작성해주세요."
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 비고 -->
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">비고</label>
|
|
||||||
<textarea
|
|
||||||
class="form-control"
|
|
||||||
v-model="form.remarkDescription"
|
|
||||||
rows="2"
|
|
||||||
placeholder="기타 참고사항"
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 투입시간 -->
|
|
||||||
<div class="mb-4">
|
|
||||||
<label class="form-label">투입 시간 (선택)</label>
|
|
||||||
<div class="input-group" style="max-width: 200px;">
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
class="form-control"
|
|
||||||
v-model="form.workHours"
|
|
||||||
min="0"
|
|
||||||
max="100"
|
|
||||||
step="0.5"
|
|
||||||
/>
|
|
||||||
<span class="input-group-text">시간</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 버튼 -->
|
|
||||||
<div class="d-flex gap-2">
|
|
||||||
<button type="submit" class="btn btn-primary" :disabled="isSubmitting">
|
|
||||||
<span v-if="isSubmitting" class="spinner-border spinner-border-sm me-1"></span>
|
|
||||||
<i class="bi bi-save me-1" v-else></i>
|
|
||||||
{{ isEdit ? '수정' : '저장' }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-success"
|
|
||||||
@click="handleSaveAndSubmit"
|
|
||||||
:disabled="isSubmitting"
|
|
||||||
>
|
|
||||||
<i class="bi bi-send me-1"></i> 저장 후 제출
|
|
||||||
</button>
|
|
||||||
<NuxtLink to="/report/weekly" class="btn btn-outline-secondary">
|
|
||||||
취소
|
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 사이드 안내 -->
|
<!-- 공통 사항 -->
|
||||||
<div class="col-lg-4">
|
<div class="card mb-4">
|
||||||
<div class="card bg-light">
|
<div class="card-header">
|
||||||
<div class="card-body">
|
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||||
<h6><i class="bi bi-info-circle me-1"></i> 작성 안내</h6>
|
</div>
|
||||||
<ul class="mb-0 ps-3">
|
<div class="card-body">
|
||||||
<li>금주 실적은 필수 항목입니다.</li>
|
<div class="mb-3">
|
||||||
<li>같은 프로젝트, 같은 주차에 하나의 보고서만 작성 가능합니다.</li>
|
<label class="form-label">이슈/리스크</label>
|
||||||
<li>제출 후에는 수정이 제한됩니다.</li>
|
<textarea class="form-control" rows="3" v-model="form.issueDescription"
|
||||||
<li>취합은 매주 자동으로 진행됩니다.</li>
|
placeholder="진행 중 발생한 이슈나 리스크를 작성해주세요."></textarea>
|
||||||
</ul>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal-backdrop fade show" v-if="showProjectModal" @click="showProjectModal = false"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { fetchCurrentUser } = useAuth()
|
const { fetchCurrentUser } = useAuth()
|
||||||
const { getCurrentWeekInfo, getWeekRangeText } = useWeekCalc()
|
const { getCurrentWeekInfo } = useWeekCalc()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
const currentWeek = getCurrentWeekInfo()
|
const weekInfo = getCurrentWeekInfo()
|
||||||
const currentYear = new Date().getFullYear()
|
|
||||||
const years = [currentYear, currentYear - 1]
|
|
||||||
|
|
||||||
const isEdit = computed(() => !!route.query.id)
|
interface ProjectItem {
|
||||||
const isSubmitting = ref(false)
|
projectId: number
|
||||||
|
projectCode: string
|
||||||
|
projectName: string
|
||||||
|
workDescription: string
|
||||||
|
planDescription: string
|
||||||
|
}
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
projectId: '',
|
projects: [] as ProjectItem[],
|
||||||
reportYear: currentWeek.year,
|
|
||||||
reportWeek: currentWeek.week,
|
|
||||||
workDescription: '',
|
|
||||||
planDescription: '',
|
|
||||||
issueDescription: '',
|
issueDescription: '',
|
||||||
remarkDescription: '',
|
vacationDescription: '',
|
||||||
workHours: null as number | null
|
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 () => {
|
onMounted(async () => {
|
||||||
@@ -193,105 +154,72 @@ onMounted(async () => {
|
|||||||
router.push('/login')
|
router.push('/login')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
loadProjects()
|
||||||
await loadProjects()
|
|
||||||
|
|
||||||
if (route.query.id) {
|
|
||||||
await loadReport(Number(route.query.id))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
async function loadProjects() {
|
async function loadProjects() {
|
||||||
|
isLoadingProjects.value = true
|
||||||
try {
|
try {
|
||||||
const res = await $fetch<{ projects: any[] }>('/api/project/list')
|
const res = await $fetch<any>('/api/project/list')
|
||||||
projects.value = res.projects || []
|
allProjects.value = res.projects || []
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Load projects error:', e)
|
console.error(e)
|
||||||
|
} finally {
|
||||||
|
isLoadingProjects.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadReport(reportId: number) {
|
function addProject(p: any) {
|
||||||
try {
|
form.value.projects.push({
|
||||||
const res = await $fetch<{ report: any }>(`/api/report/weekly/${reportId}/detail`)
|
projectId: p.projectId,
|
||||||
const r = res.report
|
projectCode: p.projectCode,
|
||||||
form.value = {
|
projectName: p.projectName,
|
||||||
projectId: r.projectId,
|
workDescription: '',
|
||||||
reportYear: r.reportYear,
|
planDescription: ''
|
||||||
reportWeek: r.reportWeek,
|
})
|
||||||
workDescription: r.workDescription || '',
|
showProjectModal.value = false
|
||||||
planDescription: r.planDescription || '',
|
}
|
||||||
issueDescription: r.issueDescription || '',
|
|
||||||
remarkDescription: r.remarkDescription || '',
|
function removeProject(idx: number) {
|
||||||
workHours: r.workHours
|
form.value.projects.splice(idx, 1)
|
||||||
}
|
|
||||||
} catch (e: any) {
|
|
||||||
alert('보고서를 불러오는데 실패했습니다.')
|
|
||||||
router.push('/report/weekly')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
if (!form.value.projectId || !form.value.workDescription) {
|
if (form.value.projects.length === 0) {
|
||||||
alert('프로젝트와 금주 실적은 필수입니다.')
|
alert('최소 1개 이상의 프로젝트를 추가해주세요.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
isSubmitting.value = true
|
isSubmitting.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isEdit.value) {
|
const res = await $fetch<any>('/api/report/weekly/create', {
|
||||||
await $fetch(`/api/report/weekly/${route.query.id}/update`, {
|
method: 'POST',
|
||||||
method: 'PUT',
|
body: {
|
||||||
body: form.value
|
reportYear: weekInfo.year,
|
||||||
})
|
reportWeek: weekInfo.week,
|
||||||
} else {
|
projects: form.value.projects.map(p => ({
|
||||||
await $fetch('/api/report/weekly/create', {
|
projectId: p.projectId,
|
||||||
method: 'POST',
|
workDescription: p.workDescription,
|
||||||
body: form.value
|
planDescription: p.planDescription
|
||||||
})
|
})),
|
||||||
}
|
issueDescription: form.value.issueDescription,
|
||||||
router.push('/report/weekly')
|
vacationDescription: form.value.vacationDescription,
|
||||||
} catch (e: any) {
|
remarkDescription: form.value.remarkDescription
|
||||||
alert(e.data?.message || e.message || '저장에 실패했습니다.')
|
}
|
||||||
} finally {
|
})
|
||||||
isSubmitting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSaveAndSubmit() {
|
|
||||||
if (!form.value.projectId || !form.value.workDescription) {
|
|
||||||
alert('프로젝트와 금주 실적은 필수입니다.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!confirm('저장 후 바로 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
|
||||||
|
|
||||||
isSubmitting.value = true
|
|
||||||
|
|
||||||
try {
|
|
||||||
let reportId: number
|
|
||||||
|
|
||||||
if (isEdit.value) {
|
alert('저장되었습니다.')
|
||||||
await $fetch(`/api/report/weekly/${route.query.id}/update`, {
|
router.push(`/report/weekly/${res.reportId}`)
|
||||||
method: 'PUT',
|
|
||||||
body: form.value
|
|
||||||
})
|
|
||||||
reportId = Number(route.query.id)
|
|
||||||
} else {
|
|
||||||
const res = await $fetch<{ report: any }>('/api/report/weekly/create', {
|
|
||||||
method: 'POST',
|
|
||||||
body: form.value
|
|
||||||
})
|
|
||||||
reportId = res.report.reportId
|
|
||||||
}
|
|
||||||
|
|
||||||
// 제출
|
|
||||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
|
||||||
router.push('/report/weekly')
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
alert(e.data?.message || e.message || '처리에 실패했습니다.')
|
alert(e.data?.message || '저장에 실패했습니다.')
|
||||||
} finally {
|
} finally {
|
||||||
isSubmitting.value = false
|
isSubmitting.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</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',
|
compatibilityDate: '2024-11-01',
|
||||||
devtools: { enabled: true },
|
devtools: { enabled: true },
|
||||||
|
|
||||||
|
// 개발 서버 포트
|
||||||
|
devServer: {
|
||||||
|
port: 2026
|
||||||
|
},
|
||||||
|
|
||||||
// 서버 설정
|
// 서버 설정
|
||||||
nitro: {
|
nitro: {
|
||||||
experimental: {
|
experimental: {
|
||||||
|
|||||||
Reference in New Issue
Block a user