- 모든 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>
579 lines
30 KiB
HTML
579 lines
30 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">
|
|
<title>공용코드관리</title>
|
|
<link href="/lib/css/tailwind.min.css" rel="stylesheet">
|
|
<link href="/css/common.css" rel="stylesheet">
|
|
<style>
|
|
/* 테이블 셀 텍스트 오버플로우 처리 */
|
|
.truncate {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* 값(문자열) 열 최대 너비 제한 */
|
|
.svalue-cell {
|
|
max-width: 128px; /* w-32 = 128px */
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
</style>
|
|
</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">
|
|
|
|
<!-- 2열 구조 메인 컨테이너 -->
|
|
<div class="flex gap-6 h-[calc(100vh-200px)]">
|
|
<!-- 좌측: 코드그룹 리스트 -->
|
|
<div class="w-80">
|
|
<div class="glass-effect rounded-2xl h-full card-hover animate-slide-up flex flex-col">
|
|
<div class="p-4 border-b border-white/10">
|
|
<h3 class="text-lg 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="M19 11H5m14-7l-7 7-7-7M19 21l-7-7-7 7"></path>
|
|
</svg>
|
|
코드그룹 목록
|
|
</h3>
|
|
</div>
|
|
<div class="flex-1 overflow-y-auto custom-scrollbar p-2">
|
|
<div id="groupList" class="space-y-1">
|
|
<!-- 그룹 목록이 여기에 표시됩니다 -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 우측: 상세 데이터 -->
|
|
<div class="flex-1">
|
|
<div class="glass-effect rounded-2xl h-full card-hover animate-slide-up flex flex-col">
|
|
<!-- 상단 헤더 -->
|
|
<div class="p-4 border-b border-white/10 flex items-center justify-between">
|
|
<div>
|
|
<h3 class="text-lg 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 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
|
|
</svg>
|
|
<span id="selectedGroupTitle">코드그룹을 선택하세요</span>
|
|
</h3>
|
|
<p class="text-white/70 text-sm mt-1">총 <span id="recordCount" class="text-white font-medium">0</span>건</p>
|
|
</div>
|
|
<button onclick="showAddModal()" class="bg-white/20 hover:bg-white/30 backdrop-blur-sm text-white px-4 py-2 rounded-lg transition-all border border-white/30 flex items-center text-sm">
|
|
<svg class="w-4 h-4 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>
|
|
</div>
|
|
|
|
<!-- 데이터 테이블 -->
|
|
<div class="flex-1 overflow-x-auto overflow-y-auto custom-scrollbar">
|
|
<table class="w-full">
|
|
<thead class="bg-white/10 sticky top-0">
|
|
<tr>
|
|
<th class="w-24 px-4 py-3 text-left text-xs font-medium text-white/70 uppercase tracking-wider">코드</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-white/70 uppercase tracking-wider">비고</th>
|
|
<th class="w-32 px-4 py-3 text-left text-xs font-medium text-white/70 uppercase tracking-wider">값(문자열)</th>
|
|
<th class="w-20 px-4 py-3 text-left text-xs font-medium text-white/70 uppercase tracking-wider">값(숫자)</th>
|
|
<th class="w-20 px-4 py-3 text-left text-xs font-medium text-white/70 uppercase tracking-wider">값(실수)</th>
|
|
<th class="w-24 px-4 py-3 text-left text-xs font-medium text-white/70 uppercase tracking-wider">값2</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="dataTable" class="divide-y divide-white/10">
|
|
<tr>
|
|
<td colspan="6" class="px-4 py-8 text-center text-white/70">
|
|
<svg class="w-12 h-12 mx-auto mb-2 text-white/30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
|
|
</svg>
|
|
좌측에서 코드그룹을 선택하세요
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</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>
|
|
</div>
|
|
|
|
<!-- 추가/편집 모달 -->
|
|
<div id="editModal" 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 id="modalTitle" class="text-xl font-semibold text-white">공용코드 추가</h2>
|
|
<button onclick="hideEditModal()" 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>
|
|
|
|
<!-- 모달 내용 -->
|
|
<form id="editForm" class="p-6">
|
|
<input type="hidden" id="editIdx" value="">
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-white/70 mb-2">코드그룹 *</label>
|
|
<select id="editGrp" required class="w-full px-3 py-2 bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all">
|
|
<option value="" class="bg-gray-800 text-white">선택하세요</option>
|
|
<!-- 동적으로 로드됩니다 -->
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-white/70 mb-2">코드 *</label>
|
|
<input type="text" id="editCode" required class="w-full px-3 py-2 bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="코드를 입력하세요">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-white/70 mb-2">값(문자열)</label>
|
|
<input type="text" id="editSvalue" class="w-full px-3 py-2 bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="문자열 값">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-white/70 mb-2">값(숫자)</label>
|
|
<input type="number" id="editIvalue" class="w-full px-3 py-2 bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="숫자 값">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-white/70 mb-2">값(실수)</label>
|
|
<input type="number" step="0.01" id="editFvalue" class="w-full px-3 py-2 bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="실수 값">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-white/70 mb-2">값2</label>
|
|
<input type="text" id="editSvalue2" class="w-full px-3 py-2 bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="추가 문자열 값">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-4">
|
|
<label class="block text-sm font-medium text-white/70 mb-2">비고</label>
|
|
<textarea id="editMemo" rows="3" class="w-full px-3 py-2 bg-white/20 backdrop-blur-sm border border-white/30 rounded-lg text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400 transition-all" placeholder="비고사항을 입력하세요"></textarea>
|
|
</div>
|
|
</form>
|
|
|
|
<!-- 모달 푸터 -->
|
|
<div class="px-6 py-4 border-t border-white/10 flex justify-between">
|
|
<button onclick="deleteCurrentItem()" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg transition-colors flex items-center">
|
|
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
|
|
</svg>
|
|
삭제
|
|
</button>
|
|
<div class="flex gap-2">
|
|
<button onclick="hideEditModal()" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg transition-colors">
|
|
취소
|
|
</button>
|
|
<button onclick="saveData()" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg transition-colors">
|
|
저장
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 삭제 확인 모달 -->
|
|
<div id="deleteModal" 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-md animate-slide-up">
|
|
<div class="p-6">
|
|
<div class="flex items-center mb-4">
|
|
<div class="w-12 h-12 bg-red-100 rounded-full flex items-center justify-center mr-4">
|
|
<svg class="w-6 h-6 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.732-.833-2.5 0L4.268 18.5c-.77.833.192 2.5 1.732 2.5z"></path>
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<h3 class="text-lg font-medium text-gray-900">삭제 확인</h3>
|
|
<p class="text-sm text-gray-500">이 작업은 되돌릴 수 없습니다.</p>
|
|
</div>
|
|
</div>
|
|
<p class="text-gray-700 mb-6">선택한 공용코드를 삭제하시겠습니까?<br><span class="text-sm text-gray-500">이 작업은 되돌릴 수 없습니다.</span></p>
|
|
<div class="flex justify-end gap-2">
|
|
<button onclick="hideDeleteModal()" class="bg-gray-300 hover:bg-gray-400 text-gray-700 px-4 py-2 rounded-lg transition-colors">
|
|
취소
|
|
</button>
|
|
<button onclick="confirmDelete()" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg transition-colors">
|
|
삭제
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 공통 네비게이션 -->
|
|
<script src="/js/common-navigation.js"></script>
|
|
|
|
<script>
|
|
let currentData = [];
|
|
let deleteTargetIdx = null;
|
|
let groupData = [];
|
|
let selectedGroupCode = null;
|
|
|
|
// 비동기 프록시 캐싱 (한 번만 초기화)
|
|
const machine = window.chrome.webview.hostObjects.machine;
|
|
|
|
// 페이지 로드시 초기 데이터 로드
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
loadGroups();
|
|
});
|
|
|
|
// 코드그룹 목록 로드
|
|
async function loadGroups() {
|
|
showLoading();
|
|
|
|
try {
|
|
const jsonStr = await machine.Common_GetGroups();
|
|
const data = JSON.parse(jsonStr);
|
|
groupData = data || [];
|
|
renderGroupList();
|
|
renderEditGroupSelect();
|
|
hideLoading();
|
|
} catch (error) {
|
|
console.error('그룹 데이터 로드 중 오류 발생:', error);
|
|
hideLoading();
|
|
showNotification('그룹 데이터 로드 중 오류가 발생했습니다.', 'error');
|
|
}
|
|
}
|
|
|
|
// 좌측 그룹 리스트 렌더링
|
|
function renderGroupList() {
|
|
const groupList = document.getElementById('groupList');
|
|
|
|
if (groupData.length === 0) {
|
|
groupList.innerHTML = '<div class="text-white/70 text-center py-4">그룹 데이터가 없습니다.</div>';
|
|
return;
|
|
}
|
|
|
|
groupList.innerHTML = groupData.map(group => `
|
|
<div class="group-item cursor-pointer p-3 rounded-lg border border-white/20 hover:bg-white/10 transition-all ${selectedGroupCode === group.code ? 'bg-white/20' : ''}"
|
|
onclick="selectGroup('${group.code}', '${group.memo}')">
|
|
<div class="flex items-center">
|
|
<div class="w-8 h-8 bg-white/20 rounded-full flex items-center justify-center mr-3">
|
|
<span class="text-white text-sm font-medium">${group.code}</span>
|
|
</div>
|
|
<div class="flex-1">
|
|
<div class="text-white font-medium">${group.memo}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
// 그룹 선택 처리
|
|
function selectGroup(code, name) {
|
|
selectedGroupCode = code;
|
|
|
|
// 선택된 그룹 하이라이트 업데이트
|
|
document.querySelectorAll('.group-item').forEach(item => {
|
|
item.classList.remove('bg-white/20');
|
|
});
|
|
event.target.closest('.group-item').classList.add('bg-white/20');
|
|
|
|
// 우측 제목 업데이트
|
|
document.getElementById('selectedGroupTitle').textContent = `${code} - ${name}`;
|
|
|
|
// 해당 그룹의 데이터 로드
|
|
loadDataByGroup(code);
|
|
}
|
|
|
|
// 편집 모달용 그룹 셀렉트 렌더링
|
|
function renderEditGroupSelect() {
|
|
const editGrp = document.getElementById('editGrp');
|
|
editGrp.innerHTML = '<option value="" class="bg-gray-800 text-white">선택하세요</option>' +
|
|
groupData.map(group =>
|
|
`<option value="${group.code}" class="bg-gray-800 text-white">${group.code}-${group.memo}</option>`
|
|
).join('');
|
|
}
|
|
|
|
// 특정 그룹의 데이터 로드
|
|
async function loadDataByGroup(grp) {
|
|
showLoading();
|
|
|
|
try {
|
|
const jsonStr = await machine.Common_GetList(grp || '99');
|
|
const data = JSON.parse(jsonStr);
|
|
currentData = data || [];
|
|
renderTable();
|
|
hideLoading();
|
|
} catch (error) {
|
|
console.error('데이터 로드 중 오류 발생:', error);
|
|
hideLoading();
|
|
showNotification('데이터 로드 중 오류가 발생했습니다.', 'error');
|
|
}
|
|
}
|
|
|
|
// 테이블 렌더링
|
|
function renderTable() {
|
|
const tbody = document.getElementById('dataTable');
|
|
const recordCount = document.getElementById('recordCount');
|
|
|
|
if (currentData.length === 0) {
|
|
tbody.innerHTML = `
|
|
<tr>
|
|
<td colspan="6" class="px-4 py-8 text-center text-white/70">
|
|
<svg class="w-12 h-12 mx-auto mb-2 text-white/30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
|
|
</svg>
|
|
${selectedGroupCode ? '데이터가 없습니다.' : '좌측에서 코드그룹을 선택하세요'}
|
|
</td>
|
|
</tr>
|
|
`;
|
|
recordCount.textContent = '0';
|
|
return;
|
|
}
|
|
|
|
recordCount.textContent = currentData.length;
|
|
|
|
tbody.innerHTML = currentData.map(item => {
|
|
return `
|
|
<tr class="hover:bg-white/5 transition-colors cursor-pointer" onclick="editItem(${item.idx})">
|
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-white">${item.code || '-'}</td>
|
|
<td class="px-4 py-4 text-sm text-white">${item.memo || '-'}</td>
|
|
<td class="px-4 py-4 text-sm text-white svalue-cell" title="${item.svalue || '-'}">${item.svalue || '-'}</td>
|
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-white">${item.ivalue || '0'}</td>
|
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-white">${item.fvalue || '0.0'}</td>
|
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-white">${item.svalue2 || '-'}</td>
|
|
</tr>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// 추가 모달 표시
|
|
function showAddModal() {
|
|
if (!selectedGroupCode) {
|
|
showNotification('먼저 코드그룹을 선택하세요.', 'warning');
|
|
return;
|
|
}
|
|
|
|
document.getElementById('modalTitle').textContent = '공용코드 추가';
|
|
document.getElementById('editForm').reset();
|
|
document.getElementById('editIdx').value = '';
|
|
|
|
// 현재 선택된 코드그룹을 자동 입력
|
|
document.getElementById('editGrp').value = selectedGroupCode;
|
|
|
|
// 삭제 버튼 비활성화 (새로 추가하는 항목이므로)
|
|
const deleteBtn = document.querySelector('#editModal button[onclick="deleteCurrentItem()"]');
|
|
if (deleteBtn) {
|
|
deleteBtn.disabled = true;
|
|
deleteBtn.classList.add('opacity-50', 'cursor-not-allowed');
|
|
}
|
|
|
|
document.getElementById('editModal').classList.remove('hidden');
|
|
}
|
|
|
|
// 편집 모달 표시
|
|
function editItem(idx) {
|
|
const item = currentData.find(x => x.idx === idx);
|
|
if (!item) return;
|
|
|
|
document.getElementById('modalTitle').textContent = '공용코드 편집';
|
|
document.getElementById('editIdx').value = item.idx;
|
|
document.getElementById('editGrp').value = item.grp || '';
|
|
document.getElementById('editCode').value = item.code || '';
|
|
document.getElementById('editSvalue').value = item.svalue || '';
|
|
document.getElementById('editIvalue').value = item.ivalue || '';
|
|
document.getElementById('editFvalue').value = item.fvalue || '';
|
|
document.getElementById('editSvalue2').value = item.svalue2 || '';
|
|
document.getElementById('editMemo').value = item.memo || '';
|
|
|
|
// 삭제 버튼 활성화 (기존 항목 편집이므로)
|
|
const deleteBtn = document.querySelector('#editModal button[onclick="deleteCurrentItem()"]');
|
|
if (deleteBtn) {
|
|
deleteBtn.disabled = false;
|
|
deleteBtn.classList.remove('opacity-50', 'cursor-not-allowed');
|
|
}
|
|
|
|
document.getElementById('editModal').classList.remove('hidden');
|
|
}
|
|
|
|
// 편집 모달 숨기기
|
|
function hideEditModal() {
|
|
document.getElementById('editModal').classList.add('hidden');
|
|
}
|
|
|
|
// 삭제 확인
|
|
function deleteItem(idx) {
|
|
deleteTargetIdx = idx;
|
|
document.getElementById('deleteModal').classList.remove('hidden');
|
|
}
|
|
|
|
// 삭제 모달 숨기기
|
|
function hideDeleteModal() {
|
|
document.getElementById('deleteModal').classList.add('hidden');
|
|
deleteTargetIdx = null;
|
|
}
|
|
|
|
// 삭제 실행
|
|
async function confirmDelete() {
|
|
if (!deleteTargetIdx) return;
|
|
|
|
showLoading();
|
|
|
|
try {
|
|
const jsonStr = await machine.Common_Delete(deleteTargetIdx);
|
|
const data = JSON.parse(jsonStr);
|
|
|
|
hideLoading();
|
|
if (data.Success) {
|
|
showNotification(data.Message, 'success');
|
|
hideDeleteModal();
|
|
// 현재 선택된 그룹의 데이터 새로고침
|
|
if (selectedGroupCode) {
|
|
loadDataByGroup(selectedGroupCode);
|
|
}
|
|
} else {
|
|
showNotification(data.Message, 'error');
|
|
}
|
|
} catch (error) {
|
|
hideLoading();
|
|
console.error('삭제 중 오류 발생:', error);
|
|
showNotification('삭제 중 오류가 발생했습니다.', 'error');
|
|
}
|
|
}
|
|
|
|
// 편집 다이얼로그에서 현재 항목 삭제
|
|
function deleteCurrentItem() {
|
|
const editIdx = document.getElementById('editIdx').value;
|
|
if (!editIdx) {
|
|
showNotification('삭제할 항목이 없습니다.', 'warning');
|
|
return;
|
|
}
|
|
|
|
deleteTargetIdx = parseInt(editIdx);
|
|
hideEditModal();
|
|
document.getElementById('deleteModal').classList.remove('hidden');
|
|
}
|
|
|
|
// 데이터 저장
|
|
async function saveData() {
|
|
const form = document.getElementById('editForm');
|
|
if (!form.checkValidity()) {
|
|
form.reportValidity();
|
|
return;
|
|
}
|
|
|
|
const idx = parseInt(document.getElementById('editIdx').value) || 0;
|
|
const grp = document.getElementById('editGrp').value;
|
|
const code = document.getElementById('editCode').value;
|
|
const svalue = document.getElementById('editSvalue').value;
|
|
const ivalue = parseInt(document.getElementById('editIvalue').value) || 0;
|
|
const fvalue = parseFloat(document.getElementById('editFvalue').value) || 0.0;
|
|
const svalue2 = document.getElementById('editSvalue2').value;
|
|
const memo = document.getElementById('editMemo').value;
|
|
|
|
showLoading();
|
|
|
|
try {
|
|
const jsonStr = await machine.Common_Save(idx, grp, code, svalue, ivalue, fvalue, svalue2, memo);
|
|
const result = JSON.parse(jsonStr);
|
|
|
|
hideLoading();
|
|
if (result.Success) {
|
|
showNotification(result.Message, 'success');
|
|
hideEditModal();
|
|
// 현재 선택된 그룹의 데이터 새로고침
|
|
if (selectedGroupCode) {
|
|
loadDataByGroup(selectedGroupCode);
|
|
}
|
|
} else {
|
|
showNotification(result.Message, 'error');
|
|
}
|
|
} catch (error) {
|
|
hideLoading();
|
|
console.error('저장 중 오류 발생:', error);
|
|
showNotification('저장 중 오류가 발생했습니다.', 'error');
|
|
}
|
|
}
|
|
|
|
// 로딩 표시
|
|
function showLoading() {
|
|
document.getElementById('loadingIndicator').classList.remove('hidden');
|
|
}
|
|
|
|
// 로딩 숨기기
|
|
function hideLoading() {
|
|
document.getElementById('loadingIndicator').classList.add('hidden');
|
|
}
|
|
|
|
// 알림 표시
|
|
function showNotification(message, type = 'info') {
|
|
const colors = {
|
|
info: 'bg-blue-500/90 backdrop-blur-sm',
|
|
success: 'bg-green-500/90 backdrop-blur-sm',
|
|
warning: 'bg-yellow-500/90 backdrop-blur-sm',
|
|
error: 'bg-red-500/90 backdrop-blur-sm'
|
|
};
|
|
|
|
const icons = {
|
|
info: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
|
</svg>`,
|
|
success: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
|
</svg>`,
|
|
warning: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.732-.833-2.5 0L4.268 18.5c-.77.833.192 2.5 1.732 2.5z"></path>
|
|
</svg>`,
|
|
error: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
|
</svg>`
|
|
};
|
|
|
|
const notification = document.createElement('div');
|
|
notification.className = `fixed top-4 right-4 ${colors[type]} text-white px-4 py-3 rounded-lg z-50 transition-all duration-300 transform translate-x-0 opacity-100 shadow-lg border border-white/20`;
|
|
notification.innerHTML = `
|
|
<div class="flex items-center">
|
|
${icons[type]}
|
|
<span class="ml-2">${message}</span>
|
|
</div>
|
|
`;
|
|
|
|
// 초기 상태 설정 (오른쪽에서 슬라이드 인)
|
|
notification.style.transform = 'translateX(100%)';
|
|
notification.style.opacity = '0';
|
|
|
|
document.body.appendChild(notification);
|
|
|
|
// 애니메이션으로 표시
|
|
setTimeout(() => {
|
|
notification.style.transform = 'translateX(0)';
|
|
notification.style.opacity = '1';
|
|
}, 10);
|
|
|
|
// 자동 숨김
|
|
setTimeout(() => {
|
|
notification.style.transform = 'translateX(100%)';
|
|
notification.style.opacity = '0';
|
|
setTimeout(() => notification.remove(), 300);
|
|
}, 3000);
|
|
}
|
|
|
|
// 키보드 이벤트
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.key === 'Escape') {
|
|
hideEditModal();
|
|
hideDeleteModal();
|
|
}
|
|
});
|
|
|
|
// 공통 네비게이션 초기화
|
|
initNavigation('common');
|
|
</script>
|
|
</body>
|
|
</html> |