4 Commits

31 changed files with 1968 additions and 1281 deletions

View File

@@ -47,6 +47,7 @@ async function initDB() {
server_id VARCHAR(100),
server_pw VARCHAR(100),
model_name VARCHAR(255),
mainboard VARCHAR(255) COMMENT '메인보드',
os VARCHAR(100),
cpu VARCHAR(255),
ram VARCHAR(100),
@@ -73,11 +74,14 @@ async function initDB() {
id VARCHAR(50) PRIMARY KEY,
corp VARCHAR(100) COMMENT '구매법인',
asset_code VARCHAR(100) COMMENT '자산번호',
category VARCHAR(100) COMMENT '분야',
dept VARCHAR(100) COMMENT '부서',
product_name VARCHAR(255) COMMENT '제품명',
license_type VARCHAR(100) COMMENT '라이선스 유형',
quantity INT COMMENT '수량',
price VARCHAR(100) COMMENT '금액',
purchase_date VARCHAR(50) COMMENT '구매일',
start_date VARCHAR(50) COMMENT '시작일',
expiry_date VARCHAR(50) COMMENT '만료일',
vendor VARCHAR(255) COMMENT '납품업체',
remarks TEXT COMMENT '비고',
@@ -91,11 +95,14 @@ async function initDB() {
id VARCHAR(50) PRIMARY KEY,
corp VARCHAR(100) COMMENT '구매법인',
asset_code VARCHAR(100) COMMENT '자산번호',
category VARCHAR(100) COMMENT '분야',
dept VARCHAR(100) COMMENT '부서',
product_name VARCHAR(255) COMMENT '제품명',
license_key VARCHAR(255) COMMENT '라이선스 키',
quantity INT COMMENT '수량',
price VARCHAR(100) COMMENT '금액',
purchase_date VARCHAR(50) COMMENT '구매일',
start_date VARCHAR(50) COMMENT '시작일',
vendor VARCHAR(255) COMMENT '납품업체',
remarks TEXT COMMENT '비고',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

View File

@@ -10,6 +10,7 @@
<link rel="stylesheet" href="/src/styles/modal.css" />
<link rel="stylesheet" href="/src/styles/dashboard.css" />
<link rel="stylesheet" href="/src/styles/table.css" />
<link rel="stylesheet" href="/src/styles/guide.css" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0"></script>
</head>
@@ -19,7 +20,7 @@
<header class="main-header">
<div class="header-container" id="nav-container">
<div class="brand">
<h1>HM <span>ITAM</span></h1>
<h1>HM <span>IT 자산관리 시스템</span></h1>
</div>
<!-- Navigation (GNB + LNB in same row) -->
@@ -28,6 +29,9 @@
</nav>
<div class="header-actions">
<button id="btn-open-guide-header" class="btn btn-outline" title="사용 가이드 열기">
<i data-lucide="book-open"></i> 가이드
</button>
<button id="btn-download-template" class="btn btn-outline" title="통합 양식 다운로드">
<i data-lucide="download"></i> 양식
</button>

104
server.js
View File

@@ -52,7 +52,46 @@ async function ensureTables() {
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
`);
console.log('✅ Cloud & Logs tables ensured.');
await connection.query(`
CREATE TABLE IF NOT EXISTS pc_assets (
id VARCHAR(50) PRIMARY KEY, corp VARCHAR(100), asset_code VARCHAR(100), purchase_date VARCHAR(50),
type VARCHAR(50), detail_purpose VARCHAR(100), purpose VARCHAR(255), details TEXT,
current_org VARCHAR(100), prev_org VARCHAR(100), location VARCHAR(255),
manager_main VARCHAR(100), manager_sub VARCHAR(100), ip_address VARCHAR(50),
remote_tool VARCHAR(100), server_id VARCHAR(100), server_pw VARCHAR(100),
model_name VARCHAR(255), mainboard VARCHAR(255), os VARCHAR(100), cpu VARCHAR(100), ram VARCHAR(100), gpu VARCHAR(100),
storage1 VARCHAR(100), storage2 VARCHAR(100), storage3 VARCHAR(100), monitoring VARCHAR(100), price VARCHAR(100), remarks TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
`);
// 다른 하드웨어 테이블들도 동일한 스키마로 생성 (서버, 스토리지, 비품, 모바일)
for (const table of ['server_assets', 'storage_assets', 'equip_assets', 'mobile_assets']) {
await connection.query(`CREATE TABLE IF NOT EXISTS ${table} LIKE pc_assets`);
}
await connection.query(`
CREATE TABLE IF NOT EXISTS sw_sub_assets (
id VARCHAR(50) PRIMARY KEY, corp VARCHAR(100), asset_code VARCHAR(100),
category VARCHAR(100), dept VARCHAR(100), product_name VARCHAR(255),
license_type VARCHAR(100), quantity INT, price VARCHAR(100), purchase_date VARCHAR(50),
start_date VARCHAR(50), expiry_date VARCHAR(50), vendor VARCHAR(100), remarks TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
`);
await connection.query(`
CREATE TABLE IF NOT EXISTS sw_perm_assets (
id VARCHAR(50) PRIMARY KEY, corp VARCHAR(100), asset_code VARCHAR(100),
category VARCHAR(100), dept VARCHAR(100), product_name VARCHAR(255),
license_key VARCHAR(255), quantity INT, price VARCHAR(100), purchase_date VARCHAR(50),
start_date VARCHAR(50), vendor VARCHAR(100), remarks TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
`);
await connection.query(`
CREATE TABLE IF NOT EXISTS sw_users (
id INT AUTO_INCREMENT PRIMARY KEY, sw_id VARCHAR(50), corp VARCHAR(100), dept VARCHAR(100),
position VARCHAR(100), user_name VARCHAR(100), usage_period VARCHAR(255), doc_name VARCHAR(255)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
`);
console.log('✅ All ITAM tables ensured.');
} finally {
connection.release();
}
@@ -83,18 +122,16 @@ const hardwareInsertSQL = (table) => `
INSERT INTO ${table} (
id, corp, asset_code, purchase_date, type, detail_purpose, purpose, details,
current_org, prev_org, location, manager_main, manager_sub, ip_address,
remote_tool, server_id, server_pw, model_name, os, cpu, ram, gpu,
storage1, storage2, storage3, monitoring, price, remarks,
storage_location, status
remote_tool, server_id, server_pw, model_name, mainboard, os, cpu, ram, gpu,
storage1, storage2, storage3, monitoring, price, remarks
) VALUES ?
`;
const getHardwareValues = (a) => [
a.id, a.법인||'', a.자산코드||'', a.구매일||'', a.type||'', a.상세용도||'', a.용도||'', a.상세||'',
a.현사용조직||'', a.이전사용조직||'', a.위치||'', a.담당자_정||'', a.담당자_부||'', a.IP주소||'',
a.원격접속||'', a.서버ID||'', a.서버PW||'', a.모델명||'', a.OS||'', a.CPU||'', a.RAM||'', a.GPU||'',
a.SSD1||'', a.SSD2||'', a.HDD1||'', a.모니터링||'', a.금액||'', a.비고||'',
a.보관위치||'', a.현재상태||''
a.원격접속||'', a.서버ID||'', a.서버PW||'', a.모델명||'', a.메인보드||'', a.OS||'', a.CPU||'', a.RAM||'', a.GPU||'',
a.SSD1||'', a.SSD2||'', a.HDD1||'', a.모니터링||'', a.금액||'', a.비고||''
];
const mapHardware = (r, defaultType) => ({
@@ -102,9 +139,8 @@ const mapHardware = (r, defaultType) => ({
상세용도: r.detail_purpose, 용도: r.purpose, 상세: r.details, 현사용조직: r.current_org,
이전사용조직: r.prev_org, 위치: r.location, 담당자_정: r.manager_main, 담당자_부: r.manager_sub,
IP주소: r.ip_address, 원격접속: r.remote_tool, 서버ID: r.server_id, 서버PW: r.server_pw,
모델명: r.model_name, OS: r.os, CPU: r.cpu, RAM: r.ram, GPU: r.gpu, SSD1: r.storage1,
SSD2: r.storage2, HDD1: r.storage3, 모니터링: r.monitoring, 금액: r.price, 비고: r.remarks,
보관위치: r.storage_location, 현재상태: r.status
모델명: r.model_name, 메인보드: r.mainboard, OS: r.os, CPU: r.cpu, RAM: r.ram, GPU: r.gpu, SSD1: r.storage1,
SSD2: r.storage2, HDD1: r.storage3, 모니터링: r.monitoring, 금액: r.price, 비고: r.remarks
});
// --- API 라우트 정의 ---
@@ -113,13 +149,8 @@ const mapHardware = (r, defaultType) => ({
app.get('/api/pc', async (req, res) => {
try {
const [rows] = await pool.query('SELECT * FROM pc_assets');
console.log('🔍 DB Raw Rows (PC):', rows.length, 'items found.');
if (rows.length > 0) console.log('🔍 First row sample:', rows[0]);
res.json(rows.map(r => mapHardware(r, '개인PC')));
} catch (err) {
console.error('❌ DB Query Error (PC):', err.message);
res.status(500).json({ error: err.message });
}
} catch (err) { res.status(500).json({ error: err.message }); }
});
app.post('/api/pc/batch', async (req, res) => {
@@ -209,9 +240,11 @@ app.get('/api/sw/sub', async (req, res) => {
try {
const [rows] = await pool.query('SELECT * FROM sw_sub_assets');
res.json(rows.map(r => ({
id: r.id, type: '구독SW', 법인: r.corp, 자산번호: r.asset_code, 제품명: r.product_name,
라이선스유형: r.license_type, 수량: r.quantity, 금액: r.price, 구매일: r.purchase_date,
만료일: r.expiry_date, 납품업체: r.vendor, 비고: r.remarks
id: r.id, type: '구독SW', 법인: r.corp, 자산번호: r.asset_code,
분야: r.category, 부서: r.dept, 제품명: r.product_name,
라이선스유형: r.license_type, 수량: r.quantity, 금액: r.price,
구매일: r.purchase_date, 시작일: r.start_date, 만료일: r.expiry_date,
납품업체: r.vendor, 비고: r.remarks
})));
} catch (err) { res.status(500).json({ error: err.message }); }
});
@@ -219,8 +252,11 @@ app.get('/api/sw/sub', async (req, res) => {
app.post('/api/sw/sub/batch', async (req, res) => {
try {
const result = await batchSave('sw_sub_assets', req.body, (assets) => ({
sql: `INSERT INTO sw_sub_assets (id, corp, asset_code, product_name, license_type, quantity, price, purchase_date, expiry_date, vendor, remarks) VALUES ?`,
values: assets.map(a => [a.id, a.법인||'', a.자산번호||'', a.제품명||'', a.라이선스유형||'', a.수량||0, a.금액||'', a.구매일||'', a.만료일||'', a.납품업체||'', a.비고||''])
sql: `INSERT INTO sw_sub_assets (id, corp, asset_code, category, dept, product_name, license_type, quantity, price, purchase_date, start_date, expiry_date, vendor, remarks) VALUES ?`,
values: assets.map(a => [
a.id, a.법인||'', a.자산번호||'', a.분야||'', a.부서||'', a.제품명||'',
a.라이선스유형||'', a.수량||0, a.금액||'', a.구매일||'', a.시작일||'', a.만료일||'', a.납품업체||'', a.비고||''
])
}));
res.json(result);
} catch (err) { res.status(500).json({ error: err.message }); }
@@ -231,8 +267,10 @@ app.get('/api/sw/perm', async (req, res) => {
try {
const [rows] = await pool.query('SELECT * FROM sw_perm_assets');
res.json(rows.map(r => ({
id: r.id, type: '영구SW', 법인: r.corp, 자산번호: r.asset_code, 제품명: r.product_name,
라이선스키: r.license_key, 수량: r.quantity, 금액: r.price, 구매일: r.purchase_date,
id: r.id, type: '영구SW', 법인: r.corp, 자산번호: r.asset_code,
분야: r.category, 부서: r.dept, 제품명: r.product_name,
라이선스키: r.license_key, 수량: r.quantity, 금액: r.price,
구매일: r.purchase_date, 시작일: r.start_date,
납품업체: r.vendor, 비고: r.remarks
})));
} catch (err) { res.status(500).json({ error: err.message }); }
@@ -241,8 +279,11 @@ app.get('/api/sw/perm', async (req, res) => {
app.post('/api/sw/perm/batch', async (req, res) => {
try {
const result = await batchSave('sw_perm_assets', req.body, (assets) => ({
sql: `INSERT INTO sw_perm_assets (id, corp, asset_code, product_name, license_key, quantity, price, purchase_date, vendor, remarks) VALUES ?`,
values: assets.map(a => [a.id, a.법인||'', a.자산번호||'', a.제품명||'', a.라이선스키||'', a.수량||0, a.금액||'', a.구매일||'', a.납품업체||'', a.비고||''])
sql: `INSERT INTO sw_perm_assets (id, corp, asset_code, category, dept, product_name, license_key, quantity, price, purchase_date, start_date, vendor, remarks) VALUES ?`,
values: assets.map(a => [
a.id, a.법인||'', a.자산번호||'', a.분야||'', a.부서||'', a.제품명||'',
a.라이선스키||'', a.수량||0, a.금액||'', a.구매일||'', a.시작일||'', a.납품업체||'', a.비고||''
])
}));
res.json(result);
} catch (err) { res.status(500).json({ error: err.message }); }
@@ -323,20 +364,17 @@ app.post('/api/sw-users/batch', async (req, res) => {
} catch (err) { res.status(500).json({ error: err.message }); }
});
// 자산번호 자동 생성 API
// 자산코드 생성 API
app.get('/api/generate-asset-code', async (req, res) => {
const { prefix } = req.query;
if (!prefix) return res.status(400).json({ error: 'Prefix is required' });
try {
const tables = ['pc_assets', 'server_assets', 'storage_assets', 'equip_assets', 'mobile_assets'];
const tables = ['pc_assets', 'server_assets', 'storage_assets', 'equip_assets', 'mobile_assets', 'sw_sub_assets', 'sw_perm_assets'];
let maxNum = 0;
for (const table of tables) {
const [rows] = await pool.query(
`SELECT asset_code FROM ${table} WHERE asset_code LIKE ?`,
[`${prefix}%`]
);
const [rows] = await pool.query(`SELECT asset_code FROM ${table} WHERE asset_code LIKE ?`, [`${prefix}%`]);
rows.forEach(r => {
const numPart = r.asset_code.replace(prefix, '');
const num = parseInt(numPart);
@@ -344,8 +382,8 @@ app.get('/api/generate-asset-code', async (req, res) => {
});
}
const nextNum = (maxNum + 1).toString().padStart(3, '0');
res.json({ nextCode: `${prefix}${nextNum}` });
const nextCode = `${prefix}${(maxNum + 1).toString().padStart(3, '0')}`;
res.json({ nextCode });
} catch (err) {
res.status(500).json({ error: err.message });
}

624
src/components/Guide.ts Normal file
View File

@@ -0,0 +1,624 @@
import { createIcons, BookOpen, X, ChevronDown, ChevronRight, RefreshCw } from 'lucide';
// ─── 자산별 가이드 콘텐츠 정의 ───
interface GuideTabConfig {
id: string;
label: string;
content: string;
}
const GUIDE_TABS: GuideTabConfig[] = [
{
id: 'overview',
label: '📋 개요',
content: `
<section class="guide-section">
<h3>IT 자산관리 시스템 개요</h3>
<p class="guide-text">
HM IT 자산관리 시스템(ITAM)은 기업의 IT 자산을 <strong>도입부터 폐기까지</strong> 전 과정에서 효율적으로 관리하기 위한 통합 플랫폼입니다.<br>
하드웨어(PC, 서버, 스토리지, 전산비품, 모바일기기)와 소프트웨어(구독SW, 영구SW, 클라우드)를 체계적으로 추적하고 유지보수합니다.
</p>
</section>
<section class="guide-section">
<h3>전체 자산관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">도입/구매</span><p class="step-desc">자산 구매 요청 → 승인 → 발주</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">등록/배정</span><p class="step-desc">자산번호 부여 → 시스템 등록 → 사용자 할당</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">운영/유지</span><p class="step-desc">현황 모니터링 → 점검/수리 → 이력 관리</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">4</span>
<div><span class="step-label">반납/폐기</span><p class="step-desc">자산 회수 → 데이터 소거 → 폐기 처리</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>시스템 기본 사용법</h3>
<table class="guide-info-table">
<thead><tr><th>기능</th><th>방법</th></tr></thead>
<tbody>
<tr><td><strong>자산 조회</strong></td><td>상단 네비게이션에서 카테고리(하드웨어/소프트웨어) 선택 → 하위 탭에서 자산유형 선택</td></tr>
<tr><td><strong>자산 등록</strong></td><td>[자산추가] 버튼 클릭 → 양식 입력 → 저장</td></tr>
<tr><td><strong>자산 수정</strong></td><td>테이블에서 행 클릭 → 모달에서 [수정] → 내용 변경 → 저장</td></tr>
<tr><td><strong>엑셀 업로드</strong></td><td>[업로드] 버튼 → 양식에 맞는 .xlsx 파일 선택 → 자동 일괄 등록</td></tr>
<tr><td><strong>엑셀 다운로드</strong></td><td>[엑셀저장] 버튼 → 전체 자산 데이터 Excel 파일로 저장</td></tr>
<tr><td><strong>양식 다운로드</strong></td><td>[양식] 버튼 → 엑셀 업로드용 빈 양식 다운로드</td></tr>
</tbody>
</table>
</section>
`
},
{
id: 'pc',
label: '💻 개인PC',
content: `
<section class="guide-section">
<h3>개인PC 관리 가이드</h3>
<p class="guide-text">
개인PC는 임직원에게 지급되는 데스크톱 및 노트북을 관리합니다. 자산의 지급, 교체, 반납까지의 전체 생애주기를 시스템에서 추적합니다.
</p>
</section>
<section class="guide-section">
<h3>관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">구매 및 입고</span><p class="step-desc">구매 요청 → 발주 → 입고 검수</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">자산 등록</span><p class="step-desc">자산코드 부여, 사양(CPU/RAM/Storage) 등록</p></div>
</div>
</div>
<i data-lucide="chevron-down" class="flow-arrow"></i>
<div class="flow-row">
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">사용자 지급</span><p class="step-desc">사용자·사용조직 지정, 설치위치 기록</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">4</span>
<div><span class="step-label">운영 관리</span><p class="step-desc">OS 업데이트, 보안 점검, 품의서 관리</p></div>
</div>
</div>
<i data-lucide="chevron-down" class="flow-arrow"></i>
<div class="flow-row">
<div class="flow-step">
<span class="step-number">5</span>
<div><span class="step-label">교체/반납</span><p class="step-desc">노후 장비 회수, 데이터 소거, 신규 장비 지급</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">6</span>
<div><span class="step-label">폐기 처리</span><p class="step-desc">폐기 대장 등록, 물리적 파기 또는 매각</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th><th>관리 주기</th></tr></thead>
<tbody>
<tr><td>구매법인</td><td>자산을 구매한 법인</td><td>등록 시 1회</td></tr>
<tr><td>현 사용조직</td><td>현재 자산을 사용하는 조직/부서</td><td>인사 변동 시</td></tr>
<tr><td>자산코드</td><td>사내 고유 자산 식별 번호</td><td>등록 시 1회</td></tr>
<tr><td>사용자</td><td>자산을 실제 사용하는 직원명</td><td>인사 변동 시</td></tr>
<tr><td>위치</td><td>자산이 실제 설치된 건물/층/좌석</td><td>이동 시 즉시</td></tr>
<tr><td>CPU / RAM / Storage</td><td>하드웨어 사양 정보</td><td>등록/증설 시</td></tr>
<tr><td>구매일</td><td>장비 구매 일자</td><td>등록 시 1회</td></tr>
<tr><td>금액</td><td>구매 비용</td><td>등록 시 1회</td></tr>
<tr><td>품의서</td><td>구매 증빙 첨부 파일</td><td>등록 시 1회</td></tr>
</tbody>
</table>
</section>
<div class="guide-tip">
<strong>💡 팁:</strong> PC 교체 시 기존 장비의 상태를 '반납'으로 변경하고, 신규 장비를 새로 등록하여 이력을 분리 관리하세요.
</div>
`
},
{
id: 'server',
label: '🖥️ 서버',
content: `
<section class="guide-section">
<h3>서버 관리 가이드</h3>
<p class="guide-text">
물리 서버와 가상 서버를 포함한 서버급 자산을 관리합니다. 안정적인 서비스 운영을 위해 체계적인 관리가 필요합니다.
</p>
</section>
<section class="guide-section">
<h3>관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">도입 계획</span><p class="step-desc">용도 정의, 사양 산정, 구매 승인</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">설치 및 등록</span><p class="step-desc">랙 배치, 네트워크 설정, 자산 등록</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">운영 관리</span><p class="step-desc">모니터링, 패치 적용, 장애 대응</p></div>
</div>
</div>
<i data-lucide="chevron-down" class="flow-arrow"></i>
<div class="flow-row">
<div class="flow-step">
<span class="step-number">4</span>
<div><span class="step-label">정기 점검</span><p class="step-desc">보안 취약점 점검, 성능 확인, 백업 검증</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">5</span>
<div><span class="step-label">폐기/교체</span><p class="step-desc">데이터 마이그레이션 후 장비 교체 또는 폐기</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th><th>관리 주기</th></tr></thead>
<tbody>
<tr><td>구매법인 / 현 사용조직</td><td>법인 및 조직 정보</td><td>등록 / 변동 시</td></tr>
<tr><td>자산번호</td><td>서버 식별 번호</td><td>등록 시 1회</td></tr>
<tr><td>용도 / 상세</td><td>서버의 역할과 상세 설명</td><td>변경 시</td></tr>
<tr><td>설치위치</td><td>데이터센터, 랙 번호, 유닛 위치</td><td>이전 시</td></tr>
<tr><td>담당자 (정/부)</td><td>관리 담당자 정보</td><td>변동 시</td></tr>
<tr><td>IP주소</td><td>서버 네트워크 주소 (최대 2개)</td><td>변경 시</td></tr>
<tr><td>모델명</td><td>서버 하드웨어 모델</td><td>등록 시</td></tr>
<tr><td>OS</td><td>운영체제 종류 및 버전</td><td>업데이트 시</td></tr>
<tr><td>CPU / RAM / Storage</td><td>서버 사양 정보</td><td>증설 시</td></tr>
</tbody>
</table>
</section>
<div class="guide-warn">
<strong>⚠️ 주의:</strong> 서버 폐기 전에는 반드시 데이터 마이그레이션과 백업 검증을 완료하고, 관련 서비스의 DNS/IP 변경 여부를 확인하세요.
</div>
`
},
{
id: 'storage',
label: '💾 스토리지',
content: `
<section class="guide-section">
<h3>스토리지 관리 가이드</h3>
<p class="guide-text">
NAS, SAN, DAS 등 스토리지 장비에 대한 자산 관리입니다. 저장 용량의 효율적 운용과 데이터 안전성 확보가 핵심입니다.
</p>
</section>
<section class="guide-section">
<h3>관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">용량 산정</span><p class="step-desc">현재 사용량 분석 및 증설 필요 여부 판단</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">도입/설치</span><p class="step-desc">스토리지 구매 → 설치 → 네트워크 연결</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">운영 관리</span><p class="step-desc">용량 모니터링, RAID 상태 점검, 백업 스케줄</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th></tr></thead>
<tbody>
<tr><td>구매법인 / 현 사용조직</td><td>법인 및 조직 정보</td></tr>
<tr><td>자산번호</td><td>스토리지 식별 번호</td></tr>
<tr><td>용도 / 상세</td><td>스토리지 사용 목적과 세부 설명</td></tr>
<tr><td>설치위치</td><td>데이터센터 내 물리적 위치</td></tr>
<tr><td>담당자 (정/부)</td><td>관리 담당자 정보</td></tr>
<tr><td>모델명</td><td>스토리지 하드웨어 모델</td></tr>
<tr><td>Storage</td><td>총 용량 및 디스크 구성 정보</td></tr>
</tbody>
</table>
</section>
<div class="guide-tip">
<strong>💡 팁:</strong> 스토리지 용량이 80%를 초과하면 증설을 검토하세요. 비고란에 용량 변경 이력을 기록하면 추적에 유용합니다.
</div>
`
},
{
id: 'equip',
label: '🔌 전산비품',
content: `
<section class="guide-section">
<h3>전산비품 관리 가이드</h3>
<p class="guide-text">
모니터, 프린터, 네트워크 장비(스위치, AP), UPS, CPU, GPU, RAM, HDD 등 IT 관련 부속장비를 관리합니다.
</p>
</section>
<section class="guide-section">
<h3>관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">구매/입고</span><p class="step-desc">소모품 및 장비 구매 → 입고 확인</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">등록/배치</span><p class="step-desc">자산코드 부여 → 유형 지정 → 관리자 배정</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">유지보수</span><p class="step-desc">고장 수리, 소모품 교체, 상태 점검</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">4</span>
<div><span class="step-label">폐기</span><p class="step-desc">노후화 시 폐기 처리 및 대장 기록</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th></tr></thead>
<tbody>
<tr><td>구매법인 / 현 사용조직</td><td>법인 및 조직 정보</td></tr>
<tr><td>유형</td><td>비품 분류 (CPU, GPU, RAM, HDD, 태블릿 등)</td></tr>
<tr><td>자산번호</td><td>비품 고유 식별 번호</td></tr>
<tr><td>모델명</td><td>비품 하드웨어 모델</td></tr>
<tr><td>관리자</td><td>비품 관리 담당자</td></tr>
<tr><td>구매일</td><td>비품 구매 일자</td></tr>
<tr><td>금액</td><td>구매 비용</td></tr>
</tbody>
</table>
</section>
`
},
{
id: 'mobile',
label: '📱 모바일기기',
content: `
<section class="guide-section">
<h3>모바일기기 관리 가이드</h3>
<p class="guide-text">
업무용 스마트폰, 태블릿 등 모바일 기기의 지급 및 회수를 관리합니다.
</p>
</section>
<section class="guide-section">
<h3>관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">기기 구매</span><p class="step-desc">통신사 계약, 기기 선정, 구매</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">등록/지급</span><p class="step-desc">자산번호 부여, 관리자 지정, 사용자 지급</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">운영</span><p class="step-desc">OS 업데이트, 앱 관리</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">4</span>
<div><span class="step-label">회수/교체</span><p class="step-desc">퇴직/교체 시 기기 회수, 초기화</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th></tr></thead>
<tbody>
<tr><td>구매법인 / 현 사용조직</td><td>법인 및 조직 정보</td></tr>
<tr><td>유형</td><td>기기 분류 (모바일, 태블릿 등)</td></tr>
<tr><td>자산번호</td><td>기기 고유 식별 번호</td></tr>
<tr><td>모델명</td><td>기기 모델 (예: Galaxy S24, iPad Pro)</td></tr>
<tr><td>관리자</td><td>기기를 관리하는 담당자</td></tr>
<tr><td>구매일</td><td>기기 구매 일자</td></tr>
<tr><td>금액</td><td>구매 비용</td></tr>
</tbody>
</table>
</section>
<div class="guide-warn">
<strong>⚠️ 주의:</strong> 모바일기기 회수 시 반드시 공장초기화를 수행하세요.
</div>
`
},
{
id: 'sub-sw',
label: '🔄 구독SW',
content: `
<section class="guide-section">
<h3>구독형 소프트웨어 관리 가이드</h3>
<p class="guide-text">
월간/연간 구독 방식의 소프트웨어(SaaS)를 관리합니다. <strong>만료일 관리</strong>와 <strong>라이선스 최적화</strong>가 핵심입니다.
</p>
</section>
<section class="guide-section">
<h3>갱신 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<div class="step-number" style="background-color: #ff9800;">!</div>
<div><span class="step-label">만료 알림 확인</span><p class="step-desc">대시보드에서 만료 예정 자산 목록 확인</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">A</span>
<div><span class="step-label">수요조사</span><p class="step-desc">실제 사용자 파악, 불필요 라이선스 정리</p></div>
</div>
</div>
<i data-lucide="chevron-down" class="flow-arrow"></i>
<div class="flow-row">
<div class="flow-step">
<span class="step-number">B</span>
<div><span class="step-label">계약 연장</span><p class="step-desc">공급사에 갱신 요청, 수량/금액 확정, 결제</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<div class="step-number" style="background-color: var(--guide-accent);">✓</div>
<div><span class="step-label">시스템 업데이트</span><p class="step-desc">시작일/만료일 갱신, 갱신 이력 자동 기록</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th><th>관리 주기</th></tr></thead>
<tbody>
<tr><td>상태</td><td>사용중 / 만료 (만료일 기준 자동 판별)</td><td>자동</td></tr>
<tr><td>분야</td><td>업무공통, 개발S/W, 디자인, 설계S/W 등</td><td>등록 시</td></tr>
<tr><td>법인 / 부서</td><td>구매 법인 및 사용 부서</td><td>등록 시</td></tr>
<tr><td>제품명</td><td>소프트웨어 제품명</td><td>등록 시</td></tr>
<tr><td>구매일</td><td>최초 구매 일자</td><td>등록 시</td></tr>
<tr><td>시작일 / 만료일</td><td>구독 계약 기간</td><td>갱신 시 업데이트</td></tr>
<tr><td>금액</td><td>연간/월간 구독 비용</td><td>갱신 시</td></tr>
<tr><td>수량 / 사용가능</td><td>구매 수량 대비 배정 후 잔여 수량</td><td>배정 시</td></tr>
</tbody>
</table>
</section>
<div class="guide-tip">
<strong>💡 팁:</strong> 대시보드의 만료 예정 위젯을 정기적으로 확인하세요. 기간 변경 시 갱신 이력이 자동으로 기록됩니다.
</div>
`
},
{
id: 'perm-sw',
label: '🔑 영구SW',
content: `
<section class="guide-section">
<h3>영구 라이선스 소프트웨어 관리 가이드</h3>
<p class="guide-text">
1회 구매로 영구적으로 사용 가능한 소프트웨어입니다. 라이선스 키 관리 및 설치 현황 추적이 중요합니다.
</p>
</section>
<section class="guide-section">
<h3>관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">구매/도입</span><p class="step-desc">라이선스 구매 → 키 수령 → 시스템 등록</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">배포/설치</span><p class="step-desc">대상 PC에 설치 → 사용자 관리에서 매핑</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">현황 관리</span><p class="step-desc">잔여 수량 확인, 사용가능 수량 추적</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th></tr></thead>
<tbody>
<tr><td>상태</td><td>유지보수 유효 / 없음</td></tr>
<tr><td>분야</td><td>업무공통, 개발S/W, 디자인, 설계S/W 등</td></tr>
<tr><td>법인 / 부서</td><td>구매 법인 및 사용 부서</td></tr>
<tr><td>제품명</td><td>소프트웨어 제품명</td></tr>
<tr><td>구매일</td><td>최초 구매 일자</td></tr>
<tr><td>시작일 / 만료일</td><td>유지보수 계약 기간 (해당 시)</td></tr>
<tr><td>금액</td><td>라이선스 구매 비용</td></tr>
<tr><td>수량 / 사용가능</td><td>보유 라이선스 대비 잔여 수량</td></tr>
</tbody>
</table>
</section>
<div class="guide-warn">
<strong>⚠️ 주의:</strong> 영구 라이선스도 보유 수량을 초과하여 설치하면 저작권 위반이 됩니다. [사용자 관리] 버튼을 통해 실제 배정 현황을 파악하세요.
</div>
`
},
{
id: 'cloud',
label: '☁️ 클라우드',
content: `
<section class="guide-section">
<h3>클라우드 서비스 관리 가이드</h3>
<p class="guide-text">
AWS, Azure, GCP 등 클라우드 인프라 서비스와 Notion, Slack 등 SaaS 서비스를 관리합니다. 비용 최적화와 계정 관리가 핵심입니다.
</p>
</section>
<section class="guide-section">
<h3>관리 프로세스</h3>
<div class="flow-container">
<div class="flow-row">
<div class="flow-step">
<span class="step-number">1</span>
<div><span class="step-label">서비스 도입</span><p class="step-desc">서비스 선정, 비용 산정, 계정 생성</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">2</span>
<div><span class="step-label">등록/설정</span><p class="step-desc">시스템 등록, 결제수단 설정, 관리자 배정</p></div>
</div>
<span class="flow-arrow-right"><i data-lucide="chevron-right"></i></span>
<div class="flow-step">
<span class="step-number">3</span>
<div><span class="step-label">운영/비용관리</span><p class="step-desc">월별 청구액 추적, 계정 관리, 갱신</p></div>
</div>
</div>
</div>
</section>
<section class="guide-section">
<h3>주요 관리 항목 (테이블 컬럼)</h3>
<table class="guide-info-table">
<thead><tr><th>항목</th><th>설명</th></tr></thead>
<tbody>
<tr><td>플랫폼명</td><td>클라우드 플랫폼 이름 (예: AWS, Azure)</td></tr>
<tr><td>법인 / 담당부서</td><td>서비스 소속 법인 및 관리 부서</td></tr>
<tr><td>진행 프로젝트 (사용용도)</td><td>서비스 사용 목적</td></tr>
<tr><td>계정명 (관리자)</td><td>관리자 계정 또는 루트 계정 정보</td></tr>
<tr><td>결제수단</td><td>법인카드 또는 인보이스(월별송금)</td></tr>
<tr><td>결제일</td><td>월 결제일</td></tr>
<tr><td>당월 청구액</td><td>이번 달 결제 금액</td></tr>
<tr><td>비고</td><td>추가 메모 및 변경 이력</td></tr>
</tbody>
</table>
</section>
<div class="guide-tip">
<strong>💡 팁:</strong> 클라우드 비용은 매월 변동될 수 있으므로, 비고란을 활용하여 비용 변경 이력을 메모해 두면 예산 관리에 도움이 됩니다.
</div>
`
}
];
// ─── 가이드 모달 초기화 ───
export function initGuide() {
const body = document.body;
// 오버레이
const overlay = document.createElement('div');
overlay.className = 'guide-overlay';
overlay.id = 'guide-overlay';
// 모달
const modal = document.createElement('div');
modal.className = 'guide-modal';
modal.id = 'guide-modal';
// 탭 바 생성
const tabsHtml = GUIDE_TABS.map((tab, i) =>
`<div class="guide-tab ${i === 0 ? 'active' : ''}" data-guide-tab="${tab.id}">${tab.label}</div>`
).join('');
// 탭 패널 생성
const panelsHtml = GUIDE_TABS.map((tab, i) =>
`<div class="guide-tab-panel ${i === 0 ? 'active' : ''}" data-guide-panel="${tab.id}">${tab.content}</div>`
).join('');
modal.innerHTML = `
<div class="guide-header">
<h2><i data-lucide="book-open"></i> IT 자산관리 프로세스 가이드</h2>
<button class="btn-close-guide" id="btn-close-guide">
<i data-lucide="x"></i>
</button>
</div>
<div class="guide-tabs">${tabsHtml}</div>
<div class="guide-body">${panelsHtml}</div>
`;
overlay.appendChild(modal);
body.appendChild(overlay);
// ─── 이벤트 바인딩 ───
const openGuide = () => overlay.classList.add('active');
const closeGuide = () => overlay.classList.remove('active');
// 헤더 버튼
document.getElementById('btn-open-guide-header')?.addEventListener('click', openGuide);
// 오버레이 배경 클릭
overlay.addEventListener('click', (e) => {
if (e.target === overlay) closeGuide();
});
// 닫기 버튼
document.getElementById('btn-close-guide')?.addEventListener('click', closeGuide);
// 탭 전환
const tabs = modal.querySelectorAll('.guide-tab');
const panels = modal.querySelectorAll('.guide-tab-panel');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const targetId = tab.getAttribute('data-guide-tab');
tabs.forEach(t => t.classList.remove('active'));
panels.forEach(p => p.classList.remove('active'));
tab.classList.add('active');
modal.querySelector(`.guide-tab-panel[data-guide-panel="${targetId}"]`)?.classList.add('active');
});
});
// 아이콘 렌더링
createIcons({
icons: { BookOpen, X, ChevronDown, ChevronRight, RefreshCw }
});
}

View File

@@ -1,26 +1,26 @@
/**
* 모든 모달의 공통 기능 (닫기, ESC 처리, 배경 클릭 등)을 관리하는 베이스 모듈입니다.
*/
export function initBaseModal() {
const closeAllModals = () => {
const modals = document.querySelectorAll('.modal-overlay');
modals.forEach(modal => modal.classList.add('hidden'));
};
export function closeModals() {
const modals = document.querySelectorAll('.modal-overlay');
modals.forEach(modal => modal.classList.add('hidden'));
}
export function initBaseModal() {
// ESC 키로 닫기
window.addEventListener('keydown', (e) => {
if (e.key === 'Escape') closeAllModals();
if (e.key === 'Escape') closeModals();
});
// 배경(Overlay) 클릭 시 닫기 (동적 생성된 모달 대응을 위해 이벤트 위임 고려 가능하나 일단 단순 구현)
// 배경(Overlay) 클릭 시 닫기
document.addEventListener('click', (e) => {
const target = e.target as HTMLElement;
if (target.classList.contains('modal-overlay')) {
closeAllModals();
closeModals();
}
});
return { closeAllModals };
return { closeAllModals: closeModals };
}
/**

View File

@@ -1,317 +0,0 @@
import { state } from '../../core/state';
import { SoftwareAsset } from '../../core/excelHandler';
import { openModal } from './BaseModal';
import { createIcons, Save, X, Edit2, RotateCcw, History, Plus } from 'lucide';
const CLOUD_MODAL_HTML = `
<div id="cloud-asset-modal" class="modal-overlay hidden">
<div class="modal-content wide">
<div class="modal-header">
<h2 id="cloud-modal-title">클라우드 서비스 상세</h2>
<button id="btn-close-cloud-modal" class="btn-icon" aria-label="닫기"><i data-lucide="x"></i></button>
</div>
<div class="modal-body">
<div class="modal-body-split">
<div class="modal-form-area">
<form id="cloud-asset-form" class="grid-form">
<input type="hidden" id="cloud-asset-id" />
<div class="form-group"><label>플랫폼명</label><input type="text" id="cloud-플랫폼명" placeholder="예: AWS, Cafe24" required /></div>
<div class="form-group">
<label>담당법인</label>
<select id="cloud-법인" required>
<option value="한맥">한맥</option><option value="삼안">삼안</option><option value="바론">바론</option>
</select>
</div>
<div class="form-group" style="grid-column: span 2;"><label>사용용도(프로젝트/제품명)</label><input type="text" id="cloud-제품명" required /></div>
<div class="form-group"><label>담당부서</label><input type="text" id="cloud-부서" /></div>
<div class="form-group"><label>계정명(이메일)</label><input type="text" id="cloud-계정명" /></div>
<div class="form-group"><label>결제수단</label>
<select id="cloud-결제수단">
<option value="">선택안함</option>
<option value="법인카드">법인카드</option>
<option value="인보이스">인보이스</option>
</select>
</div>
<div class="form-group"><label>연결카드번호(뒷4자리)</label><input type="text" id="cloud-연결카드번호" placeholder="1234" /></div>
<div class="form-group"><label>결제일(기준일)</label><input type="number" min="1" max="31" id="cloud-결제일" placeholder="15" /></div>
<div class="form-group"><label>당월 청구액(원)</label><input type="text" id="cloud-당월청구액" placeholder="0" oninput="this.value = this.value.replace(/[^0-9]/g, '') ? Number(this.value.replace(/[^0-9]/g, '')).toLocaleString() : ''" /></div>
<div class="form-group" style="grid-column: span 2;"><label>비고</label><input type="text" id="cloud-비고" /></div>
</form>
</div>
<div class="modal-history-area">
<div class="history-header" style="display:flex; justify-content:space-between; align-items:center;">
<h3><i data-lucide="history" style="width:16px; height:16px;"></i> 업데이트 내역</h3>
<button type="button" id="btn-open-cloud-update" class="btn btn-outline btn-sm"><i data-lucide="plus" style="width:14px;height:14px;"></i> 내역 추가</button>
</div>
<div id="cloud-history-list" class="history-timeline">
<div class="empty-history">내역이 없습니다.</div>
</div>
</div>
</div>
</div>
<div class="modal-footer" style="justify-content: space-between;">
<button id="btn-delete-cloud-asset" class="btn btn-outline btn-danger">삭제</button>
<div class="footer-actions">
<button id="btn-revert-cloud-edit" class="btn btn-outline hidden">취소</button>
<button id="btn-close-cloud-footer" class="btn btn-outline">닫기</button>
<button id="btn-save-cloud-asset" class="btn btn-primary">수정</button>
</div>
</div>
</div>
</div>
<div id="cloud-update-modal" class="modal-overlay hidden" style="z-index: 1100;">
<div class="modal-content" style="max-width: 400px;">
<div class="modal-header">
<h2>클라우드 결제/이력 업데이트</h2>
<button id="btn-close-cloud-update" class="btn-icon"><i data-lucide="x"></i></button>
</div>
<div class="modal-body">
<div class="grid-form" style="grid-template-columns: 1fr;">
<div class="form-group">
<label>업데이트 일자</label>
<input type="date" id="cloud-update-date" />
</div>
<div class="form-group">
<label>청구 금액(원)</label>
<input type="text" id="cloud-update-cost" oninput="this.value = this.value.replace(/[^0-9]/g, '') ? Number(this.value.replace(/[^0-9]/g, '')).toLocaleString() : ''" placeholder="ex) 150,000" />
</div>
<div class="form-group">
<label>상세 내용 (메모)</label>
<input type="text" id="cloud-update-note" placeholder="예: 트래픽 초과로 인한 요금 증가" />
</div>
</div>
</div>
<div class="modal-footer">
<div></div>
<div class="footer-actions">
<button id="btn-cancel-cloud-update" class="btn btn-outline">취소</button>
<button id="btn-save-cloud-update" class="btn btn-primary">반영하기</button>
</div>
</div>
</div>
</div>
`;
export let currentCloudAsset: SoftwareAsset | null = null;
export let isCloudEditMode = false;
export function setCloudEditMode(edit: boolean) {
isCloudEditMode = edit;
const form = document.getElementById('cloud-asset-form') as HTMLFormElement;
const btnSave = document.getElementById('btn-save-cloud-asset') as HTMLButtonElement;
const btnRevert = document.getElementById('btn-revert-cloud-edit') as HTMLButtonElement;
const btnClose = document.getElementById('btn-close-cloud-footer') as HTMLButtonElement;
if (edit) {
form.classList.add('is-edit-mode');
form.classList.remove('is-view-mode');
btnSave.textContent = '저장';
btnRevert.classList.remove('hidden');
btnClose.classList.add('hidden');
Array.from(form.elements).forEach((el: any) => el.disabled = false);
} else {
form.classList.add('is-view-mode');
form.classList.remove('is-edit-mode');
btnSave.textContent = '수정';
btnRevert.classList.add('hidden');
btnClose.classList.remove('hidden');
Array.from(form.elements).forEach((el: any) => el.disabled = true);
if (currentCloudAsset) fillCloudFormData(currentCloudAsset);
}
}
export function fillCloudFormData(asset: SoftwareAsset) {
(document.getElementById('cloud-asset-id') as HTMLInputElement).value = asset.id;
(document.getElementById('cloud-플랫폼명') as HTMLInputElement).value = asset. || '';
(document.getElementById('cloud-법인') as HTMLSelectElement).value = asset. || '한맥';
(document.getElementById('cloud-제품명') as HTMLInputElement).value = asset. || '';
(document.getElementById('cloud-부서') as HTMLInputElement).value = asset. || '';
(document.getElementById('cloud-계정명') as HTMLInputElement).value = asset. || '';
(document.getElementById('cloud-결제수단') as HTMLSelectElement).value = asset. || '';
(document.getElementById('cloud-연결카드번호') as HTMLInputElement).value = asset. || '';
(document.getElementById('cloud-결제일') as HTMLInputElement).value = asset. || '';
const billing = asset. ? asset..replace(/[^0-9]/g, '') : '';
(document.getElementById('cloud-당월청구액') as HTMLInputElement).value = billing ? Number(billing).toLocaleString() : '';
(document.getElementById('cloud-비고') as HTMLInputElement).value = asset. || '';
document.getElementById('btn-open-cloud-update')!.style.display = 'flex';
renderCloudHistory(asset.id);
}
function renderCloudHistory(assetId: string) {
const historyList = document.getElementById('cloud-history-list');
if (!historyList) return;
if (!state.masterData.logs) state.masterData.logs = [];
const logs = state.masterData.logs
.filter(l => l.assetId === assetId)
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
if (logs.length === 0) {
historyList.innerHTML = '<div class="empty-history">업데이트 내역이 없습니다.</div>';
return;
}
historyList.innerHTML = logs.map(log => `
<div class="history-item">
<div class="history-date">${log.date}</div>
<div class="history-user">작업자: ${log.user}</div>
<div class="history-details">${log.details.replace(/\n/g, '<br>')}</div>
</div>
`).join('');
createIcons({ icons: { X, History, Plus } });
}
export function initCloudModal(renderContent: () => void, closeModals: () => void) {
if (!document.getElementById('cloud-asset-modal')) {
document.body.insertAdjacentHTML('beforeend', CLOUD_MODAL_HTML);
}
const form = document.getElementById('cloud-asset-form') as HTMLFormElement;
const btnRevert = document.getElementById('btn-revert-cloud-edit');
const btnSave = document.getElementById('btn-save-cloud-asset');
const btnDelete = document.getElementById('btn-delete-cloud-asset');
document.getElementById('btn-close-cloud-modal')?.addEventListener('click', closeModals);
document.getElementById('btn-close-cloud-footer')?.addEventListener('click', closeModals);
btnRevert?.addEventListener('click', (e) => {
e.preventDefault();
setCloudEditMode(false);
});
btnSave?.addEventListener('click', (e) => {
e.preventDefault();
if (!isCloudEditMode) {
setCloudEditMode(true);
return;
}
if (!form.checkValidity()) { form.reportValidity(); return; }
const id = (document.getElementById('cloud-asset-id') as HTMLInputElement).value;
const billingRaw = (document.getElementById('cloud-당월청구액') as HTMLInputElement).value.replace(/[^0-9]/g, '');
const newAsset: SoftwareAsset = {
id: id || Math.random().toString(36).substring(2, 9),
type: '클라우드',
: (document.getElementById('cloud-플랫폼명') as HTMLInputElement).value,
: (document.getElementById('cloud-법인') as HTMLSelectElement).value,
: (document.getElementById('cloud-제품명') as HTMLInputElement).value,
: (document.getElementById('cloud-부서') as HTMLInputElement).value,
: (document.getElementById('cloud-계정명') as HTMLInputElement).value,
: (document.getElementById('cloud-결제수단') as HTMLSelectElement).value,
: (document.getElementById('cloud-연결카드번호') as HTMLInputElement).value,
: (document.getElementById('cloud-결제일') as HTMLInputElement).value,
당월청구액: billingRaw,
: (document.getElementById('cloud-비고') as HTMLInputElement).value,
: '', : '', 수량: 1, : ''
};
if (id) {
const idx = state.masterData.sw.findIndex(a => a.id === id);
if (idx !== -1) state.masterData.sw[idx] = newAsset;
} else {
state.masterData.sw.push(newAsset);
const now = new Date();
state.masterData.logs = state.masterData.logs || [];
state.masterData.logs.push({
id: Math.random().toString(36).substring(2, 9),
assetId: newAsset.id,
date: `${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`,
user: '관리자',
details: '신규 등록'
});
}
closeModals();
renderContent();
});
btnDelete?.addEventListener('click', (e) => {
e.preventDefault();
const id = (document.getElementById('cloud-asset-id') as HTMLInputElement).value;
if (confirm('클라우드 자산을 삭제하시겠습니까?')) {
state.masterData.sw = state.masterData.sw.filter(a => a.id !== id);
closeModals();
renderContent();
}
});
// 클라우드 업데이트 (이력) 모달 로직
const updateModal = document.getElementById('cloud-update-modal')!;
document.getElementById('btn-open-cloud-update')?.addEventListener('click', () => {
updateModal.classList.remove('hidden');
(document.getElementById('cloud-update-date') as HTMLInputElement).value = new Date().toISOString().split('T')[0];
(document.getElementById('cloud-update-cost') as HTMLInputElement).value = '';
(document.getElementById('cloud-update-note') as HTMLInputElement).value = '';
});
const closeUpdateModal = () => updateModal.classList.add('hidden');
document.getElementById('btn-close-cloud-update')?.addEventListener('click', closeUpdateModal);
document.getElementById('btn-cancel-cloud-update')?.addEventListener('click', closeUpdateModal);
document.getElementById('btn-save-cloud-update')?.addEventListener('click', () => {
const id = (document.getElementById('cloud-asset-id') as HTMLInputElement).value;
if (!id) return;
const date = (document.getElementById('cloud-update-date') as HTMLInputElement).value;
const costRaw = (document.getElementById('cloud-update-cost') as HTMLInputElement).value.replace(/[^0-9]/g, '');
const note = (document.getElementById('cloud-update-note') as HTMLInputElement).value;
if (!date) return alert('업데이트 일자를 입력하세요.');
let details = '결제/상태 업데이트';
if (costRaw) details += ` (비용: ₩ ${Number(costRaw).toLocaleString()})`;
if (note) details += `\n메모: ${note}`;
state.masterData.logs = state.masterData.logs || [];
state.masterData.logs.push({
id: Math.random().toString(36).substring(2, 9),
assetId: id,
date,
user: '관리자',
details
});
// 금액 업데이트 반영
if (costRaw) {
const idx = state.masterData.sw.findIndex(a => a.id === id);
if (idx !== -1) {
state.masterData.sw[idx]. = costRaw;
(document.getElementById('cloud-당월청구액') as HTMLInputElement).value = Number(costRaw).toLocaleString();
}
}
closeUpdateModal();
renderCloudHistory(id);
renderContent();
});
createIcons({ icons: { Save, X, Edit2, RotateCcw, History, Plus } });
}
export function openCloudModal(asset?: SoftwareAsset) {
currentCloudAsset = asset || null;
const form = document.getElementById('cloud-asset-form') as HTMLFormElement;
const deleteBtn = document.getElementById('btn-delete-cloud-asset')!;
openModal('cloud-asset-modal');
form.reset();
if (asset) {
document.getElementById('cloud-modal-title')!.textContent = '클라우드 서비스 상세';
deleteBtn.style.display = 'block';
fillCloudFormData(asset);
setCloudEditMode(false);
} else {
document.getElementById('cloud-modal-title')!.textContent = '신규 클라우드 서비스 등록';
deleteBtn.style.display = 'none';
(document.getElementById('cloud-asset-id') as HTMLInputElement).value = '';
document.getElementById('btn-open-cloud-update')!.style.display = 'none';
renderCloudHistory('');
setCloudEditMode(true);
}
createIcons({ icons: { History, Plus } });
}

View File

@@ -98,7 +98,7 @@ export function openSwUsageDetail(title: string, list: SoftwareAsset[]) {
thead.innerHTML = `<tr><th>No</th><th>법인</th><th>제품명</th><th>수량</th><th>사용중</th><th>사용가능</th></tr>`;
tbody.innerHTML = '';
list.forEach((sw, idx) => {
const assigned = state.masterData.swUsers.filter(u => u.swId === sw.id).length;
const assigned = state.masterData.swUsers.filter(u => u.sw_id === sw.id).length;
const tr = document.createElement('tr');
tr.innerHTML = `<td>${idx+1}</td><td>${sw.}</td><td>${sw.}</td><td>${sw.}</td><td>${assigned}</td><td>${Number(sw.) - assigned}</td>`;
tbody.appendChild(tr);

View File

@@ -1,7 +1,7 @@
import { state, saveHardwareAsset, deleteHardwareAsset } from '../../core/state';
import { HardwareAsset, MasterAssetData, HardwareLog } from '../../core/excelHandler';
import { HardwareAsset, MasterAssetData } from '../../core/excelHandler';
import { openModal, closeModals } from './BaseModal';
import { createIcons, Paperclip, History, Plus, X, Save, Edit2, RotateCcw } from 'lucide';
import { createIcons, Paperclip } from 'lucide';
import { CORP_LIST, ORG_LIST, HW_TYPE_LIST, LOCATION_DATA, TYPE_PREFIX_MAP } from './SharedData';
import {
generateOptionsHTML,
@@ -16,8 +16,6 @@ import {
let currentAsset: HardwareAsset | null = null;
let isEditMode = false;
const STATUS_LIST = ['대여중', '보관중', '수리중', '기타'];
const HW_MODAL_HTML = `
<div id="hw-asset-modal" class="modal-overlay hidden">
<div class="modal-content wide">
@@ -26,162 +24,162 @@ const HW_MODAL_HTML = `
<button id="btn-close-hw-modal" class="btn-icon" aria-label="닫기"><i data-lucide="x"></i></button>
</div>
<div class="modal-body">
<div class="modal-body-split">
<div class="modal-form-area">
<form id="hw-asset-form" class="grid-form">
<input type="hidden" id="hw-asset-id" />
<input type="hidden" id="hw-asset-type" />
<form id="hw-asset-form" class="grid-form">
<input type="hidden" id="hw-asset-id" />
<input type="hidden" id="hw-asset-type" />
<!-- Group 1: 기본 정보 (Identity) -->
<div class="form-section-title">기본 정보 (Identity)</div>
<div class="form-group">
<label for="hw-법인">구매법인</label>
<select id="hw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
</div>
<div class="form-group">
<label for="hw-자산코드">자산번호/코드</label>
<div style="display:flex; gap:0.5rem;">
<input type="text" id="hw-자산코드" readonly placeholder="번호 생성을 클릭하세요" required />
<button type="button" id="btn-generate-hw-code" class="btn btn-outline btn-sm hidden" style="white-space:nowrap;">생성</button>
</div>
</div>
<div class="form-group">
<label for="hw-현사용조직">현 사용조직</label>
<select id="hw-현사용조직">${generateOptionsHTML(ORG_LIST)}</select>
</div>
<div class="form-group" id="hw-이전사용조직-group">
<label for="hw-이전사용조직">이전 사용조직</label>
<input type="text" id="hw-이전사용조직" readonly />
</div>
<div class="form-group">
<label for="hw-유형">유형</label>
<select id="hw-유형">${generateOptionsHTML(HW_TYPE_LIST)}</select>
</div>
<div class="form-group" id="hw-상세용도-group" style="display:none;">
<label for="hw-상세용도">상세용도</label>
<select id="hw-상세용도">
<option value="">선택</option>
<option value="서버">서버</option>
<option value="개인PC">개인PC</option>
</select>
</div>
<!-- 운영 및 상태 관리 (전산비품/모바일 전용) -->
<div class="form-section-title op-only">운영 및 상태 관리</div>
<div class="form-group op-only">
<label for="hw-보관위치">보관위치</label>
<input type="text" id="hw-보관위치" placeholder="예: 7층 비품창고" />
</div>
<div class="form-group op-only">
<label for="hw-현재상태">현재상태</label>
<select id="hw-현재상태">${generateOptionsHTML(STATUS_LIST)}</select>
</div>
<!-- 네트워크 및 서버 정보 -->
<div class="form-section-title server-only" id="hw-network-title">네트워크 정보 (Connectivity)</div>
<div class="form-group server-only" id="hw-ip-group">
<label for="hw-IP주소">IP 주소 1</label>
<input type="text" id="hw-IP주소" />
</div>
<div class="form-group server-only" id="hw-ip2-group">
<label for="hw-IP2">IP 주소 2</label>
<input type="text" id="hw-IP2" />
</div>
<div class="form-group server-only" id="hw-remote-group">
<label for="hw-원격접속">원격 도구</label>
<input type="text" id="hw-원격접속" />
</div>
<div class="form-group server-only" id="hw-server-id-group">
<label for="hw-서버ID">서버 ID</label>
<input type="text" id="hw-서버ID" />
</div>
<div class="form-group server-only" id="hw-server-pw-group">
<label for="hw-서버PW">서버 PW</label>
<input type="text" id="hw-서버PW" />
</div>
<div class="form-group non-server" id="hw-ip-non-server-group">
<label for="hw-IP주소-non-server">IP 주소</label>
<input type="text" id="hw-IP주소-non-server" />
</div>
<!-- 시스템 사양 -->
<div class="form-section-title" id="hw-spec-title">시스템 사양 (Specifications)</div>
<div class="form-group" id="hw-model-group">
<label for="hw-모델명">모델명</label>
<input type="text" id="hw-모델명" />
</div>
<div class="form-group" id="hw-os-group">
<label for="hw-OS">운영체제 (OS)</label>
<input type="text" id="hw-OS" />
</div>
<div class="form-group" id="hw-cpu-group">
<label for="hw-CPU">CPU 사양</label>
<input type="text" id="hw-CPU" />
</div>
<div class="form-group" id="hw-ram-group">
<label for="hw-RAM">RAM 용량</label>
<input type="text" id="hw-RAM" />
</div>
<div class="form-group" id="hw-ssd1-group">
<label for="hw-SSD1">Storage 1 (SSD/HDD)</label>
<input type="text" id="hw-SSD1" />
</div>
<div class="form-group" id="hw-ssd2-group">
<label for="hw-SSD2">Storage 2 (SSD/HDD)</label>
<input type="text" id="hw-SSD2" />
</div>
<div class="form-group server-only" id="hw-monitoring-group">
<label for="hw-모니터링">모니터링 여부</label>
<input type="text" id="hw-모니터링" />
</div>
<div class="form-group full-width non-server" id="hw-hwspec-group">
<label for="hw-HW사양">사양 상세</label>
<textarea id="hw-HW사양" rows="2"></textarea>
</div>
<!-- 설치 위치 및 관리 -->
<div class="form-section-title" id="hw-op-title">설치 위치 및 관리</div>
<div class="form-group loc-standard">
<label for="hw-위치-빌딩">설치위치 (건물)</label>
<select id="hw-위치-빌딩">${generateOptionsHTML(Object.keys(LOCATION_DATA))}</select>
</div>
<div class="form-group loc-standard">
<label for="hw-위치-상세">상세 위치</label>
<select id="hw-위치-상세"><option value="">선택</option></select>
</div>
<div class="form-group" id="hw-위치-기타-group" style="display:none;">
<label for="hw-위치-기타">직접 입력 (기타)</label>
<input type="text" id="hw-위치-기타" />
</div>
<div class="form-group">
<label for="hw-담당자_정">담당자(정)</label>
<input type="text" id="hw-담당자_정" />
</div>
<div class="form-group">
<label for="hw-구매일">구매일</label>
<input type="text" id="hw-구매일" />
</div>
<div class="form-group">
<label for="hw-금액">금액</label>
<input type="text" id="hw-금액" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')" />
</div>
<div class="form-group full-width">
<label for="hw-비고">비고</label>
<textarea id="hw-비고" rows="2"></textarea>
</div>
</form>
<!-- Group 1: 기본 정보 (Identity) -->
<div class="form-section-title">기본 정보 (Identity)</div>
<div class="form-group">
<label for="hw-법인">구매법인</label>
<select id="hw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
</div>
<div class="modal-history-area">
<div class="history-header">
<h3><i data-lucide="history" style="width:16px; height:16px;"></i> 분출 및 변경 이력</h3>
<button type="button" id="btn-add-hw-log" class="btn btn-outline btn-sm">
내역 추가 <i data-lucide="plus" style="width:14px; height:14px;"></i>
</button>
<div class="form-group">
<label for="hw-자산코드">자산번호/코드</label>
<div style="display:flex; gap:0.5rem;">
<input type="text" id="hw-자산코드" readonly placeholder="번호 생성을 클릭하세요" required />
<button type="button" id="btn-generate-hw-code" class="btn btn-outline" style="white-space:nowrap; padding:0 10px; font-size:0.8rem;">번호 생성</button>
</div>
<div id="hw-history-list" class="history-timeline"></div>
</div>
</div>
<div class="form-group">
<label for="hw-현사용조직">현 사용조직</label>
<select id="hw-현사용조직">${generateOptionsHTML(ORG_LIST)}</select>
</div>
<div class="form-group" id="hw-이전사용조직-group">
<label for="hw-이전사용조직">이전 사용조직</label>
<input type="text" id="hw-이전사용조직" readonly />
</div>
<div class="form-group" id="hw-유형-group">
<label for="hw-유형">유형</label>
<select id="hw-유형">${generateOptionsHTML(HW_TYPE_LIST)}</select>
</div>
<div class="form-group" id="hw-상세용도-group" style="display:none;">
<label for="hw-상세용도">상세용도</label>
<select id="hw-상세용도">
<option value="">선택</option>
<option value="서버">서버</option>
<option value="개인PC">개인PC</option>
</select>
</div>
<div class="form-group server-only">
<label for="hw-용도">용도</label>
<input type="text" id="hw-용도" />
</div>
<div class="form-group server-only">
<label for="hw-상세">상세 내용</label>
<input type="text" id="hw-상세" />
</div>
<div class="form-group non-server" id="hw-명칭-group">
<label for="hw-명칭">명칭</label>
<input type="text" id="hw-명칭" />
</div>
<div class="form-group full-width server-only">
<label for="hw-비고">비고</label>
<input type="text" id="hw-비고" />
</div>
<!-- Group 2: 네트워크 정보 (Connectivity) -->
<div class="form-section-title server-only" id="hw-network-title">네트워크 정보 (Connectivity)</div>
<div class="form-group server-only" id="hw-ip-group">
<label for="hw-IP주소">IP 주소 1</label>
<input type="text" id="hw-IP주소" />
</div>
<div class="form-group server-only" id="hw-ip2-group">
<label for="hw-IP2">IP 주소 2</label>
<input type="text" id="hw-IP2" />
</div>
<div class="form-group server-only" id="hw-remote-group">
<label for="hw-원격접속">원격 도구 (Anydesk/Chrome 등)</label>
<input type="text" id="hw-원격접속" />
</div>
<div class="form-group server-only" id="hw-server-id-group">
<label for="hw-서버ID">서버 ID</label>
<input type="text" id="hw-서버ID" />
</div>
<div class="form-group server-only" id="hw-server-pw-group">
<label for="hw-서버PW">서버 PW</label>
<input type="text" id="hw-서버PW" />
</div>
<div class="form-group non-server" id="hw-ip-non-server-group">
<label for="hw-IP주소-non-server">IP 주소</label>
<input type="text" id="hw-IP주소-non-server" />
</div>
<!-- Group 3: 시스템 사양 (Specifications) -->
<div class="form-section-title" id="hw-spec-title">시스템 사양 (Specifications)</div>
<div class="form-group" id="hw-model-group">
<label for="hw-모델명">모델명</label>
<input type="text" id="hw-모델명" />
</div>
<div class="form-group" id="hw-os-group">
<label for="hw-OS">운영체제 (OS)</label>
<input type="text" id="hw-OS" />
</div>
<div class="form-group" id="hw-cpu-group">
<label for="hw-CPU">CPU 사양</label>
<input type="text" id="hw-CPU" />
</div>
<div class="form-group" id="hw-ram-group">
<label for="hw-RAM">RAM 용량</label>
<input type="text" id="hw-RAM" />
</div>
<div class="form-group" id="hw-ssd1-group">
<label for="hw-SSD1">Storage 1 (SSD/HDD)</label>
<input type="text" id="hw-SSD1" />
</div>
<div class="form-group" id="hw-ssd2-group">
<label for="hw-SSD2">Storage 2 (SSD/HDD)</label>
<input type="text" id="hw-SSD2" />
</div>
<div class="form-group server-only" id="hw-monitoring-group">
<label for="hw-모니터링">모니터링 여부</label>
<input type="text" id="hw-모니터링" />
</div>
<div class="form-group full-width non-server" id="hw-hwspec-group">
<label for="hw-HW사양">H/W 사양 상세</label>
<textarea id="hw-HW사양" rows="2"></textarea>
</div>
<!-- Group 4: 관리 및 운영 (Operation) -->
<div class="form-section-title" id="hw-op-title">관리 및 운영 (Operation)</div>
<div class="form-group hw-location-field">
<label for="hw-위치-빌딩">설치위치 (건물)</label>
<select id="hw-위치-빌딩">${generateOptionsHTML(Object.keys(LOCATION_DATA))}</select>
</div>
<div class="form-group hw-location-field">
<label for="hw-위치-상세">상세 위치</label>
<select id="hw-위치-상세">
<option value="">건물을 먼저 선택하세요</option>
</select>
</div>
<div class="form-group" id="hw-위치-기타-group" style="display:none;">
<label for="hw-위치-기타">직접 입력 (기타)</label>
<input type="text" id="hw-위치-기타" placeholder="상세 위치를 입력하세요" />
</div>
<div class="form-group">
<label for="hw-담당자_정">담당자 (정)</label>
<input type="text" id="hw-담당자_정" />
</div>
<div class="form-group">
<label for="hw-담당자_부">담당자 (부)</label>
<input type="text" id="hw-담당자_부" />
</div>
<div class="form-group non-server" id="hw-purchase-date-group">
<label for="hw-구매일">구매일</label>
<input type="text" id="hw-구매일" />
</div>
<div class="form-group non-server" id="hw-price-group">
<label for="hw-금액">금액</label>
<input type="text" id="hw-금액" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/\\\\B(?=(\\\\d{3})+(?!\d))/g, ',')" />
</div>
<div class="form-group full-width">
<label>품의서 (파일 증빙)</label>
<div style="display:flex; align-items:center; gap:0.5rem;">
<input type="file" id="hw-품의서" />
<span id="hw-품의서명" style="font-size:0.75rem; color:var(--text-light)"></span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button id="btn-delete-hw-asset" class="btn btn-outline btn-danger">삭제</button>
@@ -193,174 +191,118 @@ const HW_MODAL_HTML = `
</div>
</div>
</div>
<!-- 이력 추가 모달 -->
<div id="hw-log-modal" class="modal-overlay hidden" style="z-index: 1100;">
<div class="modal-content" style="max-width: 400px;">
<div class="modal-header">
<h2>이력 추가</h2>
<button id="btn-close-hw-log" class="btn-icon"><i data-lucide="x"></i></button>
</div>
<div class="modal-body">
<div class="grid-form" style="grid-template-columns: 1fr;">
<div class="form-group">
<label>날짜</label>
<input type="date" id="new-hw-log-date" />
</div>
<div class="form-group">
<label>변경/분출 내용</label>
<textarea id="new-hw-log-details" rows="3" placeholder="예: [분출] 기술팀 홍길동, [수리] 배터리 교체 등"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<div></div>
<div class="footer-actions">
<button id="btn-cancel-hw-log" class="btn btn-outline">취소</button>
<button id="btn-confirm-hw-log" class="btn btn-primary">추가</button>
</div>
</div>
</div>
</div>
`;
function renderHwHistory(assetId: string) {
const container = document.getElementById('hw-history-list');
if (!container) return;
const logs = (state.masterData.logs || []).filter(l => l.assetId === assetId);
if (logs.length === 0) {
container.innerHTML = '<div class="empty-history">기록된 이력이 없습니다.</div>';
return;
}
container.innerHTML = logs.map(l => `
<div class="history-item">
<div class="history-date">${l.date}</div>
<div class="history-user">${l.user}</div>
<div class="history-details">${l.details}</div>
</div>
`).join('');
}
function applyTypeSpecificUI(type: string) {
const detailPurpose = getFieldValue('hw-상세용도');
const upperType = (type || '').toUpperCase();
const groups: Record<string, HTMLElement | null> = {
detailPurpose: document.getElementById('hw-상세용도-group'),
networkTitle: document.getElementById('hw-network-title'),
specTitle: document.getElementById('hw-spec-title'),
opTitle: document.getElementById('hw-op-title'),
model: document.getElementById('hw-model-group'),
os: document.getElementById('hw-os-group'),
cpu: document.getElementById('hw-cpu-group'),
ram: document.getElementById('hw-ram-group'),
ssd1: document.getElementById('hw-ssd1-group'),
ssd2: document.getElementById('hw-ssd2-group'),
hwSpec: document.getElementById('hw-hwspec-group'),
monitoring: document.getElementById('hw-monitoring-group')
};
const serverOnly = document.querySelectorAll('.server-only');
const nonServer = document.querySelectorAll('.non-server');
const opOnly = document.querySelectorAll('.op-only');
const standardLoc = document.querySelectorAll('.loc-standard');
// 1. 초기화 (모두 숨김 및 라벨 원복)
serverOnly.forEach(el => (el as HTMLElement).style.display = 'none');
nonServer.forEach(el => (el as HTMLElement).style.display = 'none');
opOnly.forEach(el => (el as HTMLElement).style.display = 'none');
standardLoc.forEach(el => (el as HTMLElement).style.display = 'flex');
Object.values(groups).forEach(g => { if (g) g.style.display = 'none'; });
const osLabel = document.querySelector('label[for="hw-OS"]') as HTMLElement;
const ramLabel = document.querySelector('label[for="hw-RAM"]') as HTMLElement;
const modelLabel = document.querySelector('label[for="hw-모델명"]') as HTMLElement;
if (osLabel) osLabel.innerText = '운영체제 (OS)';
if (ramLabel) ramLabel.innerText = 'RAM 용량';
if (modelLabel) modelLabel.innerText = '모델명';
// 2. 분류 판별
const isMobileGroup = ['모바일', '태블릿', '휴대폰'].some(t => upperType.includes(t));
const isEquipGroup = ['CPU', 'RAM', 'HDD', 'GPU'].some(t => upperType.includes(t)) || upperType.includes('비품');
const isOpType = isMobileGroup || isEquipGroup;
const isPcType = upperType === 'PC' || upperType === '개인PC' || upperType === '노트북';
// 3. 레이아웃 적용
if (groups.opTitle) groups.opTitle.style.display = 'flex';
if (isOpType) {
opOnly.forEach(el => (el as HTMLElement).style.display = 'flex');
standardLoc.forEach(el => (el as HTMLElement).style.display = 'none');
if (groups.specTitle) groups.specTitle.style.display = 'flex';
if (groups.model) groups.model.style.display = 'flex';
// 특정 부품 유형에 따른 라벨 및 필드 제어
const isCpuGpu = ['CPU', 'GPU'].some(t => upperType.includes(t));
const isRamHdd = ['RAM', 'HDD'].some(t => upperType.includes(t));
if (isCpuGpu) {
if (groups.os && osLabel) {
osLabel.innerText = '출시연월';
groups.os.style.display = 'flex';
}
} else if (isRamHdd) {
if (groups.ram && ramLabel) {
ramLabel.innerText = '용량';
groups.ram.style.display = 'flex';
}
// HDD인 경우 모델명 라벨을 S/N으로 변경
if (upperType.includes('HDD') && modelLabel) {
modelLabel.innerText = 'S/N';
}
} else {
if (groups.hwSpec) groups.hwSpec.style.display = 'flex';
}
}
else if (isPcType) {
if (groups.detailPurpose) groups.detailPurpose.style.display = 'flex';
if (groups.specTitle) groups.specTitle.style.display = 'flex';
if (detailPurpose === '서버') {
serverOnly.forEach(el => (el as HTMLElement).style.display = 'flex');
if (groups.networkTitle) groups.networkTitle.style.display = 'flex';
['model', 'os', 'cpu', 'ram', 'ssd1', 'ssd2', 'monitoring'].forEach(k => {
if (groups[k]) groups[k]!.style.display = 'flex';
});
} else {
nonServer.forEach(el => (el as HTMLElement).style.display = 'flex');
['model', 'os', 'cpu', 'ram', 'ssd1', 'ssd2', 'hwSpec'].forEach(k => {
if (groups[k]) groups[k]!.style.display = 'flex';
});
}
}
else if (upperType.includes('서버') || ['스토리지', 'NAS', 'DAS'].includes(upperType)) {
serverOnly.forEach(el => (el as HTMLElement).style.display = 'flex');
if (groups.networkTitle) groups.networkTitle.style.display = 'flex';
if (groups.specTitle) groups.specTitle.style.display = 'flex';
['model', 'os', 'cpu', 'ram', 'ssd1', 'ssd2', 'monitoring'].forEach(k => {
if (groups[k]) groups[k]!.style.display = 'flex';
});
}
}
export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view') {
export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' | 'edit' = 'view') {
currentAsset = asset;
const modal = document.getElementById('hw-asset-modal')!;
// 1. 잠금 상태 통합 제어 (데이터 유무가 아닌 호출 mode에만 의존)
setEditLock('hw-asset-form', mode, {
saveBtnId: 'btn-save-hw-asset',
revertBtnId: 'btn-revert-hw-edit',
generateBtnId: 'btn-generate-hw-code'
});
isEditMode = (mode === 'add');
isEditMode = (mode === 'add' || mode === 'edit');
// 2. 데이터 바인딩
fillHwFormData(asset);
applyTypeSpecificUI(asset.type);
renderHwHistory(asset.id);
modal.classList.remove('hidden');
createIcons({ icons: { X, Save, Edit2, RotateCcw, History, Plus, Paperclip } });
applyTypeSpecificUI(asset.type);
createIcons({ icons: { Paperclip } });
}
function applyTypeSpecificUI(type: string) {
const detailPurpose = getFieldValue('hw-상세용도');
const form = document.getElementById('hw-asset-form') as HTMLFormElement;
if (!form) return;
const serverOnly = document.querySelectorAll('.server-only');
const nonServer = document.querySelectorAll('.non-server');
const locationFields = document.querySelectorAll('.hw-location-field');
const groups: Record<string, HTMLElement | null> = {
detailPurpose: document.getElementById('hw-상세용도-group'),
model: document.getElementById('hw-model-group'),
ip: document.getElementById('hw-ip-group'),
ip2: document.getElementById('hw-ip2-group'),
remote: document.getElementById('hw-remote-group'),
os: document.getElementById('hw-os-group'),
cpu: document.getElementById('hw-cpu-group'),
ram: document.getElementById('hw-ram-group'),
ssd1: document.getElementById('hw-ssd1-group'),
ssd2: document.getElementById('hw-ssd2-group'),
monitoring: document.getElementById('hw-monitoring-group'),
serverId: document.getElementById('hw-server-id-group'),
serverPw: document.getElementById('hw-server-pw-group'),
hwSpec: document.getElementById('hw-hwspec-group'),
ipNonServer: document.getElementById('hw-ip-non-server-group'),
type: document.getElementById('hw-유형-group'),
networkTitle: document.getElementById('hw-network-title'),
specTitle: document.getElementById('hw-spec-title'),
opTitle: document.getElementById('hw-op-title')
};
// 1. 초기화 (모든 유동 섹션 숨김)
serverOnly.forEach(el => (el as HTMLElement).style.display = 'none');
nonServer.forEach(el => (el as HTMLElement).style.display = 'none');
locationFields.forEach(el => (el as HTMLElement).style.display = 'none');
Object.values(groups).forEach(g => { if (g) g.style.display = 'none'; });
if (groups.type) groups.type.style.display = 'flex';
if (groups.opTitle) groups.opTitle.style.display = 'flex';
// 2. 유형별 정밀 규칙 적용 (사용자 정의 100% 일치)
if (type === '서버') {
serverOnly.forEach(el => (el as HTMLElement).style.display = 'flex');
locationFields.forEach(el => (el as HTMLElement).style.display = 'flex');
Object.values(groups).forEach(g => { if (g) g.style.display = 'flex'; });
}
else if (['스토리지', 'NAS', 'DAS'].includes(type)) {
serverOnly.forEach(el => (el as HTMLElement).style.display = 'flex');
locationFields.forEach(el => (el as HTMLElement).style.display = 'flex');
if (groups.networkTitle) groups.networkTitle.style.display = 'flex';
if (groups.ip) groups.ip.style.display = 'flex';
if (groups.specTitle) groups.specTitle.style.display = 'flex';
if (groups.model) groups.model.style.display = 'flex';
if (groups.ssd1) groups.ssd1.style.display = 'flex';
if (groups.ssd2) groups.ssd2.style.display = 'flex';
}
else if (type === 'PC' || type === '노트북') {
if (type === 'PC' && groups.detailPurpose) groups.detailPurpose.style.display = 'flex';
nonServer.forEach(el => (el as HTMLElement).style.display = 'flex');
if (groups.specTitle) groups.specTitle.style.display = 'flex';
['model', 'os', 'cpu', 'ram', 'ssd1', 'ssd2', 'hwSpec', 'ipNonServer'].forEach(k => {
if (groups[k]) groups[k]!.style.display = 'flex';
});
if (type === 'PC' && detailPurpose === '서버') {
locationFields.forEach(el => (el as HTMLElement).style.display = 'flex');
if (groups.networkTitle) groups.networkTitle.style.display = 'flex';
['ip', 'ip2', 'remote', 'serverId', 'serverPw', 'monitoring'].forEach(k => {
if (groups[k]) groups[k]!.style.display = 'flex';
});
if (groups.ipNonServer) groups.ipNonServer.style.display = 'none';
}
}
else if (['CPU', 'GPU', '모바일'].includes(type)) {
if (groups.specTitle) groups.specTitle.style.display = 'flex';
if (groups.model) groups.model.style.display = 'flex';
}
else if (type === 'RAM') {
if (groups.specTitle) groups.specTitle.style.display = 'flex';
if (groups.ram) groups.ram.style.display = 'flex';
}
else if (type === 'HDD') {
if (groups.specTitle) groups.specTitle.style.display = 'flex';
if (groups.ssd1) groups.ssd1.style.display = 'flex';
}
else if (type === '태블릿') {
if (groups.specTitle) groups.specTitle.style.display = 'flex';
if (groups.model) groups.model.style.display = 'flex';
if (groups.ssd1) groups.ssd1.style.display = 'flex';
}
}
function fillHwFormData(asset: HardwareAsset) {
@@ -371,29 +313,39 @@ function fillHwFormData(asset: HardwareAsset) {
setFieldValue('hw-현사용조직', asset.);
setFieldValue('hw-이전사용조직', asset.);
setFieldValue('hw-상세용도', (asset as any).);
setFieldValue('hw-유형', asset.type);
parseAndSetLocation(asset., 'hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타-group', 'hw-위치-기타');
setFieldValue('hw-모델명', asset.);
setFieldValue('hw-명칭', asset. || asset.);
setFieldValue('hw-보관위치', asset. || '');
setFieldValue('hw-현재상태', asset. || '보관중');
setFieldValue('hw-IP주소', asset.IP주소);
setFieldValue('hw-IP2', (asset as any).IP2);
setFieldValue('hw-원격접속', (asset as any).);
setFieldValue('hw-서버ID', (asset as any).ID);
setFieldValue('hw-서버PW', (asset as any).PW);
setFieldValue('hw-모니터링', (asset as any).);
setFieldValue('hw-OS', asset.OS);
setFieldValue('hw-CPU', asset.CPU);
setFieldValue('hw-RAM', asset.RAM);
setFieldValue('hw-SSD1', asset.SSD1);
setFieldValue('hw-SSD2', asset.SSD2);
setFieldValue('hw-HW사양', asset.HW사양);
setFieldValue('hw-담당자_정', asset._정 || asset.);
setFieldValue('hw-구매일', asset.);
setFieldValue('hw-금액', asset.);
setFieldValue('hw-비고', asset.);
setFieldValue('hw-담당자_부', asset._부);
parseAndSetLocation(asset., 'hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타-group', 'hw-위치-기타');
const isServerGrade = asset.type === '서버' || (asset as any). === '서버' || asset.type === '스토리지' || ['NAS', 'DAS'].includes(asset.type);
if (isServerGrade) {
setFieldValue('hw-용도', asset. || (asset as any).purpose);
setFieldValue('hw-상세', asset. || (asset as any).details);
setFieldValue('hw-비고', asset. || (asset as any).remarks);
setFieldValue('hw-구매일', asset. || (asset as any).purchase_date);
setFieldValue('hw-유형', asset.storage유형 || asset.type);
setFieldValue('hw-IP주소', asset.IP주소 || (asset as any).ip_address);
setFieldValue('hw-IP2', (asset as any).IP2 || (asset as any).ip_address_2);
setFieldValue('hw-원격접속', asset. || (asset as any).remote_tool);
setFieldValue('hw-서버ID', (asset as any).ID || (asset as any).server_id);
setFieldValue('hw-서버PW', (asset as any).PW || (asset as any).server_pw);
setFieldValue('hw-모니터링', asset. || (asset as any).monitoring);
} else {
setFieldValue('hw-명칭', asset. || asset.);
setFieldValue('hw-구매일', asset. || (asset as any).purchase_date);
setFieldValue('hw-금액', asset. || (asset as any).price);
setFieldValue('hw-HW사양', asset.HW사양 || asset. || (asset as any).details);
setFieldValue('hw-IP주소-non-server', asset.IP주소 || (asset as any).ip_address);
}
}
export function initHwModal(onSave: () => void, closeModals: () => void) {
@@ -407,8 +359,6 @@ export function initHwModal(onSave: () => void, closeModals: () => void) {
const deleteBtn = document.getElementById('btn-delete-hw-asset')!;
const typeSelect = document.getElementById('hw-유형') as HTMLSelectElement;
const detailPurposeSelect = document.getElementById('hw-상세용도') as HTMLSelectElement;
const logAddBtn = document.getElementById('btn-add-hw-log')!;
const logModal = document.getElementById('hw-log-modal')!;
[typeSelect, detailPurposeSelect].forEach(el => {
el?.addEventListener('change', () => applyTypeSpecificUI(typeSelect.value));
@@ -421,7 +371,11 @@ export function initHwModal(onSave: () => void, closeModals: () => void) {
document.getElementById('btn-cancel-hw-modal')?.addEventListener('click', closeModalAction);
revertBtn.addEventListener('click', () => {
setEditLock('hw-asset-form', 'view', { saveBtnId: 'btn-save-hw-asset', revertBtnId: 'btn-revert-hw-edit' });
setEditLock('hw-asset-form', 'view', {
saveBtnId: 'btn-save-hw-asset',
revertBtnId: 'btn-revert-hw-edit',
generateBtnId: 'btn-generate-hw-code'
});
isEditMode = false;
if (currentAsset) fillHwFormData(currentAsset);
});
@@ -430,95 +384,80 @@ export function initHwModal(onSave: () => void, closeModals: () => void) {
const typeValue = typeSelect.value;
const purchaseDate = getFieldValue('hw-구매일');
const typeCode = TYPE_PREFIX_MAP[typeValue] || 'ETC';
// 구매일에서 연월(YYMM) 추출 (예: 2026-04-21 -> 2604)
const dateStr = purchaseDate.replace(/[^0-9]/g, '');
if (dateStr.length < 4) {
alert('올바른 구매일(연월)을 입력해주세요. (예: 2026-04-21)');
return;
}
if (dateStr.length < 4) { alert('올바른 구매일(연월)을 입력해주세요.'); return; }
const prefix = `${typeCode}-${dateStr.substring(2, 6)}-`;
try {
const res = await fetch(`http://localhost:3000/api/generate-asset-code?prefix=${prefix}`);
const data = await res.json();
if (data.nextCode) {
setFieldValue('hw-자산코드', data.nextCode);
}
} catch (err) {
console.error('❌ 자산번호 생성 실패:', err);
alert('자산번호 생성에 실패했습니다.');
}
if (data.nextCode) setFieldValue('hw-자산코드', data.nextCode);
} catch (err) { alert('자산번호 생성에 실패했습니다.'); }
});
saveBtn.addEventListener('click', () => {
if (!currentAsset) return;
if (!isEditMode) {
setEditLock('hw-asset-form', 'edit', { saveBtnId: 'btn-save-hw-asset', revertBtnId: 'btn-revert-hw-edit' });
setEditLock('hw-asset-form', 'edit', {
saveBtnId: 'btn-save-hw-asset',
revertBtnId: 'btn-revert-hw-edit'
});
isEditMode = true;
applyTypeSpecificUI(getFieldValue('hw-유형'));
return;
}
const type = getFieldValue('hw-유형');
const storageLoc = getFieldValue('hw-보관위치');
const isOpType = ['CPU', 'RAM', 'HDD', 'GPU'].some(t => type.toUpperCase().includes(t)) || type.includes('비품') || ['모바일', '태블릿', '노트북'].some(t => type.includes(t));
const type = typeSelect.value;
const detailPurpose = detailPurposeSelect.value;
const updated: any = {
...currentAsset,
법인: getFieldValue('hw-법인'),
자산코드: getFieldValue('hw-자산코드'),
현사용조직: getFieldValue('hw-현사용조직'),
type: type,
상세용도: getFieldValue('hw-상세용도'),
: getFieldValue('hw-명'),
보관위치: storageLoc,
현재상태: getFieldValue('hw-현재상태'),
이전사용조직: getFieldValue('hw-이전사용조직'),
위치: getCombinedLocation('hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타'),
모델: getFieldValue('hw-모델명'),
OS: getFieldValue('hw-OS'),
CPU: getFieldValue('hw-CPU'),
RAM: getFieldValue('hw-RAM'),
SSD1: getFieldValue('hw-SSD1'),
SSD2: getFieldValue('hw-SSD2'),
IP주소: getFieldValue('hw-IP주소') || getFieldValue('hw-IP주소-non-server'),
담당자_정: getFieldValue('hw-담당자_정'),
구매일: getFieldValue('hw-구매일'),
금액: getFieldValue('hw-금액'),
비고: getFieldValue('hw-비고'),
위치: isOpType ? storageLoc : getCombinedLocation('hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타')
관리자: getFieldValue('hw-담당자_정'),
담당자_부: getFieldValue('hw-담당자_부'),
type: type,
상세용도: detailPurpose
};
if (type === '서버' || (type === 'PC' && detailPurpose === '서버') || ['스토리지', 'NAS', 'DAS'].includes(type)) {
updated. = getFieldValue('hw-용도');
updated. = getFieldValue('hw-상세');
updated. = getFieldValue('hw-비고');
updated.storage유형 = type;
updated.IP주소 = getFieldValue('hw-IP주소');
updated.IP2 = getFieldValue('hw-IP2');
updated. = getFieldValue('hw-원격접속');
updated.ID = getFieldValue('hw-서버ID');
updated.PW = getFieldValue('hw-서버PW');
updated. = getFieldValue('hw-모니터링');
} else {
updated. = getFieldValue('hw-명칭');
updated. = getFieldValue('hw-구매일');
updated. = getFieldValue('hw-금액');
updated.HW사양 = getFieldValue('hw-HW사양');
updated.IP주소 = getFieldValue('hw-IP주소-non-server');
}
saveHardwareAsset(updated);
onSave();
setEditLock('hw-asset-form', 'view', { saveBtnId: 'btn-save-hw-asset', revertBtnId: 'btn-revert-hw-edit' });
isEditMode = false;
closeModalAction();
});
deleteBtn.addEventListener('click', () => {
if (currentAsset && confirm('정말로 삭제하시겠습니까?')) {
if (!currentAsset) return;
if (confirm('정말로 이 자산을 삭제하시겠습니까?')) {
deleteHardwareAsset(currentAsset.id);
onSave();
closeModalAction();
closeModals();
}
});
logAddBtn.addEventListener('click', () => {
logModal.classList.remove('hidden');
(document.getElementById('new-hw-log-date') as HTMLInputElement).value = new Date().toISOString().split('T')[0];
(document.getElementById('new-hw-log-details') as HTMLTextAreaElement).value = '';
});
document.getElementById('btn-close-hw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
document.getElementById('btn-cancel-hw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
document.getElementById('btn-confirm-hw-log')?.addEventListener('click', () => {
if (!currentAsset) return;
const date = (document.getElementById('new-hw-log-date') as HTMLInputElement).value;
const details = (document.getElementById('new-hw-log-details') as HTMLTextAreaElement).value;
if (!date || !details) return;
state.masterData.logs = state.masterData.logs || [];
state.masterData.logs.push({ id: Math.random().toString(36).substring(2, 9), assetId: currentAsset.id, date, user: '관리자', details });
logModal.classList.add('hidden');
renderHwHistory(currentAsset.id);
});
}

View File

@@ -133,3 +133,34 @@ export function setEditLock(
if (generateBtn) generateBtn.classList.add('hidden');
}
}
// 8. 날짜 자동 마스킹 및 포커스 제어 (Auto-jump)
export function applyDateMask(el: HTMLInputElement) {
if (!el) return;
el.placeholder = 'YYYY-MM-DD';
el.maxLength = 10;
el.addEventListener('input', (e) => {
let value = el.value.replace(/[^0-9]/g, ''); // 숫자만 남김
let result = '';
if (value.length <= 4) {
result = value;
} else if (value.length <= 6) {
result = value.substring(0, 4) + '-' + value.substring(4);
} else {
result = value.substring(0, 4) + '-' + value.substring(4, 6) + '-' + value.substring(6, 10);
}
el.value = result;
});
// 엔터 키나 입력 완료 시 유효성 검사 (선택 사항)
el.addEventListener('blur', () => {
const val = el.value;
if (val && !/^\d{4}-\d{2}-\d{2}$/.test(val)) {
// 형식이 맞지 않으면 경고 효과 등을 줄 수 있음
}
});
}

View File

@@ -1,7 +1,7 @@
import { state, saveHardwareAsset, deleteHardwareAsset } from '../../core/state';
import { HardwareAsset } from '../../core/excelHandler';
import { openModal, closeModals } from './BaseModal';
import { createIcons, History, X, Paperclip } from 'lucide';
import { createIcons, History, X, Paperclip, Calendar } from 'lucide';
import { CORP_LIST, ORG_LIST, HW_TYPE_LIST, LOCATION_DATA } from './SharedData';
import {
generateOptionsHTML,
@@ -9,7 +9,8 @@ import {
getFieldValue,
parseAndSetLocation,
bindLocationEvents,
getCombinedLocation
getCombinedLocation,
applyDateMask
} from './ModalUtils';
let currentAsset: HardwareAsset | null = null;
@@ -67,6 +68,10 @@ const PC_MODAL_HTML = `
<label for="pc-모델명">모델명</label>
<input type="text" id="pc-모델명" />
</div>
<div class="form-group">
<label for="pc-메인보드">메인보드</label>
<input type="text" id="pc-메인보드" />
</div>
<div class="form-group">
<label for="pc-OS">운영체제 (OS)</label>
<input type="text" id="pc-OS" />
@@ -105,7 +110,13 @@ const PC_MODAL_HTML = `
</div>
<div class="form-group">
<label for="pc-구매일">구매일</label>
<input type="text" id="pc-구매일" />
<div style="display:flex; gap:0.25rem; align-items:center; position:relative;">
<input type="text" id="pc-구매일" style="flex:1;" />
<button type="button" class="btn-icon" onclick="const p = document.getElementById('pc-구매일-picker'); p.value = document.getElementById('pc-구매일').value; p.showPicker();" style="padding:0.25rem;">
<i data-lucide="calendar" style="width:18px; height:18px; color:var(--primary-color);"></i>
</button>
<input type="date" id="pc-구매일-picker" style="position:absolute; width:0; height:0; opacity:0; pointer-events:none;" onchange="document.getElementById('pc-구매일').value = this.value" tabindex="-1" />
</div>
</div>
<div class="form-group">
<label for="pc-금액">금액</label>
@@ -146,7 +157,7 @@ const PC_MODAL_HTML = `
</div>
`;
export function openPcModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view') {
export function openPcModal(asset: HardwareAsset, mode: 'view' | 'add' | 'edit' = 'view') {
currentAsset = asset;
const modal = document.getElementById('pc-asset-modal');
if (!modal) return;
@@ -157,14 +168,14 @@ export function openPcModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view')
if (form) form.reset();
if (mode === 'add') {
if (mode === 'add' || mode === 'edit') {
isEditMode = true;
if (form) {
form.classList.remove('is-view-mode');
form.classList.add('is-edit-mode');
}
saveBtn.textContent = '저장';
revertBtn.classList.add('hidden');
revertBtn.classList.toggle('hidden', mode === 'add');
const prevOrgGroup = document.getElementById('pc-이전사용조직-group');
if (prevOrgGroup) prevOrgGroup.style.display = 'none';
} else {
@@ -184,7 +195,7 @@ export function openPcModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view')
modal.classList.remove('hidden');
applyPcTypeSpecificUI();
createIcons({ icons: { X, History, Paperclip } });
createIcons({ icons: { X, History, Paperclip, Calendar } });
}
function applyPcTypeSpecificUI() {
@@ -199,9 +210,10 @@ function applyPcTypeSpecificUI() {
const ssd2Group = document.getElementById('pc-SSD2')?.closest('.form-group') as HTMLElement;
const locationFields = document.querySelectorAll('.pc-location-field');
const etcGroup = document.getElementById('pc-위치-기타-group');
const mainboardGroup = document.getElementById('pc-메인보드')?.closest('.form-group') as HTMLElement;
// 초기화 (숨김)
[modelGroup, osGroup, cpuGroup, ramGroup, ssd1Group, ssd2Group].forEach(g => { if(g) g.style.display = 'none'; });
[modelGroup, osGroup, cpuGroup, ramGroup, ssd1Group, ssd2Group, mainboardGroup].forEach(g => { if(g) g.style.display = 'none'; });
locationFields.forEach(el => (el as HTMLElement).style.display = 'none');
if (etcGroup) etcGroup.style.display = 'none';
@@ -214,7 +226,7 @@ function applyPcTypeSpecificUI() {
locationFields.forEach(el => (el as HTMLElement).style.display = 'flex');
}
else if (type === 'PC' || type === '노트북') {
[modelGroup, osGroup, cpuGroup, ramGroup, ssd1Group, ssd2Group].forEach(g => { if(g) g.style.display = 'flex'; });
[modelGroup, mainboardGroup, osGroup, cpuGroup, ramGroup, ssd1Group, ssd2Group].forEach(g => { if(g) g.style.display = 'flex'; });
if (detailPurpose === '서버') {
locationFields.forEach(el => (el as HTMLElement).style.display = 'flex');
}
@@ -243,6 +255,7 @@ function fillFormData(asset: HardwareAsset) {
setFieldValue('pc-현사용조직', asset.);
setFieldValue('pc-이전사용조직', asset.);
setFieldValue('pc-상세용도', (asset as any).);
setFieldValue('pc-메인보드', (asset as any). || '');
parseAndSetLocation(asset., 'pc-위치-빌딩', 'pc-위치-상세', 'pc-위치-기타-group', 'pc-위치-기타');
@@ -278,6 +291,9 @@ export function initPcModal(onSave: () => void, closeModalsCb: () => void) {
bindLocationEvents('pc-위치-빌딩', 'pc-위치-상세', 'pc-위치-기타-group', 'pc-위치-기타');
// 날짜 마스킹 적용
applyDateMask(document.getElementById('pc-구매일') as HTMLInputElement);
const handleClose = () => { closeModalsCb(); isEditMode = false; };
document.getElementById('btn-close-pc-modal')?.addEventListener('click', handleClose);
document.getElementById('btn-cancel-pc-modal')?.addEventListener('click', handleClose);
@@ -317,6 +333,7 @@ export function initPcModal(onSave: () => void, closeModalsCb: () => void) {
RAM: getFieldValue('pc-RAM'),
SSD1: getFieldValue('pc-SSD1'),
SSD2: getFieldValue('pc-SSD2'),
메인보드: getFieldValue('pc-메인보드'),
구매일: getFieldValue('pc-구매일'),
금액: getFieldValue('pc-금액'),
납품업체: getFieldValue('pc-납품업체'),
@@ -325,10 +342,7 @@ export function initPcModal(onSave: () => void, closeModalsCb: () => void) {
saveHardwareAsset(updated);
onSave();
isEditMode = false;
pcForm.classList.replace('is-edit-mode', 'is-view-mode');
saveBtn.textContent = '수정';
revertBtn?.classList.add('hidden');
handleClose();
});
deleteBtn?.addEventListener('click', () => {

View File

@@ -2,13 +2,14 @@ import { state } from '../../core/state';
import { SoftwareAsset } from '../../core/excelHandler';
import { openModal, closeModals } from './BaseModal';
import { openSwUserModal } from './SWUserModal';
import { createIcons, History, Plus, X, Save, Edit2, RotateCcw } from 'lucide';
import { createIcons, History, Plus, X, Save, Edit2, RotateCcw, Calendar } from 'lucide';
import { CORP_LIST } from './SharedData';
import {
generateOptionsHTML,
setFieldValue,
getFieldValue,
setEditLock
setEditLock,
applyDateMask
} from './ModalUtils';
let currentSwAsset: SoftwareAsset | null = null;
@@ -26,17 +27,30 @@ const SW_MODAL_HTML = `
<div class="modal-form-area">
<form id="sw-asset-form" class="grid-form">
<input type="hidden" id="sw-asset-id" />
<input type="hidden" id="sw-asset-type" />
<!-- Group 1: 기본 정보 (Identity) -->
<div class="form-section-title">기본 정보 (Identity)</div>
<div class="form-group">
<label for="sw-법인">구매법인</label>
<select id="sw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
<label for="sw-asset-type">자산 유형</label>
<select id="sw-asset-type" required>
<option value="구독SW">구독SW</option>
<option value="영구SW">영구SW</option>
<option value="클라우드">클라우드</option>
</select>
</div>
<div class="form-group sw-standard-field">
<label for="sw-자산번호">자산번호</label>
<input type="text" id="sw-자산번호" readonly placeholder="자동 생성" />
<div class="form-group">
<label for="sw-분야">분야</label>
<select id="sw-분야" required>
<option value="업무공통">업무공통</option>
<option value="개발S/W">개발S/W</option>
<option value="디자인">디자인</option>
<option value="설계S/W">설계S/W</option>
</select>
</div>
<div class="form-group">
<label for="sw-법인">법인</label>
<select id="sw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
</div>
<div class="form-group full-width">
<label for="sw-제품명">제품명 / 서비스명</label>
@@ -46,8 +60,8 @@ const SW_MODAL_HTML = `
<label for="sw-플랫폼명">플랫폼명</label>
<input type="text" id="sw-플랫폼명" placeholder="예: AWS, Cafe24" />
</div>
<div class="form-group cloud-only">
<label for="sw-부서">담당부서</label>
<div class="form-group">
<label for="sw-부서">조직 / 부서</label>
<input type="text" id="sw-부서" />
</div>
@@ -100,38 +114,56 @@ const SW_MODAL_HTML = `
<div class="form-section-title">관리 및 비고</div>
<div class="form-group sw-standard-field">
<label for="sw-구매일">구매일</label>
<input type="text" id="sw-구매일" />
</div>
<div class="form-group sw-standard-field" id="sw-expiry-group">
<label for="sw-만료일">만료일 (구독)</label>
<input type="text" id="sw-만료일" />
<div style="display:flex; gap:0.25rem; align-items:center; position:relative;">
<input type="text" id="sw-구매일" style="flex:1;" />
<button type="button" class="btn-icon" onclick="const p = document.getElementById('sw-구매일-picker'); p.value = document.getElementById('sw-구매일').value; p.showPicker();" style="padding:0.25rem;">
<i data-lucide="calendar" style="width:18px; height:18px; color:var(--primary-color);"></i>
</button>
<input type="date" id="sw-구매일-picker" style="position:absolute; width:0; height:0; opacity:0; pointer-events:none;" onchange="document.getElementById('sw-구매일').value = this.value" tabindex="-1" />
</div>
</div>
<div class="form-group sw-standard-field">
<label for="sw-납품업체">납품업체</label>
<input type="text" id="sw-납품업체" />
</div>
<div class="form-group sw-standard-field">
<label for="sw-시작일">시작일 (구독/유지보수)</label>
<div style="display:flex; gap:0.25rem; align-items:center; position:relative;">
<input type="text" id="sw-시작일" style="flex:1;" />
<button type="button" class="btn-icon" onclick="const p = document.getElementById('sw-시작일-picker'); p.value = document.getElementById('sw-시작일').value; p.showPicker();" style="padding:0.25rem;">
<i data-lucide="calendar" style="width:18px; height:18px; color:var(--primary-color);"></i>
</button>
<input type="date" id="sw-시작일-picker" style="position:absolute; width:0; height:0; opacity:0; pointer-events:none;" onchange="document.getElementById('sw-시작일').value = this.value" tabindex="-1" />
</div>
</div>
<div class="form-group sw-standard-field" id="sw-expiry-group">
<label for="sw-만료일">만료일 (종료일)</label>
<div style="display:flex; gap:0.25rem; align-items:center; position:relative;">
<input type="text" id="sw-만료일" style="flex:1;" />
<button type="button" class="btn-icon" onclick="const p = document.getElementById('sw-만료일-picker'); p.value = document.getElementById('sw-만료일').value; p.showPicker();" style="padding:0.25rem;">
<i data-lucide="calendar" style="width:18px; height:18px; color:var(--primary-color);"></i>
</button>
<input type="date" id="sw-만료일-picker" style="position:absolute; width:0; height:0; opacity:0; pointer-events:none;" onchange="document.getElementById('sw-만료일').value = this.value" tabindex="-1" />
</div>
</div>
<div class="form-group full-width">
<label for="sw-비고">비고</label>
<textarea id="sw-비고" rows="2"></textarea>
</div>
</form>
<div id="sw-user-section" class="user-management-section" style="margin-top: 2rem;">
<div class="section-header" style="display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem;">
<h3 style="font-size:1rem; font-weight:600;">사용자 할당 현황</h3>
<button type="button" id="btn-open-sw-update" class="btn btn-outline btn-sm">
할당 관리 <i data-lucide="plus" style="width:14px; height:14px;"></i>
</button>
</div>
<div id="sw-assigned-users-summary" class="user-summary-grid"></div>
<div id="sw-user-section" class="user-management-section" style="margin-top: 2rem; border-top: 1px solid var(--border-color); padding-top: 1.5rem;">
<button type="button" id="btn-open-sw-user" class="btn btn-outline btn-sm" title="사용자 관리">
<i data-lucide="users" style="width:16px; height:16px; margin-right:4px;"></i> 사용자 관리
</button>
</div>
</div>
<div class="modal-history-area">
<div class="history-header" style="display:flex; justify-content:space-between; align-items:center;">
<h3><i data-lucide="history" style="width:16px; height:16px;"></i> 업데이트 내역</h3>
<button type="button" id="btn-add-sw-log" class="btn btn-outline btn-sm cloud-only">
내역 추가 <i data-lucide="plus" style="width:14px; height:14px;"></i>
<button type="button" id="btn-open-sw-update" class="btn btn-outline btn-sm">
계약 업데이트 <i data-lucide="refresh-ccw" style="width:14px; height:14px;"></i>
</button>
</div>
<div id="sw-history-list" class="history-timeline"></div>
@@ -149,30 +181,48 @@ const SW_MODAL_HTML = `
</div>
</div>
<!-- 클라우드 이력 추가를 위한 간이 모달 -->
<div id="sw-log-modal" class="modal-overlay hidden" style="z-index: 1100;">
<!-- 계약/유지보수 기간 갱신 및 업데이트 모달 -->
<div id="sw-update-modal" class="modal-overlay hidden" style="z-index: 1100;">
<div class="modal-content" style="max-width: 400px;">
<div class="modal-header">
<h2>업데이트 내역 추가</h2>
<button id="btn-close-sw-log" class="btn-icon"><i data-lucide="x"></i></button>
<h2>계약 업데이트 반영</h2>
<button id="btn-close-sw-update" class="btn-icon"><i data-lucide="x"></i></button>
</div>
<div class="modal-body">
<div class="grid-form" style="grid-template-columns: 1fr;">
<div class="form-group">
<label>날짜</label>
<input type="date" id="new-log-date" />
<label>업데이트 일자</label>
<input type="date" id="sw-update-date" />
</div>
<div class="form-group sub-sw-update">
<label>새로운 계약 기간</label>
<div style="display: flex; align-items: center; gap: 0.5rem;">
<input type="text" id="sw-update-start" placeholder="YYYY-MM-DD" style="flex: 1;" />
<span>~</span>
<input type="text" id="sw-update-end" placeholder="YYYY-MM-DD" style="flex: 1;" />
</div>
</div>
<div class="form-group perm-sw-update" style="display:none;">
<label>유지보수 체결 (상태 연동)</label>
<label style="display:flex; align-items:center; gap:0.5rem; height: 38px; cursor: pointer;">
<input type="checkbox" id="sw-update-maintenance" /> 유효 상태로 갱신
</label>
</div>
<div class="form-group">
<label>상세 내용</label>
<textarea id="new-log-details" rows="3" placeholder="예: 결제 금액 변동, 담당자 변경 등"></textarea>
<label>발생 비용</label>
<input type="text" id="sw-update-cost" oninput="this.value = this.value.replace(/[^0-9]/g, '') ? Number(this.value.replace(/[^0-9]/g, '')).toLocaleString() : ''" placeholder="ex) 500,000" />
</div>
<div class="form-group">
<label>상세 내용 (메모)</label>
<input type="text" id="sw-update-note" placeholder="예: 25년도 구독 연장 결제 완료" />
</div>
</div>
</div>
<div class="modal-footer">
<div></div>
<div class="footer-actions">
<button id="btn-cancel-sw-log" class="btn btn-outline">취소</button>
<button id="btn-confirm-sw-log" class="btn btn-primary">추가</button>
<button id="btn-cancel-sw-update" class="btn btn-outline">취소</button>
<button id="btn-save-sw-update" class="btn btn-primary">반영하기</button>
</div>
</div>
</div>
@@ -200,10 +250,10 @@ function applySwTypeUI(type: string) {
if (keyGroup) keyGroup.style.display = 'none';
if (typeGroup) typeGroup.style.display = 'flex';
if (expiryGroup) expiryGroup.style.display = 'flex';
} else {
} else if (type === '영구SW') {
if (keyGroup) keyGroup.style.display = 'flex';
if (typeGroup) typeGroup.style.display = 'none';
if (expiryGroup) expiryGroup.style.display = 'none';
if (expiryGroup) expiryGroup.style.display = 'none'; // 영구는 유지보수 기간이 비고에 들어가는 경우가 많아 만료일 숨김 처리
}
}
}
@@ -211,18 +261,20 @@ function applySwTypeUI(type: string) {
function fillSwFormData(asset: SoftwareAsset) {
setFieldValue('sw-asset-id', asset.id);
setFieldValue('sw-asset-type', asset.type);
setFieldValue('sw-분야', asset. || '업무공통');
setFieldValue('sw-법인', asset.);
setFieldValue('sw-자산번호', asset. || '');
setFieldValue('sw-부서', asset. || '');
setFieldValue('sw-제품명', asset.);
setFieldValue('sw-수량', asset.);
setFieldValue('sw-금액', asset.);
setFieldValue('sw-구매일', asset. || '');
setFieldValue('sw-시작일', asset. || '');
setFieldValue('sw-납품업체', asset. || '');
setFieldValue('sw-비고', asset. || '');
if (asset.type === '클라우드') {
setFieldValue('sw-플랫폼명', (asset as any). || '');
setFieldValue('sw-부서', (asset as any). || '');
setFieldValue('sw-계정명', (asset as any). || '');
setFieldValue('sw-결제수단', (asset as any). || '');
setFieldValue('sw-연결카드번호', (asset as any). || '');
@@ -235,25 +287,10 @@ function fillSwFormData(asset: SoftwareAsset) {
setFieldValue('sw-라이선스키', (asset as any). || '');
}
renderUserSummary(asset.id);
renderSwHistory(asset.id);
}
function renderUserSummary(swId: string) {
const container = document.getElementById('sw-assigned-users-summary');
if (!container) return;
const userMapping = state.masterData.swUsers.find(u => u.sw_id === swId);
if (!userMapping || !userMapping.userData || userMapping.userData.length === 0) {
container.innerHTML = '<div class="empty-summary">할당된 사용자가 없습니다.</div>';
return;
}
container.innerHTML = userMapping.userData.map(u => `
<div class="user-badge-item">
<span class="u-name">${u[3] || '이름없음'}</span>
<span class="u-dept">${u[1] || '부서없음'}</span>
</div>
`).join('');
}
function renderSwHistory(swId: string) {
const container = document.getElementById('sw-history-list');
@@ -272,7 +309,7 @@ function renderSwHistory(swId: string) {
`).join('');
}
export function openSwModal(asset: SoftwareAsset, mode: 'view' | 'add' = 'view') {
export function openSwModal(asset: SoftwareAsset, mode: 'view' | 'add' | 'edit' = 'view') {
currentSwAsset = asset;
const modal = document.getElementById('sw-asset-modal')!;
@@ -282,7 +319,7 @@ export function openSwModal(asset: SoftwareAsset, mode: 'view' | 'add' = 'view')
revertBtnId: 'btn-revert-sw-edit'
});
isEditMode = (mode === 'add');
isEditMode = (mode === 'add' || mode === 'edit');
fillSwFormData(asset);
applySwTypeUI(asset.type);
@@ -300,8 +337,20 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
const saveBtn = document.getElementById('btn-save-sw-asset')!;
const revertBtn = document.getElementById('btn-revert-sw-edit')!;
const deleteBtn = document.getElementById('btn-delete-sw-asset')!;
const userUpdateBtn = document.getElementById('btn-open-sw-update')!;
const logAddBtn = document.getElementById('btn-add-sw-log')!;
const userAssignBtn = document.getElementById('btn-open-sw-user')!;
const btnOpenUpdate = document.getElementById('btn-open-sw-update')!;
const typeSelect = document.getElementById('sw-asset-type') as HTMLSelectElement;
typeSelect?.addEventListener('change', () => {
applySwTypeUI(typeSelect.value);
});
// 날짜 스마트 마스킹 적용
['sw-구매일', 'sw-시작일', 'sw-만료일', 'sw-update-start', 'sw-update-end'].forEach(id => {
applyDateMask(document.getElementById(id) as HTMLInputElement);
});
createIcons({ icons: { Calendar } });
const closeModalAction = () => { closeModals(); isEditMode = false; };
document.getElementById('btn-close-sw-modal')?.addEventListener('click', closeModalAction);
@@ -330,12 +379,15 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
const type = getFieldValue('sw-asset-type');
const updated: any = {
...currentSwAsset,
분야: getFieldValue('sw-분야'),
법인: getFieldValue('sw-법인'),
자산번호: getFieldValue('sw-자산번호'),
부서: getFieldValue('sw-부서'),
제품명: getFieldValue('sw-제품명'),
수량: parseInt(getFieldValue('sw-수량') || '0'),
금액: getFieldValue('sw-금액'),
구매일: getFieldValue('sw-구매일'),
시작일: getFieldValue('sw-시작일'),
납품업체: getFieldValue('sw-납품업체'),
비고: getFieldValue('sw-비고'),
type: type
@@ -343,7 +395,6 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
if (type === '클라우드') {
updated. = getFieldValue('sw-플랫폼명');
updated. = getFieldValue('sw-부서');
updated. = getFieldValue('sw-계정명');
updated. = getFieldValue('sw-결제수단');
updated. = getFieldValue('sw-연결카드번호');
@@ -357,21 +408,27 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
}
// 데이터 저장 로직 (state 업데이트)
const oldType = currentSwAsset.type;
const newType = updated.type;
// 유형이 변경된 경우 기존 리스트에서 삭제
if (oldType !== newType) {
if (oldType === '구독SW') state.masterData.subSw = state.masterData.subSw.filter(a => a.id !== updated.id);
else if (oldType === '영구SW') state.masterData.permSw = state.masterData.permSw.filter(a => a.id !== updated.id);
else if (oldType === '클라우드') state.masterData.cloud = state.masterData.cloud.filter(a => a.id !== updated.id);
}
let targetList: SoftwareAsset[] = [];
if (type === '구독SW') targetList = state.masterData.subSw;
else if (type === '영구SW') targetList = state.masterData.permSw;
else if (type === '클라우드') targetList = state.masterData.cloud;
if (newType === '구독SW') targetList = state.masterData.subSw;
else if (newType === '영구SW') targetList = state.masterData.permSw;
else if (newType === '클라우드') targetList = state.masterData.cloud;
const idx = targetList.findIndex(a => a.id === updated.id);
if (idx > -1) targetList[idx] = updated;
else targetList.push(updated);
onSave();
setEditLock('sw-asset-form', 'view', {
saveBtnId: 'btn-save-sw-asset',
revertBtnId: 'btn-revert-sw-edit'
});
isEditMode = false;
closeModalAction();
});
deleteBtn.addEventListener('click', () => {
@@ -386,39 +443,86 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
}
});
userUpdateBtn.addEventListener('click', () => {
userAssignBtn.addEventListener('click', () => {
if (currentSwAsset) openSwUserModal(currentSwAsset);
});
// 이력 추가 모달 로직
const logModal = document.getElementById('sw-log-modal')!;
logAddBtn.addEventListener('click', () => {
logModal.classList.remove('hidden');
(document.getElementById('new-log-date') as HTMLInputElement).value = new Date().toISOString().split('T')[0];
(document.getElementById('new-log-details') as HTMLTextAreaElement).value = '';
// 자산 업데이트(계약 갱신) 모달 로직
const subModal = document.getElementById('sw-update-modal')!;
const btnCloseUpdate = document.getElementById('btn-close-sw-update')!;
const btnCancelUpdate = document.getElementById('btn-cancel-sw-update')!;
const btnSaveUpdate = document.getElementById('btn-save-sw-update')!;
const closeUpdateModal = () => subModal.classList.add('hidden');
btnCloseUpdate?.addEventListener('click', closeUpdateModal);
btnCancelUpdate?.addEventListener('click', closeUpdateModal);
btnOpenUpdate?.addEventListener('click', (e) => {
e.preventDefault();
if (!isEditMode) {
alert('자산을 수정 모드로 변경한 후 업데이트를 진행해주세요.');
return;
}
const isSub = getFieldValue('sw-asset-type') === '구독SW';
subModal.classList.remove('hidden');
(document.getElementById('sw-update-date') as HTMLInputElement).value = new Date().toISOString().substring(0, 10);
(document.getElementById('sw-update-start') as HTMLInputElement).value = '';
(document.getElementById('sw-update-end') as HTMLInputElement).value = '';
(document.getElementById('sw-update-cost') as HTMLInputElement).value = '';
(document.getElementById('sw-update-note') as HTMLInputElement).value = '';
if (isSub) {
document.querySelector('.sub-sw-update')!.setAttribute('style', 'display:flex; flex-direction:column;');
document.querySelector('.perm-sw-update')!.setAttribute('style', 'display:none');
} else {
document.querySelector('.sub-sw-update')!.setAttribute('style', 'display:none');
document.querySelector('.perm-sw-update')!.setAttribute('style', 'display:flex; flex-direction:column;');
(document.getElementById('sw-update-maintenance') as HTMLInputElement).checked = (document.getElementById('sw-유지보수여부') as HTMLInputElement).checked;
}
});
document.getElementById('btn-close-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
document.getElementById('btn-cancel-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
btnSaveUpdate?.addEventListener('click', (e) => {
e.preventDefault();
const isSub = getFieldValue('sw-asset-type') === '구독SW';
const date = (document.getElementById('sw-update-date') as HTMLInputElement).value;
const start = (document.getElementById('sw-update-start') as HTMLInputElement).value;
const end = (document.getElementById('sw-update-end') as HTMLInputElement).value;
const maintenance = (document.getElementById('sw-update-maintenance') as HTMLInputElement).checked;
const cost = (document.getElementById('sw-update-cost') as HTMLInputElement).value;
const note = (document.getElementById('sw-update-note') as HTMLInputElement).value;
document.getElementById('btn-confirm-sw-log')?.addEventListener('click', () => {
if (!currentSwAsset) return;
const date = (document.getElementById('new-log-date') as HTMLInputElement).value;
const details = (document.getElementById('new-log-details') as HTMLTextAreaElement).value;
const periodStr = (start || end) ? `${start || ''} ~ ${end || ''}` : '';
if (!date || !details) { alert('날짜와 내용을 입력해주세요.'); return; }
let details = `[업데이트] ${note || (isSub ? '구독 갱신' : '유지보수 갱신')}\n`;
if (cost) details += `비용 추가: ${cost}\n`;
state.masterData.logs = state.masterData.logs || [];
if (isSub) {
if (periodStr) details += `계약 변경: -> ${periodStr}\n`;
// 메인 폼에 시작일 만료일 자동 세팅
if (start) setFieldValue('sw-시작일', start);
if (end) setFieldValue('sw-만료일', end);
} else {
details += `유지보수 상태: -> ${maintenance ? '유효' : '만료'}\n`;
(document.getElementById('sw-유지보수여부') as HTMLInputElement).checked = maintenance;
}
// 금액 갱신 (선택사항)
if (cost) setFieldValue('sw-금액', cost);
// 이력 탭 갱신 (메모리상)
if (!state.masterData.logs) state.masterData.logs = [];
state.masterData.logs.push({
id: Math.random().toString(36).substring(2, 9),
assetId: currentSwAsset.id,
assetId: currentSwAsset ? currentSwAsset.id : 'NEW',
date,
user: '관리자',
details
details,
user: '관리자'
});
logModal.classList.add('hidden');
renderSwHistory(currentSwAsset.id);
closeUpdateModal();
renderSwHistory(currentSwAsset ? currentSwAsset.id : '');
});
}

View File

@@ -1,12 +1,12 @@
import { state } from '../../core/state';
import { SoftwareAsset, SWUser } from '../../core/excelHandler';
import { openModal } from './BaseModal';
import { createIcons, Edit2, X, Paperclip } from 'lucide';
import { createIcons, Edit2, X, Paperclip, Calendar } from 'lucide';
import { CORP_LIST, ORG_LIST } from './SharedData';
import { generateOptionsHTML, setFieldValue, getFieldValue } from './ModalUtils';
import { generateOptionsHTML, setFieldValue, getFieldValue, applyDateMask } from './ModalUtils';
let currentSwUserAsset: SoftwareAsset | null = null;
let tempSwUsers: SWUser[] = [];
let tempSwUsers: any[] = [];
const SW_USER_MODAL_HTML = `
<div id="sw-user-modal" class="modal-overlay hidden">
@@ -27,8 +27,7 @@ const SW_USER_MODAL_HTML = `
<table>
<thead>
<tr>
<th>구매법인</th>
<th>부서/팀</th>
<th>조직</th>
<th>직위</th>
<th>이름</th>
<th>사용기간</th>
@@ -58,11 +57,7 @@ const SW_USER_MODAL_HTML = `
<form id="sw-user-edit-form" class="grid-form" style="grid-template-columns: 1fr;">
<input type="hidden" id="edit-user-index" value="-1" />
<div class="form-group">
<label>구매법인</label>
<select id="new-user-법인">${generateOptionsHTML(CORP_LIST)}</select>
</div>
<div class="form-group">
<label>부서/팀</label>
<label>조직</label>
<select id="new-user-부서">${generateOptionsHTML(ORG_LIST)}</select>
</div>
<div class="form-group">
@@ -74,8 +69,24 @@ const SW_USER_MODAL_HTML = `
<input type="text" id="new-user-이름" required />
</div>
<div class="form-group">
<label>사용기간</label>
<input type="text" id="new-user-사용기간" placeholder="ex) 2024-01-01 ~ 2024-12-31" />
<label>사용 시작일</label>
<div style="display:flex; gap:0.25rem; align-items:center; position:relative;">
<input type="text" id="new-user-시작일" style="flex:1;" />
<button type="button" class="btn-icon" onclick="const p = document.getElementById('new-user-시작일-picker'); p.value = document.getElementById('new-user-시작일').value; p.showPicker();" style="padding:0.25rem;">
<i data-lucide="calendar" style="width:18px; height:18px; color:var(--primary-color);"></i>
</button>
<input type="date" id="new-user-시작일-picker" style="position:absolute; width:0; height:0; opacity:0; pointer-events:none;" onchange="document.getElementById('new-user-시작일').value = this.value" tabindex="-1" />
</div>
</div>
<div class="form-group">
<label>사용 종료일</label>
<div style="display:flex; gap:0.25rem; align-items:center; position:relative;">
<input type="text" id="new-user-종료일" style="flex:1;" />
<button type="button" class="btn-icon" onclick="const p = document.getElementById('new-user-종료일-picker'); p.value = document.getElementById('new-user-종료일').value; p.showPicker();" style="padding:0.25rem;">
<i data-lucide="calendar" style="width:18px; height:18px; color:var(--primary-color);"></i>
</button>
<input type="date" id="new-user-종료일-picker" style="position:absolute; width:0; height:0; opacity:0; pointer-events:none;" onchange="document.getElementById('new-user-종료일').value = this.value" tabindex="-1" />
</div>
</div>
<div class="form-group">
<label>신청서 (증빙)</label>
@@ -105,7 +116,9 @@ export function openSwUserModal(asset: SoftwareAsset) {
// 기존 사용자 데이터 복사 (원본 보호를 위해 temp 사용)
const existingMapping = state.masterData.swUsers.find(u => u.sw_id === asset.id);
tempSwUsers = existingMapping ? JSON.parse(JSON.stringify(existingMapping.userDataList || [])) : [];
tempSwUsers = existingMapping ? (existingMapping.userData || []).map((u: any) => ({
법인: u[0], 부서: u[1], 직위: u[2], 이름: u[3], 사용기간: u[4], 신청서명: u[5]
})) : [];
renderUserList();
modal.classList.remove('hidden');
@@ -117,14 +130,13 @@ function renderUserList() {
tbody.innerHTML = '';
if (tempSwUsers.length === 0) {
tbody.innerHTML = '<tr><td colspan="7" style="text-align:center; padding:2rem; color:var(--text-muted);">할당된 사용자가 없습니다.</td></tr>';
tbody.innerHTML = '<tr><td colspan="6" style="text-align:center; padding:2rem; color:var(--text-muted);">할당된 사용자가 없습니다.</td></tr>';
return;
}
tempSwUsers.forEach((user, idx) => {
const tr = document.createElement('tr');
tr.innerHTML = `
<td>${user. || user. || ''}</td>
<td>${user. || ''}</td>
<td>${user. || ''}</td>
<td>${user. || ''}</td>
@@ -169,13 +181,19 @@ function openUserEditSubModal(idx: number = -1) {
if (idx > -1) {
const user = tempSwUsers[idx];
setFieldValue('new-user-법인', user. || user.);
setFieldValue('new-user-부서', user.);
setFieldValue('new-user-직위', user.);
setFieldValue('new-user-이름', user.);
setFieldValue('new-user-사용기간', user.);
} else {
setFieldValue('new-user-법인', currentSwUserAsset?.);
// 사용기간 파싱 (yyyy-mm-dd ~ yyyy-mm-dd)
if (user. && user..includes('~')) {
const parts = user..split('~');
setFieldValue('new-user-시작일', parts[0].trim());
setFieldValue('new-user-종료일', parts[1].trim());
} else {
setFieldValue('new-user-시작일', '');
setFieldValue('new-user-종료일', '');
}
}
subModal.classList.remove('hidden');
@@ -190,6 +208,12 @@ export function initSwUserModal(onSave: () => void, closeModals: () => void) {
const addUserBtn = document.getElementById('btn-open-add-user')!;
const confirmUserBtn = document.getElementById('btn-confirm-user-edit')!;
['new-user-시작일', 'new-user-종료일'].forEach(id => {
applyDateMask(document.getElementById(id) as HTMLInputElement);
});
createIcons({ icons: { Calendar } });
addUserBtn.addEventListener('click', () => openUserEditSubModal());
confirmUserBtn.addEventListener('click', () => {
@@ -203,7 +227,7 @@ export function initSwUserModal(onSave: () => void, closeModals: () => void) {
const existingIdx = state.masterData.swUsers.findIndex(u => u.sw_id === currentSwUserAsset!.id);
const newMapping = {
sw_id: currentSwUserAsset!.id,
userDataList: tempSwUsers
userData: tempSwUsers.map(u => ['', u., u., u., u., u.])
};
if (existingIdx > -1) state.masterData.swUsers[existingIdx] = newMapping as any;
@@ -233,11 +257,10 @@ function saveUserDataToList() {
const = Input.files && Input.files.length > 0 ? Input.files[0].name : (idx > -1 ? tempSwUsers[idx]. : '');
const userData: any = {
구매법인: getFieldValue('new-user-법인'),
부서: getFieldValue('new-user-부서'),
직위: getFieldValue('new-user-직위'),
이름: getFieldValue('new-user-이름'),
사용기간: getFieldValue('new-user-사용기간'),
: `${getFieldValue('new-user-시작일')} ~ ${getFieldValue('new-user-종료일')}`,
};

View File

@@ -196,5 +196,5 @@ export function generateDummyData(): MasterAssetData {
});
}
return { pc, server, storage, equip, mobile, subSw, permSw, swUsers, logs };
return { pc, server, storage, equip, mobile, subSw, permSw, cloud: [], swUsers, logs, sw: [], hw: [] };
}

View File

@@ -40,8 +40,8 @@ export interface HardwareAsset {
비고?: string;
현사용조직?: string;
이전사용조직?: string;
보관위치?: string;
현재상태?: string;
detail_purpose?: string;
메인보드?: string;
}
export interface SoftwareAsset {
@@ -62,11 +62,13 @@ export interface SoftwareAsset {
계정명: string;
납품업체: string;
비고: string;
자산번호?: string;
플랫폼명?: string;
결제수단?: string;
결제일?: string;
연결카드번호?: string;
당월청구액?: string;
시작일?: string;
}
export interface SWUser {
@@ -98,14 +100,17 @@ export interface MasterAssetData {
mobile: HardwareAsset[];
subSw: SoftwareAsset[];
permSw: SoftwareAsset[];
swUsers: any[]; // { sw_id, userData: [] } 형태로 처리
cloud: SoftwareAsset[];
swUsers: SWUser[];
logs: HardwareLog[];
sw: SoftwareAsset[];
hw: HardwareAsset[];
}
const HW_TABS = ['개인PC', '서버', '스토리지', '전산비품', '모바일기기'];
const SW_TABS = ['구독SW', '영구SW', '클라우드'];
const PC_HEADERS = ['법인', '자산코드', '사용자', '위치', 'CPU', 'GPU', 'RAM', 'SSD1', 'SSD2', 'HDD1', 'HDD2', 'IP주소', 'HW사양', '구매일', '금액', '납품업체', '품의서명', '비고'];
const PC_HEADERS = ['법인', '자산코드', '사용자', '위치', '모델명', '메인보드', 'CPU', 'GPU', 'RAM', 'SSD1', 'SSD2', 'HDD1', 'HDD2', 'IP주소', 'HW사양', '구매일', '금액', '납품업체', '품의서명', '비고'];
const SERVER_HEADERS = ['구매법인', '자산번호', '구매일자', '유형', '용도', '상세내용', '현사용조직', '이전사용조직', '설치위치', '담당자(정)', '담당자(부)', 'IP 주소 1', 'IP 주소 2', '원격도구', '서버 ID', '서버 PW', '모델명', 'OS', 'CPU', 'RAM', 'GPU', 'Storage 1', 'Storage 2', 'Storage 3', '모니터링', '비고'];
const STORAGE_HEADERS = ['구매법인', '유형', '자산코드', '명칭', '위치', '모델명', '용량', '담당자(정)', '담당자(부)', 'IP주소', 'MAC주소', '구매일', '금액', '납품업체', '품의서명', '비고'];
const EQUIP_HEADERS = ['구매법인', '비품유형', '자산코드', '명칭', '위치', '관리자', 'IP주소', 'MACaddress', 'HW사양', 'OS', '구매일', '금액', '납품업체', '품의서명', '비고'];
@@ -144,7 +149,7 @@ export function downloadTemplate() {
export function exportToExcel(masterData: MasterAssetData) {
const wb = XLSX.utils.book_new();
const exportMap = [
{ tab: '개인PC', list: masterData.pc, headers: PC_HEADERS, map: (a: any) => [a., a., a., a., a.CPU, a.GPU, a.RAM, a.SSD1, a.SSD2, a.HDD1, a.HDD2, a.IP주소, a.HW사양, a., a., a., a., a.] },
{ tab: '개인PC', list: masterData.pc, headers: PC_HEADERS, map: (a: any) => [a., a., a., a., a., a., a.CPU, a.GPU, a.RAM, a.SSD1, a.SSD2, a.HDD1, a.HDD2, a.IP주소, a.HW사양, a., a., a., a., a.] },
{ tab: '서버', list: masterData.server, headers: SERVER_HEADERS, map: (a: any) => [a., a., a., a.storage유형 || '물리', a., a., a., a., a., a._정, a._부, a.IP주소, a.IP2, a., a.ID, a.PW, a., a.OS, a.CPU, a.RAM, a.GPU, a.SSD1, a.SSD2, a.HDD1, a., a.] },
{ tab: '스토리지', list: masterData.storage, headers: STORAGE_HEADERS, map: (a: any) => [a., a.storage유형, a., a., a., a., a., a._정, a._부, a.IP주소, a.MACaddress, a., a., a., a., a.] },
{ tab: '전산비품', list: masterData.equip, headers: EQUIP_HEADERS, map: (a: any) => [a., a., a., a., a., a., a.IP주소, a.MACaddress, a.HW사양, a.OS, a., a., a., a., a.] },
@@ -166,11 +171,11 @@ export async function parseExcel(file: File): Promise<MasterAssetData> {
reader.onload = (e) => {
try {
const workbook = XLSX.read(e.target?.result, { type: 'binary' });
const data: MasterAssetData = { pc: [], server: [], storage: [], equip: [], mobile: [], subSw: [], permSw: [], swUsers: [], logs: [] };
const data: MasterAssetData = { pc: [], server: [], storage: [], equip: [], mobile: [], subSw: [], permSw: [], cloud: [], swUsers: [], logs: [], sw: [], hw: [] };
workbook.SheetNames.forEach(sheetName => {
const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]) as any[];
if (sheetName === '개인PC') {
rows.forEach(r => data.pc.push({ id: Math.random().toString(36).substring(2, 9), type: '개인PC', 법인: r['법인']||'', 자산코드: r['자산코드']||'', 사용자: r['사용자']||'', 위치: r['위치']||'', CPU: r['CPU']||'', GPU: r['GPU']||'', RAM: r['RAM']||'', SSD1: r['SSD1']||'', SSD2: r['SSD2']||'', HDD1: r['HDD1']||'', HDD2: r['HDD2']||'', IP주소: r['IP주소']||'', HW사양: r['HW사양']||'', 구매일: r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'', : '', MACaddress: '', OS: '', : '' }));
rows.forEach(r => data.pc.push({ id: Math.random().toString(36).substring(2, 9), type: '개인PC', 법인: r['법인']||'', 자산코드: r['자산코드']||'', 사용자: r['사용자']||'', 위치: r['위치']||'', 모델명: r['모델명']||'', 메인보드: r['메인보드']||'', CPU: r['CPU']||'', GPU: r['GPU']||'', RAM: r['RAM']||'', SSD1: r['SSD1']||'', SSD2: r['SSD2']||'', HDD1: r['HDD1']||'', HDD2: r['HDD2']||'', IP주소: r['IP주소']||'', HW사양: r['HW사양']||'', 구매일: r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'', : '', MACaddress: '', OS: '', : '' }));
} else if (sheetName === '서버') {
rows.forEach(r => data.server.push({ id: Math.random().toString(36).substring(2, 9), type: '서버', 법인: r['구매법인']||r['법인']||'', 자산코드: r['자산번호']||r['자산코드']||'', 구매일: r['구매일자']||r['구매일']||'', storage유형: r['유형']||'물리', 용도: r['용도']||'', 상세: r['상세내용']||'', 현사용조직: r['현사용조직']||'', 이전사용조직: r['이전사용조직']||'', 위치: r['설치위치']||r['위치']||'', 담당자_정: r['담당자(정)']||'', 담당자_부: r['담당자(부)']||'', IP주소: r['IP 주소 1']||r['IP주소']||'', IP2: r['IP 주소 2']||'', 원격접속: r['원격도구']||r['원격접속']||'', 서버ID: r['서버 ID']||r['서버ID']||'', 서버PW: r['서버 PW']||r['서버PW']||'', 모델명: r['모델명']||'', OS: r['OS']||'', CPU: r['CPU']||'', RAM: r['RAM']||'', GPU: r['GPU']||'', SSD1: r['Storage 1']||r['SSD1']||'', SSD2: r['Storage 2']||r['SSD2']||'', HDD1: r['Storage 3']||r['HDD1']||'', 모니터링: r['모니터링']||'', 비고: r['비고']||'', : '', : '', MACaddress: '', HW사양: '', : '', : '', : '' }));
} else if (sheetName === '스토리지') {

View File

@@ -14,14 +14,15 @@ export interface MasterAssetData {
logs: HardwareLog[];
// 동료 코드 호환용 통합 배열 (프론트엔드 로직용)
hw: HardwareAsset[];
sw: SoftwareAsset[];
hw: HardwareAsset[];
}
export interface AppState {
activeCategory: 'dashboard' | 'hw' | 'sw';
activeSubTab: string; // '대시보드', '개인PC', '서버', '스토리지', '전산비품', '구독SW', '영구SW', '클라우드'
activeCategory: 'dashboard' | 'hw' | 'sw' | 'ops';
activeSubTab: string;
masterData: MasterAssetData;
activeCharts: any[];
}
// 초기 상태
@@ -37,11 +38,12 @@ export const state: AppState = {
subSw: [],
permSw: [],
cloud: [],
hw: [], // 호환용
sw: [], // 호환용
swUsers: [],
logs: []
}
logs: [],
hw: []
},
activeCharts: []
};
/**
@@ -85,14 +87,12 @@ export async function loadMasterDataFromDB() {
}
}
// 동료 코드 호환을 위한 통합 sw 배열 생성
// 동료 코드 호환을 위한 통합 sw/hw 배열 생성
state.masterData.sw = [
...state.masterData.subSw,
...state.masterData.permSw,
...state.masterData.cloud
];
// 하드웨어 통합 배열 생성 (대시보드 등에서 사용)
state.masterData.hw = [
...state.masterData.pc,
...state.masterData.server,
@@ -121,25 +121,18 @@ export function saveHardwareAsset(updatedAsset: HardwareAsset) {
const type = updatedAsset.type || '';
const detailPurpose = (updatedAsset as any). || updatedAsset.detail_purpose || '';
// 1. 타겟 카테고리 결정 (사용자 정의 그룹 기준)
// 1. 타겟 카테고리 결정 (유연한 검색)
let targetKey: keyof MasterAssetData = 'equip';
const upperType = type.toUpperCase();
const isServer = type.includes('서버') || detailPurpose.includes('서버');
const isStorage = ['NAS', 'DAS', '스토리지'].some(t => type.includes(t));
const isMobileGroup = ['모바일', '태블릿', '노트북', '휴대폰', '핸드폰'].some(t => type.includes(t));
const isEquipGroup = ['CPU', 'RAM', 'HDD', 'GPU'].some(t => upperType.includes(t));
const isPc = type === 'PC' || type === '개인PC' || detailPurpose === '개인PC';
if (isServer) {
if (type.includes('서버') || detailPurpose.includes('서버')) {
targetKey = 'server';
} else if (isStorage) {
} else if (['NAS', 'DAS', '스토리지'].some(t => type.includes(t))) {
targetKey = 'storage';
} else if (isMobileGroup) {
} else if (['모바일', '태블릿', '휴대폰', '핸드폰', '노트북'].some(t => type.includes(t))) {
targetKey = 'mobile';
} else if (isPc) {
} else if (type === 'PC' || type === '개인PC' || detailPurpose === '개인PC') {
targetKey = 'pc';
} else if (isEquipGroup) {
} else if (['CPU', 'GPU', 'RAM', 'HDD'].some(t => type.toUpperCase().includes(t))) {
targetKey = 'equip';
}
@@ -155,15 +148,6 @@ export function saveHardwareAsset(updatedAsset: HardwareAsset) {
// 3. 새로운 타겟 카테고리에 추가
(state.masterData[targetKey] as HardwareAsset[]).push(updatedAsset);
// 4. 통합 hw 배열 동기화
state.masterData.hw = [
...state.masterData.pc,
...state.masterData.server,
...state.masterData.storage,
...state.masterData.equip,
...state.masterData.mobile
];
}
/**
@@ -178,13 +162,4 @@ export function deleteHardwareAsset(assetId: string) {
if (idx > -1) arr.splice(idx, 1);
}
});
// 통합 hw 배열 동기화
state.masterData.hw = [
...state.masterData.pc,
...state.masterData.server,
...state.masterData.storage,
...state.masterData.equip,
...state.masterData.mobile
];
}

View File

@@ -33,21 +33,6 @@ export function normalizeDate(dateStr: string): string {
return (dateStr || '').replace(/\./g, '-').trim();
}
/**
* 구매일로부터 현재까지의 경과 연수 계산 (소수점 첫째자리)
*/
export function calculateAssetAge(purchaseDate: string): number {
const normalized = normalizeDate(purchaseDate);
if (!normalized) return 0;
const purchase = new Date(normalized);
if (isNaN(purchase.getTime())) return 0;
const diffMs = Date.now() - purchase.getTime();
const age = diffMs / (1000 * 60 * 60 * 24 * 365.25);
return Math.max(0, parseFloat(age.toFixed(1)));
}
/**
* 고유 ID 생성 (7자리 랜덤 문자열)
*/

View File

@@ -9,7 +9,8 @@ import { initHwModal, openHwModal } from './components/Modal/HWModal';
import { initSwModal, openSwModal } from './components/Modal/SWModal';
import { initSwUserModal } from './components/Modal/SWUserModal';
import { initDashboardDetailModal } from './components/Modal/DashboardDetailModal';
import { createIcons, Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw } from 'lucide';
import { initGuide } from './components/Guide';
import { createIcons, Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw, BookOpen } from 'lucide';
// --- DB 저장을 위한 세분화된 헬퍼 함수들 ---
async function apiBatchSave(url: string, data: any[], label: string) {
@@ -19,10 +20,14 @@ async function apiBatchSave(url: string, data: any[], label: string) {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
if (!response.ok) throw new Error(`${label} DB 저장 실패`);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
throw new Error(`${label} DB 저장 실패: ${errorData.error || response.statusText}`);
}
console.log(`${label} DB 저장 완료`);
} catch (err) {
console.error(`${label} DB 저장 오류:`, err);
alert(`${label} 저장 중 오류가 발생했습니다: ${err.message}`);
}
}
@@ -36,15 +41,16 @@ const savePermSwToDB = () => apiBatchSave('http://localhost:3000/api/sw/perm/bat
const saveCloudToDB = () => apiBatchSave('http://localhost:3000/api/cloud/batch', state.masterData.cloud, '클라우드');
const saveSwUsersToDB = () => apiBatchSave('http://localhost:3000/api/sw-users/batch', state.masterData.swUsers, 'SW사용자');
// 모든 하드웨어 DB 동기화
async function saveAllHardwareToDB() {
await Promise.all([
savePcToDB(),
saveServerToDB(),
saveStorageToDB(),
saveEquipToDB(),
saveMobileToDB()
]);
// 화면 갱신 통합 핸들러 (대시보드 vs 리스트)
function refreshView() {
const mainContent = document.getElementById('main-content')!;
if (!mainContent) return;
if (state.activeSubTab === '대시보드') {
renderDashboard(mainContent);
} else {
renderSWTable(mainContent);
}
}
// 모든 소프트웨어 DB 동기화
@@ -55,6 +61,22 @@ async function saveAllSoftwareToDB() {
saveCloudToDB(),
saveSwUsersToDB()
]);
// 저장 후 최신 데이터 다시 로드 (정합성)
await loadMasterDataFromDB();
refreshView();
}
// 모든 하드웨어 DB 동기화
async function saveAllHardwareToDB() {
await Promise.all([
savePcToDB(),
saveServerToDB(),
saveStorageToDB(),
saveEquipToDB(),
saveMobileToDB()
]);
await loadMasterDataFromDB();
refreshView();
}
// --- App Initialization ---
@@ -75,20 +97,19 @@ function initApp() {
});
// 모달 초기화
initPcModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
initHwModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
initPcModal(() => saveAllHardwareToDB(), closeAllModals);
initHwModal(() => saveAllHardwareToDB(), closeAllModals);
initSwModal(() => {
saveAllSoftwareToDB();
renderSWTable(mainContent);
}, closeAllModals);
initSwModal(() => saveAllSoftwareToDB(), closeAllModals);
initSwUserModal(() => {
saveSwUsersToDB();
renderSWTable(mainContent);
saveSwUsersToDB().then(() => {
loadMasterDataFromDB().then(() => refreshView());
});
}, closeAllModals);
initDashboardDetailModal();
initGuide();
} catch (e) { console.error('❌ Initialization failed:', e); }
// 초기 로드 시 대시보드 렌더링
@@ -145,7 +166,7 @@ function initApp() {
});
createIcons({
icons: { Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw }
icons: { Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw, BookOpen }
});
}

View File

@@ -156,15 +156,16 @@ body {
/* --- Layout Frame --- */
.content-area {
flex: 1;
padding: 2rem;
overflow-y: auto;
padding: 1.25rem 1.5rem;
overflow: hidden;
}
.view-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 1.5rem;
gap: 0.75rem;
}
.hidden { display: none !important; }

349
src/styles/guide.css Normal file
View File

@@ -0,0 +1,349 @@
/* ITAM Guide Modal Styles */
:root {
--guide-modal-width: 1060px;
--guide-modal-height: 92vh;
--guide-primary: #1E5149;
--guide-accent: #6cc020;
}
/* Floating Trigger Button - REMOVED (now in header) */
.guide-trigger {
display: none;
}
/* Modal Overlay */
.guide-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(4px);
z-index: 2000;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
}
.guide-overlay.active {
opacity: 1;
visibility: visible;
}
/* Guide Modal */
.guide-modal {
width: var(--guide-modal-width);
max-width: 94vw;
height: var(--guide-modal-height);
background-color: #ffffff;
border-radius: 14px;
overflow: hidden;
box-shadow: 0 24px 60px rgba(0,0,0,0.3);
display: flex;
flex-direction: column;
transform: translateY(20px) scale(0.97);
opacity: 0;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.guide-overlay.active .guide-modal {
transform: translateY(0) scale(1);
opacity: 1;
}
/* Header */
.guide-header {
padding: 1.1rem 1.5rem;
border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: center;
background: linear-gradient(135deg, var(--guide-primary), #2a6d63);
color: white;
flex-shrink: 0;
}
.guide-header h2 {
font-size: 1.15rem;
font-weight: 700;
display: flex;
align-items: center;
gap: 10px;
margin: 0;
}
.btn-close-guide {
background: rgba(255, 255, 255, 0.12);
border: none;
color: white;
cursor: pointer;
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s;
}
.btn-close-guide:hover {
background: rgba(255, 255, 255, 0.3);
}
/* ===== Tab Navigation ===== */
.guide-tabs {
display: flex;
border-bottom: 1px solid var(--border-color);
background: #f8faf9;
padding: 0 1.5rem;
flex-shrink: 0;
gap: 2px;
overflow-x: auto;
}
.guide-tab {
padding: 0.7rem 1rem;
font-size: 13px;
font-weight: 600;
color: var(--text-muted);
cursor: pointer;
border-bottom: 2px solid transparent;
transition: all 0.2s ease;
white-space: nowrap;
position: relative;
top: 1px;
}
.guide-tab:hover {
color: var(--guide-primary);
background: rgba(30, 81, 73, 0.04);
}
.guide-tab.active {
color: var(--guide-primary);
border-bottom-color: var(--guide-primary);
background: white;
}
/* ===== Content Area ===== */
.guide-body {
flex: 1;
overflow-y: auto;
padding: 0;
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE/Edge */
}
.guide-body::-webkit-scrollbar {
display: none; /* Chrome/Safari */
}
.guide-tab-panel {
display: none;
padding: 1.5rem 2rem 2rem;
animation: guideFadeIn 0.3s ease;
}
.guide-tab-panel.active {
display: block;
}
@keyframes guideFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
/* ===== Section Styles ===== */
.guide-section {
display: flex;
flex-direction: column;
gap: 0.75rem;
margin-bottom: 1.5rem;
}
.guide-section:last-child {
margin-bottom: 0;
}
.guide-section h3 {
font-size: 1rem;
padding-bottom: 0.4rem;
border-bottom: 2px solid var(--guide-primary);
color: var(--guide-primary);
margin: 0;
display: flex;
align-items: center;
gap: 8px;
}
.guide-section h4 {
font-size: 0.9rem;
color: var(--text-main);
margin: 0.6rem 0 0.2rem;
font-weight: 700;
}
.guide-text {
font-size: 13px;
color: var(--text-muted);
line-height: 1.7;
margin: 0;
}
.guide-text strong {
color: var(--text-main);
}
/* ===== Flowchart ===== */
.flow-container {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 1.25rem;
background-color: #f8faf9;
border-radius: 12px;
border: 1px dashed #d0d7d5;
}
.flow-row {
display: flex;
width: 100%;
gap: 0.75rem;
align-items: stretch;
}
.flow-step {
flex: 1;
background: white;
padding: 0.65rem 0.9rem;
border-radius: 8px;
border: 1px solid var(--border-color);
display: flex;
align-items: flex-start;
gap: 10px;
transition: transform 0.2s, box-shadow 0.2s;
}
.flow-step:hover {
transform: translateY(-2px);
box-shadow: 0 4px 14px rgba(0,0,0,0.06);
border-color: var(--guide-primary);
}
.flow-step .step-number {
width: 22px;
height: 22px;
min-width: 22px;
border-radius: 50%;
background-color: var(--guide-primary);
color: white;
font-size: 11px;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-top: 1px;
}
.flow-step .step-label {
font-weight: 700;
color: var(--text-main);
font-size: 13px;
display: block;
}
.flow-step .step-desc {
font-size: 11.5px;
color: var(--text-muted);
line-height: 1.5;
margin-top: 2px;
}
.flow-arrow {
color: #b5c4c0;
width: 16px !important;
height: 16px !important;
}
.flow-arrow-right {
color: #b5c4c0;
width: 16px !important;
height: 16px !important;
display: flex;
align-items: center;
flex-shrink: 0;
}
/* ===== Info Table ===== */
.guide-info-table {
width: 100%;
border-collapse: collapse;
font-size: 12.5px;
margin-top: 0.5rem;
}
.guide-info-table th {
background: #f0f4f3;
color: var(--guide-primary);
font-weight: 700;
padding: 0.5rem 0.75rem;
text-align: left;
border-bottom: 2px solid var(--guide-primary);
}
.guide-info-table td {
padding: 0.45rem 0.75rem;
border-bottom: 1px solid var(--border-color);
color: var(--text-main);
line-height: 1.5;
}
.guide-info-table tr:hover td {
background: #f8faf9;
}
/* ===== Tip Box ===== */
.guide-tip {
background: linear-gradient(135deg, #f0f9eb, #e8f5e0);
border-left: 4px solid var(--guide-accent);
border-radius: 0 8px 8px 0;
padding: 0.75rem 1rem;
font-size: 12.5px;
color: #2d5016;
line-height: 1.6;
}
.guide-tip strong {
color: #1a3a0a;
}
/* ===== Warning Box ===== */
.guide-warn {
background: linear-gradient(135deg, #fff8ed, #fff3e0);
border-left: 4px solid #ff9800;
border-radius: 0 8px 8px 0;
padding: 0.75rem 1rem;
font-size: 12.5px;
color: #7a4a00;
line-height: 1.6;
}
/* ===== Badge ===== */
.guide-badge {
display: inline-block;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 700;
}
.guide-badge.green { background: #e6f4ea; color: #137333; }
.guide-badge.orange { background: #fff4e5; color: #b45309; }
.guide-badge.blue { background: #e8f0fe; color: #1a56db; }
.guide-badge.red { background: #fce8e6; color: #c5221f; }

View File

@@ -53,15 +53,20 @@
border: none !important;
}
.modal-header .btn-icon i,
.modal-header .btn-icon svg {
width: 20px !important; /* Original natural size */
height: 20px !important;
stroke: #FFFFFF !important;
.btn-icon {
display: inline-flex;
align-items: center;
justify-content: center;
background: none;
border: none;
padding: 0;
cursor: pointer;
color: var(--primary-color);
transition: opacity 0.2s;
}
.modal-header .btn-icon:hover {
background: none !important;
.btn-icon:hover {
opacity: 0.7;
}
.modal-body {
@@ -116,6 +121,13 @@
box-shadow: none !important;
}
.grid-form.is-view-mode button {
pointer-events: none !important;
background: none !important;
border: none !important;
opacity: 0.8;
}
.grid-form.is-view-mode select::-ms-expand {
display: none !important;
}

View File

@@ -62,7 +62,8 @@
border-left: none;
border-right: none;
overflow: auto;
max-height: calc(100vh - 240px);
flex: 1;
min-height: 0;
}
table {

View File

@@ -1,191 +1,104 @@
import { state } from '../../core/state';
import { HardwareAsset } from '../../core/excelHandler';
import { openHwModal } from '../../components/Modal/HWModal';
import { calculateAssetAge, normalizeDate } from '../../core/utils';
import { openDashboardDetail } from '../../components/Modal/DashboardDetailModal';
import { normalizeDate } from '../../core/utils';
declare var Chart: any;
export function renderHwDashboard(container: HTMLElement) {
const allHw = state.masterData.hw || [];
const types = ['개인PC', '서버', '스토리지', '전산비품'];
const units = ['대', '대', '대', '개'];
const groups: any = {};
// 1. 데이터 가공
let totalAge = 0;
let countWithDate = 0;
let over5YearsCount = 0;
let latestAsset: HardwareAsset | null = null;
let latestYear = 0;
types.forEach(t => { groups[t] = { idle: [], active: [] }; });
const ageGroups = { stable: 0, warning: 0, critical: 0 };
const yearlyCount: Record<string, number> = {};
allHw.forEach(a => {
const pDate = a. || (a as any).purchase_date;
if (!pDate) return;
const age = calculateAssetAge(pDate);
totalAge += age;
countWithDate++;
// 노후도 분류
if (age >= 5) {
over5YearsCount++;
ageGroups.critical++;
} else if (age >= 3) {
ageGroups.warning++;
} else {
ageGroups.stable++;
}
// 연도별 도입 현황 추출
const year = normalizeDate(pDate).split('-')[0];
if (year && year.length === 4) {
yearlyCount[year] = (yearlyCount[year] || 0) + 1;
const yNum = parseInt(year);
if (yNum > latestYear) {
latestYear = yNum;
latestAsset = a;
}
}
state.masterData.hw.forEach(a => {
if (!groups[a.type]) return;
if (isHwIdle(a)) groups[a.type].idle.push(a);
else groups[a.type].active.push(a);
});
const avgAge = countWithDate > 0 ? (totalAge / countWithDate).toFixed(1) : '0';
const over5Rate = allHw.length > 0 ? Math.round((over5YearsCount / allHw.length) * 100) : 0;
let usageCards = '';
types.forEach((t, i) => {
const total = groups[t].idle.length + groups[t].active.length;
const used = groups[t].active.length;
const per = total > 0 ? Math.round((used / total) * 100) : 0;
const barColor = per >= 50 ? 'var(--dash-primary)' : 'var(--dash-danger)';
// 교체 시급 대상 TOP 10 (오래된 순)
const criticalList = [...allHw]
.filter(a => (a. || (a as any).purchase_date))
.sort((a, b) => {
const dateA = new Date(normalizeDate(a. || (a as any).purchase_date)).getTime();
const dateB = new Date(normalizeDate(b. || (b as any).purchase_date)).getTime();
return dateA - dateB;
})
.slice(0, 10);
usageCards += `
<div class="dashboard-card" data-action="idle" data-type="${t}" style="padding: 1.25rem 1.5rem; cursor:pointer; min-height:auto;">
<span style="font-size:1rem; font-weight:700; color:var(--text-main);">${t} 사용현황</span>
<div style="font-size: 0.8125rem; color:var(--text-muted); margin-bottom: 1rem;">
${total}${units[i]}${used}${units[i]} 사용 중
</div>
<div style="font-size: 2rem; font-weight:700; color:${barColor}; line-height:1;">${per}%</div>
<div style="width:100%; height:4px; background-color:var(--border-color); border-radius:2px; overflow:hidden; margin-top:0.75rem;">
<div style="width:${per}%; height:100%; background-color:${barColor};"></div>
</div>
</div>`;
});
// 2. UI 렌더링
container.innerHTML = `
<div class="view-container">
<div class="dashboard-header-stats" style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 2rem;">
<div class="dashboard-card stat-card">
<div class="stat-label">전체 평균 사용 연수</div>
<div class="stat-value">${avgAge}<span class="unit">년</span></div>
<div class="stat-footer">권장 교체 주기: 4.5년</div>
</div>
<div class="dashboard-card stat-card ${over5Rate >= 20 ? 'critical' : ''}">
<div class="stat-label">5년 이상 노후 자산 비율</div>
<div class="stat-value" style="${over5Rate >= 20 ? 'color:var(--danger)' : ''}">${over5Rate}<span class="unit">%</span></div>
<div class="stat-footer">${over5YearsCount}대의 자산이 교체 대상을 초과함</div>
</div>
<div class="dashboard-card stat-card">
<div class="stat-label">최신 도입 모델 (${latestYear}년)</div>
<div class="stat-value" style="font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;" title="${latestAsset?. || '정보 없음'}">
${latestAsset?. || '정보 없음'}
</div>
<div class="stat-footer">가장 최근 자산번호: ${latestAsset?. || '-'}</div>
</div>
</div>
<h3 class="dashboard-section-title">자산 사용현황 요약</h3>
<div class="dashboard-grid">${usageCards}</div>
<div class="dashboard-layout-2col" style="margin-bottom: 2rem;">
<h3 class="dashboard-section-title">하드웨어 보유 통계</h3>
<div class="dashboard-layout-2col">
<div class="dashboard-card">
<h4 class="card-title">자산 노후도 분포</h4>
<div style="height: 250px;"><canvas id="chart-aging-dist"></canvas></div>
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">자산 유형별 보유 현황</h4>
<canvas id="chart-hw-types"></canvas>
</div>
<div class="dashboard-card">
<h4 class="card-title">연도별 자산 도입 추이</h4>
<div style="height: 250px;"><canvas id="chart-purchase-trend"></canvas></div>
<h4 style="margin-bottom:1rem; font-size:0.9rem; color:var(--text-muted);">구매법인별 자산 분포</h4>
<canvas id="chart-hw-corps"></canvas>
</div>
</div>
<h3 class="dashboard-section-title">⚠️ 교체 검토 대상 (가장 오래된 자산 TOP 10)</h3>
<div class="table-container" style="background: white; border-radius: 8px; border: 1px solid var(--border-color);">
<table>
<thead>
<tr>
<th>순위</th>
<th>자산번호</th>
<th>유형</th>
<th>모델명</th>
<th>사용자/담당자</th>
<th>구매일</th>
<th>연령</th>
</tr>
</thead>
<tbody>
${criticalList.map((a, i) => `
<tr class="clickable-row" data-id="${a.id}">
<td style="text-align:center; font-weight:600; color:var(--text-muted)">${i + 1}</td>
<td>${a. || '-'}</td>
<td><span class="badge-type">${a.type}</span></td>
<td>${a. || a. || '-'}</td>
<td>${a. || a._정 || '-'}</td>
<td style="text-align:center;">${a. || (a as any).purchase_date || '-'}</td>
<td style="text-align:center;"><strong style="color:${calculateAssetAge(a. || (a as any).purchase_date) >= 5 ? 'var(--danger)' : 'inherit'}">${calculateAssetAge(a. || (a as any).purchase_date)}년</strong></td>
</tr>
`).join('')}
</tbody>
</table>
</div>
</div>
`;
// 3. 차트 초기화
setTimeout(() => {
initAgingCharts(ageGroups, yearlyCount);
// 행 클릭 이벤트 바인딩
container.querySelectorAll('.clickable-row').forEach(row => {
row.addEventListener('click', () => {
const id = row.getAttribute('data-id');
const asset = allHw.find(h => h.id === id);
if (asset) openHwModal(asset, 'view');
if (typeof Chart === 'undefined') return;
const ctxType = (document.getElementById('chart-hw-types') as HTMLCanvasElement)?.getContext('2d');
const ctxCorp = (document.getElementById('chart-hw-corps') as HTMLCanvasElement)?.getContext('2d');
if (ctxType) {
const chart = new Chart(ctxType, {
type: 'doughnut',
data: { labels: types, datasets: [{ data: types.map(t => state.masterData.hw.filter(a => a.type === t).length), backgroundColor: ['#1E5149', '#3b82f6', '#10b981', '#f59e0b'] }] },
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { position: 'right' } } }
});
});
state.activeCharts.push(chart);
}
if (ctxCorp) {
const corps = ['한맥', '삼안', '바론'];
const chart = new Chart(ctxCorp, {
type: 'bar',
data: { labels: corps, datasets: [{ label: '보유 수량', data: corps.map(c => state.masterData.hw.filter(a => a. === c).length), backgroundColor: 'rgba(30, 81, 73, 0.7)', borderRadius: 4 }] },
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } } }
});
state.activeCharts.push(chart);
}
}, 100);
container.querySelectorAll('[data-action="idle"]').forEach(card => {
card.addEventListener('click', () => {
const t = card.getAttribute('data-type')!;
openDashboardDetail(`[${t}] 유휴 자산 목록`, groups[t].idle);
});
});
}
function initAgingCharts(ageGroups: any, yearlyCount: Record<string, number>) {
const agingCtx = document.getElementById('chart-aging-dist') as HTMLCanvasElement;
if (agingCtx) {
new Chart(agingCtx, {
type: 'doughnut',
data: {
labels: ['안정 (3년 미만)', '주의 (3~5년)', '위험 (5년 이상)'],
datasets: [{
data: [ageGroups.stable, ageGroups.warning, ageGroups.critical],
backgroundColor: ['#1E5149', '#9CA3AF', '#E11D48'],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { position: 'right' } },
cutout: '70%'
}
});
}
const trendCtx = document.getElementById('chart-purchase-trend') as HTMLCanvasElement;
if (trendCtx) {
const years = Object.keys(yearlyCount).sort();
new Chart(trendCtx, {
type: 'bar',
data: {
labels: years,
datasets: [{
label: '도입 수량',
data: years.map(y => yearlyCount[y]),
backgroundColor: '#1E5149',
borderRadius: 4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: { beginAtZero: true, ticks: { stepSize: 1 } },
x: { grid: { display: false } }
}
}
});
}
function isHwIdle(a: HardwareAsset) {
if (a.type === '개인PC') return !a. || a..trim() === '' || a..trim() === '-';
if (a.type === '스토리지') return !a._정 || a._정.trim() === '' || a._정.trim() === '-';
return !a. || a..trim() === '' || a..trim() === '-';
}
function getHwAgeYears(a: HardwareAsset) {
if (!a.) return 0;
try {
const buyDate = new Date(normalizeDate(a.));
if (isNaN(buyDate.getTime())) return 0;
return (Date.now() - buyDate.getTime()) / (1000 * 60 * 60 * 24 * 365.25);
} catch { return 0; }
}

View File

@@ -1,5 +1,6 @@
import { state } from '../../core/state';
import { openSwModal } from '../../components/Modal/SWModal';
import { formatPrice } from '../../core/utils';
import { createIcons, Cloud, CreditCard, DollarSign } from 'lucide';
export function renderCloudList(container: HTMLElement) {
@@ -93,7 +94,7 @@ export function renderCloudList(container: HTMLElement) {
<td>${asset.||''}</td>
<td style="text-align:center;">${paymentBadge}</td>
<td style="text-align:center;">${asset. ? asset. + '일' : ''}</td>
<td style="text-align:right; font-weight:600;">${asset. ? Number(asset.).toLocaleString() : '0'}</td>
<td style="text-align:right; font-weight:600;">${asset. ? '₩ ' + formatPrice(asset.) : '0'}</td>
<td>${asset.||''}</td>
`;

View File

@@ -1,6 +1,6 @@
import { state } from '../../core/state';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, sortAssets } from '../../core/utils';
import { formatInline, sortAssets, formatPrice } from '../../core/utils';
import { createIcons, RefreshCcw } from 'lucide';
export function renderEquipmentList(container: HTMLElement) {
@@ -28,23 +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 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>
</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);
@@ -72,31 +56,19 @@ export function renderEquipmentList(container: HTMLElement) {
filtered.forEach((asset, idx) => {
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>`;
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>${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>${formatPrice(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');
});
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr);
});
};

View File

@@ -1,6 +1,6 @@
import { state } from '../../core/state';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, sortAssets } from '../../core/utils';
import { formatInline, sortAssets, formatPrice } from '../../core/utils';
import { createIcons, RefreshCcw } from 'lucide';
export function renderMobileList(container: HTMLElement) {
@@ -28,23 +28,7 @@ export function renderMobileList(container: HTMLElement) {
const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container';
const table = document.createElement('table');
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>
</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);
@@ -72,30 +56,19 @@ export function renderMobileList(container: HTMLElement) {
filtered.forEach((asset, idx) => {
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>`;
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="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>${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>${formatPrice(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');
});
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr);
});
};

View File

@@ -1,6 +1,6 @@
import { state } from '../../core/state';
import { openPcModal } from '../../components/Modal/PCModal';
import { formatInline, sortAssets } from '../../core/utils';
import { formatInline, sortAssets, formatPrice } from '../../core/utils';
import { createIcons, Paperclip, RefreshCcw } from 'lucide';
export function renderPcList(container: HTMLElement) {
@@ -70,7 +70,7 @@ export function renderPcList(container: HTMLElement) {
<td>${asset.RAM||''}</td>
<td>${formatInline(storage)}</td>
<td>${asset.||''}</td>
<td>${asset.||''}</td>
<td>${formatPrice(asset.)}</td>
<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>
`;

View File

@@ -1,7 +1,7 @@
import { state } from '../../core/state';
import { openSwModal } from '../../components/Modal/SWModal';
import { openSwUserModal } from '../../components/Modal/SWUserModal';
import { sortAssets } from '../../core/utils';
import { sortAssets, formatPrice } from '../../core/utils';
import { CORP_LIST } from '../../components/Modal/SharedData';
import { generateOptionsHTML } from '../../components/Modal/ModalUtils';
import { createIcons, Edit2, Users, RefreshCcw } from 'lucide';
@@ -28,7 +28,7 @@ export function renderSwList(container: HTMLElement) {
</select>
</div>
<div class="search-item">
<label>구매법인</label>
<label>법인</label>
<select id="filter-corp">${generateOptionsHTML(CORP_LIST, '', true)}</select>
</div>
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
@@ -46,15 +46,15 @@ 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>
${isSub ? '<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>
</tr>
</thead>
<tbody id="dynamic-tbody"></tbody>
@@ -82,7 +82,7 @@ export function renderSwList(container: HTMLElement) {
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="12" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
return;
}
@@ -94,9 +94,8 @@ export function renderSwList(container: HTMLElement) {
let statusHtml = '';
if (isSub) {
let isExpired = false;
if (asset.) {
const parts = asset..split('~');
const endDateStr = parts[parts.length - 1].trim().replace(/\./g, '-');
if (asset.) {
const endDateStr = asset..replace(/\./g, '-');
const endDate = new Date(endDateStr);
if (!isNaN(endDate.getTime())) {
endDate.setHours(23, 59, 59, 999);
@@ -121,26 +120,16 @@ export function renderSwList(container: HTMLElement) {
<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;">${asset.||''}</td>
<td style="text-align:center;">${asset.||''}</td>
<td style="text-align:right;">${formatPrice(asset.)}</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');
}
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); });
tbody.appendChild(tr);
});
createIcons({ icons: { Edit2, Users, RefreshCcw } });

View File

@@ -1,24 +1,4 @@
@echo off
chcp 65001 >nul
title HM ITAM 서버
echo ============================================
echo HM ITAM 개발 서버 시작
echo ============================================
echo.
cd /d "%~dp0"
:: node_modules 존재 여부 확인
if not exist "node_modules" (
echo [INFO] node_modules가 없습니다. 패키지를 설치합니다...
echo.
call npm install
echo.
)
echo [INFO] 개발 서버를 시작합니다...
echo [INFO] 종료하려면 stop_server.bat을 실행하거나 이 창에서 Ctrl+C를 누르세요.
echo.
npm run dev
powershell -ExecutionPolicy Bypass -File "%~dp0start_server.ps1"

47
start_server.ps1 Normal file
View File

@@ -0,0 +1,47 @@
# HM ITAM Server Start Script
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " HM ITAM System Start" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "[INFO] Checking Node.js and npm..."
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Host "[ERROR] Node.js not found." -ForegroundColor Red
Read-Host "Press Enter to exit"
exit
}
if (-not (Test-Path "node_modules")) {
Write-Host "[INFO] Installing dependencies..."
npm install
}
Write-Host "[INFO] Checking ports..."
$backendPort = 3000
$frontendPort = 8080
if (Get-NetTCPConnection -LocalPort $backendPort -ErrorAction SilentlyContinue) {
Write-Host "[WARNING] Port $backendPort [Backend] is already in use." -ForegroundColor Yellow
}
if (Get-NetTCPConnection -LocalPort $frontendPort -ErrorAction SilentlyContinue) {
Write-Host "[WARNING] Port $frontendPort [Frontend] is already in use." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "[INFO] Starting Backend [Port: 3000]..."
Start-Process cmd -ArgumentList "/k npm run server"
Write-Host "[INFO] Starting Frontend [Port: 8080]..."
Start-Process cmd -ArgumentList "/k npm run dev"
Write-Host ""
Write-Host "============================================" -ForegroundColor Green
Write-Host " [OK] Server commands issued successfully." -ForegroundColor Green
Write-Host " [INFO] Please check the new windows for logs."
Write-Host "============================================" -ForegroundColor Green
Write-Host ""
Read-Host "Press Enter to continue..."

View File

@@ -1,35 +1,31 @@
@echo off
chcp 65001 >nul
title HM ITAM 서버 종료
title HM ITAM 서버 통합 종료 (강력 모드)
echo ============================================
echo HM ITAM 개발 서버 종료
echo HM ITAM 통합 개발 환경 종료
echo ============================================
echo.
:: Vite 개발 서버가 사용하는 node 프로세스 찾기
set "found=0"
set "frontend_port=8080"
set "backend_port=3000"
for /f "tokens=2" %%a in ('netstat -ano ^| findstr ":5173" ^| findstr "LISTENING" 2^>nul') do (
set "found=1"
)
if "%found%"=="0" (
echo [INFO] 실행 중인 Vite 개발 서버를 찾을 수 없습니다.
echo.
pause
exit /b 0
)
echo [INFO] 포트 5173에서 실행 중인 서버를 종료합니다...
echo [INFO] 서버 프로세스를 정밀 검색 중...
echo.
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":5173" ^| findstr "LISTENING"') do (
echo [INFO] PID %%a 프로세스를 종료합니다...
taskkill /PID %%a /F >nul 2>&1
)
:: 백엔드 종료 (3000)
echo [INFO] 백엔드 서버(Port: %backend_port%) 종료 시도...
powershell -Command "$pids = Get-NetTCPConnection -LocalPort %backend_port% -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique; if ($pids) { foreach ($pid in $pids) { Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue; Write-Host '[OK] PID'$pid' 종료됨.' } } else { Write-Host '[INFO] 실행 중인 백엔드 서버가 없습니다.' }"
:: 프론트엔드 종료 (8080)
echo.
echo [INFO] 프론트엔드 서버(Port: %frontend_port%) 종료 시도...
powershell -Command "$pids = Get-NetTCPConnection -LocalPort %frontend_port% -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique; if ($pids) { foreach ($pid in $pids) { Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue; Write-Host '[OK] PID'$pid' 종료됨.' } } else { Write-Host '[INFO] 실행 중인 프론트엔드 서버가 없습니다.' }"
echo.
echo [OK] 서버가 종료되었습니다.
echo ============================================
echo [OK] 모든 종료 명령을 전달했습니다.
echo [HINT] 여전히 종료되지 않는다면 '관리자 권한'으로 실행하세요.
echo ============================================
echo.
pause

BIN
temp_sw.txt Normal file

Binary file not shown.