추가
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<h4><i class="bi bi-collection me-2"></i>취합 보고서</h4>
|
||||
<p class="text-muted mb-0">프로젝트별 주간보고 취합 목록</p>
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4><i class="bi bi-collection me-2"></i>취합 보고서</h4>
|
||||
<p class="text-muted mb-0">프로젝트별 주간보고 취합 목록</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="showAggregateModal = true">
|
||||
<i class="bi bi-plus-lg me-1"></i> 취합하기
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 필터 -->
|
||||
@@ -95,14 +100,75 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 취합 모달 -->
|
||||
<div class="modal fade" :class="{ show: showAggregateModal }"
|
||||
:style="{ display: showAggregateModal ? 'block' : 'none' }"
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="bi bi-collection me-2"></i>주간보고 취합
|
||||
</h5>
|
||||
<button type="button" class="btn-close" @click="showAggregateModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">프로젝트 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="aggregateForm.projectId">
|
||||
<option value="">선택하세요</option>
|
||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
||||
{{ p.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<label class="form-label">연도 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="aggregateForm.reportYear">
|
||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">주차 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="aggregateForm.reportWeek">
|
||||
<option v-for="w in 53" :key="w" :value="w">W{{ String(w).padStart(2, '0') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info mt-3 mb-0">
|
||||
<i class="bi bi-info-circle me-2"></i>
|
||||
선택한 프로젝트/주차의 제출된 보고서를 취합합니다.
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" @click="showAggregateModal = false">
|
||||
취소
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" @click="doAggregate" :disabled="isAggregating">
|
||||
<span v-if="isAggregating">
|
||||
<span class="spinner-border spinner-border-sm me-1"></span>취합 중...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-check-lg me-1"></i>취합하기
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showAggregateModal"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const { getCurrentWeekInfo } = useWeekCalc()
|
||||
const router = useRouter()
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const currentWeek = getCurrentWeekInfo()
|
||||
const years = [currentYear, currentYear - 1, currentYear - 2]
|
||||
|
||||
const filter = ref({
|
||||
@@ -113,6 +179,15 @@ const filter = ref({
|
||||
const summaries = ref<any[]>([])
|
||||
const projects = ref<any[]>([])
|
||||
|
||||
// 취합 모달
|
||||
const showAggregateModal = ref(false)
|
||||
const isAggregating = ref(false)
|
||||
const aggregateForm = ref({
|
||||
projectId: '',
|
||||
reportYear: currentYear,
|
||||
reportWeek: currentWeek.week > 1 ? currentWeek.week - 1 : 1 // 기본값: 지난주
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
if (!user) {
|
||||
@@ -145,6 +220,33 @@ async function loadSummaries() {
|
||||
}
|
||||
}
|
||||
|
||||
async function doAggregate() {
|
||||
if (!aggregateForm.value.projectId) {
|
||||
alert('프로젝트를 선택해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
isAggregating.value = true
|
||||
try {
|
||||
const res = await $fetch<{ success: boolean; memberCount: number }>('/api/report/summary/aggregate', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
projectId: parseInt(aggregateForm.value.projectId as string),
|
||||
reportYear: aggregateForm.value.reportYear,
|
||||
reportWeek: aggregateForm.value.reportWeek
|
||||
}
|
||||
})
|
||||
|
||||
alert(`취합 완료! (${res.memberCount}명의 보고서)`)
|
||||
showAggregateModal.value = false
|
||||
await loadSummaries()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '취합에 실패했습니다.')
|
||||
} finally {
|
||||
isAggregating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
const classes: Record<string, string> = {
|
||||
'AGGREGATED': 'badge bg-info',
|
||||
@@ -176,3 +278,9 @@ function formatDateTime(dateStr: string) {
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user