refactor: 교체 대상 PC 교체 수요를 보급 PC 신규 구매 필요 수량으로 이전 합산

This commit is contained in:
2026-06-15 13:17:01 +09:00
parent c35f57acab
commit d6e75f8b2c

View File

@@ -378,15 +378,13 @@ function updateDashboardData(pcs: any[], selectedDept: string) {
// 6. 종합 매트릭스 테이블 렌더링 및 바인딩
const matrixTbody = document.getElementById('pc-grade-matrix-tbody')!;
const renderMatrixRow = (gradeKey: keyof typeof matrix, label: string, color: string) => {
const renderMatrixRow = (gradeKey: keyof typeof matrix, label: string, color: string, shortage: number) => {
const data = matrix[gradeKey];
const totalRate = filtered.length > 0 ? Math.round((data.total / filtered.length) * 100) : 0;
const cellStyle = `padding: 14px 12px; text-align: center; font-weight: 700; cursor: pointer; transition: background 0.2s; font-size: 1.25rem;`;
const hoverEvents = `onmouseover="this.style.background='#F1F5F9'" onmouseout="this.style.background='none'"`;
const shortage = Math.max(0, data.under - data.stock);
return `
<tr style="border-bottom: 1px solid #F1F5F9;">
<td style="padding: 14px 12px; font-weight: 800; color: ${color}; font-size: 1.25rem;">${label}</td>
@@ -405,19 +403,24 @@ function updateDashboardData(pcs: any[], selectedDept: string) {
const premiumShortage = Math.max(0, matrix.premium.under - matrix.premium.stock);
const highShortage = Math.max(0, matrix.high.under - matrix.high.stock);
const normalShortage = Math.max(0, matrix.normal.under - matrix.normal.stock);
const entryShortage = Math.max(0, matrix.entry.under - matrix.entry.stock);
const replaceShortage = Math.max(0, matrix.replace.under - matrix.replace.stock);
// 보급 PC 구매 필요 = (보급 under + 교체대상 under) - 보급 stock (교체 대상을 위해 최소 보급 PC 사양을 구매한다는 논리 적용)
const entryShortage = Math.max(0, (matrix.entry.under + matrix.replace.under) - matrix.entry.stock);
// 교체 대상 PC 자체는 새로 구매하는 기종이 아니므로 구매 필요 0대
const replaceShortage = 0;
const totalShortage = premiumShortage + highShortage + normalShortage + entryShortage + replaceShortage;
const cellStyleHeader = `padding: 14px 12px; text-align: center; font-weight: 800; cursor: pointer; transition: background 0.2s; background: #F8FAFC; font-size: 1.25rem;`;
const hoverEventsHeader = `onmouseover="this.style.background='#EEF2F6'" onmouseout="this.style.background='#F8FAFC'"`;
matrixTbody.innerHTML = `
${renderMatrixRow('premium', '최상급 PC (85점 이상)', '#11302B')}
${renderMatrixRow('high', '상급 PC (70점 ~ 85점)', '#1E8E7C')}
${renderMatrixRow('normal', '중급 PC (40점 ~ 70점)', '#10B981')}
${renderMatrixRow('entry', '보급 PC (20점 ~ 40점)', '#F59E0B')}
${renderMatrixRow('replace', '교체 대상 PC (20점 미만 또는 Win11 불가)', '#EF4444')}
${renderMatrixRow('premium', '최상급 PC (85점 이상)', '#11302B', premiumShortage)}
${renderMatrixRow('high', '상급 PC (70점 ~ 85점)', '#1E8E7C', highShortage)}
${renderMatrixRow('normal', '중급 PC (40점 ~ 70점)', '#10B981', normalShortage)}
${renderMatrixRow('entry', '보급 PC (20점 ~ 40점)', '#F59E0B', entryShortage)}
${renderMatrixRow('replace', '교체 대상 PC (20점 미만 또는 Win11 불가)', '#EF4444', replaceShortage)}
<tr style="background: #F8FAFC; border-top: 2px solid #E2E8F0; font-weight: 800;">
<td style="padding: 14px 12px; color: #1E293B; font-weight: 800; font-size: 1.25rem;">합계 (Total)</td>
<td class="matrix-cell" data-grade="all" data-type="total" style="${cellStyleHeader}" ${hoverEventsHeader}>${totalPcs}대 <span style="font-size:1.125rem; color:#64748B; font-weight:600;">(100%)</span></td>