feat: 자산 관리 시스템 고도화 및 데이터 구조 최적화

- 모바일 자산(Mobile) 카테고리 추가 및 엑셀 업로드/다운로드 지원
- 클라우드 자산(Cloud) 및 변경 이력(Logs) 테이블 및 API 구현
- 데이터베이스 초기화 로직 개선 및 테이블 자동 생성 기능 추가
- 하드웨어 저장 로직 통합 및 카테고리 판별 자동화
- SW 대시보드 사용량 산출 방식 개선 (sw_id 기반 맵핑)
- 수동 모달(Storage)을 통합 하드웨어 모달(HWModal)로 통합 및 정리
This commit is contained in:
2026-04-21 10:30:05 +09:00
parent 213bbe4734
commit 153e422180
7 changed files with 349 additions and 360 deletions

View File

@@ -9,12 +9,7 @@ export function renderSwDashboard(container: HTMLElement) {
let subQty = 0, subUsed = 0, subExp = 0, subTotal = 0;
let permQty = 0, permUsed = 0, permExp = 0, permTotal = 0;
let thisMonthCloudCost = 0;
let lastMonthCloudCost = 0;
let cloudExp = 0;
const currentYear = new Date().getFullYear();
const today = new Date();
const corps = ['한맥', '삼안', '바론'];
const categories = ['업무공통', '개발S/W', '디자인', '설계S/W'];
@@ -23,11 +18,12 @@ export function renderSwDashboard(container: HTMLElement) {
const costByCat: Record<string, number> = {};
categories.forEach(c => costByCat[c] = 0);
// 통합 SW 데이터 (호환용)
// 통합 SW 데이터
const allSw = [...state.masterData.subSw, ...state.masterData.permSw];
allSw.forEach(sw => {
const assigned = state.masterData.swUsers.filter(u => u.swId === sw.id).length;
const userMapping = state.masterData.swUsers.find(u => u.sw_id === sw.id);
const assigned = userMapping ? (userMapping.userData ? userMapping.userData.length : 0) : 0;
const qty = typeof sw. === 'number' ? sw.수량 : parseInt(sw.||'0', 10);
const priceStr = sw. ? String(sw.).replace(/,/g, '') : '0';
const price = parseInt(priceStr, 10) || 0;
@@ -46,22 +42,11 @@ 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 cloudCostTrend = [0, 0, 0, 0];
const trendLabels: string[] = [];
for(let i=3; i>=0; i--) {
const d = new Date();
d.setMonth(d.getMonth() - i);
trendLabels.push(`${d.getMonth()+1}`);
}
container.innerHTML = `
<div class="view-container">
<h3 class="dashboard-section-title">소프트웨어 라이선스 현황</h3>
@@ -153,21 +138,17 @@ export function renderSwDashboard(container: HTMLElement) {
}
function isSWExpiring(sw: SoftwareAsset) {
if (sw.type === '구독SW' && sw.) {
const parts = sw..split('~');
if (parts.length > 1) {
const endMs = new Date(normalizeDate(parts[1])).getTime();
const diffDays = (endMs - Date.now()) / (1000 * 60 * 60 * 24);
return diffDays >= 0 && diffDays <= 30;
}
} else if (sw.type === '영구SW' && sw. && sw..includes('~')) {
// 임시 로직: 비고란에 날짜가 포함된 경우
if (sw.type === '구독SW' && sw.) {
const endMs = new Date(normalizeDate(sw.)).getTime();
const diffDays = (endMs - Date.now()) / (1000 * 60 * 60 * 24);
return diffDays >= 0 && diffDays <= 30;
} else if (sw.type === '영구SW' && sw. && sw..includes('유지보수: ~')) {
try {
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;
const parts = sw..split('~');
if (parts.length > 1) {
const endMs = new Date(normalizeDate(parts[1].trim())).getTime();
const diffDays = (endMs - Date.now()) / (1000 * 60 * 60 * 24);
return diffDays >= 0 && diffDays <= 30;
}
} catch { return false; }
}