Files
Groupware/Project/Web/wwwroot/DashBoard/index.html
backuppc faa912532f perf: CDN 대신 로컬 CSS 파일 사용으로 페이지 전환 속도 개선
- 모든 HTML 파일에서 cdn.tailwindcss.com 대신 /lib/css/tailwind.min.css 사용
- 중복되는 인라인 스타일을 /css/common.css로 통합
- 외부 네트워크 의존성 제거로 페이지 로딩 지연 해결

변경된 파일:
- DashBoard/index.html
- Todo/index.html
- Jobreport/index.html
- Kuntae/index.html
- Common.html
- login.html
- Project/index.html

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 17:38:17 +09:00

1014 lines
54 KiB
HTML

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="version" content="v2.0-20250127">
<title>근태현황 대시보드*</title>
<link href="/lib/css/tailwind.min.css" rel="stylesheet">
<link href="/css/common.css" rel="stylesheet">
</head>
<body class="bg-gradient-to-br from-blue-900 via-purple-900 to-indigo-900 min-h-screen text-white">
<div class="container mx-auto px-4 py-8">
<!-- 통계 카드 -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 mb-8">
<!-- 구매요청 카드(NR) -->
<div class="glass-effect rounded-2xl p-6 card-hover animate-slide-up cursor-pointer" onclick="showPurchaseNRModal()">
<div class="flex items-center justify-between">
<div>
<p class="text-white/70 text-sm font-medium">구매요청(NR)</p>
<p class="text-3xl font-bold text-white" id="purchaseCountNR">0</p>
</div>
<div class="w-12 h-12 bg-danger-500/20 rounded-full flex items-center justify-center">
<svg class="w-6 h-6 text-danger-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"></path>
</svg>
</div>
</div>
</div>
<!-- 구매요청 카드(CR) -->
<div class="glass-effect rounded-2xl p-6 card-hover animate-slide-up cursor-pointer" onclick="showPurchaseCRModal()">
<div class="flex items-center justify-between">
<div>
<p class="text-white/70 text-sm font-medium">구매요청(CR)</p>
<p class="text-3xl font-bold text-white" id="purchaseCountCR">0</p>
</div>
<div class="w-12 h-12 bg-danger-500/20 rounded-full flex items-center justify-center">
<svg class="w-6 h-6 text-danger-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"></path>
</svg>
</div>
</div>
</div>
</div>
<!-- 통계 카드들을 새로운 컨테이너로 이동 -->
<div class="mb-8">
</div>
<!-- 2칸 레이아웃: 좌측 휴가현황, 우측 할일 -->
<div class="grid grid-cols-1 lg:grid-cols-1 gap-8 animate-slide-up">
<!-- 우측: 할일 -->
<div class="glass-effect rounded-2xl overflow-hidden">
<div class="px-6 py-4 border-b border-white/10">
<h2 class="text-xl font-semibold text-white flex items-center justify-between">
<span class="flex items-center">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
</svg>
할일
</span>
<div class="flex items-center space-x-2">
<button onclick="showDashboardAddTodoModal()" class="text-xs bg-primary-500/20 hover:bg-primary-500/30 text-primary-300 hover:text-primary-200 px-3 py-1 rounded-full transition-colors flex items-center">
<svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
</svg>
할일추가
</button>
<button onclick="window.location.href='/Todo/index.html'" class="text-xs bg-white/20 hover:bg-white/30 px-3 py-1 rounded-full transition-colors">
전체보기
</button>
</div>
</h2>
</div>
<div class="p-4">
<div id="urgentTodoList" class="space-y-3 max-h-[384px] overflow-y-auto custom-scrollbar">
<!-- 할일이 여기에 표시됩니다 -->
<div class="text-center text-white/50 py-8">
<svg class="w-8 h-8 mx-auto mb-2 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
</svg>
급한 할일이 없습니다
</div>
</div>
</div>
</div>
</div>
<!-- 로딩 인디케이터 -->
<div id="loadingIndicator" class="fixed top-4 right-4 bg-white/20 backdrop-blur-sm rounded-full px-4 py-2 text-white text-sm hidden">
<div class="flex items-center">
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
데이터 업데이트 중...
</div>
</div>
<!-- 구매NR 모달 -->
<div id="purchaseNRModal" class="fixed inset-0 bg-black/50 backdrop-blur-sm hidden z-50">
<div class="flex items-center justify-center min-h-screen p-4">
<div class="glass-effect rounded-2xl w-full max-w-7xl max-h-[80vh] overflow-hidden animate-slide-up">
<!-- 모달 헤더 -->
<div class="px-6 py-4 border-b border-white/10 flex items-center justify-between">
<h2 class="text-xl font-semibold text-white flex items-center">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"></path>
</svg>
구매요청(NR) 목록
</h2>
<button onclick="hidePurchaseNRModal()" class="text-white/70 hover:text-white transition-colors">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- 모달 내용 -->
<div class="overflow-x-auto max-h-[60vh] custom-scrollbar">
<table class="w-full">
<thead class="bg-white/10 sticky top-0">
<tr>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">요청일</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">공정</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">품명</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">규격</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">단위</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">수량</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">단가</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">금액</th>
</tr>
</thead>
<tbody id="purchaseNRTable" class="divide-y divide-white/10">
<!-- 데이터가 여기에 표시됩니다 -->
</tbody>
</table>
</div>
<!-- 모달 푸터 -->
<div class="px-6 py-4 border-t border-white/10 flex justify-between items-center">
<p class="text-white/70 text-sm"><span id="purchaseNRCount">0</span></p>
<button onclick="hidePurchaseNRModal()" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg transition-colors">
닫기
</button>
</div>
</div>
</div>
</div>
<!-- 구매CR 모달 -->
<div id="purchaseCRModal" class="fixed inset-0 bg-black/50 backdrop-blur-sm hidden z-50">
<div class="flex items-center justify-center min-h-screen p-4">
<div class="glass-effect rounded-2xl w-full max-w-7xl max-h-[80vh] overflow-hidden animate-slide-up">
<!-- 모달 헤더 -->
<div class="px-6 py-4 border-b border-white/10 flex items-center justify-between">
<h2 class="text-xl font-semibold text-white flex items-center">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"></path>
</svg>
구매요청(CR) 목록
</h2>
<button onclick="hidePurchaseCRModal()" class="text-white/70 hover:text-white transition-colors">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- 모달 내용 -->
<div class="overflow-x-auto max-h-[60vh] custom-scrollbar">
<table class="w-full">
<thead class="bg-white/10 sticky top-0">
<tr>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">요청일</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">공정</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">품명</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">규격</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">단위</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">수량</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">단가</th>
<th class="px-6 py-4 text-left text-xs font-medium text-white/70 uppercase tracking-wider">금액</th>
</tr>
</thead>
<tbody id="purchaseCRTable" class="divide-y divide-white/10">
<!-- 데이터가 여기에 표시됩니다 -->
</tbody>
</table>
</div>
<!-- 모달 푸터 -->
<div class="px-6 py-4 border-t border-white/10 flex justify-between items-center">
<p class="text-white/70 text-sm"><span id="purchaseCRCount">0</span></p>
<button onclick="hidePurchaseCRModal()" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg transition-colors">
닫기
</button>
</div>
</div>
</div>
</div>
<!-- 할일 상세 정보 모달 -->
<div id="todoDetailModal" class="fixed inset-0 bg-black/50 backdrop-blur-sm hidden z-50">
<div class="flex items-center justify-center min-h-screen p-4">
<div class="glass-effect rounded-2xl w-full max-w-2xl max-h-[80vh] overflow-hidden animate-slide-up">
<!-- 모달 헤더 -->
<div class="px-6 py-4 border-b border-white/10 flex items-center justify-between">
<h2 class="text-xl font-semibold text-white flex items-center">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
</svg>
할일 상세 정보
</h2>
<button onclick="hideTodoDetailModal()" class="text-white/70 hover:text-white transition-colors">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- 모달 내용 -->
<div class="p-6 max-h-[60vh] overflow-y-auto custom-scrollbar">
<div class="space-y-4">
<!-- 제목 -->
<div>
<label class="block text-white/70 text-sm font-medium mb-2">제목</label>
<div id="detailTitle" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[2.5rem] flex items-center">
-
</div>
</div>
<!-- 내용 -->
<div>
<label class="block text-white/70 text-sm font-medium mb-2">내용</label>
<div id="detailRemark" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[4rem] whitespace-pre-wrap">
-
</div>
</div>
<!-- 요청자 -->
<div>
<label class="block text-white/70 text-sm font-medium mb-2">요청자</label>
<div id="detailRequest" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[2.5rem] flex items-center">
-
</div>
</div>
<!-- 중요도 및 플래그 -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-white/70 text-sm font-medium mb-2">중요도</label>
<div id="detailSeqno" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[2.5rem] flex items-center">
-
</div>
</div>
<div>
<label class="block text-white/70 text-sm font-medium mb-2">상태</label>
<div id="detailFlag" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[2.5rem] flex items-center">
-
</div>
</div>
</div>
<!-- 만료일, 완료일 및 작성일 -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label class="block text-white/70 text-sm font-medium mb-2">만료일</label>
<div id="detailExpire" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[2.5rem] flex items-center">
-
</div>
</div>
<div>
<label class="block text-white/70 text-sm font-medium mb-2">완료일</label>
<div id="detailOkdate" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[2.5rem] flex items-center">
-
</div>
</div>
<div>
<label class="block text-white/70 text-sm font-medium mb-2">작성일</label>
<div id="detailWdate" class="bg-white/10 rounded-lg px-4 py-3 text-white min-h-[2.5rem] flex items-center">
-
</div>
</div>
</div>
</div>
</div>
<!-- 모달 푸터 -->
<div class="px-6 py-4 border-t border-white/10 flex justify-between items-center">
<button onclick="goToTodoPageFromDetail()" class="text-primary-400 hover:text-primary-300 text-sm transition-colors">
전체 할일 목록으로 이동 →
</button>
<button onclick="hideTodoDetailModal()" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg transition-colors">
닫기
</button>
</div>
</div>
</div>
</div>
<!-- 할일 추가 모달 -->
<div id="dashboardAddTodoModal" class="fixed inset-0 bg-black/50 backdrop-blur-sm hidden z-50">
<div class="flex items-center justify-center min-h-screen p-4">
<div class="glass-effect rounded-2xl w-full max-w-2xl animate-slide-up">
<!-- 모달 헤더 -->
<div class="px-6 py-4 border-b border-white/10 flex items-center justify-between">
<h2 class="text-xl font-semibold text-white flex items-center">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
</svg>
새 할일 추가
</h2>
<button onclick="hideDashboardAddTodoModal()" class="text-white/70 hover:text-white transition-colors">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- 모달 내용 -->
<div class="p-6">
<form id="dashboardTodoForm" class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-white/70 text-sm font-medium mb-2">제목 (선택사항)</label>
<input type="text" id="dashboardTodoTitle" class="w-full bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg px-4 py-2 text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="할일 제목을 입력하세요">
</div>
<div>
<label class="block text-white/70 text-sm font-medium mb-2">만료일 (선택사항)</label>
<input type="date" id="dashboardTodoExpire" class="w-full bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all">
</div>
</div>
<div>
<label class="block text-white/70 text-sm font-medium mb-2">내용 *</label>
<textarea id="dashboardTodoRemark" rows="3" class="w-full bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg px-4 py-2 text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="할일 내용을 입력하세요 (필수)" required></textarea>
</div>
<div>
<label class="block text-white/70 text-sm font-medium mb-2">요청자</label>
<input type="text" id="dashboardTodoRequest" class="w-full bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg px-4 py-2 text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="업무 요청자를 입력하세요">
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label class="block text-white/70 text-sm font-medium mb-2">진행상태</label>
<input type="hidden" id="dashboardTodoStatus" value="0">
<div class="flex flex-wrap gap-2">
<button type="button" onclick="setDashboardTodoStatus('0')" id="dashboardStatusBtn0" class="px-3 py-1 rounded-lg text-xs font-medium bg-gray-500/20 text-gray-300 border border-gray-500/30 transition-all">대기</button>
<button type="button" onclick="setDashboardTodoStatus('1')" id="dashboardStatusBtn1" class="px-3 py-1 rounded-lg text-xs font-medium bg-white/10 text-white/50 border border-white/20 hover:bg-primary-500/20 hover:text-primary-300 transition-all">진행</button>
<button type="button" onclick="setDashboardTodoStatus('3')" id="dashboardStatusBtn3" class="px-3 py-1 rounded-lg text-xs font-medium bg-white/10 text-white/50 border border-white/20 hover:bg-warning-500/20 hover:text-warning-300 transition-all">보류</button>
<button type="button" onclick="setDashboardTodoStatus('2')" id="dashboardStatusBtn2" class="px-3 py-1 rounded-lg text-xs font-medium bg-white/10 text-white/50 border border-white/20 hover:bg-danger-500/20 hover:text-danger-300 transition-all">취소</button>
<button type="button" onclick="setDashboardTodoStatus('5')" id="dashboardStatusBtn5" class="px-3 py-1 rounded-lg text-xs font-medium bg-white/10 text-white/50 border border-white/20 hover:bg-success-500/20 hover:text-success-300 transition-all">완료</button>
</div>
</div>
<div>
<label class="block text-white/70 text-sm font-medium mb-2">중요도</label>
<select id="dashboardTodoSeqno" class="w-full bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all">
<option value="0">보통</option>
<option value="1">중요</option>
<option value="2">매우 중요</option>
<option value="3">긴급</option>
</select>
</div>
<div class="flex items-end">
<label class="flex items-center text-white/70 text-sm font-medium">
<input type="checkbox" id="dashboardTodoFlag" class="mr-2 text-primary-500 focus:ring-primary-400 focus:ring-offset-0 rounded">
플래그 (상단 고정)
</label>
</div>
</div>
</form>
</div>
<!-- 모달 푸터 -->
<div class="px-6 py-4 border-t border-white/10 flex justify-end space-x-3">
<button type="button" onclick="hideDashboardAddTodoModal()" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg transition-colors">
취소
</button>
<button type="submit" form="dashboardTodoForm" class="bg-primary-500 hover:bg-primary-600 text-white px-6 py-2 rounded-lg transition-colors flex items-center">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
</svg>
추가
</button>
</div>
</div>
</div>
</div>
</div>
<!-- 공통 네비게이션 JS -->
<script src="/js/common-navigation.js"></script>
<script>
// 대시보드 전용 스크립트
// 비동기 프록시 캐싱 (한 번만 초기화)
const machine = window.chrome.webview.hostObjects.machine;
// 구매요청 데이터 Ajax 업데이트
async function updatePurchaseCount() {
showLoading();
try {
const jsonData = await machine.GetPurchaseWaitCount();
const data = JSON.parse(jsonData);
if (data) {
// NR 구매요청 카운트 업데이트
if (data.NR !== undefined) {
animateNumberChange('purchaseCountNR', data.NR);
}
// CR 구매요청 카운트 업데이트
if (data.CR !== undefined) {
animateNumberChange('purchaseCountCR', data.CR);
}
}
} catch (error) {
console.error('구매요청 데이터 업데이트 중 오류 발생:', error);
}
hideLoading();
}
// 숫자 애니메이션
function animateNumberChange(elementId, newValue) {
const element = document.getElementById(elementId);
if (!element) {
console.warn(`Element not found: ${elementId}`);
return;
}
const currentValue = parseInt(element.textContent) || 0;
const increment = (newValue - currentValue) / 20;
let current = currentValue;
const timer = setInterval(() => {
current += increment;
if ((increment > 0 && current >= newValue) || (increment < 0 && current <= newValue)) {
element.textContent = newValue;
clearInterval(timer);
} else {
element.textContent = Math.floor(current);
}
}, 50);
}
// 로딩 표시
function showLoading() {
document.getElementById('loadingIndicator').classList.remove('hidden');
}
function hideLoading() {
document.getElementById('loadingIndicator').classList.add('hidden');
}
// Todo 목록 Ajax 업데이트
async function updateTodoList() {
showLoading();
try {
const jsonData = await machine.GetUrgentTodos();
const data = JSON.parse(jsonData);
if (data.Success && data.Data) {
displayTodoList(data.Data);
} else {
displayTodoList([]);
}
} catch (error) {
console.error('Todo 목록 업데이트 중 오류 발생:', error);
displayTodoList([]);
}
hideLoading();
}
// Todo 목록 표시
function displayTodoList(todos) {
const todoListElement = document.getElementById('urgentTodoList');
let todoItems = '';
if (todos && todos.length > 0) {
todos.forEach(todo => {
const flagIcon = todo.flag ? '📌 ' : '';
const seqnoClass = getTodoSeqnoClass(todo.seqno);
const seqnoText = getTodoSeqnoText(todo.seqno);
const expireText = todo.expire ? new Date(todo.expire).toLocaleDateString('ko-KR') : '';
const isExpired = todo.expire && new Date(todo.expire) < new Date();
const expireClass = isExpired ? 'text-danger-400' : 'text-white/60';
// 만료일이 지난 경우 배경을 적색계통으로 강조
const expiredBgClass = isExpired ? 'bg-danger-600/30 border-danger-400/40 hover:bg-danger-600/40' : 'bg-white/10 hover:bg-white/15 border-white/20';
todoItems += `
<div class="${expiredBgClass} backdrop-blur-sm rounded-lg p-3 transition-colors cursor-pointer border" onclick="showTodoDetail(${todo.idx})">
<div class="flex items-start justify-between mb-2">
<div class="flex items-center gap-1">
${flagIcon ? `<span class="text-xs">${flagIcon}</span>` : ''}
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${seqnoClass}">
${seqnoText}
</span>
</div>
<div class="text-xs text-right">
${expireText ? `<div class="${expireClass}">${expireText}</div>` : ''}
${todo.request ? `<div class="text-white/50">요청: ${todo.request}</div>` : ''}
</div>
</div>
<h3 class="text-white font-medium text-sm mb-1 line-clamp-1">${todo.title || '제목 없음'}</h3>
<p class="text-white/70 text-xs line-clamp-2">${todo.remark || ''}</p>
</div>
`;
});
} else {
todoItems = `
<div class="text-center text-white/50 py-8">
<svg class="w-8 h-8 mx-auto mb-2 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
</svg>
<p class="text-sm">할일이 없습니다</p>
<button onclick="window.location.href='/Todo/index.html'" class="text-primary-400 hover:text-primary-300 text-xs transition-colors mt-1 inline-block">
할일 추가하기 →
</button>
</div>
`;
}
todoListElement.innerHTML = todoItems;
}
// Todo 중요도 클래스 반환
function getTodoSeqnoClass(seqno) {
switch(seqno) {
case 1: return 'bg-primary-500/20 text-primary-300';
case 2: return 'bg-warning-500/20 text-warning-300';
case 3: return 'bg-danger-500/20 text-danger-300';
default: return 'bg-white/10 text-white/50';
}
}
// Todo 중요도 텍스트 반환
function getTodoSeqnoText(seqno) {
switch(seqno) {
case 1: return '중요';
case 2: return '매우 중요';
case 3: return '긴급';
default: return '보통';
}
}
// Todo 페이지로 이동
function goToTodoPage() {
window.location.href = '/Todo/index.html';
}
// 할일 상세 정보 표시
async function showTodoDetail(todoId) {
showLoading();
try {
const jsonData = await machine.GetTodo(todoId);
const data = JSON.parse(jsonData);
if (data.Success && data.Data) {
displayTodoDetail(data.Data);
document.getElementById('todoDetailModal').classList.remove('hidden');
} else {
showError('할일 정보를 불러올 수 없습니다.');
}
} catch (error) {
console.error('할일 상세 정보 로드 중 오류 발생:', error);
showError('할일 정보를 불러오는 중 오류가 발생했습니다.');
}
hideLoading();
}
// 할일 상세 정보를 모달에 표시
function displayTodoDetail(todo) {
document.getElementById('detailTitle').textContent = todo.title || '제목 없음';
document.getElementById('detailRemark').textContent = todo.remark || '-';
document.getElementById('detailRequest').textContent = todo.request || '-';
// 중요도 표시
const seqnoText = getTodoSeqnoText(todo.seqno);
const seqnoClass = getTodoSeqnoClass(todo.seqno);
document.getElementById('detailSeqno').innerHTML = `
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${seqnoClass}">
${seqnoText}
</span>
`;
// 플래그 상태 표시
const flagText = todo.flag ? '중요' : '일반';
const flagClass = todo.flag ? 'bg-danger-500/20 text-danger-300' : 'bg-white/10 text-white/50';
document.getElementById('detailFlag').innerHTML = `
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${flagClass}">
${todo.flag ? '📌 ' : ''}${flagText}
</span>
`;
// 만료일 표시
const expireText = todo.expire ? new Date(todo.expire).toLocaleDateString('ko-KR') : '-';
const isExpired = todo.expire && new Date(todo.expire) < new Date();
const expireClass = isExpired ? 'text-danger-400' : 'text-white';
document.getElementById('detailExpire').innerHTML = `<span class="${expireClass}">${expireText}</span>`;
// 완료일 표시
const okdateText = todo.okdate ? new Date(todo.okdate).toLocaleDateString('ko-KR') + ' ' + new Date(todo.okdate).toLocaleTimeString('ko-KR') : '-';
const okdateClass = todo.okdate ? 'text-success-400' : 'text-white';
document.getElementById('detailOkdate').innerHTML = `<span class="${okdateClass}">${okdateText}</span>`;
// 작성일 표시
const wdateText = todo.wdate ? new Date(todo.wdate).toLocaleDateString('ko-KR') + ' ' + new Date(todo.wdate).toLocaleTimeString('ko-KR') : '-';
document.getElementById('detailWdate').textContent = wdateText;
}
// 할일 상세 정보 모달 숨기기
function hideTodoDetailModal() {
document.getElementById('todoDetailModal').classList.add('hidden');
}
// 할일 상세 정보에서 Todo 페이지로 이동
function goToTodoPageFromDetail() {
hideTodoDetailModal();
window.location.href = '/Todo/index.html';
}
// 간단한 에러 표시 함수
function showError(message) {
alert(message); // 나중에 더 예쁜 toast나 modal로 변경 가능
}
// 간단한 성공 표시 함수
function showSuccess(message) {
alert(message);
}
// 대시보드 할일 추가 모달 표시/숨기기
function showDashboardAddTodoModal() {
document.getElementById('dashboardAddTodoModal').classList.remove('hidden');
// 폼 초기화
document.getElementById('dashboardTodoForm').reset();
document.getElementById('dashboardTodoStatus').value = '0';
setDashboardTodoStatus('0');
}
function hideDashboardAddTodoModal() {
document.getElementById('dashboardAddTodoModal').classList.add('hidden');
}
// 대시보드에서 할일 상태 설정
function setDashboardTodoStatus(status) {
document.getElementById('dashboardTodoStatus').value = status;
// 모든 버튼 초기화
['0', '1', '2', '3', '5'].forEach(s => {
const btn = document.getElementById(`dashboardStatusBtn${s}`);
if (btn) {
btn.className = 'px-3 py-1 rounded-lg text-xs font-medium bg-white/10 text-white/50 border border-white/20 hover:bg-white/20 transition-all';
}
});
// 선택된 버튼 활성화
const selectedBtn = document.getElementById(`dashboardStatusBtn${status}`);
if (selectedBtn) {
const statusClass = getTodoStatusClass(status).replace('bg-', 'bg-').replace('text-', 'text-');
const borderClass = statusClass.replace('bg-', 'border-').replace('text-', 'border-').replace('/20', '/30');
selectedBtn.className = `px-3 py-1 rounded-lg text-xs font-medium ${statusClass} ${borderClass} transition-all`;
}
}
// 대시보드에서 할일 추가
async function addDashboardTodo() {
const title = document.getElementById('dashboardTodoTitle').value;
const remark = document.getElementById('dashboardTodoRemark').value;
const expire = document.getElementById('dashboardTodoExpire').value || '';
const seqno = parseInt(document.getElementById('dashboardTodoSeqno').value) || 0;
const flag = document.getElementById('dashboardTodoFlag').checked;
const request = document.getElementById('dashboardTodoRequest').value || '';
const status = document.getElementById('dashboardTodoStatus').value || '0';
if (!remark.trim()) {
showError('할일 내용을 입력해주세요.');
return;
}
showLoading();
try {
const jsonData = await machine.CreateTodo(title, remark, expire, seqno, flag, request, status);
const data = JSON.parse(jsonData);
if (data.Success) {
hideDashboardAddTodoModal();
updateTodoList(); // 대시보드 할일 목록 새로고침
showSuccess(data.Message || '할일이 추가되었습니다.');
} else {
showError(data.Message || '할일 추가에 실패했습니다.');
}
} catch (error) {
console.error('할일 추가 중 오류:', error);
showError('서버 연결에 실패했습니다.');
}
hideLoading();
}
// Todo 목록 업데이트 (중복 함수 - 이미 위에서 정의됨, displayUrgentTodos 호출용으로 유지)
async function updateTodoListUrgent() {
showLoading();
try {
const jsonData = await machine.GetUrgentTodos();
const data = JSON.parse(jsonData);
if (data.Success && data.Data) {
displayUrgentTodos(data.Data);
} else {
displayEmptyTodos();
}
} catch (error) {
console.error('급한 할일 목록 업데이트 중 오류 발생:', error);
displayEmptyTodos();
}
hideLoading();
}
// 급한 할일 목록 표시
function displayUrgentTodos(todos) {
const todoContainer = document.getElementById('urgentTodoList');
let todoItems = '';
if (todos && todos.length > 0) {
todos.forEach(todo => {
const statusClass = getTodoStatusClass(todo.status);
const statusText = getTodoStatusText(todo.status);
const seqnoClass = getTodoSeqnoClass(todo.seqno);
const seqnoText = getTodoSeqnoText(todo.seqno);
const flagIcon = todo.flag ? '📌 ' : '';
const expireText = todo.expire ? new Date(todo.expire).toLocaleDateString('ko-KR') : '';
const isExpired = todo.expire && new Date(todo.expire) < new Date();
const expireClass = isExpired ? 'text-danger-400' : 'text-white/60';
const okdateText = todo.okdate ? new Date(todo.okdate).toLocaleDateString('ko-KR') : '';
todoItems += `
<div class="bg-white/10 rounded-lg p-4 hover:bg-white/15 transition-colors cursor-pointer" onclick="showTodoDetail(${todo.idx})">
<div class="flex items-start justify-between mb-2">
<div class="flex items-center space-x-2">
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${statusClass}">
${statusText}
</span>
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${seqnoClass}">
${seqnoText}
</span>
</div>
<div class="text-xs text-right">
${expireText ? `<div class="${expireClass}">만료: ${expireText}</div>` : ''}
${okdateText ? `<div class="text-success-400">완료: ${okdateText}</div>` : ''}
</div>
</div>
<h4 class="text-white font-medium mb-1">${flagIcon}${todo.title || '제목 없음'}</h4>
<p class="text-white/70 text-sm line-clamp-2">${todo.remark || ''}</p>
${todo.request ? `<p class="text-white/50 text-xs mt-2">요청자: ${todo.request}</p>` : ''}
</div>
`;
});
} else {
todoItems = `
<div class="text-center text-white/50 py-8">
<svg class="w-8 h-8 mx-auto mb-2 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
</svg>
급한 할일이 없습니다
</div>
`;
}
todoContainer.innerHTML = todoItems;
}
// 빈 할일 목록 표시
function displayEmptyTodos() {
const todoContainer = document.getElementById('urgentTodoList');
todoContainer.innerHTML = `
<div class="text-center text-white/50 py-8">
<svg class="w-8 h-8 mx-auto mb-2 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
</svg>
급한 할일이 없습니다
</div>
`;
}
// Todo 상태 클래스 반환
function getTodoStatusClass(status) {
switch(status) {
case '0': return 'bg-gray-500/20 text-gray-300';
case '1': return 'bg-primary-500/20 text-primary-300';
case '2': return 'bg-danger-500/20 text-danger-300';
case '3': return 'bg-warning-500/20 text-warning-300';
case '5': return 'bg-success-500/20 text-success-300';
default: return 'bg-white/10 text-white/50';
}
}
// Todo 상태 텍스트 반환
function getTodoStatusText(status) {
switch(status) {
case '0': return '대기';
case '1': return '진행';
case '2': return '취소';
case '3': return '보류';
case '5': return '완료';
default: return '대기';
}
}
// 페이지 로드 시 데이터 업데이트
updatePurchaseCount();
updateTodoList();
// 30초마다 데이터 새로고침
setInterval(() => {
updatePurchaseCount();
updateTodoList();
}, 30000);
// 대시보드 할일 추가 폼 이벤트 리스너
document.getElementById('dashboardTodoForm').addEventListener('submit', function(e) {
e.preventDefault();
addDashboardTodo();
});
// 대시보드 할일 추가 모달 외부 클릭으로 닫기
document.getElementById('dashboardAddTodoModal').addEventListener('click', function(event) {
if (event.target === this) {
hideDashboardAddTodoModal();
}
});
// 공통 네비게이션 초기화
initNavigation('dashboard');
// ESC 키로 모달 닫기
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
hidePurchaseNRModal();
hidePurchaseCRModal();
hideTodoDetailModal();
hideDashboardAddTodoModal();
}
});
// 구매NR 모달 표시
function showPurchaseNRModal() {
document.getElementById('purchaseNRModal').classList.remove('hidden');
loadPurchaseNRList();
}
// 구매NR 모달 숨기기
function hidePurchaseNRModal() {
document.getElementById('purchaseNRModal').classList.add('hidden');
}
// 구매NR 목록 로드
async function loadPurchaseNRList() {
showLoading();
try {
const jsonData = await machine.GetPurchaseNRList();
const data = JSON.parse(jsonData);
let tableRows = '';
if (data && data.length > 0) {
data.forEach(item => {
// 요청일 포맷팅
const requestDate = item.pdate ? new Date(item.pdate).toLocaleDateString('ko-KR') : '-';
// 금액 포맷팅 (천 단위 콤마)
const amount = item.pumamt ? Number(item.pumamt).toLocaleString() : '-';
const price = item.pumprice ? Number(item.pumprice).toLocaleString() : '-';
tableRows += `
<tr class="hover:bg-white/5 transition-colors">
<td class="px-6 py-4 whitespace-nowrap text-white/80">${requestDate}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.process || '-'}</td>
<td class="px-6 py-4 text-white">${item.pumname || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.pumscale || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.pumunit || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.pumqtyreq || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${price}</td>
<td class="px-6 py-4 whitespace-nowrap text-white font-medium">${amount}</td>
</tr>
`;
});
document.getElementById('purchaseNRCount').textContent = data.length;
} else {
tableRows = `
<tr>
<td colspan="8" class="px-6 py-8 text-center text-white/50">
구매요청이 없습니다
</td>
</tr>
`;
document.getElementById('purchaseNRCount').textContent = '0';
}
document.getElementById('purchaseNRTable').innerHTML = tableRows;
} catch (error) {
console.error('구매NR 목록 로드 중 오류 발생:', error);
document.getElementById('purchaseNRTable').innerHTML = `
<tr>
<td colspan="8" class="px-6 py-8 text-center text-danger-400">
데이터를 불러오는 중 오류가 발생했습니다
</td>
</tr>
`;
document.getElementById('purchaseNRCount').textContent = '0';
}
hideLoading();
}
// 구매NR 모달 외부 클릭으로 닫기
document.getElementById('purchaseNRModal').addEventListener('click', function(event) {
if (event.target === this) {
hidePurchaseNRModal();
}
});
// 구매CR 모달 표시
function showPurchaseCRModal() {
document.getElementById('purchaseCRModal').classList.remove('hidden');
loadPurchaseCRList();
}
// 구매CR 모달 숨기기
function hidePurchaseCRModal() {
document.getElementById('purchaseCRModal').classList.add('hidden');
}
// 구매CR 목록 로드
async function loadPurchaseCRList() {
showLoading();
try {
const jsonData = await machine.GetPurchaseCRList();
const data = JSON.parse(jsonData);
let tableRows = '';
if (data && data.length > 0) {
data.forEach(item => {
// 요청일 포맷팅
const requestDate = item.pdate ? new Date(item.pdate).toLocaleDateString('ko-KR') : '-';
// 금액 포맷팅 (천 단위 콤마)
const amount = item.pumamt ? Number(item.pumamt).toLocaleString() : '-';
const price = item.pumprice ? Number(item.pumprice).toLocaleString() : '-';
tableRows += `
<tr class="hover:bg-white/5 transition-colors">
<td class="px-6 py-4 whitespace-nowrap text-white/80">${requestDate}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.process || '-'}</td>
<td class="px-6 py-4 text-white">${item.pumname || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.pumscale || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.pumunit || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${item.pumqtyreq || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-white/80">${price}</td>
<td class="px-6 py-4 whitespace-nowrap text-white font-medium">${amount}</td>
</tr>
`;
});
document.getElementById('purchaseCRCount').textContent = data.length;
} else {
tableRows = `
<tr>
<td colspan="8" class="px-6 py-8 text-center text-white/50">
구매요청이 없습니다
</td>
</tr>
`;
document.getElementById('purchaseCRCount').textContent = '0';
}
document.getElementById('purchaseCRTable').innerHTML = tableRows;
} catch (error) {
console.error('구매CR 목록 로드 중 오류 발생:', error);
document.getElementById('purchaseCRTable').innerHTML = `
<tr>
<td colspan="8" class="px-6 py-8 text-center text-danger-400">
데이터를 불러오는 중 오류가 발생했습니다
</td>
</tr>
`;
document.getElementById('purchaseCRCount').textContent = '0';
}
hideLoading();
}
// 구매CR 모달 외부 클릭으로 닫기
document.getElementById('purchaseCRModal').addEventListener('click', function(event) {
if (event.target === this) {
hidePurchaseCRModal();
}
});
// 할일 상세 정보 모달 외부 클릭으로 닫기
document.getElementById('todoDetailModal').addEventListener('click', function(event) {
if (event.target === this) {
hideTodoDetailModal();
}
});
</script>
</body>
</html>