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,11 +1,14 @@
import { state } from '../../core/state';
import { openSwModal } from '../../components/Modal/SWModal';
import { openSwUserModal } from '../../components/Modal/SWUserModal';
import { sortAssets } from '../../core/utils';
import { CORP_LIST } from '../../components/Modal/SharedData';
import { generateOptionsHTML } from '../../components/Modal/ModalUtils';
import { createIcons, Edit2, Users, RefreshCcw } from 'lucide';
import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema';
import { createIcons, RefreshCcw } from 'lucide';
/**
* 소프트웨어(구독/영구) 자산 목록 뷰
*/
export function renderSwList(container: HTMLElement) {
const isSub = state.activeSubTab === '구독SW';
const fullList = sortAssets(isSub ? state.masterData.subSw : state.masterData.permSw);
@@ -14,7 +17,7 @@ export function renderSwList(container: HTMLElement) {
filterBar.className = 'search-bar';
filterBar.innerHTML = `
<div class="search-item flex-1">
<label>통합 검색 (제품명/부서)</label>
<label>통합 검색 (${ASSET_SCHEMA.PRODUCT.ui}/부서)</label>
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
</div>
<div class="search-item">
@@ -28,11 +31,11 @@ export function renderSwList(container: HTMLElement) {
</select>
</div>
<div class="search-item">
<label>구매법인</label>
<label>${ASSET_SCHEMA.CORP.ui}</label>
<select id="filter-corp">${generateOptionsHTML(CORP_LIST, '', true)}</select>
</div>
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
<i data-lucide="refresh-ccw"></i> 필터 초기화
<i data-lucide="refresh-ccw"></i> ${UI_TEXT.ACTION.RESET_FILTER}
</button>
`;
container.appendChild(filterBar);
@@ -46,15 +49,14 @@ export function renderSwList(container: HTMLElement) {
<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;">${ASSET_SCHEMA.CORP.ui}</th>
<th style="text-align:center;">부서</th>
<th style="text-align:center;">제품명</th>
<th style="text-align:center;">구매연월</th>
${isSub ? '<th style="text-align:center;">구독일</th>' : ''}
<th style="text-align:center;">금액</th>
<th style="text-align:center;">수량</th>
<th style="text-align:center;">${ASSET_SCHEMA.PRODUCT.ui}</th>
<th style="text-align:center;">${ASSET_SCHEMA.PURCHASE_YM.ui}</th>
${isSub ? `<th style="text-align:center;">${ASSET_SCHEMA.EXPIRY.ui}</th>` : ''}
<th style="text-align:center;">${ASSET_SCHEMA.PRICE.ui}</th>
<th style="text-align:center;">${ASSET_SCHEMA.QTY.ui}</th>
<th style="text-align:center;">사용가능</th>
<th style="text-align:center;">관리</th>
</tr>
</thead>
<tbody id="dynamic-tbody"></tbody>
@@ -74,28 +76,28 @@ export function renderSwList(container: HTMLElement) {
const corp = corpSelect ? corpSelect.value : '';
const filtered = fullList.filter(asset => {
const matchKeyword = !keyword || (asset. || '').toLowerCase().includes(keyword) || (asset. || '').toLowerCase().includes(keyword);
const matchKeyword = !keyword || (asset[ASSET_SCHEMA.PRODUCT.key] || '').toLowerCase().includes(keyword) || (asset. || '').toLowerCase().includes(keyword);
const matchField = !field || asset. === field;
const matchCorp = !corp || asset. === corp;
const matchCorp = !corp || asset[ASSET_SCHEMA.CORP.key] === corp;
return matchKeyword && matchField && matchCorp;
});
tbody.innerHTML = '';
if (filtered.length === 0) {
tbody.innerHTML = `<tr><td colspan="${isSub ? 12 : 11}" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
tbody.innerHTML = `<tr><td colspan="${isSub ? 11 : 10}" style="text-align:center; padding: 3rem; color: var(--text-muted);">${UI_TEXT.MESSAGES.NO_DATA}</td></tr>`;
return;
}
filtered.forEach((asset, idx) => {
const assigned = state.masterData.swUsers.filter(u => u.sw_id === asset.id).length;
const qty = typeof asset. === 'number' ? asset.수량 : parseInt(asset.||'0', 10);
const qty = typeof asset[ASSET_SCHEMA.QTY.key] === 'number' ? asset[ASSET_SCHEMA.QTY.key] : parseInt(asset[ASSET_SCHEMA.QTY.key]||'0', 10);
const avail = qty - assigned;
let statusHtml = '';
let statusBadge = '';
if (isSub) {
let isExpired = false;
if (asset.) {
const parts = asset..split('~');
if (asset[ASSET_SCHEMA.EXPIRY.key]) {
const parts = asset[ASSET_SCHEMA.EXPIRY.key].split('~');
const endDateStr = parts[parts.length - 1].trim().replace(/\./g, '-');
const endDate = new Date(endDateStr);
if (!isNaN(endDate.getTime())) {
@@ -103,11 +105,9 @@ export function renderSwList(container: HTMLElement) {
if (endDate < new Date()) isExpired = true;
}
}
if (isExpired) statusHtml = `<span style="background: var(--danger, #ef4444); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">만료</span>`;
else statusHtml = `<span style="background: var(--primary-color, #1E5149); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">사용중</span>`;
statusBadge = isExpired ? `<span class="badge badge-danger">만료</span>` : `<span class="badge badge-primary">사용중</span>`;
} else {
if (asset.) statusHtml = `<span style="background: #3b82f6; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">유효</span>`;
else statusHtml = `<span style="background: #6b7280; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">없음</span>`;
statusBadge = asset. ? `<span class="badge badge-success">유효</span>` : `<span class="badge badge-muted">없음</span>`;
}
const tr = document.createElement('tr');
@@ -115,35 +115,22 @@ export function renderSwList(container: HTMLElement) {
tr.innerHTML = `
<td style="text-align:center;">${idx+1}</td>
<td style="text-align:center;">${statusHtml}</td>
<td>${asset.||''}</td>
<td>${asset.}</td>
<td>${asset.||''}</td>
<td>${asset.}</td>
<td style="text-align:center;">${asset.||''}</td>
${isSub ? `<td style="text-align:center;">${asset.||''}</td>` : ''}
<td style="text-align:right;">${asset.||'0'}</td>
<td style="text-align:center;">${statusBadge}</td>
<td style="text-align:center;">${asset.||''}</td>
<td style="text-align:center;">${asset[ASSET_SCHEMA.CORP.key]}</td>
<td style="text-align:center;">${asset.||''}</td>
<td>${asset[ASSET_SCHEMA.PRODUCT.key]}</td>
<td style="text-align:center;">${asset[ASSET_SCHEMA.PURCHASE_YM.key]||''}</td>
${isSub ? `<td style="text-align:center;">${asset[ASSET_SCHEMA.EXPIRY.key]||''}</td>` : ''}
<td style="text-align:right;">${Number(asset[ASSET_SCHEMA.PRICE.key]||0).toLocaleString()}</td>
<td style="text-align:center;">${qty}</td>
<td style="text-align:center;"><strong style="color: ${avail > 0 ? 'var(--primary-color)' : 'var(--danger)'}">${avail}</strong></td>
<td style="display:flex; justify-content:center; align-items:center; gap:0.5rem;">
<button type="button" class="btn-icon btn-edit" title="수정" style="color: var(--text-muted);"><i data-lucide="edit-2"></i></button>
<button type="button" class="btn-icon btn-users" title="사용자 관리" style="color: var(--primary-color);"><i data-lucide="users"></i></button>
</td>
`;
tr.addEventListener('click', (e) => {
if (!(e.target as HTMLElement).closest('button')) {
openSwModal(asset, 'view');
}
});
tr.querySelector('.btn-edit')?.addEventListener('click', (e) => {
e.stopPropagation();
openSwModal(asset, 'edit');
});
tr.querySelector('.btn-users')?.addEventListener('click', (e) => { e.stopPropagation(); openSwUserModal(asset); });
tr.addEventListener('click', () => openSwModal(asset, 'view'));
tbody.appendChild(tr);
});
createIcons({ icons: { Edit2, Users, RefreshCcw } });
createIcons({ icons: { RefreshCcw } });
};
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);