1ㅊㅏ완료
This commit is contained in:
@@ -50,9 +50,29 @@ export function useWeekCalc() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 이번 주 정보
|
||||
* 이번 주 정보 (보고서 기준)
|
||||
* - 금~일: 현재 주차
|
||||
* - 월~목: 이전 주차
|
||||
*/
|
||||
function getCurrentWeekInfo(): WeekInfo {
|
||||
const today = new Date()
|
||||
const dayOfWeek = today.getDay() // 0=일, 1=월, ..., 5=금, 6=토
|
||||
|
||||
// 월~목 (1~4)이면 이전 주차 기준
|
||||
if (dayOfWeek >= 1 && dayOfWeek <= 4) {
|
||||
const lastWeek = new Date(today)
|
||||
lastWeek.setDate(today.getDate() - 7)
|
||||
return getWeekInfo(lastWeek)
|
||||
}
|
||||
|
||||
// 금~일 (5, 6, 0)이면 현재 주차 기준
|
||||
return getWeekInfo(today)
|
||||
}
|
||||
|
||||
/**
|
||||
* 실제 이번 주 정보 (달력 기준, 항상 현재 주차)
|
||||
*/
|
||||
function getActualCurrentWeekInfo(): WeekInfo {
|
||||
return getWeekInfo(new Date())
|
||||
}
|
||||
|
||||
@@ -110,6 +130,7 @@ export function useWeekCalc() {
|
||||
return {
|
||||
getWeekInfo,
|
||||
getCurrentWeekInfo,
|
||||
getActualCurrentWeekInfo,
|
||||
getLastWeekInfo,
|
||||
formatDate,
|
||||
parseWeekString,
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<th style="width: 150px">소속사</th>
|
||||
<th style="width: 120px">직급</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 80px">상세</th>
|
||||
<th style="width: 120px">관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -69,10 +69,18 @@
|
||||
<td>
|
||||
<NuxtLink
|
||||
:to="`/employee/${emp.employeeId}`"
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
class="btn btn-sm btn-outline-primary me-1"
|
||||
title="상세보기"
|
||||
>
|
||||
<i class="bi bi-eye"></i>
|
||||
</NuxtLink>
|
||||
<button
|
||||
class="btn btn-sm btn-outline-danger"
|
||||
@click.stop="confirmDelete(emp)"
|
||||
title="삭제"
|
||||
>
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!isLoading && filteredEmployees.length === 0">
|
||||
@@ -153,6 +161,37 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showCreateModal"></div>
|
||||
|
||||
<!-- 삭제 확인 모달 -->
|
||||
<div class="modal fade" :class="{ show: showDeleteModal }" :style="{ display: showDeleteModal ? 'block' : 'none' }">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title text-danger">
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>직원 삭제
|
||||
</h5>
|
||||
<button type="button" class="btn-close" @click="showDeleteModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
<strong>{{ deleteTarget?.employeeName }}</strong> ({{ deleteTarget?.employeeEmail }}) 님을 삭제하시겠습니까?
|
||||
</p>
|
||||
<div class="alert alert-warning small">
|
||||
<i class="bi bi-info-circle me-1"></i>
|
||||
주간보고가 있는 경우 비활성화 처리됩니다.
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" @click="showDeleteModal = false">취소</button>
|
||||
<button type="button" class="btn btn-danger" @click="deleteEmployee" :disabled="isDeleting">
|
||||
<span v-if="isDeleting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
<i v-else class="bi bi-trash me-1"></i>삭제
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showDeleteModal"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -164,7 +203,10 @@ const employees = ref<any[]>([])
|
||||
const searchKeyword = ref('')
|
||||
const filterStatus = ref('')
|
||||
const showCreateModal = ref(false)
|
||||
const showDeleteModal = ref(false)
|
||||
const deleteTarget = ref<any>(null)
|
||||
const isLoading = ref(true)
|
||||
const isDeleting = ref(false)
|
||||
|
||||
const newEmployee = ref({
|
||||
employeeName: '',
|
||||
@@ -243,6 +285,32 @@ async function createEmployee() {
|
||||
alert(e.data?.message || e.message || '등록에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
function confirmDelete(emp: any) {
|
||||
deleteTarget.value = emp
|
||||
showDeleteModal.value = true
|
||||
}
|
||||
|
||||
async function deleteEmployee() {
|
||||
if (!deleteTarget.value) return
|
||||
|
||||
isDeleting.value = true
|
||||
try {
|
||||
const res = await $fetch<{ success: boolean; action: string; message: string }>(
|
||||
`/api/employee/${deleteTarget.value.employeeId}/delete`,
|
||||
{ method: 'DELETE' }
|
||||
)
|
||||
|
||||
alert(res.message)
|
||||
showDeleteModal.value = false
|
||||
deleteTarget.value = null
|
||||
await loadEmployees()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '삭제에 실패했습니다.')
|
||||
} finally {
|
||||
isDeleting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -3,77 +3,90 @@
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<!-- 헤더 -->
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h4>
|
||||
<i class="bi bi-speedometer2 me-2"></i>대시보드
|
||||
</h4>
|
||||
<p class="text-muted mb-0">
|
||||
{{ currentWeek.weekString }} ({{ currentWeek.startDateStr }} ~ {{ currentWeek.endDateStr }})
|
||||
</p>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<h4 class="mb-1">
|
||||
<i class="bi bi-speedometer2 me-2"></i>리소스 현황
|
||||
</h4>
|
||||
<p class="text-muted mb-0">
|
||||
{{ currentWeek.year }}년 {{ currentWeek.week }}주차
|
||||
({{ currentWeek.startDateStr }} ~ {{ currentWeek.endDateStr }})
|
||||
</p>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<select class="form-select form-select-sm" style="width: 100px;" v-model="selectedYear" @change="loadStats">
|
||||
<option v-for="y in yearOptions" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
<select class="form-select form-select-sm" style="width: 90px;" v-model="selectedWeek" @change="loadStats">
|
||||
<option v-for="w in weekOptions" :key="w" :value="w">{{ w }}주</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 요약 카드 -->
|
||||
<div class="row g-4 mb-4">
|
||||
<div class="col-md-3">
|
||||
<div class="card border-primary h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h6 class="text-muted">이번 주 내 보고서</h6>
|
||||
<h2 class="mb-0">{{ stats.myReportsThisWeek }}</h2>
|
||||
</div>
|
||||
<div class="text-primary">
|
||||
<i class="bi bi-journal-text display-4"></i>
|
||||
</div>
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-md-2">
|
||||
<div class="card h-100 border-primary">
|
||||
<div class="card-body text-center">
|
||||
<div class="text-muted small">제출현황</div>
|
||||
<h3 class="mb-0">
|
||||
<span class="text-primary">{{ stats.summary.submittedCount }}</span>
|
||||
<span class="text-muted">/{{ stats.summary.activeEmployees }}</span>
|
||||
</h3>
|
||||
<div class="small" :class="stats.summary.notSubmittedCount > 0 ? 'text-danger' : 'text-success'">
|
||||
{{ stats.summary.notSubmittedCount > 0 ? `${stats.summary.notSubmittedCount}명 미제출` : '전원 제출' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card border-success h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h6 class="text-muted">참여 프로젝트</h6>
|
||||
<h2 class="mb-0">{{ stats.myProjects }}</h2>
|
||||
</div>
|
||||
<div class="text-success">
|
||||
<i class="bi bi-folder-check display-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="card h-100 border-success">
|
||||
<div class="card-body text-center">
|
||||
<div class="text-muted small">금주 실적</div>
|
||||
<h3 class="mb-0 text-success">{{ formatHours(stats.summary.totalWorkHours) }}</h3>
|
||||
<div class="small text-muted">{{ stats.summary.projectCount }}개 프로젝트</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card border-info h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h6 class="text-muted">이번 주 취합</h6>
|
||||
<h2 class="mb-0">{{ stats.summariesThisWeek }}</h2>
|
||||
</div>
|
||||
<div class="text-info">
|
||||
<i class="bi bi-collection display-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="card h-100 border-info">
|
||||
<div class="card-body text-center">
|
||||
<div class="text-muted small">차주 계획</div>
|
||||
<h3 class="mb-0 text-info">{{ formatHours(stats.summary.totalPlanHours) }}</h3>
|
||||
<div class="small text-muted">예정 업무량</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card border-warning h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="card h-100">
|
||||
<div class="card-body text-center">
|
||||
<div class="text-muted small">평균 업무시간</div>
|
||||
<h3 class="mb-0">{{ formatHours(avgWorkHours) }}</h3>
|
||||
<div class="small text-muted">인당 (40h 기준)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card h-100">
|
||||
<div class="card-body text-center">
|
||||
<div class="text-muted small">리소스 현황</div>
|
||||
<div class="d-flex justify-content-around mt-1">
|
||||
<div>
|
||||
<h6 class="text-muted">전체 프로젝트</h6>
|
||||
<h2 class="mb-0">{{ stats.totalProjects }}</h2>
|
||||
<span class="badge bg-success">{{ resourceStatus.available }}</span>
|
||||
<div class="small text-muted">여유</div>
|
||||
</div>
|
||||
<div class="text-warning">
|
||||
<i class="bi bi-briefcase display-4"></i>
|
||||
<div>
|
||||
<span class="badge bg-primary">{{ resourceStatus.normal }}</span>
|
||||
<div class="small text-muted">정상</div>
|
||||
</div>
|
||||
<div>
|
||||
<span class="badge bg-danger">{{ resourceStatus.overload }}</span>
|
||||
<div class="small text-muted">과부하</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -82,85 +95,142 @@
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
<!-- 내 주간보고 -->
|
||||
<!-- 인원별 현황 -->
|
||||
<div class="col-lg-6">
|
||||
<div class="card h-100">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span><i class="bi bi-journal-text me-2"></i>내 주간보고</span>
|
||||
<NuxtLink to="/report/weekly/write" class="btn btn-primary btn-sm">
|
||||
<i class="bi bi-plus"></i> 작성
|
||||
</NuxtLink>
|
||||
<span><i class="bi bi-people me-2"></i>인원별 업무 현황</span>
|
||||
<div class="small text-muted">
|
||||
<span class="badge bg-success me-1">~32h</span>
|
||||
<span class="badge bg-primary me-1">32~48h</span>
|
||||
<span class="badge bg-danger">48h~</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="list-group list-group-flush" v-if="myReports.length > 0">
|
||||
<NuxtLink
|
||||
v-for="report in myReports"
|
||||
:key="report.reportId"
|
||||
:to="`/report/weekly/${report.reportId}`"
|
||||
class="list-group-item list-group-item-action"
|
||||
>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<strong>{{ report.projectName }}</strong>
|
||||
<br />
|
||||
<small class="text-muted">
|
||||
{{ report.reportYear }}-W{{ String(report.reportWeek).padStart(2, '0') }}
|
||||
</small>
|
||||
</div>
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="p-4 text-center text-muted" v-else>
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">작성한 보고서가 없습니다.</p>
|
||||
</div>
|
||||
<div class="card-body p-0" style="max-height: 500px; overflow-y: auto;">
|
||||
<table class="table table-sm table-hover mb-0">
|
||||
<thead class="table-light sticky-top">
|
||||
<tr>
|
||||
<th>이름</th>
|
||||
<th class="text-center" style="width: 80px;">금주실적</th>
|
||||
<th class="text-center" style="width: 80px;">차주계획</th>
|
||||
<th class="text-center" style="width: 60px;">상태</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="emp in stats.employees" :key="emp.employeeId"
|
||||
:class="{ 'table-light text-muted': !emp.isSubmitted }">
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<span :class="getWorkloadBadge(emp.workHours)" class="me-2" style="width: 8px; height: 8px; border-radius: 50%; display: inline-block;"></span>
|
||||
<div>
|
||||
<div>{{ emp.employeeName }}</div>
|
||||
<div class="small text-muted">{{ emp.company || '' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span v-if="emp.isSubmitted" :class="getWorkloadClass(emp.workHours)">
|
||||
{{ emp.workHours }}h
|
||||
</span>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span v-if="emp.isSubmitted" :class="getWorkloadClass(emp.planHours)">
|
||||
{{ emp.planHours }}h
|
||||
</span>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span v-if="emp.isSubmitted" class="badge bg-success">제출</span>
|
||||
<span v-else class="badge bg-secondary">미제출</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="stats.employees.length === 0">
|
||||
<td colspan="4" class="text-center py-4 text-muted">데이터가 없습니다.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 최근 취합 보고서 -->
|
||||
<!-- 프로젝트별 현황 -->
|
||||
<div class="col-lg-6">
|
||||
<div class="card h-100">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span><i class="bi bi-collection me-2"></i>최근 취합 보고서</span>
|
||||
<NuxtLink to="/report/summary" class="btn btn-outline-secondary btn-sm">
|
||||
전체보기
|
||||
</NuxtLink>
|
||||
<div class="card-header">
|
||||
<i class="bi bi-briefcase me-2"></i>프로젝트별 투입 현황
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="list-group list-group-flush" v-if="summaries.length > 0">
|
||||
<NuxtLink
|
||||
v-for="summary in summaries"
|
||||
:key="summary.summaryId"
|
||||
:to="`/report/summary/${summary.summaryId}`"
|
||||
class="list-group-item list-group-item-action"
|
||||
>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<strong>{{ summary.projectName }}</strong>
|
||||
<br />
|
||||
<small class="text-muted">
|
||||
{{ summary.reportYear }}-W{{ String(summary.reportWeek).padStart(2, '0') }}
|
||||
· {{ summary.memberCount }}명 참여
|
||||
</small>
|
||||
</div>
|
||||
<span :class="getSummaryBadgeClass(summary.summaryStatus)">
|
||||
{{ getSummaryStatusText(summary.summaryStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="p-4 text-center text-muted" v-else>
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">취합된 보고서가 없습니다.</p>
|
||||
</div>
|
||||
<div class="card-body p-0" style="max-height: 500px; overflow-y: auto;">
|
||||
<table class="table table-sm table-hover mb-0">
|
||||
<thead class="table-light sticky-top">
|
||||
<tr>
|
||||
<th>프로젝트</th>
|
||||
<th class="text-center" style="width: 60px;">인원</th>
|
||||
<th class="text-center" style="width: 80px;">금주실적</th>
|
||||
<th class="text-center" style="width: 80px;">차주계획</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="proj in stats.projects" :key="proj.projectId">
|
||||
<td>
|
||||
<div>{{ proj.projectName }}</div>
|
||||
<div class="small text-muted">{{ proj.members.slice(0, 3).join(', ') }}{{ proj.members.length > 3 ? ` 외 ${proj.members.length - 3}명` : '' }}</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-primary">{{ proj.memberCount }}명</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<strong>{{ proj.workHours }}h</strong>
|
||||
</td>
|
||||
<td class="text-center text-info">
|
||||
{{ proj.planHours }}h
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="stats.projects.length === 0">
|
||||
<td colspan="4" class="text-center py-4 text-muted">데이터가 없습니다.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 하단: 빠른 링크 -->
|
||||
<div class="row g-3 mt-3">
|
||||
<div class="col-md-3">
|
||||
<NuxtLink to="/report/weekly/write" class="card text-decoration-none h-100">
|
||||
<div class="card-body text-center py-3">
|
||||
<i class="bi bi-plus-circle display-6 text-primary"></i>
|
||||
<div class="mt-2">주간보고 작성</div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<NuxtLink to="/report/weekly" class="card text-decoration-none h-100">
|
||||
<div class="card-body text-center py-3">
|
||||
<i class="bi bi-journal-text display-6 text-success"></i>
|
||||
<div class="mt-2">주간보고 목록</div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="col-md-3" v-if="isAdmin">
|
||||
<NuxtLink to="/report/summary" class="card text-decoration-none h-100">
|
||||
<div class="card-body text-center py-3">
|
||||
<i class="bi bi-collection display-6 text-info"></i>
|
||||
<div class="mt-2">취합 보고서</div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<NuxtLink to="/project" class="card text-decoration-none h-100">
|
||||
<div class="card-body text-center py-3">
|
||||
<i class="bi bi-briefcase display-6 text-warning"></i>
|
||||
<div class="mt-2">프로젝트 관리</div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -171,18 +241,46 @@ const { getCurrentWeekInfo } = useWeekCalc()
|
||||
const router = useRouter()
|
||||
|
||||
const currentWeek = getCurrentWeekInfo()
|
||||
const isAdmin = ref(false)
|
||||
|
||||
const stats = ref({
|
||||
myReportsThisWeek: 0,
|
||||
myProjects: 0,
|
||||
summariesThisWeek: 0,
|
||||
totalProjects: 0
|
||||
const currentYear = new Date().getFullYear()
|
||||
const yearOptions = [currentYear, currentYear - 1]
|
||||
const weekOptions = Array.from({ length: 53 }, (_, i) => i + 1)
|
||||
|
||||
const selectedYear = ref(currentWeek.year)
|
||||
const selectedWeek = ref(currentWeek.week)
|
||||
|
||||
const stats = ref<any>({
|
||||
summary: {
|
||||
activeEmployees: 0,
|
||||
submittedCount: 0,
|
||||
notSubmittedCount: 0,
|
||||
totalWorkHours: 0,
|
||||
totalPlanHours: 0,
|
||||
projectCount: 0
|
||||
},
|
||||
employees: [],
|
||||
projects: []
|
||||
})
|
||||
|
||||
const myReports = ref<any[]>([])
|
||||
const summaries = ref<any[]>([])
|
||||
// 평균 업무시간 (제출자 기준)
|
||||
const avgWorkHours = computed(() => {
|
||||
const submitted = stats.value.employees.filter((e: any) => e.isSubmitted)
|
||||
if (submitted.length === 0) return 0
|
||||
const total = submitted.reduce((sum: number, e: any) => sum + e.workHours, 0)
|
||||
return Math.round(total / submitted.length)
|
||||
})
|
||||
|
||||
// 리소스 현황 (여유/정상/과부하)
|
||||
const resourceStatus = computed(() => {
|
||||
const submitted = stats.value.employees.filter((e: any) => e.isSubmitted)
|
||||
return {
|
||||
available: submitted.filter((e: any) => e.workHours < 32).length,
|
||||
normal: submitted.filter((e: any) => e.workHours >= 32 && e.workHours <= 48).length,
|
||||
overload: submitted.filter((e: any) => e.workHours > 48).length
|
||||
}
|
||||
})
|
||||
|
||||
// 로그인 체크 및 데이터 로드
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
@@ -190,77 +288,40 @@ onMounted(async () => {
|
||||
return
|
||||
}
|
||||
|
||||
await loadDashboardData()
|
||||
isAdmin.value = user.employeeEmail === 'coziny@gmail.com'
|
||||
await loadStats()
|
||||
})
|
||||
|
||||
async function loadDashboardData() {
|
||||
async function loadStats() {
|
||||
try {
|
||||
// 내 주간보고 목록
|
||||
const reportsRes = await $fetch<{ reports: any[] }>('/api/report/weekly/list', {
|
||||
query: { limit: 5 }
|
||||
const res = await $fetch<any>('/api/dashboard/stats', {
|
||||
query: { year: selectedYear.value, week: selectedWeek.value }
|
||||
})
|
||||
myReports.value = reportsRes.reports || []
|
||||
|
||||
// 취합 보고서 목록
|
||||
const summariesRes = await $fetch<{ summaries: any[] }>('/api/report/summary/list', {
|
||||
query: { limit: 5 }
|
||||
})
|
||||
summaries.value = summariesRes.summaries || []
|
||||
|
||||
// 내 프로젝트
|
||||
const projectsRes = await $fetch<{ projects: any[] }>('/api/project/my-projects')
|
||||
|
||||
// 전체 프로젝트
|
||||
const allProjectsRes = await $fetch<{ projects: any[] }>('/api/project/list')
|
||||
|
||||
// 통계 계산
|
||||
stats.value = {
|
||||
myReportsThisWeek: myReports.value.filter(r =>
|
||||
r.reportYear === currentWeek.year && r.reportWeek === currentWeek.week
|
||||
).length,
|
||||
myProjects: projectsRes.projects?.length || 0,
|
||||
summariesThisWeek: summaries.value.filter(s =>
|
||||
s.reportYear === currentWeek.year && s.reportWeek === currentWeek.week
|
||||
).length,
|
||||
totalProjects: allProjectsRes.projects?.length || 0
|
||||
}
|
||||
stats.value = res
|
||||
} catch (e) {
|
||||
console.error('Dashboard data load error:', e)
|
||||
console.error('Dashboard stats error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'DRAFT': 'badge bg-secondary',
|
||||
'SUBMITTED': 'badge bg-success',
|
||||
'AGGREGATED': 'badge bg-info'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
function formatHours(hours: number): string {
|
||||
if (!hours || hours <= 0) return '0h'
|
||||
const days = Math.floor(hours / 8)
|
||||
const remain = hours % 8
|
||||
if (days === 0) return `${hours}h`
|
||||
if (remain === 0) return `${days}일`
|
||||
return `${days}일 ${remain}h`
|
||||
}
|
||||
|
||||
function getStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'DRAFT': '작성중',
|
||||
'SUBMITTED': '제출완료',
|
||||
'AGGREGATED': '취합완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
function getWorkloadBadge(hours: number): string {
|
||||
if (hours < 32) return 'bg-success'
|
||||
if (hours <= 48) return 'bg-primary'
|
||||
return 'bg-danger'
|
||||
}
|
||||
|
||||
function getSummaryBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'AGGREGATED': 'badge bg-info',
|
||||
'REVIEWED': 'badge bg-success'
|
||||
}
|
||||
return classes[status] || 'badge bg-secondary'
|
||||
}
|
||||
|
||||
function getSummaryStatusText(status: string) {
|
||||
const texts: Record<string, string> = {
|
||||
'AGGREGATED': '취합완료',
|
||||
'REVIEWED': '검토완료'
|
||||
}
|
||||
return texts[status] || status
|
||||
function getWorkloadClass(hours: number): string {
|
||||
if (hours < 32) return 'text-success'
|
||||
if (hours <= 48) return ''
|
||||
return 'text-danger fw-bold'
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -272,4 +333,12 @@ function getSummaryStatusText(status: string) {
|
||||
background-color: #f8f9fa;
|
||||
font-weight: 500;
|
||||
}
|
||||
.sticky-top {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
a.card:hover {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -45,10 +45,10 @@
|
||||
<tbody>
|
||||
<tr v-for="week in weeklyList" :key="week.reportWeek">
|
||||
<td>
|
||||
<strong class="text-primary">{{ week.reportWeek }}주차</strong>
|
||||
<strong>{{ week.reportYear }}년 {{ week.reportWeek }}주</strong>
|
||||
</td>
|
||||
<td>
|
||||
<small>{{ formatDateRange(week.weekStartDate, week.weekEndDate) }}</small>
|
||||
<td class="small">
|
||||
{{ formatDate(week.weekStartDate) }} ~ {{ formatDate(week.weekEndDate) }}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-secondary me-1" v-for="p in week.projects.slice(0, 3)" :key="p">
|
||||
@@ -311,6 +311,11 @@ function getWeekDateRange(year: number, week: number): string {
|
||||
return `${fmt(monday)}~${fmt(sunday)}`
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
return dateStr.split('T')[0].replace(/-/g, '.')
|
||||
}
|
||||
|
||||
function formatDateRange(start: string, end: string) {
|
||||
if (!start || !end) return '-'
|
||||
const s = new Date(start)
|
||||
|
||||
@@ -40,44 +40,20 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 프로젝트 -->
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small text-muted">프로젝트</label>
|
||||
<select class="form-select form-select-sm" v-model="filters.projectId" @change="loadReports">
|
||||
<option value="">전체</option>
|
||||
<option v-for="proj in projects" :key="proj.projectId" :value="proj.projectId">
|
||||
{{ proj.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 연도 -->
|
||||
<div class="col-md-1">
|
||||
<label class="form-label small text-muted">연도</label>
|
||||
<select class="form-select form-select-sm" v-model="filters.year" @change="loadReports">
|
||||
<option value="">전체</option>
|
||||
<option v-for="y in yearOptions" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 기간 -->
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small text-muted">시작일</label>
|
||||
<input type="date" class="form-control form-control-sm" v-model="filters.startDate" @change="loadReports">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small text-muted">종료일</label>
|
||||
<input type="date" class="form-control form-control-sm" v-model="filters.endDate" @change="loadReports">
|
||||
</div>
|
||||
|
||||
<!-- 상태 -->
|
||||
<!-- 주차 -->
|
||||
<div class="col-md-1">
|
||||
<label class="form-label small text-muted">상태</label>
|
||||
<select class="form-select form-select-sm" v-model="filters.status" @change="loadReports">
|
||||
<label class="form-label small text-muted">주차</label>
|
||||
<select class="form-select form-select-sm" v-model="filters.week" @change="loadReports">
|
||||
<option value="">전체</option>
|
||||
<option value="DRAFT">작성중</option>
|
||||
<option value="SUBMITTED">제출완료</option>
|
||||
<option value="AGGREGATED">취합완료</option>
|
||||
<option v-for="w in weekOptions" :key="w" :value="w">{{ w }}주</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -161,21 +137,18 @@ const router = useRouter()
|
||||
|
||||
const reports = ref<any[]>([])
|
||||
const employees = ref<any[]>([])
|
||||
const projects = ref<any[]>([])
|
||||
const isLoading = ref(true)
|
||||
const isAdmin = ref(false)
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const yearOptions = [currentYear, currentYear - 1, currentYear - 2]
|
||||
const weekOptions = Array.from({ length: 53 }, (_, i) => i + 1)
|
||||
|
||||
const filters = ref({
|
||||
viewAll: false,
|
||||
authorId: '',
|
||||
projectId: '',
|
||||
year: '',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
status: ''
|
||||
year: currentYear,
|
||||
week: ''
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -216,20 +189,11 @@ async function loadReports() {
|
||||
|
||||
if (filters.value.viewAll) params.append('viewAll', 'true')
|
||||
if (filters.value.authorId) params.append('authorId', filters.value.authorId)
|
||||
if (filters.value.projectId) params.append('projectId', filters.value.projectId)
|
||||
if (filters.value.year) params.append('year', filters.value.year)
|
||||
if (filters.value.startDate) params.append('startDate', filters.value.startDate)
|
||||
if (filters.value.endDate) params.append('endDate', filters.value.endDate)
|
||||
if (filters.value.status) params.append('status', filters.value.status)
|
||||
if (filters.value.year) params.append('year', String(filters.value.year))
|
||||
if (filters.value.week) params.append('week', String(filters.value.week))
|
||||
|
||||
const res = await $fetch<any>(`/api/report/weekly/list?${params.toString()}`)
|
||||
reports.value = res.reports || []
|
||||
|
||||
// 일반 사용자도 프로젝트 필터 사용할 수 있도록
|
||||
if (!isAdmin.value && projects.value.length === 0) {
|
||||
const projRes = await $fetch<any>('/api/project/list')
|
||||
projects.value = projRes.projects || []
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
@@ -241,11 +205,8 @@ function resetFilters() {
|
||||
filters.value = {
|
||||
viewAll: false,
|
||||
authorId: '',
|
||||
projectId: '',
|
||||
year: '',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
status: ''
|
||||
year: currentYear,
|
||||
week: ''
|
||||
}
|
||||
loadReports()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user