feat: implement unified schema mapper, enhance UI/UX with responsive design, and optimize asset log logic

This commit is contained in:
2026-04-23 18:00:10 +09:00
parent bb1cc36d01
commit 9365af4522
21 changed files with 1129 additions and 892 deletions

View File

@@ -1,29 +1,31 @@
import { state } from '../../core/state';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, sortAssets } from '../../core/utils';
import { formatInline, createBadge, sortAssets } from '../../core/utils';
import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema';
import { createIcons, RefreshCcw } from 'lucide';
/**
* 전산비품 자산 목록 뷰
* 라인 정렬 보정 및 헤더 통일
*/
export function renderEquipmentList(container: HTMLElement) {
const fullList = sortAssets(state.masterData.equip);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
const corps = Array.from(new Set(fullList.map(a => a.))).filter(Boolean).sort();
const corps = Array.from(new Set(fullList.map(a => a[ASSET_SCHEMA.CORP.key]))).filter(Boolean).sort();
filterBar.innerHTML = `
<div class="search-item flex-1">
<label>통합 검색 (자산코드/명칭)</label>
<label>통합 검색 (${ASSET_SCHEMA.ASSET_CODE.ui}/${ASSET_SCHEMA.MODEL.ui}/${ASSET_SCHEMA.MANAGER_MAIN.ui})</label>
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
</div>
<div class="search-item">
<label>구매법인</label>
<label>${ASSET_SCHEMA.CORP.ui}</label>
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
</div>
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
<i data-lucide="refresh-ccw"></i> 필터 초기화
</button>
<button id="btn-add-equip" class="btn btn-primary" style="margin-left: auto;">
<i data-lucide="plus"></i> 자산 추가
<i data-lucide="refresh-ccw"></i> ${UI_TEXT.ACTION.RESET_FILTER}
</button>
`;
container.appendChild(filterBar);
@@ -34,16 +36,16 @@ export function renderEquipmentList(container: HTMLElement) {
table.innerHTML = `
<thead>
<tr>
<th style="text-align:center;">No.</th>
<th style="text-align:center;">상태</th>
<th style="text-align:center;">구매법인</th>
<th style="text-align:center;">유형</th>
<th style="text-align:center;">자산번호</th>
<th style="text-align:center;">모델명</th>
<th style="text-align:center;">보관위치</th>
<th style="text-align:center;">관리자</th>
<th style="text-align:center;">구매연월</th>
<th style="text-align:center;">금액</th>
<th class="text-center">No.</th>
<th class="text-center">${ASSET_SCHEMA.STATUS.ui}</th>
<th class="text-center">${ASSET_SCHEMA.CORP.ui}</th>
<th class="text-center">유형</th>
<th class="text-center">${ASSET_SCHEMA.ASSET_CODE.ui}</th>
<th>${ASSET_SCHEMA.MODEL.ui}</th>
<th class="text-center">${ASSET_SCHEMA.STORE_LOC.ui}</th>
<th class="text-center">담당자(정/부)</th>
<th class="text-center">${ASSET_SCHEMA.PURCHASE_YM.ui}</th>
<th class="text-center">${ASSET_SCHEMA.PRICE.ui}</th>
</tr>
</thead>
<tbody id="dynamic-tbody"></tbody>
@@ -61,14 +63,17 @@ export function renderEquipmentList(container: HTMLElement) {
const corp = corpSelect ? corpSelect.value : '';
const filtered = fullList.filter(asset => {
const matchKeyword = !keyword || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword);
const matchCorp = !corp || asset. === corp;
const matchKeyword = !keyword ||
String(asset[ASSET_SCHEMA.ASSET_CODE.key]||'').toLowerCase().includes(keyword) ||
String(asset[ASSET_SCHEMA.MODEL.key]||'').toLowerCase().includes(keyword) ||
String(asset[ASSET_SCHEMA.MANAGER_MAIN.key]||'').toLowerCase().includes(keyword);
const matchCorp = !corp || asset[ASSET_SCHEMA.CORP.key] === corp;
return matchKeyword && matchCorp;
});
tbody.innerHTML = '';
if (filtered.length === 0) {
tbody.innerHTML = `<tr><td colspan="10" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
tbody.innerHTML = `<tr><td colspan="10" class="text-center" style="padding: 3rem; color: var(--text-muted);">${UI_TEXT.MESSAGES.NO_DATA}</td></tr>`;
return;
}
@@ -76,32 +81,34 @@ export function renderEquipmentList(container: HTMLElement) {
const tr = document.createElement('tr');
tr.style.cursor = 'pointer';
const statusColors: Record<string, string> = {
'대여중': '#3b82f6',
'보관중': '#1E5149',
'수리중': '#ef4444',
'기타': '#6b7280'
};
const statusColor = statusColors[asset. || '보관중'] || '#6b7280';
const statusBadge = `<span style="background:${statusColor}; color:white; padding:2px 6px; border-radius:4px; font-size:0.75rem; font-weight:bold;">${asset. || '보관중'}</span>`;
const statusColors: Record<string, string> = { '대여중': 'primary', '보관중': 'success', '수리중': 'danger', '기타': 'muted' };
const statusValue = asset[ASSET_SCHEMA.STATUS.key] || '보관중';
const statusType = statusColors[statusValue] || 'muted';
const statusBadge = `<span class="badge badge-${statusType}">${statusValue}</span>`;
const mainManager = asset[ASSET_SCHEMA.MANAGER_MAIN.key] || '';
const subManager = asset[ASSET_SCHEMA.MANAGER_SUB.key] || '';
const managerHtml = [
mainManager ? `${createBadge('정', 'primary')} ${mainManager}` : '',
subManager ? `${createBadge('부', 'muted')} ${subManager}` : ''
].filter(v => v !== '').join(' / ');
tr.innerHTML = `
<td style="text-align:center;">${idx + 1}</td>
<td style="text-align:center;">${statusBadge}</td>
<td style="text-align:center;">${asset.}</td>
<td style="text-align:center;">${asset.type}</td>
<td style="font-weight:600; color:var(--primary-color);">${asset. || '-'}</td>
<td>${formatInline(asset. || asset.)}</td>
<td style="text-align:center;">${asset. || '-'}</td>
<td style="text-align:center;">${formatInline(asset._정 || asset.)}</td>
<td style="text-align:center;">${asset. || ''}</td>
<td style="text-align:right;">${asset. || '0'}</td>
<td class="text-center">${idx + 1}</td>
<td class="text-center">${statusBadge}</td>
<td class="text-center">${asset[ASSET_SCHEMA.CORP.key]}</td>
<td class="text-center">${asset[ASSET_SCHEMA.TYPE.key]}</td>
<td class="text-center" style="font-family: monospace;">${asset[ASSET_SCHEMA.ASSET_CODE.key] || '-'}</td>
<td>${formatInline(asset[ASSET_SCHEMA.MODEL.key] || asset.)}</td>
<td class="text-center">${asset[ASSET_SCHEMA.STORE_LOC.key] || '-'}</td>
<td class="text-center">${managerHtml || '-'}</td>
<td class="text-center">${asset[ASSET_SCHEMA.PURCHASE_YM.key] || ''}</td>
<td class="text-right">${Number(asset[ASSET_SCHEMA.PRICE.key]||0).toLocaleString()}</td>
`;
tr.addEventListener('click', (e) => {
if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view');
});
tr.addEventListener('click', () => openHwModal(asset, 'view'));
tbody.appendChild(tr);
});
createIcons({ icons: { RefreshCcw } });
};
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);