Files
TK-FB-Project/web-ui/pages.backup.20260202/work/issue-detail.html
Hyungi Ahn 74d3a78aa3 feat: 페이지 구조 재구성 및 사이드바 네비게이션 구현
- 페이지 폴더 재구성: safety/, attendance/ 폴더 신규 생성
  - work/ → safety/: 이슈 신고, 출입 신청 관련 페이지 이동
  - common/ → attendance/: 근태/휴가 관련 페이지 이동
  - admin/ 정리: safety-* 파일들을 safety/로 이동

- 사이드바 네비게이션 메뉴 구현
  - 카테고리별 메뉴: 작업관리, 안전관리, 근태관리, 시스템관리
  - 접기/펼치기 기능 및 상태 저장
  - 관리자 전용 메뉴 자동 표시/숨김

- 날씨 API 연동 (기상청 단기예보)
  - TBM 및 navbar에 현재 날씨 표시
  - weatherService.js 추가

- 안전 체크리스트 확장
  - 기본/날씨별/작업별 체크 유형 추가
  - checklist-manage.html 페이지 추가

- 이슈 신고 시스템 구현
  - workIssueController, workIssueModel, workIssueRoutes 추가

- DB 마이그레이션 파일 추가 (실행 대기)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:27:22 +09:00

947 lines
32 KiB
HTML

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>신고 상세 | (주)테크니컬코리아</title>
<link rel="stylesheet" href="/css/design-system.css">
<link rel="stylesheet" href="/css/common.css?v=2">
<link rel="stylesheet" href="/css/project-management.css?v=3">
<link rel="icon" type="image/png" href="/img/favicon.png">
<script src="/js/auth-check.js?v=1" defer></script>
<script type="module" src="/js/api-config.js?v=3"></script>
<style>
.detail-container {
max-width: 900px;
margin: 0 auto;
}
.detail-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 24px;
}
.detail-title {
font-size: 24px;
font-weight: 600;
}
.detail-id {
font-size: var(--text-sm);
color: var(--gray-500);
margin-bottom: 8px;
}
.status-badge {
padding: 8px 20px;
border-radius: 9999px;
font-size: var(--text-sm);
font-weight: 600;
}
.status-badge.reported { background: var(--blue-100); color: var(--blue-700); }
.status-badge.received { background: var(--orange-100); color: var(--orange-700); }
.status-badge.in_progress { background: var(--purple-100); color: var(--purple-700); }
.status-badge.completed { background: var(--green-100); color: var(--green-700); }
.status-badge.closed { background: var(--gray-100); color: var(--gray-700); }
.detail-section {
background: white;
border-radius: var(--radius-lg);
padding: 24px;
margin-bottom: 20px;
box-shadow: var(--shadow-sm);
border: 1px solid var(--gray-200);
}
.section-title {
font-size: var(--text-lg);
font-weight: 600;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid var(--gray-200);
}
.info-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16px;
}
.info-item {
padding: 12px;
background: var(--gray-50);
border-radius: var(--radius-md);
}
.info-label {
font-size: var(--text-xs);
color: var(--gray-500);
margin-bottom: 4px;
text-transform: uppercase;
}
.info-value {
font-size: var(--text-base);
font-weight: 500;
}
.type-badge {
display: inline-block;
padding: 4px 12px;
border-radius: 4px;
font-size: var(--text-sm);
font-weight: 500;
}
.type-badge.nonconformity {
background: var(--orange-100);
color: var(--orange-700);
}
.type-badge.safety {
background: var(--red-100);
color: var(--red-700);
}
.severity-badge {
display: inline-block;
padding: 2px 8px;
border-radius: 4px;
font-size: var(--text-xs);
font-weight: 600;
}
.severity-badge.critical { background: var(--red-100); color: var(--red-700); }
.severity-badge.high { background: var(--orange-100); color: var(--orange-700); }
.severity-badge.medium { background: var(--yellow-100); color: var(--yellow-700); }
.severity-badge.low { background: var(--gray-100); color: var(--gray-700); }
.photo-gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 12px;
}
.photo-item {
aspect-ratio: 1;
border-radius: var(--radius-md);
overflow: hidden;
cursor: pointer;
border: 1px solid var(--gray-200);
}
.photo-item img {
width: 100%;
height: 100%;
object-fit: cover;
}
.description-text {
padding: 16px;
background: var(--gray-50);
border-radius: var(--radius-md);
white-space: pre-wrap;
line-height: 1.6;
}
.action-buttons {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 24px;
}
.action-btn {
padding: 12px 24px;
border-radius: var(--radius-md);
font-size: var(--text-sm);
font-weight: 600;
cursor: pointer;
border: 1px solid var(--gray-300);
background: white;
transition: all var(--transition-fast);
}
.action-btn:hover {
background: var(--gray-50);
}
.action-btn.primary {
background: var(--primary-500);
color: white;
border-color: var(--primary-500);
}
.action-btn.primary:hover {
background: var(--primary-600);
}
.action-btn.success {
background: var(--green-500);
color: white;
border-color: var(--green-500);
}
.action-btn.success:hover {
background: var(--green-600);
}
.action-btn.danger {
background: var(--red-500);
color: white;
border-color: var(--red-500);
}
.action-btn.danger:hover {
background: var(--red-600);
}
/* 상태 변경 이력 */
.status-timeline {
position: relative;
padding-left: 24px;
}
.status-timeline::before {
content: '';
position: absolute;
left: 6px;
top: 0;
bottom: 0;
width: 2px;
background: var(--gray-200);
}
.timeline-item {
position: relative;
padding-bottom: 16px;
}
.timeline-item:last-child {
padding-bottom: 0;
}
.timeline-item::before {
content: '';
position: absolute;
left: -18px;
top: 4px;
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--primary-500);
}
.timeline-status {
font-weight: 600;
margin-bottom: 4px;
}
.timeline-meta {
font-size: var(--text-sm);
color: var(--gray-500);
}
/* 담당자 배정 모달 */
.modal-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
align-items: center;
justify-content: center;
}
.modal-overlay.visible {
display: flex;
}
.modal-content {
background: white;
padding: 24px;
border-radius: var(--radius-lg);
max-width: 500px;
width: 90%;
}
.modal-title {
font-size: var(--text-lg);
font-weight: 600;
margin-bottom: 20px;
}
.modal-form-group {
margin-bottom: 16px;
}
.modal-form-group label {
display: block;
font-weight: 500;
margin-bottom: 8px;
}
.modal-form-group input,
.modal-form-group select,
.modal-form-group textarea {
width: 100%;
padding: 12px;
border: 1px solid var(--gray-300);
border-radius: var(--radius-md);
}
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 12px;
margin-top: 20px;
}
/* 사진 확대 모달 */
.photo-modal {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.9);
z-index: 1001;
align-items: center;
justify-content: center;
}
.photo-modal.visible {
display: flex;
}
.photo-modal img {
max-width: 90%;
max-height: 90%;
object-fit: contain;
}
.photo-modal-close {
position: absolute;
top: 20px;
right: 20px;
color: white;
font-size: 32px;
cursor: pointer;
}
@media (max-width: 768px) {
.info-grid {
grid-template-columns: 1fr;
}
.detail-header {
flex-direction: column;
gap: 16px;
}
.action-buttons {
flex-direction: column;
}
.action-btn {
width: 100%;
text-align: center;
}
}
</style>
</head>
<body>
<div id="navbar-container"></div>
<main class="main-content">
<div class="detail-container">
<a href="/pages/work/issue-list.html" style="color: var(--primary-600); text-decoration: none; margin-bottom: 16px; display: inline-block;">
&#8592; 목록으로
</a>
<div class="detail-header">
<div>
<div class="detail-id" id="reportId"></div>
<h1 class="detail-title" id="reportTitle">로딩 중...</h1>
</div>
<span class="status-badge" id="statusBadge"></span>
</div>
<!-- 기본 정보 -->
<div class="detail-section">
<h2 class="section-title">신고 정보</h2>
<div class="info-grid" id="basicInfo"></div>
</div>
<!-- 신고 내용 -->
<div class="detail-section">
<h2 class="section-title">신고 내용</h2>
<div id="issueContent"></div>
</div>
<!-- 사진 -->
<div class="detail-section" id="photoSection" style="display: none;">
<h2 class="section-title">첨부 사진</h2>
<div class="photo-gallery" id="photoGallery"></div>
</div>
<!-- 처리 정보 (담당자 배정 시) -->
<div class="detail-section" id="processSection" style="display: none;">
<h2 class="section-title">처리 정보</h2>
<div id="processInfo"></div>
</div>
<!-- 상태 이력 -->
<div class="detail-section">
<h2 class="section-title">상태 변경 이력</h2>
<div class="status-timeline" id="statusTimeline"></div>
</div>
<!-- 액션 버튼 -->
<div class="action-buttons" id="actionButtons"></div>
</div>
</main>
<!-- 담당자 배정 모달 -->
<div class="modal-overlay" id="assignModal">
<div class="modal-content">
<h3 class="modal-title">담당자 배정</h3>
<div class="modal-form-group">
<label>담당 부서</label>
<input type="text" id="assignDepartment" placeholder="담당 부서 입력">
</div>
<div class="modal-form-group">
<label>담당자</label>
<select id="assignUser">
<option value="">담당자 선택</option>
</select>
</div>
<div class="modal-actions">
<button class="action-btn" onclick="closeAssignModal()">취소</button>
<button class="action-btn primary" onclick="submitAssign()">배정</button>
</div>
</div>
</div>
<!-- 처리 완료 모달 -->
<div class="modal-overlay" id="completeModal">
<div class="modal-content">
<h3 class="modal-title">처리 완료</h3>
<div class="modal-form-group">
<label>처리 내용</label>
<textarea id="resolutionNotes" rows="4" placeholder="처리 내용을 입력하세요"></textarea>
</div>
<div class="modal-actions">
<button class="action-btn" onclick="closeCompleteModal()">취소</button>
<button class="action-btn success" onclick="submitComplete()">완료 처리</button>
</div>
</div>
</div>
<!-- 사진 확대 모달 -->
<div class="photo-modal" id="photoModal" onclick="closePhotoModal()">
<span class="photo-modal-close">&times;</span>
<img id="photoModalImg" src="" alt="">
</div>
<script src="/js/load-navbar.js?v=1"></script>
<script>
const API_BASE = window.API_BASE_URL || 'http://localhost:20005/api';
let currentReport = null;
let currentUserLevel = null;
const STATUS_LABELS = {
reported: '신고',
received: '접수',
in_progress: '처리중',
completed: '완료',
closed: '종료'
};
const TYPE_LABELS = {
nonconformity: '부적합',
safety: '안전'
};
const SEVERITY_LABELS = {
critical: '심각',
high: '높음',
medium: '보통',
low: '낮음'
};
// 초기화
document.addEventListener('DOMContentLoaded', async () => {
const urlParams = new URLSearchParams(window.location.search);
const reportId = urlParams.get('id');
if (!reportId) {
alert('잘못된 접근입니다.');
window.location.href = '/pages/work/issue-list.html';
return;
}
// 사용자 정보 확인
const token = localStorage.getItem('token');
if (token) {
try {
const payload = JSON.parse(atob(token.split('.')[1]));
currentUserLevel = payload.access_level;
} catch (e) {}
}
await loadReport(reportId);
await loadStatusLogs(reportId);
await loadUsers();
});
// 신고 상세 로드
async function loadReport(reportId) {
try {
const response = await fetch(`${API_BASE}/work-issues/${reportId}`, {
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
});
if (!response.ok) {
if (response.status === 404) {
alert('신고를 찾을 수 없습니다.');
} else if (response.status === 403) {
alert('권한이 없습니다.');
}
window.location.href = '/pages/work/issue-list.html';
return;
}
const data = await response.json();
if (data.success) {
currentReport = data.data;
renderReport(currentReport);
}
} catch (error) {
console.error('신고 로드 실패:', error);
alert('데이터를 불러올 수 없습니다.');
}
}
// 신고 렌더링
function renderReport(report) {
const baseUrl = (window.API_BASE_URL || 'http://localhost:20005').replace('/api', '');
// 헤더
document.getElementById('reportId').textContent = `#${report.report_id}`;
document.getElementById('reportTitle').textContent = report.issue_item_name || report.issue_category_name || '신고';
const statusBadge = document.getElementById('statusBadge');
statusBadge.textContent = STATUS_LABELS[report.status] || report.status;
statusBadge.className = `status-badge ${report.status}`;
// 기본 정보
const reportDate = new Date(report.report_date).toLocaleString('ko-KR');
let location = report.custom_location || '';
if (report.factory_name) {
location = report.factory_name;
if (report.workplace_name) {
location += ` - ${report.workplace_name}`;
}
}
document.getElementById('basicInfo').innerHTML = `
<div class="info-item">
<div class="info-label">신고자</div>
<div class="info-value">${report.reporter_full_name || report.reporter_name}</div>
</div>
<div class="info-item">
<div class="info-label">신고 일시</div>
<div class="info-value">${reportDate}</div>
</div>
<div class="info-item">
<div class="info-label">발생 위치</div>
<div class="info-value">${location || '-'}</div>
</div>
<div class="info-item">
<div class="info-label">문제 유형</div>
<div class="info-value">
<span class="type-badge ${report.category_type}">${TYPE_LABELS[report.category_type]}</span>
</div>
</div>
`;
// 신고 내용
let contentHtml = `
<div class="info-grid" style="margin-bottom: 16px;">
<div class="info-item">
<div class="info-label">카테고리</div>
<div class="info-value">${report.issue_category_name}</div>
</div>
${report.issue_item_name ? `
<div class="info-item">
<div class="info-label">신고 항목</div>
<div class="info-value">
${report.issue_item_name}
${report.severity ? `<span class="severity-badge ${report.severity}">${SEVERITY_LABELS[report.severity]}</span>` : ''}
</div>
</div>
` : ''}
</div>
`;
if (report.additional_description) {
contentHtml += `
<div class="info-label" style="margin-bottom: 8px;">추가 설명</div>
<div class="description-text">${report.additional_description}</div>
`;
}
document.getElementById('issueContent').innerHTML = contentHtml;
// 사진
const photos = [
report.photo_path1,
report.photo_path2,
report.photo_path3,
report.photo_path4,
report.photo_path5
].filter(Boolean);
if (photos.length > 0) {
document.getElementById('photoSection').style.display = 'block';
document.getElementById('photoGallery').innerHTML = photos.map(p => `
<div class="photo-item" onclick="showPhoto('${baseUrl}${p}')">
<img src="${baseUrl}${p}" alt="신고 사진" loading="lazy">
</div>
`).join('');
}
// 처리 정보
if (report.assigned_user_id || report.resolution_notes) {
document.getElementById('processSection').style.display = 'block';
let processHtml = '<div class="info-grid">';
if (report.assigned_full_name) {
processHtml += `
<div class="info-item">
<div class="info-label">담당자</div>
<div class="info-value">${report.assigned_full_name}</div>
</div>
`;
}
if (report.assigned_department) {
processHtml += `
<div class="info-item">
<div class="info-label">담당 부서</div>
<div class="info-value">${report.assigned_department}</div>
</div>
`;
}
processHtml += '</div>';
if (report.resolution_notes) {
processHtml += `
<div class="info-label" style="margin-top: 16px; margin-bottom: 8px;">처리 내용</div>
<div class="description-text">${report.resolution_notes}</div>
`;
}
// 처리 완료 사진
const resolutionPhotos = [
report.resolution_photo_path1,
report.resolution_photo_path2
].filter(Boolean);
if (resolutionPhotos.length > 0) {
processHtml += `
<div class="info-label" style="margin-top: 16px; margin-bottom: 8px;">처리 완료 사진</div>
<div class="photo-gallery">
${resolutionPhotos.map(p => `
<div class="photo-item" onclick="showPhoto('${baseUrl}${p}')">
<img src="${baseUrl}${p}" alt="처리 완료 사진" loading="lazy">
</div>
`).join('')}
</div>
`;
}
document.getElementById('processInfo').innerHTML = processHtml;
}
// 액션 버튼
renderActionButtons(report);
}
// 액션 버튼 렌더링
function renderActionButtons(report) {
const buttons = [];
const isManager = ['admin', 'system', 'support_team'].includes(currentUserLevel);
switch (report.status) {
case 'reported':
if (isManager) {
buttons.push(`<button class="action-btn primary" onclick="receiveReport()">접수</button>`);
}
break;
case 'received':
if (isManager) {
buttons.push(`<button class="action-btn" onclick="showAssignModal()">담당자 배정</button>`);
buttons.push(`<button class="action-btn primary" onclick="startProcessing()">처리 시작</button>`);
}
break;
case 'in_progress':
buttons.push(`<button class="action-btn success" onclick="showCompleteModal()">처리 완료</button>`);
if (isManager) {
buttons.push(`<button class="action-btn" onclick="showAssignModal()">담당자 변경</button>`);
}
break;
case 'completed':
if (['admin', 'system'].includes(currentUserLevel)) {
buttons.push(`<button class="action-btn" onclick="closeReport()">종료</button>`);
}
break;
}
document.getElementById('actionButtons').innerHTML = buttons.join('');
}
// 상태 이력 로드
async function loadStatusLogs(reportId) {
try {
const response = await fetch(`${API_BASE}/work-issues/${reportId}/logs`, {
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
});
if (!response.ok) return;
const data = await response.json();
if (data.success && data.data) {
renderStatusLogs(data.data);
}
} catch (error) {
console.error('상태 이력 로드 실패:', error);
}
}
// 상태 이력 렌더링
function renderStatusLogs(logs) {
const timeline = document.getElementById('statusTimeline');
if (logs.length === 0) {
timeline.innerHTML = '<p style="color: var(--gray-500);">이력이 없습니다.</p>';
return;
}
timeline.innerHTML = logs.map(log => {
const date = new Date(log.changed_at).toLocaleString('ko-KR');
const prevStatus = log.previous_status ? STATUS_LABELS[log.previous_status] : '(없음)';
const newStatus = STATUS_LABELS[log.new_status] || log.new_status;
return `
<div class="timeline-item">
<div class="timeline-status">${prevStatus}${newStatus}</div>
<div class="timeline-meta">
${log.changed_by_full_name || log.changed_by_name} | ${date}
${log.change_reason ? `<br><span style="color: var(--gray-600);">${log.change_reason}</span>` : ''}
</div>
</div>
`;
}).join('');
}
// 사용자 목록 로드 (담당자 배정용)
async function loadUsers() {
try {
const response = await fetch(`${API_BASE}/users`, {
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
});
if (!response.ok) return;
const data = await response.json();
if (data.success && data.data) {
const select = document.getElementById('assignUser');
data.data.forEach(user => {
const option = document.createElement('option');
option.value = user.user_id;
option.textContent = `${user.name} (${user.username})`;
select.appendChild(option);
});
}
} catch (error) {
console.error('사용자 목록 로드 실패:', error);
}
}
// 접수
async function receiveReport() {
if (!confirm('이 신고를 접수하시겠습니까?')) return;
try {
const response = await fetch(`${API_BASE}/work-issues/${currentReport.report_id}/receive`, {
method: 'PUT',
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
});
const data = await response.json();
if (data.success) {
alert('접수되었습니다.');
location.reload();
} else {
throw new Error(data.error);
}
} catch (error) {
alert('접수 실패: ' + error.message);
}
}
// 처리 시작
async function startProcessing() {
if (!confirm('처리를 시작하시겠습니까?')) return;
try {
const response = await fetch(`${API_BASE}/work-issues/${currentReport.report_id}/start`, {
method: 'PUT',
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
});
const data = await response.json();
if (data.success) {
alert('처리가 시작되었습니다.');
location.reload();
} else {
throw new Error(data.error);
}
} catch (error) {
alert('처리 시작 실패: ' + error.message);
}
}
// 담당자 배정 모달
function showAssignModal() {
document.getElementById('assignModal').classList.add('visible');
}
function closeAssignModal() {
document.getElementById('assignModal').classList.remove('visible');
}
async function submitAssign() {
const department = document.getElementById('assignDepartment').value;
const userId = document.getElementById('assignUser').value;
if (!userId) {
alert('담당자를 선택하세요.');
return;
}
try {
const response = await fetch(`${API_BASE}/work-issues/${currentReport.report_id}/assign`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('token')}`
},
body: JSON.stringify({
assigned_department: department,
assigned_user_id: parseInt(userId)
})
});
const data = await response.json();
if (data.success) {
alert('담당자가 배정되었습니다.');
location.reload();
} else {
throw new Error(data.error);
}
} catch (error) {
alert('담당자 배정 실패: ' + error.message);
}
}
// 처리 완료 모달
function showCompleteModal() {
document.getElementById('completeModal').classList.add('visible');
}
function closeCompleteModal() {
document.getElementById('completeModal').classList.remove('visible');
}
async function submitComplete() {
const resolutionNotes = document.getElementById('resolutionNotes').value;
if (!resolutionNotes.trim()) {
alert('처리 내용을 입력하세요.');
return;
}
try {
const response = await fetch(`${API_BASE}/work-issues/${currentReport.report_id}/complete`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('token')}`
},
body: JSON.stringify({
resolution_notes: resolutionNotes
})
});
const data = await response.json();
if (data.success) {
alert('처리가 완료되었습니다.');
location.reload();
} else {
throw new Error(data.error);
}
} catch (error) {
alert('처리 완료 실패: ' + error.message);
}
}
// 종료
async function closeReport() {
if (!confirm('이 신고를 종료하시겠습니까?')) return;
try {
const response = await fetch(`${API_BASE}/work-issues/${currentReport.report_id}/close`, {
method: 'PUT',
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
});
const data = await response.json();
if (data.success) {
alert('종료되었습니다.');
location.reload();
} else {
throw new Error(data.error);
}
} catch (error) {
alert('종료 실패: ' + error.message);
}
}
// 사진 확대
function showPhoto(src) {
document.getElementById('photoModalImg').src = src;
document.getElementById('photoModal').classList.add('visible');
}
function closePhotoModal() {
document.getElementById('photoModal').classList.remove('visible');
}
</script>
</body>
</html>