diff --git a/frontend/issues-management.html b/frontend/issues-management.html index b76104b..73452de 100644 --- a/frontend/issues-management.html +++ b/frontend/issues-management.html @@ -708,6 +708,44 @@ // 진행 중 카드 생성 function createInProgressRow(issue, project) { + // 상태 판별 + const isPendingCompletion = issue.completion_requested_at; + const isOverdue = issue.expected_completion_date && new Date(issue.expected_completion_date) < new Date(); + const isUrgent = issue.expected_completion_date && + (new Date(issue.expected_completion_date) - new Date()) / (1000 * 60 * 60 * 24) <= 3 && + !isOverdue; + + // 상태 설정 + let statusConfig = { + text: '진행 중', + bgColor: 'bg-gradient-to-r from-blue-500 to-blue-600', + icon: 'fas fa-cog fa-spin', + dotColor: 'bg-white' + }; + + if (isPendingCompletion) { + statusConfig = { + text: '완료 대기', + bgColor: 'bg-gradient-to-r from-purple-500 to-purple-600', + icon: 'fas fa-hourglass-half', + dotColor: 'bg-white' + }; + } else if (isOverdue) { + statusConfig = { + text: '지연됨', + bgColor: 'bg-gradient-to-r from-red-500 to-red-600', + icon: 'fas fa-clock', + dotColor: 'bg-white' + }; + } else if (isUrgent) { + statusConfig = { + text: '긴급', + bgColor: 'bg-gradient-to-r from-orange-500 to-orange-600', + icon: 'fas fa-exclamation-triangle', + dotColor: 'bg-white' + }; + } + return `
@@ -719,18 +757,38 @@
${project ? project.project_name : '프로젝트 미지정'} + +
+
+ ${statusConfig.text} + +

${getIssueTitle(issue)}

- - + ${isPendingCompletion ? ` + + + + + ` : ` + + + + `}
@@ -744,9 +802,15 @@ - + ${!isPendingCompletion ? ` + + ` : ` + + 완료 대기 중 + + `}
@@ -793,7 +857,7 @@ - +
@@ -801,7 +865,7 @@ - ${getDepartmentOptions().map(opt => `` ).join('')} @@ -812,7 +876,7 @@ - +
@@ -820,16 +884,43 @@ - + + + ${isPendingCompletion ? ` +
+

+ 완료 신청 정보 +

+
+
+ + ${issue.completion_photo_path ? ` +
+ 완료 사진 +
+ ` : '

완료 사진 없음

'} +
+
+ +

${issue.completion_comment || '코멘트 없음'}

+
+
+ +

${new Date(issue.completion_requested_at).toLocaleString('ko-KR')}

+
+
+
+ ` : ''} + -
+
- - 진행 중 + + ${statusConfig.text} - + 신고일: ${new Date(issue.report_date).toLocaleDateString('ko-KR')}
@@ -1638,6 +1729,216 @@ alert('저장 중 오류가 발생했습니다.'); } } + + // 완료 대기 상태 관련 함수들 + function editIssue(issueId) { + // 수정 모드로 전환 (완료 대기 상태를 해제) + if (confirm('완료 대기 상태를 해제하고 수정 모드로 전환하시겠습니까?')) { + // 완료 신청 정보 초기화 API 호출 + resetCompletionRequest(issueId); + } + } + + function rejectCompletion(issueId) { + const reason = prompt('반려 사유를 입력하세요:'); + if (reason && reason.trim()) { + // 반려 처리 API 호출 + rejectCompletionRequest(issueId, reason.trim()); + } + } + + function confirmCompletion(issueId) { + // 모든 정보 확인 모달 열기 + openCompletionConfirmModal(issueId); + } + + // 완료 신청 초기화 (수정 모드로 전환) + async function resetCompletionRequest(issueId) { + try { + const response = await fetch(`/api/issues/${issueId}/reset-completion`, { + method: 'POST', + headers: { + 'Authorization': `Bearer ${localStorage.getItem('access_token')}`, + 'Content-Type': 'application/json' + } + }); + + if (response.ok) { + alert('완료 대기 상태가 해제되었습니다. 수정이 가능합니다.'); + loadManagementData(); // 페이지 새로고침 + } else { + const error = await response.json(); + alert(`상태 변경 실패: ${error.detail || '알 수 없는 오류'}`); + } + } catch (error) { + console.error('상태 변경 오류:', error); + alert('상태 변경 중 오류가 발생했습니다.'); + } + } + + // 완료 신청 반려 + async function rejectCompletionRequest(issueId, reason) { + try { + const response = await fetch(`/api/issues/${issueId}/reject-completion`, { + method: 'POST', + headers: { + 'Authorization': `Bearer ${localStorage.getItem('access_token')}`, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + rejection_reason: reason + }) + }); + + if (response.ok) { + alert('완료 신청이 반려되었습니다.'); + loadManagementData(); // 페이지 새로고침 + } else { + const error = await response.json(); + alert(`반려 처리 실패: ${error.detail || '알 수 없는 오류'}`); + } + } catch (error) { + console.error('반려 처리 오류:', error); + alert('반려 처리 중 오류가 발생했습니다.'); + } + } + + // 완료 확인 모달 열기 + function openCompletionConfirmModal(issueId) { + const issue = issues.find(i => i.id === issueId); + if (!issue) return; + + const project = projects.find(p => p.id === issue.project_id); + + // 모달 내용 생성 + const modalContent = ` +
+
+
+ +
+

+ + 완료 확인 - No.${issue.project_sequence_no || '-'} +

+ +
+ + +
+ +
+
+

기본 정보

+
+
프로젝트: ${project ? project.project_name : '-'}
+
부적합명: ${getIssueTitle(issue)}
+
상세내용: ${getIssueDetail(issue)}
+
원인분류: ${getCategoryText(issue.final_category || issue.category)}
+
+
+ +
+

관리 정보

+
+
해결방안: ${issue.solution || '-'}
+
담당부서: ${issue.responsible_department || '-'}
+
담당자: ${issue.responsible_person || '-'}
+
조치예상일: ${issue.expected_completion_date ? new Date(issue.expected_completion_date).toLocaleDateString('ko-KR') : '-'}
+
+
+
+ + +
+
+

완료 신청 정보

+
+
+ 완료 사진: + ${issue.completion_photo_path ? ` +
+ 완료 사진 +
+ ` : '

완료 사진 없음

'} +
+
+ 완료 코멘트: +

${issue.completion_comment || '코멘트 없음'}

+
+
+ 신청일시: +

${new Date(issue.completion_requested_at).toLocaleString('ko-KR')}

+
+
+
+ +
+

업로드 사진

+
+ ${issue.photo_path ? `업로드 사진 1` : '
사진 없음
'} + ${issue.photo_path2 ? `업로드 사진 2` : '
사진 없음
'} +
+
+
+
+ + +
+ + +
+
+
+
+ `; + + // 모달을 body에 추가 + document.body.insertAdjacentHTML('beforeend', modalContent); + } + + // 완료 확인 모달 닫기 + function closeCompletionConfirmModal() { + const modal = document.getElementById('completionConfirmModal'); + if (modal) { + modal.remove(); + } + } + + // 최종 완료 확인 + async function finalConfirmCompletion(issueId) { + if (!confirm('이 부적합을 최종 완료 처리하시겠습니까?\n완료 처리 후에는 수정할 수 없습니다.')) { + return; + } + + try { + const response = await fetch(`/api/issues/${issueId}/final-completion`, { + method: 'POST', + headers: { + 'Authorization': `Bearer ${localStorage.getItem('access_token')}`, + 'Content-Type': 'application/json' + } + }); + + if (response.ok) { + alert('부적합이 최종 완료 처리되었습니다.'); + closeCompletionConfirmModal(); + loadManagementData(); // 페이지 새로고침 + } else { + const error = await response.json(); + alert(`완료 처리 실패: ${error.detail || '알 수 없는 오류'}`); + } + } catch (error) { + console.error('완료 처리 오류:', error); + alert('완료 처리 중 오류가 발생했습니다.'); + } + }