1ㅊㅏ완료
This commit is contained in:
@@ -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