📊 Complete Issue Display Redesign: - 기존 카드 형태에서 테이블 형태로 완전 변경 - No.부터 완료 사진까지 모든 정보를 일렬로 표시 - 좌우 스크롤 가능한 테이블 구조 (min-width: 1200px) 📅 Date-based Grouping: - 날짜별로 이슈들을 그룹화하여 표시 - 각 날짜 그룹마다 접기/펼치기 기능 구현 - 날짜 헤더 클릭으로 해당 그룹 토글 가능 - 부드러운 애니메이션 효과 적용 🗂️ Comprehensive Data Display: - No. (프로젝트별 순번) - 프로젝트명 - 내용 (final_description 우선, 없으면 description) - 원인 (카테고리) - 해결방안 (solution) - 담당부서 (responsible_department) - 담당자 (responsible_person) - 조치예상일 (expected_completion_date) - 완료확인일 (actual_completion_date) - 확인자 (신고자 + 중복 신고자들) - 원인부서 (cause_department) - 의견 (management_comment) - 조치결과 (진행 중/완료됨) - 업로드 사진 (photo_path, photo_path2) - 완료 사진 (completion_photo_path) 🎨 Enhanced UI/UX: - 좌우 스크롤로 모든 정보 확인 가능 - 사진 클릭 시 확대 모달 표시 - 텍스트 오버플로우 시 툴팁으로 전체 내용 표시 - 상태별 색상 구분 (진행 중: 파란색, 완료됨: 초록색) - 호버 효과로 행 강조 🔧 Technical Implementation: - CSS 그리드 및 테이블 스타일링 - 반응형 스크롤 컨테이너 - 날짜 그룹 토글 애니메이션 - 사진 모달 팝업 기능 - 유틸리티 함수로 데이터 변환 🚀 User Experience: - 한 화면에서 모든 정보 확인 가능 - 날짜별 정리로 체계적인 관리 - 접기/펼치기로 필요한 정보만 표시 - 직관적인 테이블 형태로 데이터 비교 용이 Expected Result: ✅ No.부터 사진까지 모든 정보가 테이블 형태로 표시 ✅ 좌우 스크롤로 긴 데이터도 편리하게 확인 ✅ 날짜별 그룹화로 체계적인 관리 ✅ 접기/펼치기로 필요한 정보만 선택적 표시 ✅ 사진 클릭으로 확대 보기 가능
809 lines
34 KiB
HTML
809 lines
34 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>
|
|
|
|
<!-- Tailwind CSS -->
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
|
<!-- Font Awesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
|
|
<!-- 모바일 캘린더 스타일 -->
|
|
<link rel="stylesheet" href="/static/css/mobile-calendar.css">
|
|
|
|
<!-- Custom Styles -->
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
|
|
|
body {
|
|
font-family: 'Inter', sans-serif;
|
|
}
|
|
|
|
.issue-card {
|
|
transition: all 0.2s ease;
|
|
border-left: 4px solid transparent;
|
|
}
|
|
|
|
.issue-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.priority-high { border-left-color: #ef4444; }
|
|
.priority-medium { border-left-color: #f59e0b; }
|
|
.priority-low { border-left-color: #10b981; }
|
|
|
|
.status-new { border-left-color: #3b82f6; }
|
|
.status-processing { border-left-color: #f59e0b; }
|
|
.status-pending { border-left-color: #8b5cf6; }
|
|
.status-completed { border-left-color: #10b981; }
|
|
|
|
.action-btn {
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.action-btn:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.modal {
|
|
backdrop-filter: blur(4px);
|
|
}
|
|
|
|
.badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 9999px;
|
|
font-size: 0.75rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
/* 날짜 그룹 스타일 */
|
|
.date-group {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.date-header {
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.date-header:hover {
|
|
background-color: #f9fafb;
|
|
}
|
|
|
|
/* 좌우 스크롤 가능한 이슈 테이블 */
|
|
.issue-table-container {
|
|
overflow-x: auto;
|
|
border: 1px solid #e5e7eb;
|
|
border-radius: 0.5rem;
|
|
margin-top: 0.5rem;
|
|
}
|
|
|
|
.issue-table {
|
|
min-width: 1200px;
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.issue-table th,
|
|
.issue-table td {
|
|
padding: 0.75rem;
|
|
text-align: left;
|
|
border-bottom: 1px solid #f3f4f6;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.issue-table th {
|
|
background-color: #f9fafb;
|
|
font-weight: 600;
|
|
color: #374151;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.issue-table tbody tr:hover {
|
|
background-color: #f9fafb;
|
|
}
|
|
|
|
.issue-photo {
|
|
width: 60px;
|
|
height: 40px;
|
|
object-fit: cover;
|
|
border-radius: 0.375rem;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.issue-description {
|
|
max-width: 200px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.collapse-content {
|
|
max-height: 1000px;
|
|
overflow: hidden;
|
|
transition: max-height 0.3s ease-out;
|
|
}
|
|
|
|
.collapse-content.collapsed {
|
|
max-height: 0;
|
|
}
|
|
|
|
.badge-new { background: #dbeafe; color: #1e40af; }
|
|
.badge-processing { background: #fef3c7; color: #92400e; }
|
|
.badge-pending { background: #ede9fe; color: #7c3aed; }
|
|
.badge-completed { background: #d1fae5; color: #065f46; }
|
|
</style>
|
|
</head>
|
|
<body class="bg-gray-50 min-h-screen">
|
|
<!-- 공통 헤더가 여기에 자동으로 삽입됩니다 -->
|
|
|
|
<!-- Main Content -->
|
|
<main class="container mx-auto px-4 py-8" style="padding-top: 80px;">
|
|
<!-- 페이지 헤더 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-6 mb-6">
|
|
<div class="flex items-center justify-between mb-4">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-900 flex items-center">
|
|
<i class="fas fa-cog text-green-500 mr-3"></i>
|
|
관리함
|
|
</h1>
|
|
<p class="text-gray-600 mt-1">부적합 사항을 처리하고 상태를 관리하세요</p>
|
|
</div>
|
|
<div class="flex items-center space-x-3">
|
|
<button onclick="bulkAction()" class="px-4 py-2 bg-purple-500 text-white rounded-lg hover:bg-purple-600 transition-colors">
|
|
<i class="fas fa-tasks mr-2"></i>
|
|
일괄 처리
|
|
</button>
|
|
<button onclick="exportData()" class="px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 transition-colors">
|
|
<i class="fas fa-download mr-2"></i>
|
|
내보내기
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 관리 통계 -->
|
|
<div class="grid grid-cols-1 md:grid-cols-5 gap-4">
|
|
<div class="bg-blue-50 p-4 rounded-lg">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-exclamation-circle text-blue-500 text-xl mr-3"></i>
|
|
<div>
|
|
<p class="text-sm text-blue-600">처리 필요</p>
|
|
<p class="text-2xl font-bold text-blue-700" id="needActionCount">0</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-yellow-50 p-4 rounded-lg">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-spinner text-yellow-500 text-xl mr-3"></i>
|
|
<div>
|
|
<p class="text-sm text-yellow-600">처리 중</p>
|
|
<p class="text-2xl font-bold text-yellow-700" id="processingCount">0</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-purple-50 p-4 rounded-lg">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-pause-circle text-purple-500 text-xl mr-3"></i>
|
|
<div>
|
|
<p class="text-sm text-purple-600">대기 중</p>
|
|
<p class="text-2xl font-bold text-purple-700" id="pendingCount">0</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-green-50 p-4 rounded-lg">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-check-circle text-green-500 text-xl mr-3"></i>
|
|
<div>
|
|
<p class="text-sm text-green-600">완료</p>
|
|
<p class="text-2xl font-bold text-green-700" id="completedCount">0</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-gray-50 p-4 rounded-lg">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-chart-pie text-gray-500 text-xl mr-3"></i>
|
|
<div>
|
|
<p class="text-sm text-gray-600">전체</p>
|
|
<p class="text-2xl font-bold text-gray-700" id="totalCount">0</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 프로젝트 필터 및 상태 탭 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-6 mb-6">
|
|
<div class="space-y-4">
|
|
<!-- 프로젝트 선택 -->
|
|
<div class="max-w-md">
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">📁 프로젝트</label>
|
|
<select id="projectFilter" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500" onchange="filterIssues()">
|
|
<option value="">전체 프로젝트</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- 상태 탭 -->
|
|
<div class="flex space-x-1 bg-gray-100 p-1 rounded-lg max-w-md">
|
|
<button id="inProgressTab"
|
|
class="flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors duration-200 bg-blue-500 text-white"
|
|
onclick="switchTab('in_progress')">
|
|
<i class="fas fa-cog mr-2"></i>진행 중
|
|
</button>
|
|
<button id="completedTab"
|
|
class="flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors duration-200 text-gray-600 hover:text-gray-900"
|
|
onclick="switchTab('completed')">
|
|
<i class="fas fa-check-circle mr-2"></i>완료됨
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 부적합 관리 목록 -->
|
|
<div class="bg-white rounded-xl shadow-sm">
|
|
<div class="p-6 border-b border-gray-200">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-lg font-semibold text-gray-800">부적합 관리</h2>
|
|
<div class="flex items-center space-x-4">
|
|
<select id="sortOrder" class="text-sm border border-gray-300 rounded px-2 py-1" onchange="sortIssues()">
|
|
<option value="newest">최신순</option>
|
|
<option value="oldest">오래된순</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issuesList" class="p-4">
|
|
<!-- 날짜별 그룹화된 부적합 목록이 여기에 동적으로 생성됩니다 -->
|
|
</div>
|
|
|
|
<!-- 빈 상태 -->
|
|
<div id="emptyState" class="hidden p-12 text-center">
|
|
<i class="fas fa-cog text-6xl text-gray-300 mb-4"></i>
|
|
<h3 class="text-lg font-medium text-gray-900 mb-2">관리할 부적합이 없습니다</h3>
|
|
<p class="text-gray-500">처리가 필요한 부적합이 있으면 여기에 표시됩니다.</p>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- 상태 변경 모달 -->
|
|
<div id="statusModal" class="fixed inset-0 bg-black bg-opacity-50 modal hidden z-50">
|
|
<div class="flex items-center justify-center min-h-screen p-4">
|
|
<div class="bg-white rounded-xl max-w-md w-full p-6">
|
|
<div class="flex items-center justify-between mb-4">
|
|
<h3 class="text-lg font-semibold text-gray-900">상태 변경</h3>
|
|
<button onclick="closeStatusModal()" class="text-gray-400 hover:text-gray-600">
|
|
<i class="fas fa-times"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">새 상태</label>
|
|
<select id="newStatus" class="w-full px-3 py-2 border border-gray-300 rounded-lg">
|
|
<option value="processing">처리 중</option>
|
|
<option value="pending">대기 중</option>
|
|
<option value="completed">완료</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">처리 메모</label>
|
|
<textarea id="statusNote" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-lg"
|
|
placeholder="상태 변경 사유나 처리 내용을 입력하세요..."></textarea>
|
|
</div>
|
|
|
|
<div class="flex justify-end space-x-3">
|
|
<button onclick="closeStatusModal()" class="px-4 py-2 text-gray-600 hover:text-gray-800">
|
|
취소
|
|
</button>
|
|
<button onclick="updateStatus()" class="px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600">
|
|
변경
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Scripts -->
|
|
<script src="/static/js/date-utils.js?v=20250917"></script>
|
|
<script src="/static/js/core/permissions.js?v=20251025"></script>
|
|
<script src="/static/js/components/common-header.js?v=20251025"></script>
|
|
<script src="/static/js/core/page-manager.js?v=20251025"></script>
|
|
<script>
|
|
let currentUser = null;
|
|
let issues = [];
|
|
let projects = [];
|
|
let filteredIssues = [];
|
|
let selectedIssues = new Set();
|
|
let currentIssueId = null;
|
|
let currentTab = 'in_progress'; // 기본값: 진행 중
|
|
|
|
// API 로드 후 초기화 함수
|
|
async function initializeManagement() {
|
|
const token = localStorage.getItem('access_token');
|
|
if (!token) {
|
|
window.location.href = '/index.html';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const user = await AuthAPI.getCurrentUser();
|
|
currentUser = user;
|
|
localStorage.setItem('currentUser', JSON.stringify(user));
|
|
|
|
// 공통 헤더 초기화
|
|
await window.commonHeader.init(user, 'issues_management');
|
|
|
|
// 페이지 접근 권한 체크
|
|
setTimeout(() => {
|
|
if (!canAccessPage('issues_management')) {
|
|
alert('관리함 페이지에 접근할 권한이 없습니다.');
|
|
window.location.href = '/index.html';
|
|
return;
|
|
}
|
|
}, 500);
|
|
|
|
// 데이터 로드
|
|
await loadProjects();
|
|
await loadIssues();
|
|
|
|
} catch (error) {
|
|
console.error('인증 실패:', error);
|
|
localStorage.removeItem('access_token');
|
|
localStorage.removeItem('currentUser');
|
|
window.location.href = '/index.html';
|
|
}
|
|
}
|
|
|
|
// 프로젝트 로드
|
|
async function loadProjects() {
|
|
try {
|
|
const response = await fetch('/api/projects/', {
|
|
headers: {
|
|
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
if (response.ok) {
|
|
projects = await response.json();
|
|
updateProjectFilter();
|
|
}
|
|
} catch (error) {
|
|
console.error('프로젝트 로드 실패:', error);
|
|
}
|
|
}
|
|
|
|
// 부적합 목록 로드 (관리자는 모든 부적합 조회)
|
|
async function loadIssues() {
|
|
try {
|
|
let endpoint = '/api/issues/admin/all';
|
|
|
|
const response = await fetch(endpoint, {
|
|
headers: {
|
|
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
if (response.ok) {
|
|
const allIssues = await response.json();
|
|
// 관리함에서는 진행 중(in_progress)과 완료됨(completed) 상태만 표시
|
|
issues = allIssues.filter(issue =>
|
|
issue.review_status === 'in_progress' || issue.review_status === 'completed'
|
|
);
|
|
filterIssues();
|
|
updateStatistics();
|
|
} else {
|
|
throw new Error('부적합 목록을 불러올 수 없습니다.');
|
|
}
|
|
} catch (error) {
|
|
console.error('부적합 로드 실패:', error);
|
|
alert('부적합 목록을 불러오는데 실패했습니다.');
|
|
}
|
|
}
|
|
|
|
// 탭 전환 함수
|
|
function switchTab(tab) {
|
|
currentTab = tab;
|
|
|
|
// 탭 버튼 스타일 업데이트
|
|
const inProgressTab = document.getElementById('inProgressTab');
|
|
const completedTab = document.getElementById('completedTab');
|
|
|
|
if (tab === 'in_progress') {
|
|
inProgressTab.className = 'flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors duration-200 bg-blue-500 text-white';
|
|
completedTab.className = 'flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors duration-200 text-gray-600 hover:text-gray-900';
|
|
} else {
|
|
inProgressTab.className = 'flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors duration-200 text-gray-600 hover:text-gray-900';
|
|
completedTab.className = 'flex-1 px-4 py-2 text-sm font-medium rounded-md transition-colors duration-200 bg-green-500 text-white';
|
|
}
|
|
|
|
filterIssues();
|
|
}
|
|
|
|
// 필터링 및 표시 함수들
|
|
function filterIssues() {
|
|
const projectFilter = document.getElementById('projectFilter').value;
|
|
|
|
filteredIssues = issues.filter(issue => {
|
|
// 현재 탭에 따른 상태 필터링
|
|
if (issue.review_status !== currentTab) return false;
|
|
|
|
// 프로젝트 필터링
|
|
if (projectFilter && issue.project_id != projectFilter) return false;
|
|
|
|
return true;
|
|
});
|
|
|
|
sortIssues();
|
|
displayIssues();
|
|
}
|
|
|
|
function sortIssues() {
|
|
const sortOrder = document.getElementById('sortOrder').value;
|
|
|
|
filteredIssues.sort((a, b) => {
|
|
switch (sortOrder) {
|
|
case 'newest':
|
|
return new Date(b.report_date) - new Date(a.report_date);
|
|
case 'oldest':
|
|
return new Date(a.report_date) - new Date(b.report_date);
|
|
default:
|
|
return new Date(b.report_date) - new Date(a.report_date);
|
|
}
|
|
});
|
|
}
|
|
|
|
function displayIssues() {
|
|
const container = document.getElementById('issuesList');
|
|
const emptyState = document.getElementById('emptyState');
|
|
|
|
if (filteredIssues.length === 0) {
|
|
container.innerHTML = '';
|
|
emptyState.classList.remove('hidden');
|
|
return;
|
|
}
|
|
|
|
emptyState.classList.add('hidden');
|
|
|
|
// 날짜별로 그룹화
|
|
const groupedByDate = {};
|
|
filteredIssues.forEach(issue => {
|
|
const date = new Date(issue.report_date).toLocaleDateString('ko-KR');
|
|
if (!groupedByDate[date]) {
|
|
groupedByDate[date] = [];
|
|
}
|
|
groupedByDate[date].push(issue);
|
|
});
|
|
|
|
// 날짜별 그룹을 HTML로 생성
|
|
const dateGroups = Object.keys(groupedByDate).map(date => {
|
|
const issues = groupedByDate[date];
|
|
const groupId = `group-${date.replace(/\./g, '-')}`;
|
|
|
|
return `
|
|
<div class="date-group">
|
|
<div class="date-header flex items-center justify-between p-3 bg-gray-50 rounded-lg"
|
|
onclick="toggleDateGroup('${groupId}')">
|
|
<div class="flex items-center space-x-3">
|
|
<i class="fas fa-chevron-down transition-transform duration-200" id="icon-${groupId}"></i>
|
|
<h3 class="font-semibold text-gray-800">${date}</h3>
|
|
<span class="text-sm text-gray-500">(${issues.length}건)</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="collapse-content" id="${groupId}">
|
|
<div class="issue-table-container">
|
|
<table class="issue-table">
|
|
<thead>
|
|
<tr>
|
|
<th>No.</th>
|
|
<th>프로젝트</th>
|
|
<th>내용</th>
|
|
<th>원인</th>
|
|
<th>해결방안</th>
|
|
<th>담당부서</th>
|
|
<th>담당자</th>
|
|
<th>조치예상일</th>
|
|
<th>완료확인일</th>
|
|
<th>확인자</th>
|
|
<th>원인부서</th>
|
|
<th>의견</th>
|
|
<th>조치결과</th>
|
|
<th>업로드 사진</th>
|
|
<th>완료 사진</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
${issues.map(issue => createIssueRow(issue)).join('')}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
|
|
container.innerHTML = dateGroups;
|
|
}
|
|
|
|
// 이슈 행 생성 함수
|
|
function createIssueRow(issue) {
|
|
const project = projects.find(p => p.id === issue.project_id);
|
|
const statusText = issue.review_status === 'in_progress' ? '진행 중' : '완료됨';
|
|
const statusClass = issue.review_status === 'in_progress' ? 'text-blue-600' : 'text-green-600';
|
|
|
|
return `
|
|
<tr>
|
|
<td class="font-medium">${issue.project_sequence_no || '-'}</td>
|
|
<td>${project ? project.project_name : '-'}</td>
|
|
<td class="issue-description" title="${issue.final_description || issue.description}">
|
|
${issue.final_description || issue.description}
|
|
</td>
|
|
<td>${getCategoryText(issue.final_category || issue.category)}</td>
|
|
<td class="issue-description" title="${issue.solution || '-'}">
|
|
${issue.solution || '-'}
|
|
</td>
|
|
<td>${getDepartmentText(issue.responsible_department) || '-'}</td>
|
|
<td>${issue.responsible_person || '-'}</td>
|
|
<td>${issue.expected_completion_date ? new Date(issue.expected_completion_date).toLocaleDateString('ko-KR') : '-'}</td>
|
|
<td>${issue.actual_completion_date ? new Date(issue.actual_completion_date).toLocaleDateString('ko-KR') : '-'}</td>
|
|
<td>${getReporterNames(issue)}</td>
|
|
<td>${getDepartmentText(issue.cause_department) || '-'}</td>
|
|
<td class="issue-description" title="${issue.management_comment || '-'}">
|
|
${issue.management_comment || '-'}
|
|
</td>
|
|
<td class="${statusClass} font-medium">${statusText}</td>
|
|
<td>
|
|
${issue.photo_path ? `<img src="${issue.photo_path}" class="issue-photo" onclick="openPhotoModal('${issue.photo_path}')" alt="업로드 사진">` : '-'}
|
|
${issue.photo_path2 ? `<br><img src="${issue.photo_path2}" class="issue-photo mt-1" onclick="openPhotoModal('${issue.photo_path2}')" alt="업로드 사진 2">` : ''}
|
|
</td>
|
|
<td>
|
|
${issue.completion_photo_path ? `<img src="${issue.completion_photo_path}" class="issue-photo" onclick="openPhotoModal('${issue.completion_photo_path}')" alt="완료 사진">` : '-'}
|
|
</td>
|
|
</tr>
|
|
`;
|
|
}
|
|
|
|
// 날짜 그룹 토글 함수
|
|
function toggleDateGroup(groupId) {
|
|
const content = document.getElementById(groupId);
|
|
const icon = document.getElementById(`icon-${groupId}`);
|
|
|
|
if (content.classList.contains('collapsed')) {
|
|
content.classList.remove('collapsed');
|
|
icon.style.transform = 'rotate(0deg)';
|
|
} else {
|
|
content.classList.add('collapsed');
|
|
icon.style.transform = 'rotate(-90deg)';
|
|
}
|
|
}
|
|
|
|
// 유틸리티 함수들
|
|
function getDepartmentText(department) {
|
|
const departments = {
|
|
'production': '생산',
|
|
'quality': '품질',
|
|
'purchasing': '구매',
|
|
'design': '설계',
|
|
'sales': '영업'
|
|
};
|
|
return departments[department] || department;
|
|
}
|
|
|
|
function getReporterNames(issue) {
|
|
let names = [issue.reporter?.full_name || issue.reporter?.username || '알 수 없음'];
|
|
|
|
if (issue.duplicate_reporters && issue.duplicate_reporters.length > 0) {
|
|
const duplicateNames = issue.duplicate_reporters.map(r => r.full_name || r.username);
|
|
names = names.concat(duplicateNames);
|
|
}
|
|
|
|
return names.join(', ');
|
|
}
|
|
|
|
function getCategoryText(category) {
|
|
const categories = {
|
|
'quality': '품질',
|
|
'safety': '안전',
|
|
'environment': '환경',
|
|
'process': '공정',
|
|
'equipment': '장비',
|
|
'material': '자재',
|
|
'etc': '기타'
|
|
};
|
|
return categories[category] || category;
|
|
}
|
|
|
|
// 사진 모달 함수
|
|
function openPhotoModal(photoPath) {
|
|
const modal = document.createElement('div');
|
|
modal.className = 'fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50';
|
|
modal.onclick = () => modal.remove();
|
|
|
|
modal.innerHTML = `
|
|
<div class="max-w-4xl max-h-4xl p-4">
|
|
<img src="${photoPath}" class="max-w-full max-h-full object-contain rounded-lg" alt="확대된 사진">
|
|
</div>
|
|
`;
|
|
|
|
document.body.appendChild(modal);
|
|
}
|
|
|
|
// 통계 업데이트
|
|
function updateStatistics() {
|
|
const needAction = issues.filter(issue => issue.status === 'new').length;
|
|
const processing = issues.filter(issue => issue.status === 'processing').length;
|
|
const pending = issues.filter(issue => issue.status === 'pending').length;
|
|
const completed = issues.filter(issue => issue.status === 'completed').length;
|
|
|
|
document.getElementById('needActionCount').textContent = needAction;
|
|
document.getElementById('processingCount').textContent = processing;
|
|
document.getElementById('pendingCount').textContent = pending;
|
|
document.getElementById('completedCount').textContent = completed;
|
|
document.getElementById('totalCount').textContent = issues.length;
|
|
}
|
|
|
|
// 선택 관리
|
|
function toggleIssueSelection(issueId) {
|
|
if (selectedIssues.has(issueId)) {
|
|
selectedIssues.delete(issueId);
|
|
} else {
|
|
selectedIssues.add(issueId);
|
|
}
|
|
displayIssues();
|
|
}
|
|
|
|
function toggleSelectAll() {
|
|
const selectAll = document.getElementById('selectAll').checked;
|
|
if (selectAll) {
|
|
filteredIssues.forEach(issue => selectedIssues.add(issue.id));
|
|
} else {
|
|
selectedIssues.clear();
|
|
}
|
|
displayIssues();
|
|
}
|
|
|
|
// 상태 변경 모달
|
|
function openStatusModal(issueId) {
|
|
currentIssueId = issueId;
|
|
document.getElementById('statusModal').classList.remove('hidden');
|
|
}
|
|
|
|
function closeStatusModal() {
|
|
currentIssueId = null;
|
|
document.getElementById('statusModal').classList.add('hidden');
|
|
document.getElementById('newStatus').value = 'processing';
|
|
document.getElementById('statusNote').value = '';
|
|
}
|
|
|
|
async function updateStatus() {
|
|
if (!currentIssueId) return;
|
|
|
|
const newStatus = document.getElementById('newStatus').value;
|
|
const note = document.getElementById('statusNote').value;
|
|
|
|
try {
|
|
const response = await fetch(`/api/issues/${currentIssueId}`, {
|
|
method: 'PUT',
|
|
headers: {
|
|
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
status: newStatus,
|
|
note: note
|
|
})
|
|
});
|
|
|
|
if (response.ok) {
|
|
await loadIssues();
|
|
closeStatusModal();
|
|
alert('상태가 성공적으로 변경되었습니다.');
|
|
} else {
|
|
throw new Error('상태 변경에 실패했습니다.');
|
|
}
|
|
} catch (error) {
|
|
console.error('상태 변경 실패:', error);
|
|
alert('상태 변경에 실패했습니다.');
|
|
}
|
|
}
|
|
|
|
// 기타 함수들
|
|
function bulkAction() {
|
|
if (selectedIssues.size === 0) {
|
|
alert('처리할 부적합을 선택해주세요.');
|
|
return;
|
|
}
|
|
// 일괄 처리 로직 구현
|
|
alert(`${selectedIssues.size}개의 부적합을 일괄 처리합니다.`);
|
|
}
|
|
|
|
function exportData() {
|
|
// 데이터 내보내기 로직 구현
|
|
alert('데이터를 내보냅니다.');
|
|
}
|
|
|
|
function viewIssueDetail(issueId) {
|
|
window.location.href = `/issue-view.html#detail-${issueId}`;
|
|
}
|
|
|
|
// 유틸리티 함수들
|
|
function updateProjectFilter() {
|
|
const projectFilter = document.getElementById('projectFilter');
|
|
projectFilter.innerHTML = '<option value="">전체 프로젝트</option>';
|
|
|
|
projects.forEach(project => {
|
|
const option = document.createElement('option');
|
|
option.value = project.id;
|
|
option.textContent = project.project_name;
|
|
projectFilter.appendChild(option);
|
|
});
|
|
}
|
|
|
|
function getStatusBadgeClass(status) {
|
|
const statusMap = {
|
|
'new': 'new',
|
|
'processing': 'processing',
|
|
'pending': 'pending',
|
|
'completed': 'completed'
|
|
};
|
|
return statusMap[status] || 'new';
|
|
}
|
|
|
|
function getStatusText(status) {
|
|
const statusMap = {
|
|
'new': '새 부적합',
|
|
'processing': '처리 중',
|
|
'pending': '대기 중',
|
|
'completed': '완료'
|
|
};
|
|
return statusMap[status] || status;
|
|
}
|
|
|
|
function getPriorityBadge(priority) {
|
|
const priorityMap = {
|
|
'high': { text: '높음', class: 'bg-red-100 text-red-800' },
|
|
'medium': { text: '보통', class: 'bg-yellow-100 text-yellow-800' },
|
|
'low': { text: '낮음', class: 'bg-green-100 text-green-800' }
|
|
};
|
|
const p = priorityMap[priority] || { text: '보통', class: 'bg-gray-100 text-gray-800' };
|
|
return `<span class="badge ${p.class}">${p.text}</span>`;
|
|
}
|
|
|
|
function getCategoryText(category) {
|
|
const categoryMap = {
|
|
'material_missing': '자재 누락',
|
|
'design_error': '설계 오류',
|
|
'incoming_defect': '반입 불량',
|
|
'inspection_miss': '검사 누락',
|
|
'etc': '기타'
|
|
};
|
|
return categoryMap[category] || category;
|
|
}
|
|
|
|
// API 스크립트 동적 로딩
|
|
const cacheBuster = Date.now() + Math.random() + Math.floor(Math.random() * 1000000);
|
|
const script = document.createElement('script');
|
|
script.src = `/static/js/api.js?v=20251025-2&cb=${cacheBuster}&t=${Date.now()}&r=${Math.random()}`;
|
|
script.setAttribute('cache-control', 'no-cache');
|
|
script.setAttribute('pragma', 'no-cache');
|
|
script.onload = function() {
|
|
console.log('✅ API 스크립트 로드 완료 (issues-management.html)');
|
|
initializeManagement();
|
|
};
|
|
script.onerror = function() {
|
|
console.error('❌ API 스크립트 로드 실패');
|
|
};
|
|
document.head.appendChild(script);
|
|
</script>
|
|
</body>
|
|
</html>
|