추가
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>
|
||||
|
||||
@@ -2,123 +2,230 @@
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<NuxtLink to="/report/weekly" class="text-decoration-none">
|
||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
||||
</NuxtLink>
|
||||
<div class="container py-4">
|
||||
<div v-if="isLoading" class="text-center py-5">
|
||||
<span class="spinner-border"></span>
|
||||
<p class="mt-2">로딩 중...</p>
|
||||
</div>
|
||||
|
||||
<div class="card" v-if="report">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-journal-text me-2"></i>
|
||||
{{ report.projectName }} - {{ report.reportYear }}-W{{ String(report.reportWeek).padStart(2, '0') }}
|
||||
</h5>
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
|
||||
<div v-else-if="report">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="mb-1">
|
||||
<i class="bi bi-journal-text me-2"></i>주간보고
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)" class="ms-2">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
</h4>
|
||||
<p class="text-muted mb-0">
|
||||
{{ report.reportYear }}년 {{ report.reportWeek }}주차
|
||||
({{ formatDate(report.weekStartDate) }} ~ {{ formatDate(report.weekEndDate) }})
|
||||
</p>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<NuxtLink to="/report/weekly" class="btn btn-outline-secondary">목록</NuxtLink>
|
||||
<button v-if="canEdit" class="btn btn-primary" @click="isEditing = !isEditing">
|
||||
{{ isEditing ? '취소' : '수정' }}
|
||||
</button>
|
||||
<button v-if="canSubmit" class="btn btn-success" @click="handleSubmit" :disabled="isSubmitting">
|
||||
<span v-if="isSubmitting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
제출
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<!-- 기본 정보 -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label text-muted">작성자</label>
|
||||
<p class="mb-0">{{ report.authorName }}</p>
|
||||
<!-- 보기 모드 -->
|
||||
<div v-if="!isEditing">
|
||||
<!-- 프로젝트별 실적 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||
<span class="badge bg-secondary ms-2">{{ projects.length }}개</span>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label text-muted">기간</label>
|
||||
<p class="mb-0">{{ formatDate(report.weekStartDate) }} ~ {{ formatDate(report.weekEndDate) }}</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label text-muted">투입시간</label>
|
||||
<p class="mb-0">{{ report.workHours ? report.workHours + '시간' : '-' }}</p>
|
||||
<div class="card-body">
|
||||
<div v-for="(proj, idx) in projects" :key="proj.detailId"
|
||||
:class="{ 'border-top pt-3 mt-3': idx > 0 }">
|
||||
<h6 class="mb-3">
|
||||
<i class="bi bi-folder2 me-1"></i>
|
||||
{{ proj.projectName }}
|
||||
<small class="text-muted">({{ proj.projectCode }})</small>
|
||||
</h6>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label text-muted small">금주 실적</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ proj.workDescription || '-' }}</div>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label text-muted small">차주 계획</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ proj.planDescription || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 금주 실적 -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-check-circle me-1"></i>금주 실적
|
||||
</label>
|
||||
<div class="p-3 bg-light rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.workDescription || '-' }}</pre>
|
||||
|
||||
<!-- 공통 사항 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label text-muted small">이슈/리스크</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ report.issueDescription || '-' }}</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label text-muted small">휴가일정</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ report.vacationDescription || '-' }}</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label text-muted small">기타사항</label>
|
||||
<div class="bg-light rounded p-3" style="white-space: pre-wrap;">{{ report.remarkDescription || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 차주 계획 -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-calendar-event me-1"></i>차주 계획
|
||||
</label>
|
||||
<div class="p-3 bg-light rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.planDescription || '-' }}</pre>
|
||||
</div>
|
||||
|
||||
<!-- 수정 모드 -->
|
||||
<form v-else @submit.prevent="handleUpdate">
|
||||
<!-- 프로젝트별 실적 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" @click="showProjectModal = true">
|
||||
<i class="bi bi-plus"></i> 프로젝트 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-for="(proj, idx) in editForm.projects" :key="idx" class="border rounded p-3 mb-3">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<strong>{{ proj.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ proj.projectCode }})</small>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" @click="removeProject(idx)">
|
||||
<i class="bi bi-x"></i> 삭제
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">금주 실적</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.workDescription"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">차주 계획</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.planDescription"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 이슈사항 -->
|
||||
<div class="mb-4" v-if="report.issueDescription">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-exclamation-triangle me-1"></i>이슈/리스크
|
||||
</label>
|
||||
<div class="p-3 bg-warning bg-opacity-10 rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.issueDescription }}</pre>
|
||||
|
||||
<!-- 공통 사항 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이슈/리스크</label>
|
||||
<textarea class="form-control" rows="3" v-model="editForm.issueDescription"></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">휴가일정</label>
|
||||
<textarea class="form-control" rows="2" v-model="editForm.vacationDescription"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">기타사항</label>
|
||||
<textarea class="form-control" rows="2" v-model="editForm.remarkDescription"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 비고 -->
|
||||
<div class="mb-4" v-if="report.remarkDescription">
|
||||
<label class="form-label text-muted">
|
||||
<i class="bi bi-chat-text me-1"></i>비고
|
||||
</label>
|
||||
<div class="p-3 bg-light rounded">
|
||||
<pre class="mb-0" style="white-space: pre-wrap;">{{ report.remarkDescription }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 작업 버튼 -->
|
||||
<div class="d-flex gap-2 mt-4 pt-3 border-top">
|
||||
<NuxtLink
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
:to="`/report/weekly/write?id=${report.reportId}`"
|
||||
class="btn btn-primary"
|
||||
>
|
||||
<i class="bi bi-pencil me-1"></i> 수정
|
||||
</NuxtLink>
|
||||
<button
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
class="btn btn-success"
|
||||
@click="submitReport"
|
||||
>
|
||||
<i class="bi bi-send me-1"></i> 제출
|
||||
</button>
|
||||
<button
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
class="btn btn-outline-danger"
|
||||
@click="deleteReport"
|
||||
>
|
||||
<i class="bi bi-trash me-1"></i> 삭제
|
||||
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button type="button" class="btn btn-secondary" @click="isEditing = false">취소</button>
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSaving">
|
||||
<span v-if="isSaving" class="spinner-border spinner-border-sm me-1"></span>
|
||||
저장
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 프로젝트 선택 모달 -->
|
||||
<div class="modal fade" :class="{ show: showProjectModal }" :style="{ display: showProjectModal ? 'block' : 'none' }" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">프로젝트 선택</h5>
|
||||
<button type="button" class="btn-close" @click="showProjectModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div v-if="availableProjects.length === 0" class="text-center text-muted py-4">
|
||||
추가할 수 있는 프로젝트가 없습니다.
|
||||
</div>
|
||||
<div v-else class="list-group">
|
||||
<button type="button" class="list-group-item list-group-item-action"
|
||||
v-for="p in availableProjects" :key="p.projectId"
|
||||
@click="addProject(p)">
|
||||
<strong>{{ p.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ p.projectCode }})</small>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center py-5" v-else-if="isLoading">
|
||||
<div class="spinner-border text-primary"></div>
|
||||
<p class="mt-2 text-muted">로딩중...</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showProjectModal" @click="showProjectModal = false"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const { currentUser, fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const reportId = route.params.id as string
|
||||
|
||||
const report = ref<any>(null)
|
||||
const projects = ref<any[]>([])
|
||||
const allProjects = ref<any[]>([])
|
||||
const isLoading = ref(true)
|
||||
const isEditing = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const isSubmitting = ref(false)
|
||||
const showProjectModal = ref(false)
|
||||
|
||||
interface EditProjectItem {
|
||||
projectId: number
|
||||
projectCode: string
|
||||
projectName: string
|
||||
workDescription: string
|
||||
planDescription: string
|
||||
}
|
||||
|
||||
const editForm = ref({
|
||||
projects: [] as EditProjectItem[],
|
||||
issueDescription: '',
|
||||
vacationDescription: '',
|
||||
remarkDescription: ''
|
||||
})
|
||||
|
||||
const canEdit = computed(() => {
|
||||
if (!report.value || !currentUser.value) return false
|
||||
return report.value.authorId === currentUser.value.employeeId && report.value.reportStatus === 'DRAFT'
|
||||
})
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
if (!report.value || !currentUser.value) return false
|
||||
return report.value.authorId === currentUser.value.employeeId && report.value.reportStatus === 'DRAFT'
|
||||
})
|
||||
|
||||
const availableProjects = computed(() => {
|
||||
const addedIds = editForm.value.projects.map(p => p.projectId)
|
||||
return allProjects.value.filter(p => !addedIds.includes(p.projectId))
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
@@ -126,43 +233,114 @@ onMounted(async () => {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadReport()
|
||||
await loadAllProjects()
|
||||
})
|
||||
|
||||
async function loadReport() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await $fetch<{ report: any }>(`/api/report/weekly/${route.params.id}/detail`)
|
||||
const res = await $fetch<any>(`/api/report/weekly/${reportId}/detail`)
|
||||
report.value = res.report
|
||||
projects.value = res.projects
|
||||
} catch (e: any) {
|
||||
alert('보고서를 불러오는데 실패했습니다.')
|
||||
alert(e.data?.message || '보고서를 불러올 수 없습니다.')
|
||||
router.push('/report/weekly')
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReport() {
|
||||
if (!confirm('보고서를 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
||||
|
||||
async function loadAllProjects() {
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${route.params.id}/submit`, { method: 'POST' })
|
||||
await loadReport()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '제출에 실패했습니다.')
|
||||
const res = await $fetch<any>('/api/project/list')
|
||||
allProjects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteReport() {
|
||||
if (!confirm('보고서를 삭제하시겠습니까?')) return
|
||||
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${route.params.id}/detail`, { method: 'DELETE' })
|
||||
router.push('/report/weekly')
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '삭제에 실패했습니다.')
|
||||
watch(isEditing, (val) => {
|
||||
if (val) {
|
||||
editForm.value = {
|
||||
projects: projects.value.map(p => ({
|
||||
projectId: p.projectId,
|
||||
projectCode: p.projectCode,
|
||||
projectName: p.projectName,
|
||||
workDescription: p.workDescription || '',
|
||||
planDescription: p.planDescription || ''
|
||||
})),
|
||||
issueDescription: report.value.issueDescription || '',
|
||||
vacationDescription: report.value.vacationDescription || '',
|
||||
remarkDescription: report.value.remarkDescription || ''
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function addProject(p: any) {
|
||||
editForm.value.projects.push({
|
||||
projectId: p.projectId,
|
||||
projectCode: p.projectCode,
|
||||
projectName: p.projectName,
|
||||
workDescription: '',
|
||||
planDescription: ''
|
||||
})
|
||||
showProjectModal.value = false
|
||||
}
|
||||
|
||||
function removeProject(idx: number) {
|
||||
editForm.value.projects.splice(idx, 1)
|
||||
}
|
||||
|
||||
async function handleUpdate() {
|
||||
if (editForm.value.projects.length === 0) {
|
||||
alert('최소 1개 이상의 프로젝트가 필요합니다.')
|
||||
return
|
||||
}
|
||||
|
||||
isSaving.value = true
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${reportId}/update`, {
|
||||
method: 'PUT',
|
||||
body: {
|
||||
projects: editForm.value.projects.map(p => ({
|
||||
projectId: p.projectId,
|
||||
workDescription: p.workDescription,
|
||||
planDescription: p.planDescription
|
||||
})),
|
||||
issueDescription: editForm.value.issueDescription,
|
||||
vacationDescription: editForm.value.vacationDescription,
|
||||
remarkDescription: editForm.value.remarkDescription
|
||||
}
|
||||
})
|
||||
alert('저장되었습니다.')
|
||||
isEditing.value = false
|
||||
await loadReport()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!confirm('제출하시겠습니까? 제출 후에는 수정할 수 없습니다.')) return
|
||||
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
||||
alert('제출되었습니다.')
|
||||
await loadReport()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '제출에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
return dateStr.split('T')[0]
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
@@ -182,9 +360,10 @@ function getStatusText(status: string) {
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
const d = new Date(dateStr)
|
||||
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,109 +2,61 @@
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="container py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4><i class="bi bi-journal-text me-2"></i>주간보고</h4>
|
||||
<p class="text-muted mb-0">내가 작성한 주간보고 목록</p>
|
||||
</div>
|
||||
<h4 class="mb-0">
|
||||
<i class="bi bi-journal-text me-2"></i>내 주간보고
|
||||
</h4>
|
||||
<NuxtLink to="/report/weekly/write" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i> 새 보고서 작성
|
||||
<i class="bi bi-plus me-1"></i>작성하기
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 필터 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">프로젝트</label>
|
||||
<select class="form-select" v-model="filter.projectId">
|
||||
<option value="">전체</option>
|
||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
||||
{{ p.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">연도</label>
|
||||
<select class="form-select" v-model="filter.year">
|
||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">상태</label>
|
||||
<select class="form-select" v-model="filter.status">
|
||||
<option value="">전체</option>
|
||||
<option value="DRAFT">작성중</option>
|
||||
<option value="SUBMITTED">제출완료</option>
|
||||
<option value="AGGREGATED">취합완료</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex align-items-end">
|
||||
<button class="btn btn-outline-secondary" @click="loadReports">
|
||||
<i class="bi bi-search me-1"></i> 조회
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 보고서 목록 -->
|
||||
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 80px">주차</th>
|
||||
<th>프로젝트</th>
|
||||
<th style="width: 120px">기간</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 150px">작성일</th>
|
||||
<th style="width: 100px">작업</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="report in reports" :key="report.reportId">
|
||||
<td>
|
||||
<strong>W{{ String(report.reportWeek).padStart(2, '0') }}</strong>
|
||||
</td>
|
||||
<td>{{ report.projectName }}</td>
|
||||
<td>
|
||||
<small>{{ formatDateRange(report.weekStartDate, report.weekEndDate) }}</small>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="getStatusBadgeClass(report.reportStatus)">
|
||||
{{ getStatusText(report.reportStatus) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<small>{{ formatDateTime(report.createdAt) }}</small>
|
||||
</td>
|
||||
<td>
|
||||
<NuxtLink
|
||||
:to="`/report/weekly/${report.reportId}`"
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
>
|
||||
<i class="bi bi-eye"></i>
|
||||
</NuxtLink>
|
||||
<button
|
||||
v-if="report.reportStatus === 'DRAFT'"
|
||||
class="btn btn-sm btn-outline-success ms-1"
|
||||
@click="submitReport(report.reportId)"
|
||||
>
|
||||
<i class="bi bi-send"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="reports.length === 0">
|
||||
<td colspan="6" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">보고서가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 150px">주차</th>
|
||||
<th style="width: 200px">기간</th>
|
||||
<th>프로젝트</th>
|
||||
<th style="width: 100px">상태</th>
|
||||
<th style="width: 150px">작성일</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="isLoading">
|
||||
<td colspan="5" class="text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else-if="reports.length === 0">
|
||||
<td colspan="5" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">작성한 주간보고가 없습니다.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else v-for="r in reports" :key="r.reportId"
|
||||
@click="router.push(`/report/weekly/${r.reportId}`)"
|
||||
style="cursor: pointer;">
|
||||
<td>
|
||||
<strong>{{ r.reportYear }}년 {{ r.reportWeek }}주차</strong>
|
||||
</td>
|
||||
<td>{{ formatDate(r.weekStartDate) }} ~ {{ formatDate(r.weekEndDate) }}</td>
|
||||
<td>
|
||||
<span class="badge bg-primary">{{ r.projectCount }}개 프로젝트</span>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="getStatusBadgeClass(r.reportStatus)">
|
||||
{{ getStatusText(r.reportStatus) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ formatDateTime(r.createdAt) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,17 +67,8 @@
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const router = useRouter()
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const years = [currentYear, currentYear - 1, currentYear - 2]
|
||||
|
||||
const filter = ref({
|
||||
projectId: '',
|
||||
year: currentYear,
|
||||
status: ''
|
||||
})
|
||||
|
||||
const reports = ref<any[]>([])
|
||||
const projects = ref<any[]>([])
|
||||
const isLoading = ref(true)
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await fetchCurrentUser()
|
||||
@@ -133,42 +76,30 @@ onMounted(async () => {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
await loadReports()
|
||||
loadReports()
|
||||
})
|
||||
|
||||
async function loadProjects() {
|
||||
try {
|
||||
const res = await $fetch<{ projects: any[] }>('/api/project/my-projects')
|
||||
projects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error('Load projects error:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadReports() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const query: Record<string, any> = { year: filter.value.year }
|
||||
if (filter.value.projectId) query.projectId = filter.value.projectId
|
||||
if (filter.value.status) query.status = filter.value.status
|
||||
|
||||
const res = await $fetch<{ reports: any[] }>('/api/report/weekly/list', { query })
|
||||
const res = await $fetch<any>('/api/report/weekly/list')
|
||||
reports.value = res.reports || []
|
||||
} catch (e) {
|
||||
console.error('Load reports error:', e)
|
||||
console.error(e)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReport(reportId: number) {
|
||||
if (!confirm('보고서를 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
||||
|
||||
try {
|
||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
||||
await loadReports()
|
||||
} catch (e: any) {
|
||||
alert(e.message || '제출에 실패했습니다.')
|
||||
}
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
return dateStr.split('T')[0]
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleDateString('ko-KR')
|
||||
}
|
||||
|
||||
function getStatusBadgeClass(status: string) {
|
||||
@@ -188,18 +119,4 @@ function getStatusText(status: string) {
|
||||
}
|
||||
return texts[status] || status
|
||||
}
|
||||
|
||||
function formatDateRange(start: string, end: string) {
|
||||
const s = new Date(start)
|
||||
const e = new Date(end)
|
||||
return `${s.getMonth()+1}/${s.getDate()} ~ ${e.getMonth()+1}/${e.getDate()}`
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
const d = new Date(dateStr)
|
||||
return d.toLocaleString('ko-KR', {
|
||||
month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -2,189 +2,150 @@
|
||||
<div>
|
||||
<AppHeader />
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="mb-4">
|
||||
<NuxtLink to="/report/weekly" class="text-decoration-none">
|
||||
<i class="bi bi-arrow-left me-1"></i> 목록으로
|
||||
</NuxtLink>
|
||||
<div class="container py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h4 class="mb-0">
|
||||
<i class="bi bi-journal-plus me-2"></i>주간보고 작성
|
||||
</h4>
|
||||
<span class="text-muted">{{ weekInfo.weekString }} ({{ weekInfo.startDateStr }} ~ {{ weekInfo.endDateStr }})</span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-pencil-square me-2"></i>
|
||||
{{ isEdit ? '주간보고 수정' : '주간보고 작성' }}
|
||||
</h5>
|
||||
|
||||
<form @submit.prevent="handleSubmit">
|
||||
<!-- 프로젝트별 실적 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<strong><i class="bi bi-folder me-2"></i>프로젝트별 실적</strong>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" @click="showProjectModal = true">
|
||||
<i class="bi bi-plus"></i> 프로젝트 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-if="form.projects.length === 0" class="text-center text-muted py-4">
|
||||
<i class="bi bi-inbox display-4"></i>
|
||||
<p class="mt-2 mb-0">프로젝트를 추가해주세요.</p>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form @submit.prevent="handleSubmit">
|
||||
<!-- 프로젝트 선택 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">프로젝트 <span class="text-danger">*</span></label>
|
||||
<select class="form-select" v-model="form.projectId" required :disabled="isEdit">
|
||||
<option value="">프로젝트를 선택하세요</option>
|
||||
<option v-for="p in projects" :key="p.projectId" :value="p.projectId">
|
||||
{{ p.projectName }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<div v-for="(proj, idx) in form.projects" :key="idx" class="border rounded p-3 mb-3">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<strong>{{ proj.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ proj.projectCode }})</small>
|
||||
</div>
|
||||
|
||||
<!-- 주차 선택 -->
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">연도</label>
|
||||
<select class="form-select" v-model="form.reportYear" :disabled="isEdit">
|
||||
<option v-for="y in years" :key="y" :value="y">{{ y }}년</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">주차</label>
|
||||
<select class="form-select" v-model="form.reportWeek" :disabled="isEdit">
|
||||
<option v-for="w in 53" :key="w" :value="w">
|
||||
W{{ String(w).padStart(2, '0') }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">기간</label>
|
||||
<input type="text" class="form-control" :value="weekRangeText" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 금주 실적 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">금주 실적 <span class="text-danger">*</span></label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.workDescription"
|
||||
rows="5"
|
||||
placeholder="이번 주에 수행한 업무 내용을 작성해주세요."
|
||||
required
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 차주 계획 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">차주 계획</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.planDescription"
|
||||
rows="4"
|
||||
placeholder="다음 주에 수행할 업무 계획을 작성해주세요."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 이슈사항 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이슈/리스크</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.issueDescription"
|
||||
rows="3"
|
||||
placeholder="업무 진행 중 발생한 이슈나 리스크를 작성해주세요."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 비고 -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">비고</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="form.remarkDescription"
|
||||
rows="2"
|
||||
placeholder="기타 참고사항"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 투입시간 -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label">투입 시간 (선택)</label>
|
||||
<div class="input-group" style="max-width: 200px;">
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
v-model="form.workHours"
|
||||
min="0"
|
||||
max="100"
|
||||
step="0.5"
|
||||
/>
|
||||
<span class="input-group-text">시간</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 버튼 -->
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSubmitting">
|
||||
<span v-if="isSubmitting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
<i class="bi bi-save me-1" v-else></i>
|
||||
{{ isEdit ? '수정' : '저장' }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success"
|
||||
@click="handleSaveAndSubmit"
|
||||
:disabled="isSubmitting"
|
||||
>
|
||||
<i class="bi bi-send me-1"></i> 저장 후 제출
|
||||
</button>
|
||||
<NuxtLink to="/report/weekly" class="btn btn-outline-secondary">
|
||||
취소
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</form>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" @click="removeProject(idx)">
|
||||
<i class="bi bi-x"></i> 삭제
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">금주 실적</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.workDescription"
|
||||
placeholder="이번 주에 수행한 업무를 작성해주세요."></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">차주 계획</label>
|
||||
<textarea class="form-control" rows="3" v-model="proj.planDescription"
|
||||
placeholder="다음 주에 수행할 업무를 작성해주세요."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 사이드 안내 -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<h6><i class="bi bi-info-circle me-1"></i> 작성 안내</h6>
|
||||
<ul class="mb-0 ps-3">
|
||||
<li>금주 실적은 필수 항목입니다.</li>
|
||||
<li>같은 프로젝트, 같은 주차에 하나의 보고서만 작성 가능합니다.</li>
|
||||
<li>제출 후에는 수정이 제한됩니다.</li>
|
||||
<li>취합은 매주 자동으로 진행됩니다.</li>
|
||||
</ul>
|
||||
|
||||
<!-- 공통 사항 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-chat-left-text me-2"></i>공통 사항</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">이슈/리스크</label>
|
||||
<textarea class="form-control" rows="3" v-model="form.issueDescription"
|
||||
placeholder="진행 중 발생한 이슈나 리스크를 작성해주세요."></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">휴가일정</label>
|
||||
<textarea class="form-control" rows="2" v-model="form.vacationDescription"
|
||||
placeholder="예: 1/6(월) 연차, 1/8(수) 오후 반차"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">기타사항</label>
|
||||
<textarea class="form-control" rows="2" v-model="form.remarkDescription"
|
||||
placeholder="기타 전달사항이 있으면 작성해주세요."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 버튼 -->
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<NuxtLink to="/report/weekly" class="btn btn-secondary">취소</NuxtLink>
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSubmitting || form.projects.length === 0">
|
||||
<span v-if="isSubmitting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
임시저장
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 프로젝트 선택 모달 -->
|
||||
<div class="modal fade" :class="{ show: showProjectModal }" :style="{ display: showProjectModal ? 'block' : 'none' }" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">프로젝트 선택</h5>
|
||||
<button type="button" class="btn-close" @click="showProjectModal = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div v-if="isLoadingProjects" class="text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>로딩 중...
|
||||
</div>
|
||||
<div v-else-if="availableProjects.length === 0" class="text-center text-muted py-4">
|
||||
추가할 수 있는 프로젝트가 없습니다.
|
||||
</div>
|
||||
<div v-else class="list-group">
|
||||
<button type="button" class="list-group-item list-group-item-action"
|
||||
v-for="p in availableProjects" :key="p.projectId"
|
||||
@click="addProject(p)">
|
||||
<strong>{{ p.projectName }}</strong>
|
||||
<small class="text-muted ms-2">({{ p.projectCode }})</small>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade show" v-if="showProjectModal" @click="showProjectModal = false"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { fetchCurrentUser } = useAuth()
|
||||
const { getCurrentWeekInfo, getWeekRangeText } = useWeekCalc()
|
||||
const { getCurrentWeekInfo } = useWeekCalc()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const currentWeek = getCurrentWeekInfo()
|
||||
const currentYear = new Date().getFullYear()
|
||||
const years = [currentYear, currentYear - 1]
|
||||
const weekInfo = getCurrentWeekInfo()
|
||||
|
||||
const isEdit = computed(() => !!route.query.id)
|
||||
const isSubmitting = ref(false)
|
||||
interface ProjectItem {
|
||||
projectId: number
|
||||
projectCode: string
|
||||
projectName: string
|
||||
workDescription: string
|
||||
planDescription: string
|
||||
}
|
||||
|
||||
const form = ref({
|
||||
projectId: '',
|
||||
reportYear: currentWeek.year,
|
||||
reportWeek: currentWeek.week,
|
||||
workDescription: '',
|
||||
planDescription: '',
|
||||
projects: [] as ProjectItem[],
|
||||
issueDescription: '',
|
||||
remarkDescription: '',
|
||||
workHours: null as number | null
|
||||
vacationDescription: '',
|
||||
remarkDescription: ''
|
||||
})
|
||||
|
||||
const projects = ref<any[]>([])
|
||||
const allProjects = ref<any[]>([])
|
||||
const isLoadingProjects = ref(false)
|
||||
const isSubmitting = ref(false)
|
||||
const showProjectModal = ref(false)
|
||||
|
||||
const weekRangeText = computed(() => {
|
||||
return getWeekRangeText(form.value.reportYear, form.value.reportWeek)
|
||||
// 아직 추가하지 않은 프로젝트만
|
||||
const availableProjects = computed(() => {
|
||||
const addedIds = form.value.projects.map(p => p.projectId)
|
||||
return allProjects.value.filter(p => !addedIds.includes(p.projectId))
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -193,105 +154,72 @@ onMounted(async () => {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
await loadProjects()
|
||||
|
||||
if (route.query.id) {
|
||||
await loadReport(Number(route.query.id))
|
||||
}
|
||||
loadProjects()
|
||||
})
|
||||
|
||||
async function loadProjects() {
|
||||
isLoadingProjects.value = true
|
||||
try {
|
||||
const res = await $fetch<{ projects: any[] }>('/api/project/list')
|
||||
projects.value = res.projects || []
|
||||
const res = await $fetch<any>('/api/project/list')
|
||||
allProjects.value = res.projects || []
|
||||
} catch (e) {
|
||||
console.error('Load projects error:', e)
|
||||
console.error(e)
|
||||
} finally {
|
||||
isLoadingProjects.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadReport(reportId: number) {
|
||||
try {
|
||||
const res = await $fetch<{ report: any }>(`/api/report/weekly/${reportId}/detail`)
|
||||
const r = res.report
|
||||
form.value = {
|
||||
projectId: r.projectId,
|
||||
reportYear: r.reportYear,
|
||||
reportWeek: r.reportWeek,
|
||||
workDescription: r.workDescription || '',
|
||||
planDescription: r.planDescription || '',
|
||||
issueDescription: r.issueDescription || '',
|
||||
remarkDescription: r.remarkDescription || '',
|
||||
workHours: r.workHours
|
||||
}
|
||||
} catch (e: any) {
|
||||
alert('보고서를 불러오는데 실패했습니다.')
|
||||
router.push('/report/weekly')
|
||||
}
|
||||
function addProject(p: any) {
|
||||
form.value.projects.push({
|
||||
projectId: p.projectId,
|
||||
projectCode: p.projectCode,
|
||||
projectName: p.projectName,
|
||||
workDescription: '',
|
||||
planDescription: ''
|
||||
})
|
||||
showProjectModal.value = false
|
||||
}
|
||||
|
||||
function removeProject(idx: number) {
|
||||
form.value.projects.splice(idx, 1)
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!form.value.projectId || !form.value.workDescription) {
|
||||
alert('프로젝트와 금주 실적은 필수입니다.')
|
||||
if (form.value.projects.length === 0) {
|
||||
alert('최소 1개 이상의 프로젝트를 추가해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
isSubmitting.value = true
|
||||
|
||||
try {
|
||||
if (isEdit.value) {
|
||||
await $fetch(`/api/report/weekly/${route.query.id}/update`, {
|
||||
method: 'PUT',
|
||||
body: form.value
|
||||
})
|
||||
} else {
|
||||
await $fetch('/api/report/weekly/create', {
|
||||
method: 'POST',
|
||||
body: form.value
|
||||
})
|
||||
}
|
||||
router.push('/report/weekly')
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSaveAndSubmit() {
|
||||
if (!form.value.projectId || !form.value.workDescription) {
|
||||
alert('프로젝트와 금주 실적은 필수입니다.')
|
||||
return
|
||||
}
|
||||
|
||||
if (!confirm('저장 후 바로 제출하시겠습니까?\n제출 후에는 수정이 제한됩니다.')) return
|
||||
|
||||
isSubmitting.value = true
|
||||
|
||||
try {
|
||||
let reportId: number
|
||||
const res = await $fetch<any>('/api/report/weekly/create', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
reportYear: weekInfo.year,
|
||||
reportWeek: weekInfo.week,
|
||||
projects: form.value.projects.map(p => ({
|
||||
projectId: p.projectId,
|
||||
workDescription: p.workDescription,
|
||||
planDescription: p.planDescription
|
||||
})),
|
||||
issueDescription: form.value.issueDescription,
|
||||
vacationDescription: form.value.vacationDescription,
|
||||
remarkDescription: form.value.remarkDescription
|
||||
}
|
||||
})
|
||||
|
||||
if (isEdit.value) {
|
||||
await $fetch(`/api/report/weekly/${route.query.id}/update`, {
|
||||
method: 'PUT',
|
||||
body: form.value
|
||||
})
|
||||
reportId = Number(route.query.id)
|
||||
} else {
|
||||
const res = await $fetch<{ report: any }>('/api/report/weekly/create', {
|
||||
method: 'POST',
|
||||
body: form.value
|
||||
})
|
||||
reportId = res.report.reportId
|
||||
}
|
||||
|
||||
// 제출
|
||||
await $fetch(`/api/report/weekly/${reportId}/submit`, { method: 'POST' })
|
||||
router.push('/report/weekly')
|
||||
alert('저장되었습니다.')
|
||||
router.push(`/report/weekly/${res.reportId}`)
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || e.message || '처리에 실패했습니다.')
|
||||
alert(e.data?.message || '저장에 실패했습니다.')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user