diff --git a/src/main.ts b/src/main.ts index a7e52c3..a8d3667 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,7 +52,6 @@ function refreshView() {
-
@@ -60,7 +59,7 @@ function refreshView() { `; // 이벤트 바인딩 - mainContent.querySelectorAll('.mode-toggle-btn').forEach(btn => { + mainContent.querySelectorAll('.mode-toggle-btn').forEach(btn => { btn.addEventListener('click', () => { const mode = (btn as HTMLElement).getAttribute('data-mode') as any; state.viewMode = mode; @@ -71,12 +70,10 @@ function refreshView() { const viewBody = document.getElementById('view-body')!; if (state.viewMode === 'location') { renderLocationView(viewBody); - } else if (state.viewMode === 'legacy') { - renderDashboard(viewBody); // 통계/차트 } else { renderSWTable(viewBody); // 리스트 형식 } -} + } // 통합 저장 및 갱신 async function saveAllDataToDB() { diff --git a/src/views/LocationView.ts b/src/views/LocationView.ts index 33d919d..5bb81ff 100644 --- a/src/views/LocationView.ts +++ b/src/views/LocationView.ts @@ -49,29 +49,32 @@ export async function renderLocationView(container: HTMLElement) {
- -
- - ${locImages.length > 1 ? ` -
- 사진: ${currentPage + 1} / ${locImages.length} -
- - +
+ + + + ${locImages.length > 1 ? ` +
+
+ + +
+ (${currentPage + 1} / ${locImages.length}) +
+ ` : ''}
- ` : ''}
-
- -
-
+
+ +
+
${mapPath ? ` - -
+ +
${boxes.map((box: any, idx: number) => { const name = box.name || `#${idx+1}`; return ` @@ -86,32 +89,48 @@ export async function renderLocationView(container: HTMLElement) {
` : '
해당 위치의 도면이 등록되지 않았습니다.
'}
-

* 지도 위의 구역을 클릭하면 자산 상세 정보가 표시됩니다.

- -
-
-

📍 구역을 선택하세요

+ +
+
+

📍 구역을 선택하세요

-
-
지도에서 자산 위치를 클릭하세요.
+
+
지도에서 자산 위치를 클릭하세요.
+
+

* 지도 위의 구역을 클릭하면 자산 상세 정보가 표시됩니다.

+
`; - // 이미지 로드 후 오버레이 크기 재조정 (좌표 밀림 방지) + // 이미지 로드 및 윈도우 리사이즈 시 오버레이 크기와 위치를 이미지에 정확히 맞춤 + const syncOverlaySize = () => { + const img = container.querySelector('#main-map-img') as HTMLImageElement; + const overlay = container.querySelector('#box-overlay') as HTMLElement; + if (img && overlay && img.complete) { + overlay.style.width = img.clientWidth + 'px'; + overlay.style.height = img.clientHeight + 'px'; + overlay.style.left = img.offsetLeft + 'px'; + overlay.style.top = img.offsetTop + 'px'; + } + }; + const img = container.querySelector('#main-map-img') as HTMLImageElement; if (img) { - img.onload = () => { - const overlay = container.querySelector('#box-overlay') as HTMLElement; - if (overlay) { - overlay.style.height = img.offsetHeight + 'px'; - } - }; + if (img.complete) { + syncOverlaySize(); + setTimeout(syncOverlaySize, 50); // 레이아웃 안정화 대기 + } else { + img.onload = syncOverlaySize; + } } + + window.removeEventListener('resize', syncOverlaySize); + window.addEventListener('resize', syncOverlaySize); // 이벤트 바인딩 const selMain = container.querySelector('#sel-loc-main') as HTMLSelectElement; @@ -137,7 +156,6 @@ export async function renderLocationView(container: HTMLElement) { const x = box.getAttribute('data-x'); const y = box.getAttribute('data-y'); - // 좌표 및 위치 정보를 기반으로 정확한 자산 1개 찾기 const targetAsset = state.masterData.hw.find(a => a.location === currentLoc && a.location_detail === currentDetail && @@ -149,7 +167,7 @@ export async function renderLocationView(container: HTMLElement) { renderAssetDetail(targetAsset); } - container.querySelectorAll('.location-box-point').forEach(b => (b as HTMLElement).style.background = 'rgba(30, 81, 81, 0.1)'); + container.querySelectorAll('.location-box-point').forEach(b => (b as HTMLElement).style.background = 'rgba(30, 81, 73, 0.1)'); (box as HTMLElement).style.background = 'rgba(30, 81, 73, 0.4)'; }); }); @@ -166,20 +184,18 @@ export async function renderLocationView(container: HTMLElement) {
`; - // 섹션별 렌더링 함수 const renderSection = (title: string, fields: { label: string; value: any }[]) => ` -
+
${title}
${fields.map(f => `
${f.label}
-
${f.value || '-'}
+
${f.value || '-'}
`).join('')}
`; - // 하드웨어 정보 구성 const sectionsHTML = [ renderSection('기본 관리 정보', [ { label: ASSET_SCHEMA.ASSET_CODE.ui, value: asset.asset_code }, @@ -208,25 +224,20 @@ export async function renderLocationView(container: HTMLElement) { ].join(''); tableContainer.innerHTML = ` -
+
${sectionsHTML}
`; - // 뒤로가기 버튼: 목록 대신 초기 상태로 리셋 container.querySelector('#btn-back-to-list')?.addEventListener('click', () => { title.textContent = `📍 구역을 선택하세요`; - tableContainer.innerHTML = `
지도에서 자산 위치를 클릭하세요.
`; + tableContainer.innerHTML = `
지도에서 자산 위치를 클릭하세요.
`; }); - // 수정 버튼 (기존 모달 활용) container.querySelector('#btn-edit-from-loc')?.addEventListener('click', () => { openHwModal(asset, 'edit'); }); }; - // showAssets 함수 제거 (목록 표시 불필요) - - render(); }