- UI/UX: 메일 리스트 영역 너비 확장(400px), 검색 및 날짜 선택 영역 여백 조정 - 기능: 탭별 샘플 데이터 동적 렌더링, 메일 검색 및 초기화 기능 구현 - 기능: 메일 선택 시 본문 내용 동적 업데이트 연동 - 기능: 메일 개별 삭제(텍스트 버튼) 및 체크박스를 이용한 다중 삭제 기능 추가 - UI: 메일 쓰기 및 주소록 버튼 하단 고정 레이아웃 적용
481 lines
27 KiB
JavaScript
481 lines
27 KiB
JavaScript
let currentFiles = [];
|
|
let editingIndex = -1;
|
|
|
|
const HIERARCHY = {
|
|
"행정": {
|
|
"계약": ["계약관리", "기성관리", "업무지시서", "인원관리"],
|
|
"업무관리": ["업무일지(2025)", "업무일지(2025년 이전)", "발주처 정기보고", "본사업무보고", "공사감독일지", "양식서류"]
|
|
},
|
|
"설계성과품": {
|
|
"시방서": ["공사시방서", "장비 반입허가 검토서"],
|
|
"설계도면": ["공통", "토공", "비탈면안전공", "배수공", "교량공", "포장공", "교통안전시설공", "부대공", "용지공 & 기타공"],
|
|
"수량산출서": ["토공", "비탈면안전공", "배수공", "교량공", "포장공", "교통안전시설공", "부대공", "용지공 & 기타공"],
|
|
"내역서": ["단가산출서"],
|
|
"보고서": ["실시설계보고서", "지반조사보고서", "구조계산서", "수리 및 전기계산서", "기타보고서", "기술자문 및 심의"],
|
|
"측량계산부": ["측량계산부"],
|
|
"설계단계 수행협의": ["회의·협의"]
|
|
},
|
|
"시공성과품": {
|
|
"설계도면": ["공통", "토공", "비탈면안전공", "배수공", "교량공", "포장공", "교통안전시설공", "부대공", "용지공 & 기타공"]
|
|
},
|
|
"시공검측": {
|
|
"토공": ["검측 (깨기)", "검측 (연약지반)", "검측 (발파)", "검측 (노체)", "검측 (노상)", "검측 (토취장)"],
|
|
"배수공": ["검측 (V형측구)", "검측 (산마루측구)", "검측 (U형측구)", "검측 (U형측구)(안)", "검측 (L형측구, J형측구)", "검측 (도수로)", "검측 (도수로)(안)", "검측 (횡배수관)", "검측 (종배수관)", "검측 (맹암거)", "검측 (통로암거)", "검측 (수로암거)", "검측 (호안공)", "검측 (옹벽공)", "검측 (용수개거)"],
|
|
"구조물공": ["검측 (평목교-거더, 부대공)", "검측 (평목교)(안)", "검측 (개착터널, 생태통로)"],
|
|
"포장공": ["검측 (기층, 보조기층)"],
|
|
"부대공": ["검측 (환경)", "검측 (지장가옥,건물 철거)", "검측 (방음벽 등)"],
|
|
"비탈면안전공": ["검측 (식생보호공)", "검측 (구조물보호공)"],
|
|
"교통안전시설공": ["검측 (낙석방지책)"],
|
|
"검측 양식서류": ["검측 양식서류"]
|
|
},
|
|
"설계변경": {
|
|
"실정보고(어천~공주)": ["토공", "배수공", "교량공(평목교)", "구조물공", "포장공", "교통안전공", "부대공", "전기공사", "미확정공", "안전관리", "환경관리", "품질관리", "자재관리", "지장물", "기타"],
|
|
"실정보고(대술~정안)": ["토공", "배수공", "비탈면안전공", "포장공", "부대공", "안전관리", "환경관리", "자재관리", "기타"],
|
|
"기술지원 검토": ["토공", "배수공", "교량공(평목교)", "구조물&부대공", "기타"],
|
|
"시공계획(어천~공주)": ["토공", "배수공", "교량공(평목교)", "구조물&부대&포장&교통안전공", "환경 및 품질관리"]
|
|
},
|
|
"공사관리": {
|
|
"공정·일정": ["공정표", "월간 공정보고", "작업일보"],
|
|
"품질 관리": ["품질시험계획서", "품질시험 실적보고", "콘크리트 타설현황[어천~공주(4차)]", "품질관리비 사용내역", "균열관리", "품질관리 양식서류"],
|
|
"안전 관리": ["안전관리계획서", "안전관리 실적보고", "위험성 평가", "사전작업허가서", "안전관리비 사용내역", "안전관리수준평가", "안전관리 양식서류"],
|
|
"환경 관리": ["환경영향평가", "사전재해영향성검토", "유지관리 및 보수점검", "환경보전비 사용내역", "건설폐기물 관리"],
|
|
"자재 관리 (관급)": ["자재구매요청 (레미콘, 철근)", "자재구매요청 (그 외)", "납품기한", "계약 변경", "자재 반입·수불 관리", "자재관리 양식서류"],
|
|
"자재 관리 (사급)": ["자재공급원 승인", "자재 반입·수불 관리", "자재 검수·확인"],
|
|
"점검 (정리중)": ["내부점검", "외부점검"],
|
|
"공문": ["접수(수신)", "발송(발신)", "하도급", "인력", "방침"]
|
|
},
|
|
"민원관리": {
|
|
"민원(어천~공주)": ["처리대장", "보상", "공사일반", "환경분쟁"],
|
|
"실정보고(어천~공주)": ["민원"],
|
|
"실정보고(대술~정안)": ["민원"]
|
|
}
|
|
};
|
|
|
|
const MAIL_SAMPLES = {
|
|
inbound: [
|
|
{ person: "라오스 농림부", email: "pany.s@lao.gov.la", time: "2026-03-05", title: "ITTC 교육센터 착공식 일정 협의", summary: "안녕하세요. 착공식 관련하여 정부 측 인사의 일정을 반영한 최종 공문을 송부합니다. 원활한 진행을 위해 협조 부탁드립니다.", active: true },
|
|
{ person: "베트남 전력청 (EVN)", email: "contact@evn.com.vn", time: "2026-03-05", title: "송전망 확충사업 기술자문 검토 요청", summary: "제8차 전력개발계획에 따른 북부 지역 계통 안정화 방안에 대한 귀사의 의견을 요청드립니다. 전문가의 식견이 필요합니다.", active: false },
|
|
{ person: "현대건설 (김철수 소장)", email: "cs.kim@hdec.co.kr", time: "2026-03-04", title: "[긴급] 어천-공주(4차) 하도급 변경계약 통보", summary: "철거공사 물량 변동에 따른 계약 금액 조정 건입니다. 검토 후 승인 부탁드립니다. 기한이 촉박합니다.", active: false },
|
|
{ person: "한국도로공사", email: "safety@ex.co.kr", time: "2026-02-24", title: "설 연휴 대비 현장 안전점검 실시 안내", summary: "전 현장을 대상으로 동절기 및 연휴 기간 화재 예방 및 비상연락망 점검을 실시할 예정입니다. 준비에 만전을 기해 주십시오.", active: false },
|
|
{ person: "정안-대술 현장사무소", email: "office@jeongan.site", time: "2026-02-23", title: "지반조사보고서 및 구조계산서 송부", summary: "STA. 15+200 구간 암반 노출에 따른 설계 변경 기초 자료를 보내드립니다. 구조적 안전성 검토가 완료되었습니다.", active: false }
|
|
],
|
|
outbound: [
|
|
{ person: "Pany S. (라오스 농림부)", email: "pany.s@lao.gov.la", time: "2026-03-05", title: "Re: ITTC 교육센터 착공식 일정 확인", summary: "네, 보내주신 공문 확인하였습니다. 내부 검토 후 회신 드리겠습니다. 긍정적인 방향으로 검토 중입니다.", active: false },
|
|
{ person: "김철수 소장 (현대건설)", email: "cs.kim@hdec.co.kr", time: "2026-03-05", title: "하도급 변경계약 검토 의견 회신", summary: "요청하신 물량 변동 내역 중 일부 항목에 대해 보완이 필요합니다. 상세 내역을 다시 정리해서 보내주세요.", active: false },
|
|
{ person: "베트남 전력청 담당자", email: "admin@evn.com.vn", time: "2026-03-05", title: "[자료제공] 송전망 기술 규격서", summary: "요청하신 한국 내 송전망 설계 가이드라인 및 규격서를 송부합니다. 업무에 참고하시기 바랍니다.", active: false },
|
|
{ person: "공사관리부 (본사)", email: "hq_pm@projectmaster.com", time: "2026-03-04", title: "어천-공주 2월 월간 공정보고서 제출", summary: "2월 한 달간의 주요 공정 및 예산 집행 현황 보고서입니다. 목표 대비 진척률은 95%입니다.", active: false },
|
|
{ person: "안전관리팀", email: "safety_team@projectmaster.com", time: "2026-03-04", title: "현장 안전 점검 조치 결과 보고", summary: "지난 점검 시 지적된 5개 항목에 대한 시정 조치를 완료하였습니다. 증빙 사진을 첨부합니다.", active: false },
|
|
{ person: "라오스 관개국", email: "irrigation@lao.gov.la", time: "2026-03-03", title: "교육생 명단 및 비자 발급 서류 요청", summary: "국내 초청 연수를 위한 교육생 여권 사본 및 비자 서류를 요청드립니다. 빠른 회신 부탁드립니다.", active: false },
|
|
{ person: "동아지질 현장팀", email: "donga@site.com", time: "2026-03-02", title: "지반 개량 공법 검토안 발송", summary: "연약지반 구간에 대한 DCM 공법 적용 검토 자료입니다. 시공 효율성 향상이 기대됩니다.", active: false },
|
|
{ person: "품질관리실", email: "quality@projectmaster.com", time: "2026-02-28", title: "레미콘 공급원 승인 서류 제출", summary: "어천 현장용 레미콘 공급업체(동양) 승인 요청 건입니다. 시험 성적서를 첨부하였습니다.", active: false },
|
|
{ person: "민원인 (정안면)", email: "citizen@jeongan.net", time: "2026-02-27", title: "소음 분진 대책 수립 답변", summary: "민원 제기하신 구간에 대해 방진벽 추가 설치 및 살수차 증차를 결정하였습니다. 불편을 드려 죄송합니다.", active: false },
|
|
{ person: "한국엔지니어링", email: "design@k-eng.com", time: "2026-02-26", title: "설계 도면 수정 사항 반영 요청", summary: "STA. 250~300 구간 옹벽 높이 변경 사항 반영 부탁드립니다. 배수 계획과 연동되어야 합니다.", active: false }
|
|
],
|
|
drafts: [
|
|
{ person: "(임시저장)", email: "unknown@draft.com", time: "2026-03-05", title: "기술 지원 검토 의견서 작성 중", summary: "검토 의견: 1. 교량 상부 공법 변경에 따른 구조 검토가 선행되어야 함. 2. 공기 단축 가능성 분석 중...", active: false }
|
|
],
|
|
deleted: [
|
|
{ person: "스팸메일", email: "spam@ads.com", time: "2026-02-20", title: "[광고] 건설 장비 렌탈 특가", summary: "본 메일은 관련 법규에 의거하여 발송되었습니다. 무선 굴착기 및 지게차 렌탈 할인 혜택을 확인하세요.", active: false }
|
|
]
|
|
};
|
|
|
|
let currentMailTab = 'inbound';
|
|
let filteredMails = [];
|
|
|
|
async function loadAttachments() {
|
|
try {
|
|
const res = await fetch('/attachments');
|
|
currentFiles = await res.json();
|
|
renderFiles();
|
|
} catch (e) {
|
|
console.error("Failed to load attachments:", e);
|
|
}
|
|
}
|
|
|
|
function renderFiles() {
|
|
const isAiActive = document.getElementById('aiToggle').checked;
|
|
const container = document.getElementById('attachmentList');
|
|
if (!container) return;
|
|
container.innerHTML = '';
|
|
|
|
currentFiles.forEach((file, index) => {
|
|
const item = document.createElement('div');
|
|
item.className = 'attachment-item-wrap';
|
|
item.style.marginBottom = "8px";
|
|
|
|
let pathText = "경로를 선택해주세요";
|
|
let modeClass = "manual-mode";
|
|
|
|
if (file.analysis) {
|
|
const prefix = file.analysis.isManual ? "선택 경로: " : "추천: ";
|
|
pathText = `${prefix}${file.analysis.suggested_path}`;
|
|
modeClass = file.analysis.isManual ? "manual-mode" : "smart-mode";
|
|
} else if (isAiActive) {
|
|
pathText = "AI 분석 대기 중...";
|
|
modeClass = "smart-mode";
|
|
}
|
|
|
|
item.innerHTML = `
|
|
<div class="attachment-item" onclick="showPreview(${index}, event)">
|
|
<span class="file-icon">📄</span>
|
|
<div class="file-details">
|
|
<div class="file-name" title="${file.name}">${file.name}</div>
|
|
<div class="file-size">${file.size}</div>
|
|
</div>
|
|
<div class="btn-group">
|
|
<span id="recommend-${index}" class="ai-recommend path-display ${modeClass}" onclick="openPathModal(${index}, event)">${pathText}</span>
|
|
${isAiActive ? `<button class="btn-upload btn-ai" onclick="startAnalysis(${index}, event)">AI 분석</button>` : ''}
|
|
<button class="btn-upload btn-normal" onclick="confirmUpload(${index}, event)">파일 업로드</button>
|
|
</div>
|
|
</div>
|
|
<div id="log-area-${index}" class="file-log-area">
|
|
<div id="log-content-${index}"></div>
|
|
</div>
|
|
`;
|
|
container.appendChild(item);
|
|
});
|
|
}
|
|
|
|
function renderMailList(tabType, mailsToShow = null) {
|
|
currentMailTab = tabType;
|
|
const container = document.querySelector('.mail-items-container');
|
|
if (!container) return;
|
|
|
|
const mails = mailsToShow || MAIL_SAMPLES[tabType] || [];
|
|
filteredMails = mails; // 현재 보여지는 리스트 저장
|
|
updateBulkActionBar();
|
|
|
|
container.innerHTML = mails.map((mail, idx) => `
|
|
<div class="mail-item ${mail.active ? 'active' : ''}" onclick="selectMailItem(this, ${idx})">
|
|
<input type="checkbox" class="mail-item-checkbox" onclick="handleCheckboxClick(event)" onchange="updateBulkActionBar()">
|
|
<div class="mail-item-content">
|
|
<div class="flex-between" style="margin-bottom:6px;">
|
|
<span style="font-weight:700; font-size:14px; color:${mail.active ? 'var(--primary-color)' : 'var(--text-main)'};">
|
|
${mail.person}
|
|
</span>
|
|
<div class="mail-item-info">
|
|
<span class="mail-date">${mail.time}</span>
|
|
${tabType !== 'deleted' ? `<button class="btn-mail-delete" onclick="deleteSingleMail(event, '${tabType}', ${idx})">삭제</button>` : ''}
|
|
</div>
|
|
</div>
|
|
<div style="font-weight:600; font-size:12px; margin-bottom:4px; color:#2d3748;">${mail.title}</div>
|
|
<div style="font-size:11px; color:var(--text-sub); display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; line-height:1.4;">
|
|
${mail.summary}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
|
|
// 초기 로드 시 active가 있다면 본문도 업데이트
|
|
const activeIdx = mails.findIndex(m => m.active);
|
|
if (activeIdx !== -1) {
|
|
updateMailContent(mails[activeIdx]);
|
|
}
|
|
}
|
|
|
|
function handleCheckboxClick(event) {
|
|
event.stopPropagation();
|
|
}
|
|
|
|
function updateBulkActionBar() {
|
|
const checkboxes = document.querySelectorAll('.mail-item-checkbox:checked');
|
|
const actionBar = document.getElementById('mailBulkActions');
|
|
const selectedCountSpan = document.getElementById('selectedCount');
|
|
const selectAllCheckbox = document.getElementById('selectAllMails');
|
|
|
|
if (!actionBar || !selectedCountSpan) return;
|
|
|
|
if (checkboxes.length > 0) {
|
|
actionBar.classList.add('active');
|
|
selectedCountSpan.innerText = `${checkboxes.length}개 선택됨`;
|
|
} else {
|
|
actionBar.classList.remove('active');
|
|
if (selectAllCheckbox) selectAllCheckbox.checked = false;
|
|
}
|
|
}
|
|
|
|
function toggleSelectAll(el) {
|
|
const checkboxes = document.querySelectorAll('.mail-item-checkbox');
|
|
checkboxes.forEach(cb => cb.checked = el.checked);
|
|
updateBulkActionBar();
|
|
}
|
|
|
|
function deleteSingleMail(event, tabType, index) {
|
|
if (event) event.stopPropagation();
|
|
if (!confirm("이 메일을 삭제하시겠습니까?")) return;
|
|
const mail = MAIL_SAMPLES[tabType].splice(index, 1)[0];
|
|
MAIL_SAMPLES.deleted.unshift(mail);
|
|
renderMailList(tabType);
|
|
}
|
|
|
|
function deleteSelectedMails() {
|
|
const checkboxes = document.querySelectorAll('.mail-item-checkbox');
|
|
const selectedIndices = [];
|
|
checkboxes.forEach((cb, idx) => { if (cb.checked) selectedIndices.push(idx); });
|
|
if (selectedIndices.length === 0) return;
|
|
if (!confirm(`${selectedIndices.length}개의 메일을 삭제하시겠습니까?`)) return;
|
|
const tabMails = MAIL_SAMPLES[currentMailTab];
|
|
selectedIndices.sort((a, b) => b - a).forEach(idx => {
|
|
const mail = tabMails.splice(idx, 1)[0];
|
|
MAIL_SAMPLES.deleted.unshift(mail);
|
|
});
|
|
renderMailList(currentMailTab);
|
|
}
|
|
|
|
function selectMailItem(el, index) {
|
|
// UI 업데이트
|
|
document.querySelectorAll('.mail-item').forEach(item => {
|
|
item.classList.remove('active');
|
|
const nameSpan = item.querySelector('.mail-item-content span:first-child');
|
|
if (nameSpan) nameSpan.style.color = 'var(--text-main)';
|
|
});
|
|
el.classList.add('active');
|
|
const currentNameSpan = el.querySelector('.mail-item-content span:first-child');
|
|
if (currentNameSpan) currentNameSpan.style.color = 'var(--primary-color)';
|
|
|
|
// 본문 업데이트
|
|
const mail = filteredMails[index];
|
|
if (mail) {
|
|
updateMailContent(mail);
|
|
}
|
|
}
|
|
|
|
function updateMailContent(mail) {
|
|
const headerTitle = document.querySelector('.mail-content-header h2');
|
|
const senderInfo = document.querySelectorAll('.mail-content-header div')[0];
|
|
const dateInfo = document.querySelectorAll('.mail-content-header div')[1];
|
|
const bodyInfo = document.querySelector('.mail-body');
|
|
|
|
if (headerTitle) headerTitle.innerText = mail.title;
|
|
if (senderInfo) senderInfo.innerHTML = `<strong>${currentMailTab === 'outbound' ? '받는사람' : '보낸사람'}</strong> ${mail.email} (${mail.person})`;
|
|
if (dateInfo) dateInfo.innerHTML = `<strong>날짜</strong> ${mail.time}`;
|
|
if (bodyInfo) bodyInfo.innerHTML = mail.summary.replace(/\n/g, '<br>') + "<br><br>" + "본 내용은 샘플 데이터입니다.";
|
|
}
|
|
|
|
function switchMailTab(el, tabType) {
|
|
document.querySelectorAll('.mail-tab').forEach(tab => tab.classList.remove('active'));
|
|
el.classList.add('active');
|
|
|
|
// 탭 이동 시 active 상태 초기화 (첫 번째 메일만 active 하거나 전부 해제)
|
|
MAIL_SAMPLES[tabType].forEach((m, idx) => m.active = (idx === 0));
|
|
|
|
renderMailList(tabType);
|
|
}
|
|
|
|
// --- 검색 기능 ---
|
|
function searchMails() {
|
|
const query = document.querySelector('.search-bar input[type="text"]').value.toLowerCase();
|
|
const startDate = document.getElementById('startDate').value;
|
|
const endDate = document.getElementById('endDate').value;
|
|
|
|
const mails = MAIL_SAMPLES[currentMailTab];
|
|
const results = mails.filter(mail => {
|
|
const matchQuery = mail.title.toLowerCase().includes(query) ||
|
|
mail.person.toLowerCase().includes(query) ||
|
|
mail.summary.toLowerCase().includes(query);
|
|
|
|
let matchDate = true;
|
|
if (startDate) matchDate = matchDate && (mail.time >= startDate);
|
|
if (endDate) matchDate = matchDate && (mail.time <= endDate);
|
|
|
|
return matchQuery && matchDate;
|
|
});
|
|
|
|
renderMailList(currentMailTab, results);
|
|
}
|
|
|
|
function resetSearch() {
|
|
document.querySelector('.search-bar input[type="text"]').value = '';
|
|
document.getElementById('startDate').value = '';
|
|
document.getElementById('endDate').value = '';
|
|
document.querySelector('.search-bar select').selectedIndex = 0;
|
|
|
|
renderMailList(currentMailTab);
|
|
}
|
|
|
|
// --- 모달 및 기타 유틸리티 ---
|
|
function togglePreview(show) {
|
|
const previewArea = document.getElementById('mailPreviewArea');
|
|
if (show) previewArea.classList.add('active');
|
|
else previewArea.classList.remove('active');
|
|
}
|
|
|
|
function showPreview(index, event) {
|
|
if (event.target.closest('.btn-group') || event.target.closest('.path-display')) return;
|
|
const file = currentFiles[index];
|
|
const previewContainer = document.getElementById('previewContainer');
|
|
const fullViewBtn = document.getElementById('fullViewBtn');
|
|
document.querySelectorAll('.attachment-item').forEach(item => item.classList.remove('active'));
|
|
event.currentTarget.classList.add('active');
|
|
togglePreview(true);
|
|
const isPdf = file.name.toLowerCase().endsWith('.pdf');
|
|
const fileUrl = `/sample_files/${encodeURIComponent(file.name)}`;
|
|
if (fullViewBtn) {
|
|
fullViewBtn.style.display = 'block';
|
|
fullViewBtn.onclick = () => window.open(fileUrl, 'PMFullView', 'width=1000,height=800');
|
|
}
|
|
if (isPdf) {
|
|
previewContainer.innerHTML = `<iframe src="${fileUrl}#page=1" style="width:100%; height:100%; border:none;"></iframe>`;
|
|
} else {
|
|
previewContainer.innerHTML = `<div style="width:100%; height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:20px; text-align:center;"><img src="/sample.png" class="preview-image"><div style="margin-top:20px; font-weight:700; color:var(--primary-color);">${file.name}</div></div>`;
|
|
}
|
|
}
|
|
|
|
function openPathModal(index, event) {
|
|
if (event) event.stopPropagation();
|
|
editingIndex = index;
|
|
const modal = document.getElementById('pathModal');
|
|
const tabSelect = document.getElementById('tabSelect');
|
|
if (!tabSelect) return;
|
|
tabSelect.innerHTML = Object.keys(HIERARCHY).map(tab => `<option value="${tab}">${tab}</option>`).join('');
|
|
updateCategories();
|
|
modal.style.display = 'flex';
|
|
}
|
|
|
|
function updateCategories() {
|
|
const tabSelect = document.getElementById('tabSelect');
|
|
const catSelect = document.getElementById('categorySelect');
|
|
if (!tabSelect || !catSelect) return;
|
|
const tab = tabSelect.value;
|
|
const cats = Object.keys(HIERARCHY[tab]);
|
|
catSelect.innerHTML = cats.map(cat => `<option value="${cat}">${cat}</option>`).join('');
|
|
updateSubs();
|
|
}
|
|
|
|
function updateSubs() {
|
|
const tabSelect = document.getElementById('tabSelect');
|
|
const catSelect = document.getElementById('categorySelect');
|
|
const subSelect = document.getElementById('subSelect');
|
|
if (!tabSelect || !catSelect || !subSelect) return;
|
|
const tab = tabSelect.value;
|
|
const cat = catSelect.value;
|
|
const subs = HIERARCHY[tab][cat];
|
|
subSelect.innerHTML = subs.map(sub => `<option value="${sub}">${sub}</option>`).join('');
|
|
}
|
|
|
|
function applyPathSelection() {
|
|
const tabSelect = document.getElementById('tabSelect');
|
|
const catSelect = document.getElementById('categorySelect');
|
|
const subSelect = document.getElementById('subSelect');
|
|
const tab = tabSelect.value;
|
|
const cat = catSelect.value;
|
|
const sub = subSelect.value;
|
|
const fullPath = `${tab} > ${cat} > ${sub}`;
|
|
if (!currentFiles[editingIndex].analysis) currentFiles[editingIndex].analysis = {};
|
|
currentFiles[editingIndex].analysis.suggested_path = fullPath;
|
|
currentFiles[editingIndex].analysis.isManual = true;
|
|
renderFiles();
|
|
closeModal();
|
|
}
|
|
|
|
function closeModal() {
|
|
const modal = document.getElementById('pathModal');
|
|
if (modal) modal.style.display = 'none';
|
|
}
|
|
|
|
async function startAnalysis(index, event) {
|
|
if (event) event.stopPropagation();
|
|
const file = currentFiles[index];
|
|
const logArea = document.getElementById(`log-area-${index}`);
|
|
const logContent = document.getElementById(`log-content-${index}`);
|
|
const recLabel = document.getElementById(`recommend-${index}`);
|
|
if (!logArea || !logContent || !recLabel) return;
|
|
logArea.classList.add('active');
|
|
logContent.innerHTML = '<div class="log-line log-info">>>> 3중 레이어 AI 분석 엔진 가동...</div>';
|
|
recLabel.innerText = '분석 중...';
|
|
try {
|
|
const res = await fetch(`/analyze-file?filename=${encodeURIComponent(file.name)}`);
|
|
const analysis = await res.json();
|
|
const result = analysis.final_result;
|
|
const steps = [`1. 파일 포맷 분석: ${file.name.split('.').pop().toUpperCase()} 감지`, `2. 페이지 스캔: 총 ${analysis.total_pages}페이지 분석 완료`, `3. 문맥 추론: ${result.reason}`];
|
|
steps.forEach(step => {
|
|
const line = document.createElement('div');
|
|
line.className = 'log-line';
|
|
line.innerText = " " + step;
|
|
logContent.appendChild(line);
|
|
});
|
|
currentFiles[index].analysis = { suggested_path: result.suggested_path, isManual: false };
|
|
renderFiles();
|
|
} catch (e) {
|
|
logContent.innerHTML += `<div class="log-line" style="color:red;">ERR: ${e.message}</div>`;
|
|
recLabel.innerText = '분석 실패';
|
|
}
|
|
}
|
|
|
|
function confirmUpload(index, event) {
|
|
if (event) event.stopPropagation();
|
|
const file = currentFiles[index];
|
|
if (!file.analysis || !file.analysis.suggested_path) { alert("경로를 설정해주세요."); return; }
|
|
if (confirm(`정해진 위치로 업로드하시겠습니까?\n\n위치: ${file.analysis.suggested_path}`)) alert("업로드가 완료되었습니다.");
|
|
}
|
|
|
|
// --- 주소록 기능 ---
|
|
let addressBookData = [
|
|
{ name: "이태훈", dept: "PM Overseas / 선임연구원", email: "th.lee@projectmaster.com", phone: "010-1234-5678" },
|
|
{ name: "Pany S.", dept: "라오스 농림부 / 국장", email: "pany.s@lao.gov.la", phone: "+856-20-1234-5678" },
|
|
{ name: "김철수", dept: "현대건설 / 현장소장", email: "cs.kim@hdec.co.kr", phone: "010-9876-5432" },
|
|
{ name: "Nguyen Van A", dept: "베트남 전력청 / 팀장", email: "nva@evn.com.vn", phone: "+84-90-1234-5678" }
|
|
];
|
|
let contactEditingIndex = -1;
|
|
|
|
function openAddressBook() {
|
|
const modal = document.getElementById('addressBookModal');
|
|
if (modal) { renderAddressBook(); modal.style.display = 'flex'; }
|
|
}
|
|
|
|
function closeAddressBook() {
|
|
const modal = document.getElementById('addressBookModal');
|
|
if (modal) { modal.style.display = 'none'; document.getElementById('addContactForm').style.display = 'none'; contactEditingIndex = -1; }
|
|
}
|
|
|
|
function renderAddressBook() {
|
|
const body = document.getElementById('addressBookBody');
|
|
if (!body) return;
|
|
body.innerHTML = addressBookData.map((c, idx) => `<tr><td><strong>${c.name}</strong></td><td>${c.dept}</td><td>${c.email}</td><td>${c.phone}</td><td style="text-align:right;"><button class="_button-xsmall" onclick="editContact(${idx})">수정</button><button class="_button-xsmall" onclick="deleteContact(${idx})">삭제</button></td></tr>`).join('');
|
|
}
|
|
|
|
function toggleAddContactForm() {
|
|
const form = document.getElementById('addContactForm');
|
|
if (form.style.display === 'none') form.style.display = 'block';
|
|
else { form.style.display = 'none'; contactEditingIndex = -1; }
|
|
}
|
|
|
|
function editContact(index) {
|
|
const contact = addressBookData[index];
|
|
contactEditingIndex = index;
|
|
document.getElementById('newContactName').value = contact.name;
|
|
document.getElementById('newContactDept').value = contact.dept;
|
|
document.getElementById('newContactEmail').value = contact.email;
|
|
document.getElementById('newContactPhone').value = contact.phone;
|
|
document.getElementById('addContactForm').style.display = 'block';
|
|
}
|
|
|
|
function deleteContact(index) {
|
|
if (confirm(`'${addressBookData[index].name}'님을 주소록에서 삭제하시겠습니까?`)) { addressBookData.splice(index, 1); renderAddressBook(); }
|
|
}
|
|
|
|
function addContact() {
|
|
const name = document.getElementById('newContactName').value;
|
|
const dept = document.getElementById('newContactDept').value;
|
|
const email = document.getElementById('newContactEmail').value;
|
|
const phone = document.getElementById('newContactPhone').value;
|
|
if (!name) { alert("이름을 입력해주세요."); return; }
|
|
const newData = { name, dept, email, phone };
|
|
if (contactEditingIndex > -1) { addressBookData[contactEditingIndex] = newData; contactEditingIndex = -1; }
|
|
else addressBookData.push(newData);
|
|
renderAddressBook();
|
|
toggleAddContactForm();
|
|
}
|
|
|
|
function togglePreviewAuto() {
|
|
const area = document.getElementById('mailPreviewArea');
|
|
const icon = document.getElementById('previewToggleIcon');
|
|
const isActive = area.classList.toggle('active');
|
|
if (icon) icon.innerText = isActive ? '▶' : '◀';
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
loadAttachments();
|
|
renderMailList('inbound');
|
|
});
|