merge: integrate collaborator features and synchronize with shared DB infrastructure

This commit is contained in:
2026-04-21 10:00:57 +09:00
25 changed files with 5706 additions and 1906 deletions

View File

@@ -50,7 +50,7 @@ export function renderHwDashboard(container: HTMLElement) {
<canvas id="chart-hw-types"></canvas>
</div>
<div class="dashboard-card">
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">법인별 자산 분포</h4>
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">구매법인별 자산 분포</h4>
<canvas id="chart-hw-corps"></canvas>
</div>
</div>

View File

@@ -14,6 +14,7 @@ export function renderSwDashboard(container: HTMLElement) {
let cloudExp = 0;
const currentYear = new Date().getFullYear();
const today = new Date();
const corps = ['한맥', '삼안', '바론'];
const categories = ['업무공통', '개발S/W', '디자인', '설계S/W'];
@@ -22,9 +23,10 @@ export function renderSwDashboard(container: HTMLElement) {
const costByCat: Record<string, number> = {};
categories.forEach(c => costByCat[c] = 0);
const today = new Date();
// 통합 SW 데이터 (호환용)
const allSw = [...state.masterData.subSw, ...state.masterData.permSw];
state.masterData.sw.forEach(sw => {
allSw.forEach(sw => {
const assigned = state.masterData.swUsers.filter(u => u.swId === sw.id).length;
const qty = typeof sw. === 'number' ? sw.수량 : parseInt(sw.||'0', 10);
const priceStr = sw. ? String(sw.).replace(/,/g, '') : '0';
@@ -36,22 +38,6 @@ export function renderSwDashboard(container: HTMLElement) {
} else if (sw.type === '영구SW') {
permQty += qty; permUsed += assigned; permTotal++;
if (isSWExpiring(sw)) permExp++;
} else if (sw.type === '클라우드') {
if (sw.) {
thisMonthCloudCost += parseInt(String(sw.).replace(/,/g, ''), 10) || 0;
}
if (sw.) {
const payDay = parseInt(sw., 10);
if (!isNaN(payDay)) {
const nextPayMs = new Date(today.getFullYear(), today.getMonth(), payDay).getTime();
let diff = (nextPayMs - today.getTime()) / (1000 * 60 * 60 * 24);
if (diff < 0) {
const nextMonthMs = new Date(today.getFullYear(), today.getMonth() + 1, payDay).getTime();
diff = (nextMonthMs - today.getTime()) / (1000 * 60 * 60 * 24);
}
if (diff <= 14) cloudExp++;
}
}
}
if (sw. && sw..startsWith(String(currentYear))) {
@@ -60,14 +46,14 @@ export function renderSwDashboard(container: HTMLElement) {
}
});
// 클라우드 데이터 처리 (필요시 추가)
// ...
const subPer = subQty > 0 ? Math.round((subUsed/subQty)*100) : 0;
const permPer = permQty > 0 ? Math.round((permUsed/permQty)*100) : 0;
const subExpPer = subTotal > 0 ? Math.round((subExp/subTotal)*100) : 0;
const permExpPer = permTotal > 0 ? Math.round((permExp/permTotal)*100) : 0;
const cloudExpTotal = state.masterData.sw.filter(s => s.type === '클라우드').length;
const cloudExpPer = cloudExpTotal > 0 ? Math.round((cloudExp/cloudExpTotal)*100) : 0;
// Cloud trend & Last month cost logic
const cloudCostTrend = [0, 0, 0, 0];
const trendLabels: string[] = [];
for(let i=3; i>=0; i--) {
@@ -75,25 +61,6 @@ export function renderSwDashboard(container: HTMLElement) {
d.setMonth(d.getMonth() - i);
trendLabels.push(`${d.getMonth()+1}`);
}
if (state.masterData.logs) {
state.masterData.logs.forEach(log => {
const match = log.details.match(/[^\d]*([\d,]+)/);
if (match && (log.details.includes('청구액') || log.details.includes('비용'))) {
const cost = parseInt(match[1].replace(/,/g, ''), 10);
const logDate = new Date(log.date);
const monthDiff = (today.getFullYear() - logDate.getFullYear())*12 + (today.getMonth() - logDate.getMonth());
if (monthDiff === 1) lastMonthCloudCost += cost;
if (monthDiff >= 0 && monthDiff < 4) cloudCostTrend[3 - monthDiff] += cost;
}
});
}
const costDiff = thisMonthCloudCost - lastMonthCloudCost;
const costDiffText = lastMonthCloudCost > 0
? `${costDiff >= 0 ? '+' : ''}${((costDiff/lastMonthCloudCost)*100).toFixed(1)}%`
: 'New';
container.innerHTML = `
<div class="view-container">
@@ -143,53 +110,16 @@ export function renderSwDashboard(container: HTMLElement) {
</div>
</div>
<!-- 클라우드 전월/당월 통합 및 결제 임박 (1:1 비율) -->
<div class="dashboard-layout-2col" style="margin-bottom: 2.5rem;">
<div class="dashboard-card" data-action="cloud-billing" style="flex-direction:row; cursor:pointer; min-height:auto; align-items:center; gap: 1.5rem;">
<div style="flex:1;">
<span style="font-size:1rem; font-weight:700; color:var(--text-main);">☁️ 클라우드 청구 현황 (통합)</span>
<div style="margin-top: 0.5rem; display:flex; align-items:baseline; gap: 0.75rem;">
<span style="font-size: 2rem; font-weight:800; color:var(--primary-color);">₩ ${thisMonthCloudCost.toLocaleString()}</span>
<span style="font-size: 0.85rem; font-weight:600; color:${costDiff >= 0 ? 'var(--dash-danger)' : 'var(--dash-primary)'};">
${costDiff >= 0 ? '▲' : '▼'} ${costDiffText}
</span>
</div>
<div style="font-size: 0.8125rem; color:var(--text-muted); margin-top:0.25rem;">전월 실적: ₩ ${lastMonthCloudCost.toLocaleString()}</div>
</div>
<div style="width: 50px; height: 50px; border-radius: 50%; background: conic-gradient(var(--primary-color) 100%, var(--border-color) 0); display:flex; justify-content:center; align-items:center; opacity:0.8;">
<div style="width: 40px; height: 40px; border-radius: 50%; background: var(--white); display:flex; justify-content:center; align-items:center;">
<span style="font-size: 0.75rem; color:var(--text-muted); font-weight:600;">₩</span>
</div>
</div>
</div>
<div class="dashboard-card" data-action="cloud-exp" style="flex-direction:row; justify-content:space-between; align-items:center; cursor:pointer; min-height:auto;">
<div style="flex:1;">
<span style="font-size:1rem; font-weight:700; color:var(--text-main);">클라우드 결제 임박<br><span style="font-size:0.8rem;font-weight:400;color:var(--text-muted);">(14일 이내)</span></span>
<div style="font-size: 1.5rem; font-weight:700; color:${cloudExp > 0 ? 'var(--dash-danger)' : 'var(--text-main)'}; margin-top:0.5rem;">${cloudExp}건 청구</div>
</div>
<div style="width: 50px; height: 50px; border-radius: 50%; background: conic-gradient(var(--dash-danger) ${cloudExpPer}%, var(--border-color) 0); display:flex; justify-content:center; align-items:center;">
<div style="width: 40px; height: 40px; border-radius: 50%; background: var(--white); display:flex; justify-content:center; align-items:center;">
<span style="font-size: 0.75rem; color:var(--text-muted); font-weight:600;">${cloudExpPer}%</span>
</div>
</div>
</div>
</div>
<h3 class="dashboard-section-title">비용 분석 현황</h3>
<div style="display:grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2rem;">
<div class="dashboard-card" style="grid-column: span 1;">
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">${currentYear}년 법인별 도입 금액 (원)</h4>
<h3 class="dashboard-section-title">${currentYear}년 도입 비용 분석</h3>
<div class="dashboard-layout-2col">
<div class="dashboard-card">
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">구매법인별 도입 금액 (원)</h4>
<canvas id="chart-sw-corp"></canvas>
</div>
<div class="dashboard-card" style="grid-column: span 1;">
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">${currentYear}분야별 도입 금액 (원)</h4>
<div class="dashboard-card">
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">분야별 도입 금액 (원)</h4>
<canvas id="chart-sw-cat"></canvas>
</div>
<div class="dashboard-card" style="grid-column: span 1;">
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">직전 4개월 클라우드 결제 추이 (원)</h4>
<canvas id="chart-cloud-trend"></canvas>
</div>
</div>
</div>
`;
@@ -199,71 +129,27 @@ export function renderSwDashboard(container: HTMLElement) {
const ctxCorp = (document.getElementById('chart-sw-corp') as HTMLCanvasElement)?.getContext('2d');
if (ctxCorp) {
const chart = new Chart(ctxCorp, {
new Chart(ctxCorp, {
type: 'bar',
data: { labels: corps, datasets: [{ data: corps.map(c => costByCorp[c]), backgroundColor: 'rgba(30, 81, 73, 0.8)', borderRadius: 4 }] },
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } } }
});
state.activeCharts.push(chart);
}
const ctxTrend = (document.getElementById('chart-cloud-trend') as HTMLCanvasElement)?.getContext('2d');
if (ctxTrend) {
const chart = new Chart(ctxTrend, {
type: 'line',
data: {
labels: trendLabels,
datasets: [{
data: cloudCostTrend,
borderColor: '#6366f1',
backgroundColor: 'rgba(99, 102, 241, 0.05)',
borderWidth: 2,
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { display: false } },
scales: { y: { beginAtZero: true } }
}
});
state.activeCharts.push(chart);
}
const ctxCat = (document.getElementById('chart-sw-cat') as HTMLCanvasElement)?.getContext('2d');
if (ctxCat) {
const chart = new Chart(ctxCat, {
new Chart(ctxCat, {
type: 'bar',
data: { labels: categories, datasets: [{ data: categories.map(c => costByCat[c]), backgroundColor: 'rgba(59, 130, 246, 0.8)', borderRadius: 4 }] },
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } } }
});
state.activeCharts.push(chart);
}
}, 100);
container.querySelector('[data-action="sub-usage"]')?.addEventListener('click', () => openSwUsageDetail('구독 소프트웨어 사용 목록', state.masterData.sw.filter(sw => sw.type === '구독SW')));
container.querySelector('[data-action="perm-usage"]')?.addEventListener('click', () => openSwUsageDetail('영구 소프트웨어 사용 목록', state.masterData.sw.filter(sw => sw.type === '영구SW')));
container.querySelector('[data-action="sub-exp"]')?.addEventListener('click', () => openSwDashboardDetail('구독 SW 만료 예정 목록', state.masterData.sw.filter(sw => sw.type === '구독SW' && isSWExpiring(sw))));
container.querySelector('[data-action="perm-exp"]')?.addEventListener('click', () => openSwDashboardDetail('유지보수 만료 예정 목록', state.masterData.sw.filter(sw => sw.type === '영구SW' && isSWExpiring(sw))));
container.querySelector('[data-action="cloud-billing"]')?.addEventListener('click', () => openCloudDashboardDetail('클라우드 청구 현황 (전체)', state.masterData.sw.filter(sw => sw.type === '클라우드')));
container.querySelector('[data-action="cloud-exp"]')?.addEventListener('click', () => {
const expiringClouds = state.masterData.sw.filter(sw => {
if (sw.type !== '클라우드' || !sw.) return false;
const payDay = parseInt(sw., 10);
if (isNaN(payDay)) return false;
const nextPayMs = new Date(today.getFullYear(), today.getMonth(), payDay).getTime();
let diff = (nextPayMs - today.getTime()) / (1000 * 60 * 60 * 24);
if (diff < 0) {
const nextMonthMs = new Date(today.getFullYear(), today.getMonth() + 1, payDay).getTime();
diff = (nextMonthMs - today.getTime()) / (1000 * 60 * 60 * 24);
}
return diff <= 14;
});
openCloudDashboardDetail('결제 임박 클라우드 목록 (14일 이내)', expiringClouds);
});
container.querySelector('[data-action="sub-usage"]')?.addEventListener('click', () => openSwUsageDetail('구독 소프트웨어 사용 목록', state.masterData.subSw));
container.querySelector('[data-action="perm-usage"]')?.addEventListener('click', () => openSwUsageDetail('영구 소프트웨어 사용 목록', state.masterData.permSw));
container.querySelector('[data-action="sub-exp"]')?.addEventListener('click', () => openSwDashboardDetail('구독 SW 만료 예정 목록', state.masterData.subSw.filter(sw => isSWExpiring(sw))));
container.querySelector('[data-action="perm-exp"]')?.addEventListener('click', () => openSwDashboardDetail('유지보수 만료 예정 목록', state.masterData.permSw.filter(sw => isSWExpiring(sw))));
}
function isSWExpiring(sw: SoftwareAsset) {
@@ -274,11 +160,15 @@ function isSWExpiring(sw: SoftwareAsset) {
const diffDays = (endMs - Date.now()) / (1000 * 60 * 60 * 24);
return diffDays >= 0 && diffDays <= 30;
}
} else if (sw.type === '영구SW' && sw. && sw..includes('유지보수: ~')) {
} else if (sw.type === '영구SW' && sw. && sw..includes('~')) {
// 임시 로직: 비고란에 날짜가 포함된 경우
try {
const endMs = new Date(normalizeDate(sw..split('~')[1])).getTime();
const diffDays = (endMs - Date.now()) / (1000 * 60 * 60 * 24);
return diffDays >= 0 && diffDays <= 30;
const dateMatch = sw..match(/\\d{4}-\\d{2}-\\d{2}/);
if (dateMatch) {
const endMs = new Date(normalizeDate(dateMatch[0])).getTime();
const diffDays = (endMs - Date.now()) / (1000 * 60 * 60 * 24);
return diffDays >= 0 && diffDays <= 30;
}
} catch { return false; }
}
return false;

View File

@@ -1,10 +1,10 @@
import { state } from '../../core/state';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline } from '../../core/utils';
import { formatInline, sortAssets } from '../../core/utils';
import { createIcons, RefreshCcw } from 'lucide';
export function renderEquipmentList(container: HTMLElement) {
const fullList = state.masterData.hw.filter(a => a.type === '전산비품');
const fullList = sortAssets(state.masterData.equip);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
@@ -16,7 +16,7 @@ export function renderEquipmentList(container: HTMLElement) {
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
</div>
<div class="search-item">
<label>법인</label>
<label>구매법인</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">
@@ -28,7 +28,7 @@ export function renderEquipmentList(container: HTMLElement) {
const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container';
const table = document.createElement('table');
table.innerHTML = `<thead><tr><th>No</th><th>법인</th><th>유형</th><th>자산코드</th><th>명칭</th><th>위치</th><th>관리자</th><th>구매일</th><th>금액</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>유형</th><th>자산번호</th><th>모델명</th><th>관리자</th><th>구매일</th><th>금액</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
tableWrapper.appendChild(table);
container.appendChild(tableWrapper);
@@ -42,7 +42,7 @@ 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);
const matchKeyword = !keyword || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword);
const matchCorp = !corp || asset. === corp;
return matchKeyword && matchCorp;
});
@@ -59,16 +59,16 @@ export function renderEquipmentList(container: HTMLElement) {
tr.innerHTML = `
<td>${idx+1}</td>
<td>${asset.}</td>
<td>${asset.||'-'}</td>
<td>${asset.||''}</td>
<td>${asset.type}</td>
<td>${asset.}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset._정 || asset.)}</td>
<td>${asset.||''}</td>
<td>${asset.||''}</td>
<td><button class="btn btn-outline btn-sm">수정</button></td>
`;
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset); });
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr);
});
};

View File

@@ -0,0 +1,85 @@
import { state } from '../../core/state';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, sortAssets } from '../../core/utils';
import { createIcons, RefreshCcw } from 'lucide';
export function renderMobileList(container: HTMLElement) {
const fullList = sortAssets(state.masterData.mobile);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
const corps = Array.from(new Set(fullList.map(a => a.))).filter(Boolean).sort();
filterBar.innerHTML = `
<div class="search-item flex-1">
<label>통합 검색 (자산코드/명칭)</label>
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
</div>
<div class="search-item">
<label>구매법인</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>
`;
container.appendChild(filterBar);
const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container';
const table = document.createElement('table');
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>유형</th><th>자산번호</th><th>모델명</th><th>관리자</th><th>구매일</th><th>금액</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
tableWrapper.appendChild(table);
container.appendChild(tableWrapper);
const tbody = table.querySelector('tbody')!;
const updateTable = () => {
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
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;
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>`;
return;
}
filtered.forEach((asset, idx) => {
const tr = document.createElement('tr');
tr.style.cursor = 'pointer';
tr.innerHTML = `
<td>${idx+1}</td>
<td>${asset.}</td>
<td>${asset.||''}</td>
<td>${asset.type}</td>
<td>${asset.}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset._정 || asset.)}</td>
<td>${asset.||''}</td>
<td>${asset.||''}</td>
<td><button class="btn btn-outline btn-sm">수정</button></td>
`;
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr);
});
};
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
updateTable();
});
updateTable();
}

View File

@@ -1,10 +1,10 @@
import { state } from '../../core/state';
import { openPcModal } from '../../components/Modal/PCModal';
import { formatInline } from '../../core/utils';
import { formatInline, sortAssets } from '../../core/utils';
import { createIcons, Paperclip, RefreshCcw } from 'lucide';
export function renderPcList(container: HTMLElement) {
const fullList = state.masterData.hw.filter(a => a.type === '개인PC');
const fullList = sortAssets(state.masterData.pc);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
@@ -16,11 +16,8 @@ export function renderPcList(container: HTMLElement) {
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
</div>
<div class="search-item">
<label>법인</label>
<select id="filter-corp">
<option value="">전체 법인</option>
${corps.map(c => `<option value="${c}">${c}</option>`).join('')}
</select>
<label>구매법인</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> 필터 초기화
@@ -31,7 +28,7 @@ export function renderPcList(container: HTMLElement) {
const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container';
const table = document.createElement('table');
table.innerHTML = `<thead><tr><th>No</th><th>법인</th><th>자산코드</th><th>사용자</th><th>위치</th><th>CPU</th><th>RAM</th><th>Storage</th><th>구매일</th><th>금액</th><th>품의서</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>자산코드</th><th>사용자</th><th>위치</th><th>CPU</th><th>RAM</th><th>Storage</th><th>구매일</th><th>금액</th><th>품의서</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
tableWrapper.appendChild(table);
container.appendChild(tableWrapper);
@@ -46,14 +43,14 @@ export function renderPcList(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);
const matchKeyword = !keyword || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword);
const matchCorp = !corp || asset. === corp;
return matchKeyword && matchCorp;
});
tbody.innerHTML = '';
if (filtered.length === 0) {
tbody.innerHTML = `<tr><td colspan="12" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
tbody.innerHTML = `<tr><td colspan="13" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
return;
}
@@ -65,6 +62,7 @@ export function renderPcList(container: HTMLElement) {
tr.innerHTML = `
<td>${idx+1}</td>
<td>${asset.}</td>
<td>${asset.||''}</td>
<td>${asset.}</td>
<td>${asset.||''}</td>
<td>${asset.||''}</td>
@@ -76,7 +74,7 @@ export function renderPcList(container: HTMLElement) {
<td style="text-align:center;">${asset. ? '<i data-lucide="paperclip" class="text-primary"></i>' : '-'}</td>
<td><button class="btn btn-outline btn-sm">수정</button></td>
`;
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openPcModal(asset); });
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openPcModal(asset, 'view'); });
tbody.appendChild(tr);
});
createIcons({ icons: { Paperclip } });

View File

@@ -1,10 +1,10 @@
import { state } from '../../core/state';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, createBadge } from '../../core/utils';
import { formatInline, createBadge, sortAssets } from '../../core/utils';
import { createIcons, RefreshCcw } from 'lucide';
export function renderServerList(container: HTMLElement) {
const fullList = state.masterData.hw.filter(a => a.type === '서버');
const fullList = sortAssets(state.masterData.server);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
@@ -17,7 +17,7 @@ export function renderServerList(container: HTMLElement) {
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
</div>
<div class="search-item">
<label>법인</label>
<label>구매법인</label>
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
</div>
<div class="search-item">
@@ -33,7 +33,7 @@ export function renderServerList(container: HTMLElement) {
const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container';
const table = document.createElement('table');
table.innerHTML = `<thead><tr><th>No</th><th>법인</th><th>현 사용조직</th><th>자산번호</th><th>용도</th><th>상세</th><th>설치위치</th><th>담당자</th><th>IP주소</th><th>모델명</th><th>OS</th><th>CPU/RAM</th><th>Storage</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>자산번호</th><th>용도</th><th>상세</th><th>설치위치</th><th>담당자</th><th>IP주소</th><th>모델명</th><th>OS</th><th>CPU/RAM</th><th>Storage</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
tableWrapper.appendChild(table);
container.appendChild(tableWrapper);
@@ -89,7 +89,7 @@ export function renderServerList(container: HTMLElement) {
<td>${formatInline(storage)}</td>
<td><button class="btn btn-outline btn-sm">수정</button></td>
`;
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset); });
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr);
});
};

View File

@@ -1,24 +1,29 @@
import { state } from '../../core/state';
import { openStorageModal } from '../../components/Modal/StorageModal';
import { formatInline } from '../../core/utils';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, createBadge, sortAssets } from '../../core/utils';
import { createIcons, RefreshCcw } from 'lucide';
export function renderStorageList(container: HTMLElement) {
const fullList = state.masterData.hw.filter(a => a.type === '스토리지');
const fullList = sortAssets(state.masterData.storage);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
const corps = Array.from(new Set(fullList.map(a => a.))).filter(Boolean).sort();
const orgUnits = Array.from(new Set(fullList.map(a => a.))).filter(Boolean).sort();
filterBar.innerHTML = `
<div class="search-item flex-1">
<label>통합 검색 (자산코드/명칭/모델명)</label>
<label>통합 검색 (자산번호/조직/모델명)</label>
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
</div>
<div class="search-item">
<label>법인</label>
<label>구매법인</label>
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
</div>
<div class="search-item">
<label>현 사용조직</label>
<select id="filter-org-unit"><option value="">전체 조직</option>${orgUnits.map(o => `<option value="${o}">${o}</option>`).join('')}</select>
</div>
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
<i data-lucide="refresh-ccw"></i> 필터 초기화
</button>
@@ -28,7 +33,7 @@ export function renderStorageList(container: HTMLElement) {
const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container';
const table = document.createElement('table');
table.innerHTML = `<thead><tr><th>No</th><th>법인</th><th>유형</th><th>자산코드</th><th>명칭</th><th>위치</th><th>모델명</th><th>용량</th><th>IP주소</th><th>구매일</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>자산번호</th><th>용도</th><th>상세</th><th>설치위치</th><th>담당자</th><th>모델명</th><th>Storage</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
tableWrapper.appendChild(table);
container.appendChild(tableWrapper);
@@ -37,14 +42,17 @@ export function renderStorageList(container: HTMLElement) {
const updateTable = () => {
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
const orgSelect = document.getElementById('filter-org-unit') as HTMLSelectElement;
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
const corp = corpSelect ? corpSelect.value : '';
const orgUnit = orgSelect ? orgSelect.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 matchKeyword = !keyword || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword);
const matchCorp = !corp || asset. === corp;
return matchKeyword && matchCorp;
const matchOrg = !orgUnit || asset. === orgUnit;
return matchKeyword && matchCorp && matchOrg;
});
tbody.innerHTML = '';
@@ -56,29 +64,38 @@ export function renderStorageList(container: HTMLElement) {
filtered.forEach((asset, idx) => {
const tr = document.createElement('tr');
tr.style.cursor = 'pointer';
const mainManager = asset._정 || asset. || '';
const subManager = asset._부 || '';
const managerHtml = [mainManager ? `${createBadge('정', '#1E5149')} ${mainManager}` : '', subManager ? `${createBadge('부', '#9CA3AF')} ${subManager}` : ''].filter(v => v !== '').join(' / ');
const storage = [asset.SSD1, asset.SSD2, asset.].filter(v => v).join(' / ');
tr.innerHTML = `
<td>${idx+1}</td>
<td>${asset.}</td>
<td>${asset.storage유형||''}</td>
<td>${asset.||''}</td>
<td>${asset.}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${asset.||''}</td>
<td>${asset.IP주소||''}</td>
<td>${asset.||''}</td>
<td>${managerHtml}</td>
<td>${asset.||''}</td>
<td>${formatInline(storage)}</td>
<td><button class="btn btn-outline btn-sm">수정</button></td>
`;
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openStorageModal(asset); });
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr);
});
};
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
document.getElementById('filter-org-unit')?.addEventListener('change', updateTable);
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
(document.getElementById('filter-org-unit') as HTMLSelectElement).value = '';
updateTable();
});

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';
export function renderSwList(container: HTMLElement) {
const fullList = state.masterData.sw.filter(a => a.type === state.activeSubTab);
const isSub = state.activeSubTab === '구독SW';
const fullList = sortAssets(isSub ? state.masterData.subSw : state.masterData.permSw);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
@@ -25,11 +28,8 @@ export function renderSwList(container: HTMLElement) {
</select>
</div>
<div class="search-item">
<label>법인</label>
<select id="filter-corp">
<option value="">전체 법인</option>
<option value="한맥">한맥</option><option value="삼안">삼안</option><option value="바론">바론</option>
</select>
<label>구매법인</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> 필터 초기화
@@ -46,7 +46,7 @@ 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;">구매법인</th>
<th style="text-align:center;">부서</th>
<th style="text-align:center;">제품명</th>
<th style="text-align:center;">구매일</th>
@@ -87,7 +87,7 @@ export function renderSwList(container: HTMLElement) {
}
filtered.forEach((asset, idx) => {
const assigned = state.masterData.swUsers.filter(u => u.swId === asset.id).length;
const assigned = state.masterData.swUsers.filter(u => u.sw_id === asset.id).length;
const qty = typeof asset. === 'number' ? asset.수량 : parseInt(asset.||'0', 10);
const avail = qty - assigned;
@@ -100,22 +100,14 @@ export function renderSwList(container: HTMLElement) {
const endDate = new Date(endDateStr);
if (!isNaN(endDate.getTime())) {
endDate.setHours(23, 59, 59, 999);
if (endDate < new Date()) {
isExpired = true;
}
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>`;
}
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>`;
} 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>`;
}
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>`;
}
const tr = document.createElement('tr');
@@ -144,7 +136,7 @@ export function renderSwList(container: HTMLElement) {
tr.querySelector('.btn-users')?.addEventListener('click', (e) => { e.stopPropagation(); openSwUserModal(asset); });
tbody.appendChild(tr);
});
createIcons({ icons: { Edit2, Users } });
createIcons({ icons: { Edit2, Users, RefreshCcw } });
};
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);

View File

@@ -3,6 +3,7 @@ import { renderPcList } from './List/PcListView';
import { renderServerList } from './List/ServerListView';
import { renderStorageList } from './List/StorageListView';
import { renderEquipmentList } from './List/EquipmentListView';
import { renderMobileList } from './List/MobileListView';
import { renderSwList } from './List/SwListView';
import { renderCloudList } from './List/CloudListView';
import { createIcons, Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, RefreshCcw } from 'lucide';
@@ -26,6 +27,7 @@ export function renderSWTable(mainContent: HTMLElement) {
else if (tab === '서버') renderServerList(container);
else if (tab === '스토리지') renderStorageList(container);
else if (tab === '전산비품') renderEquipmentList(container);
else if (tab === '모바일기기') renderMobileList(container);
else {
container.innerHTML = `<div style="padding:2rem; color:var(--text-muted);">"${tab}" 탭에 대한 하드웨어 리스트 뷰가 정의되지 않았습니다.</div>`;
}