Compare commits
11 Commits
HW_dashboa
...
809f3fcf3b
| Author | SHA1 | Date | |
|---|---|---|---|
| 809f3fcf3b | |||
| e1cdcfd93a | |||
| fdc29b23c1 | |||
| af37df7f2d | |||
| d52c2c4200 | |||
| 4b765aba2e | |||
| 7247737ce0 | |||
| e4d958b5f2 | |||
| ba7ce796d1 | |||
| fca9f5caf8 | |||
| 34baea9143 |
49
db_fix_data.js
Normal file
49
db_fix_data.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import mysql from 'mysql2/promise';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const { DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT } = process.env;
|
||||
|
||||
async function migrateData() {
|
||||
const connection = await mysql.createConnection({
|
||||
host: DB_HOST,
|
||||
user: DB_USER,
|
||||
password: DB_PASS,
|
||||
database: DB_NAME,
|
||||
port: parseInt(DB_PORT || '3306')
|
||||
});
|
||||
|
||||
console.log('🔄 기존 데이터 보정 시작 (상세유형 = 유형)...');
|
||||
|
||||
const tables = ['pc_assets', 'server_assets', 'storage_assets', 'equip_assets', 'mobile_assets'];
|
||||
|
||||
for (const table of tables) {
|
||||
// 1. 유형(type)이 비어있는 경우 기본값 채우기 (보정 전 단계)
|
||||
let defaultType = '기타';
|
||||
if (table === 'server_assets') defaultType = '서버';
|
||||
else if (table === 'pc_assets') defaultType = '개인PC';
|
||||
else if (table === 'storage_assets') defaultType = '스토리지';
|
||||
else if (table === 'equip_assets') defaultType = '전산비품';
|
||||
else if (table === 'mobile_assets') defaultType = '모바일기기';
|
||||
|
||||
await connection.query(`UPDATE ${table} SET type = ? WHERE type IS NULL OR type = ''`, [defaultType]);
|
||||
|
||||
// 2. 개인PC가 아닌 데이터들에 대해 상세유형 = 유형 업데이트
|
||||
const [result] = await connection.query(`
|
||||
UPDATE ${table}
|
||||
SET detail_purpose = type
|
||||
WHERE type NOT IN ('개인PC', 'PC')
|
||||
`);
|
||||
|
||||
console.log(`✅ ${table}: ${result.affectedRows}개 데이터 보정 완료`);
|
||||
}
|
||||
|
||||
console.log('✨ 모든 기존 데이터 보정이 완료되었습니다.');
|
||||
await connection.end();
|
||||
}
|
||||
|
||||
migrateData().catch(err => {
|
||||
console.error('❌ 데이터 보정 실패:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -32,7 +32,7 @@ async function initDB() {
|
||||
id VARCHAR(50) PRIMARY KEY,
|
||||
corp VARCHAR(100) COMMENT '구매법인',
|
||||
asset_code VARCHAR(100) COMMENT '자산번호',
|
||||
purchase_date VARCHAR(50) COMMENT '구매일자',
|
||||
purchase_date VARCHAR(50) COMMENT '구매연월',
|
||||
type VARCHAR(50) COMMENT '유형',
|
||||
detail_purpose VARCHAR(50) COMMENT '상세용도',
|
||||
purpose VARCHAR(255) COMMENT '용도',
|
||||
@@ -57,6 +57,8 @@ async function initDB() {
|
||||
monitoring VARCHAR(100),
|
||||
price VARCHAR(100) COMMENT '금액',
|
||||
remarks TEXT,
|
||||
storage_location VARCHAR(255) COMMENT '보관위치',
|
||||
status VARCHAR(50) COMMENT '현재상태',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='${comment}';
|
||||
`;
|
||||
@@ -77,7 +79,7 @@ async function initDB() {
|
||||
license_type VARCHAR(100) COMMENT '라이선스 유형',
|
||||
quantity INT COMMENT '수량',
|
||||
price VARCHAR(100) COMMENT '금액',
|
||||
purchase_date VARCHAR(50) COMMENT '구매일',
|
||||
purchase_date VARCHAR(50) COMMENT '구매연월',
|
||||
expiry_date VARCHAR(50) COMMENT '만료일',
|
||||
vendor VARCHAR(255) COMMENT '납품업체',
|
||||
remarks TEXT COMMENT '비고',
|
||||
@@ -95,7 +97,7 @@ async function initDB() {
|
||||
license_key VARCHAR(255) COMMENT '라이선스 키',
|
||||
quantity INT COMMENT '수량',
|
||||
price VARCHAR(100) COMMENT '금액',
|
||||
purchase_date VARCHAR(50) COMMENT '구매일',
|
||||
purchase_date VARCHAR(50) COMMENT '구매연월',
|
||||
vendor VARCHAR(255) COMMENT '납품업체',
|
||||
remarks TEXT COMMENT '비고',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
|
||||
@@ -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>
|
||||
|
||||
473
server.js
473
server.js
@@ -1,330 +1,243 @@
|
||||
import express from 'express';
|
||||
import mysql from 'mysql2/promise';
|
||||
import cors from 'cors';
|
||||
import mysql from 'mysql2/promise';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
app.use(express.json({ limit: '50mb' }));
|
||||
|
||||
// MySQL Connection Pool
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME,
|
||||
port: parseInt(process.env.DB_PORT || '3306'),
|
||||
host: process.env.DB_HOST || 'localhost',
|
||||
user: process.env.DB_USER || 'itam_user',
|
||||
password: process.env.DB_PASSWORD || 'itam_pw',
|
||||
database: process.env.DB_NAME || 'itam_db',
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0
|
||||
});
|
||||
|
||||
// 테이블 존재 여부 확인 및 자동 생성
|
||||
// Helper for DB updates
|
||||
async function ensureTables() {
|
||||
const connection = await pool.getConnection();
|
||||
try {
|
||||
await connection.query(`
|
||||
// Cloud_Assets Table
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS cloud_assets (
|
||||
id VARCHAR(50) PRIMARY KEY,
|
||||
platform_name VARCHAR(100),
|
||||
corp VARCHAR(100),
|
||||
corp VARCHAR(50),
|
||||
dept VARCHAR(100),
|
||||
product_name VARCHAR(255),
|
||||
account_name VARCHAR(255),
|
||||
pay_method VARCHAR(100),
|
||||
pay_day VARCHAR(50),
|
||||
card_num VARCHAR(100),
|
||||
monthly_fee VARCHAR(100),
|
||||
remarks TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
purpose VARCHAR(255),
|
||||
account_name VARCHAR(100),
|
||||
payment_method VARCHAR(50),
|
||||
payment_date VARCHAR(50),
|
||||
card_number VARCHAR(50),
|
||||
monthly_fee VARCHAR(50),
|
||||
note TEXT
|
||||
)
|
||||
`);
|
||||
await connection.query(`
|
||||
|
||||
// Logs Table
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS asset_logs (
|
||||
id VARCHAR(50) PRIMARY KEY,
|
||||
asset_id VARCHAR(50),
|
||||
log_date VARCHAR(50),
|
||||
log_user VARCHAR(100),
|
||||
date VARCHAR(20),
|
||||
details TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
user VARCHAR(50),
|
||||
INDEX(asset_id)
|
||||
)
|
||||
`);
|
||||
console.log('✅ Cloud & Logs tables ensured.');
|
||||
} finally {
|
||||
connection.release();
|
||||
} catch (err) {
|
||||
console.error('❌ Error ensuring tables:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// 공통 배치 저장 로직
|
||||
async function batchSave(tableName, assets, getQuery) {
|
||||
const connection = await pool.getConnection();
|
||||
ensureTables();
|
||||
|
||||
// --- API Endpoints ---
|
||||
|
||||
// Get Master Data (Multi-tab)
|
||||
app.get('/api/master-data', async (req, res) => {
|
||||
try {
|
||||
await connection.beginTransaction();
|
||||
await connection.query(`DELETE FROM ${tableName}`);
|
||||
if (assets.length > 0) {
|
||||
const { sql, values } = getQuery(assets);
|
||||
await connection.query(sql, [values]);
|
||||
}
|
||||
await connection.commit();
|
||||
return { success: true, count: assets.length };
|
||||
const [pc] = await pool.query('SELECT * FROM pc_assets');
|
||||
const [server] = await pool.query('SELECT * FROM server_assets');
|
||||
const [storage] = await pool.query('SELECT * FROM storage_assets');
|
||||
const [equip] = await pool.query('SELECT * FROM equip_assets');
|
||||
const [mobile] = await pool.query('SELECT * FROM mobile_assets');
|
||||
const [subSw] = await pool.query('SELECT * FROM sw_sub_assets');
|
||||
const [permSw] = await pool.query('SELECT * FROM sw_perm_assets');
|
||||
const [cloud] = await pool.query('SELECT * FROM cloud_assets');
|
||||
const [swUsers] = await pool.query('SELECT * FROM sw_users');
|
||||
const [logs] = await pool.query('SELECT * FROM asset_logs ORDER BY date DESC');
|
||||
|
||||
res.json({
|
||||
pc, server, storage, equip, mobile,
|
||||
subSw, permSw, cloud,
|
||||
swUsers,
|
||||
logs
|
||||
});
|
||||
} catch (err) {
|
||||
await connection.rollback();
|
||||
throw err;
|
||||
} finally {
|
||||
connection.release();
|
||||
}
|
||||
}
|
||||
|
||||
// 하드웨어 쿼리 헬퍼
|
||||
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
|
||||
) 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.비고||''
|
||||
];
|
||||
|
||||
const mapHardware = (r, defaultType) => ({
|
||||
id: r.id, 법인: r.corp, 자산코드: r.asset_code, 구매일: r.purchase_date, type: r.type || 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
|
||||
});
|
||||
|
||||
// --- API 라우트 정의 ---
|
||||
|
||||
// PC API
|
||||
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 });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/pc/batch', async (req, res) => {
|
||||
try {
|
||||
const result = await batchSave('pc_assets', req.body, (assets) => ({
|
||||
sql: hardwareInsertSQL('pc_assets'),
|
||||
values: assets.map(getHardwareValues)
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
// Save Hardware Asset (PC, Server, Storage, etc.)
|
||||
app.post('/api/hardware/save', async (req, res) => {
|
||||
const asset = req.body;
|
||||
const type = asset.type;
|
||||
let table = '';
|
||||
|
||||
// 서버 API
|
||||
app.get('/api/server', async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT * FROM server_assets');
|
||||
res.json(rows.map(r => mapHardware(r, '서버')));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
if (type === '개인PC' || type === 'PC') table = 'pc_assets';
|
||||
else if (type === '서버') table = 'server_assets';
|
||||
else if (type === '스토리지') table = 'storage_assets';
|
||||
else if (type === '모바일' || type === '모바일기기') table = 'mobile_assets';
|
||||
else table = 'equip_assets';
|
||||
|
||||
app.post('/api/server/batch', async (req, res) => {
|
||||
try {
|
||||
const result = await batchSave('server_assets', req.body, (assets) => ({
|
||||
sql: hardwareInsertSQL('server_assets'),
|
||||
values: assets.map(getHardwareValues)
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
// Check if exists
|
||||
const [rows] = await pool.query(`SELECT id FROM ${table} WHERE id = ?`, [asset.id]);
|
||||
|
||||
// 스토리지 API
|
||||
app.get('/api/storage', async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT * FROM storage_assets');
|
||||
res.json(rows.map(r => mapHardware(r, '스토리지')));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
const data = { ...asset };
|
||||
delete data.id;
|
||||
delete data.type;
|
||||
|
||||
app.post('/api/storage/batch', async (req, res) => {
|
||||
try {
|
||||
const result = await batchSave('storage_assets', req.body, (assets) => ({
|
||||
sql: hardwareInsertSQL('storage_assets'),
|
||||
values: assets.map(getHardwareValues)
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 전산비품 API
|
||||
app.get('/api/equip', async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT * FROM equip_assets');
|
||||
res.json(rows.map(r => mapHardware(r, '전산비품')));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
app.post('/api/equip/batch', async (req, res) => {
|
||||
try {
|
||||
const result = await batchSave('equip_assets', req.body, (assets) => ({
|
||||
sql: hardwareInsertSQL('equip_assets'),
|
||||
values: assets.map(getHardwareValues)
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 모바일 API
|
||||
app.get('/api/mobile', async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT * FROM mobile_assets');
|
||||
res.json(rows.map(r => mapHardware(r, '모바일기기')));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
app.post('/api/mobile/batch', async (req, res) => {
|
||||
try {
|
||||
const result = await batchSave('mobile_assets', req.body, (assets) => ({
|
||||
sql: hardwareInsertSQL('mobile_assets'),
|
||||
values: assets.map(getHardwareValues)
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 구독 SW API
|
||||
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
|
||||
})));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
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.비고||''])
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 영구 SW API
|
||||
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,
|
||||
납품업체: r.vendor, 비고: r.remarks
|
||||
})));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
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.비고||''])
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 클라우드 API
|
||||
app.get('/api/cloud', async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT * FROM cloud_assets');
|
||||
res.json(rows.map(r => ({
|
||||
id: r.id, type: '클라우드', 플랫폼명: r.platform_name, 법인: r.corp, 부서: r.dept,
|
||||
제품명: r.product_name, 계정명: r.account_name, 결제수단: r.pay_method,
|
||||
결제일: r.pay_day, 연결카드번호: r.card_num, 당월청구액: r.monthly_fee, 비고: r.remarks
|
||||
})));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
app.post('/api/cloud/batch', async (req, res) => {
|
||||
try {
|
||||
const result = await batchSave('cloud_assets', req.body, (assets) => ({
|
||||
sql: `INSERT INTO cloud_assets (id, platform_name, corp, dept, product_name, account_name, pay_method, pay_day, card_num, monthly_fee, remarks) VALUES ?`,
|
||||
values: assets.map(a => [a.id, a.플랫폼명||'', a.법인||'', a.부서||'', a.제품명||'', a.계정명||'', a.결제수단||'', a.결제일||'', a.연결카드번호||'', a.당월청구액||'', a.비고||''])
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 로그 API
|
||||
app.get('/api/logs', async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT * FROM asset_logs ORDER BY log_date DESC');
|
||||
res.json(rows.map(r => ({
|
||||
id: r.id, assetId: r.asset_id, date: r.log_date, user: r.log_user, details: r.details
|
||||
})));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
app.post('/api/logs/batch', async (req, res) => {
|
||||
try {
|
||||
const result = await batchSave('asset_logs', req.body, (assets) => ({
|
||||
sql: `INSERT INTO asset_logs (id, asset_id, log_date, log_user, details) VALUES ?`,
|
||||
values: assets.map(a => [a.id, a.assetId||'', a.date||'', a.user||'', a.details||''])
|
||||
}));
|
||||
res.json(result);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// SW 사용자 API
|
||||
app.get('/api/sw-users', async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT * FROM sw_users');
|
||||
const grouped = rows.reduce((acc, u) => {
|
||||
if (!acc[u.sw_id]) acc[u.sw_id] = [];
|
||||
acc[u.sw_id].push([u.corp, u.dept, u.position, u.user_name, u.usage_period, u.doc_name]);
|
||||
return acc;
|
||||
}, {});
|
||||
res.json(Object.keys(grouped).map(sw_id => ({ sw_id, userData: grouped[sw_id] })));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
app.post('/api/sw-users/batch', async (req, res) => {
|
||||
try {
|
||||
const connection = await pool.getConnection();
|
||||
await connection.beginTransaction();
|
||||
await connection.query('DELETE FROM sw_users');
|
||||
const allUsers = req.body;
|
||||
if (allUsers.length > 0) {
|
||||
const values = allUsers.flatMap(item =>
|
||||
(item.userData || []).map(u => [item.sw_id, u[0], u[1], u[2], u[3], u[4], u[5]])
|
||||
);
|
||||
if (values.length > 0) {
|
||||
await connection.query('INSERT INTO sw_users (sw_id, corp, dept, position, user_name, usage_period, doc_name) VALUES ?', [values]);
|
||||
if (rows.length > 0) {
|
||||
await pool.query(`UPDATE ${table} SET ? WHERE id = ?`, [data, asset.id]);
|
||||
} else {
|
||||
await pool.query(`INSERT INTO ${table} SET ?`, [{ id: asset.id, ...data }]);
|
||||
}
|
||||
res.json({ success: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Save Software Asset
|
||||
app.post('/api/software/save', async (req, res) => {
|
||||
const asset = req.body;
|
||||
const table = asset.type === '구독SW' ? 'sw_sub_assets' : (asset.type === '영구SW' ? 'sw_perm_assets' : 'cloud_assets');
|
||||
|
||||
try {
|
||||
const [rows] = await pool.query(`SELECT id FROM ${table} WHERE id = ?`, [asset.id]);
|
||||
const data = { ...asset };
|
||||
delete data.id;
|
||||
delete data.type;
|
||||
|
||||
if (rows.length > 0) {
|
||||
await pool.query(`UPDATE ${table} SET ? WHERE id = ?`, [data, asset.id]);
|
||||
} else {
|
||||
await pool.query(`INSERT INTO ${table} SET ?`, [{ id: asset.id, ...data }]);
|
||||
}
|
||||
res.json({ success: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Delete Asset
|
||||
app.delete('/api/asset/:type/:id', async (req, res) => {
|
||||
const { type, id } = req.params;
|
||||
let table = '';
|
||||
|
||||
if (type === '개인PC' || type === 'PC') table = 'pc_assets';
|
||||
else if (type === '서버') table = 'server_assets';
|
||||
else if (type === '스토리지') table = 'storage_assets';
|
||||
else if (type === '모바일' || type === '모바일기기') table = 'mobile_assets';
|
||||
else if (type === '전산비품' || type === '기타자산') table = 'equip_assets';
|
||||
else if (type === '구독SW') table = 'sw_sub_assets';
|
||||
else if (type === '영구SW') table = 'sw_perm_assets';
|
||||
else if (type === '클라우드') table = 'cloud_assets';
|
||||
|
||||
try {
|
||||
await pool.query(`DELETE FROM ${table} WHERE id = ?`, [id]);
|
||||
// Also delete logs and users if needed
|
||||
if (table.includes('sw')) await pool.query('DELETE FROM sw_users WHERE sw_id = ?', [id]);
|
||||
await pool.query('DELETE FROM asset_logs WHERE asset_id = ?', [id]);
|
||||
|
||||
res.json({ success: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Log Save
|
||||
app.post('/api/logs/save', async (req, res) => {
|
||||
const log = req.body;
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT id FROM asset_logs WHERE id = ?', [log.id]);
|
||||
if (rows.length > 0) {
|
||||
await pool.query('UPDATE asset_logs SET ? WHERE id = ?', [log, log.id]);
|
||||
} else {
|
||||
await pool.query('INSERT INTO asset_logs SET ?', [log]);
|
||||
}
|
||||
await connection.commit();
|
||||
connection.release();
|
||||
res.json({ success: true });
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 초기화 및 서버 기동
|
||||
ensureTables().then(() => {
|
||||
app.listen(PORT, () => {
|
||||
console.log(`📡 ITAM Dedicated API Server running on http://localhost:${PORT}`);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('❌ Failed to start server:', err);
|
||||
// SW User Save
|
||||
app.post('/api/sw-users/save', async (req, res) => {
|
||||
const user = req.body;
|
||||
try {
|
||||
const [rows] = await pool.query('SELECT id FROM sw_users WHERE id = ?', [user.id]);
|
||||
if (rows.length > 0) {
|
||||
await pool.query('UPDATE sw_users SET ? WHERE id = ?', [user, user.id]);
|
||||
} else {
|
||||
await pool.query('INSERT INTO sw_users SET ?', [user]);
|
||||
}
|
||||
res.json({ success: true });
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
app.post('/api/sw-users/batch', async (req, res) => {
|
||||
const { swId, users } = req.body;
|
||||
try {
|
||||
await pool.query('DELETE FROM sw_users WHERE sw_id = ?', [swId]);
|
||||
for (const u of users) {
|
||||
await pool.query('INSERT INTO sw_users SET ?', { ...u, sw_id: swId });
|
||||
}
|
||||
res.json({ success: true });
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// 자산번호 생성 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',
|
||||
'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}%`]);
|
||||
rows.forEach(r => {
|
||||
const numPart = r.asset_code.replace(prefix, '');
|
||||
const num = parseInt(numPart);
|
||||
if (!isNaN(num) && num > maxNum) maxNum = num;
|
||||
});
|
||||
}
|
||||
|
||||
const nextCode = `${prefix}${(maxNum + 1).toString().padStart(3, '0')}`;
|
||||
res.json({ nextCode });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 ITAM Dedicated API Server running on http://localhost:${PORT}`);
|
||||
});
|
||||
|
||||
624
src/components/Guide.ts
Normal file
624
src/components/Guide.ts
Normal 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 }
|
||||
});
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
/**
|
||||
* 모든 모달의 공통 기능 (닫기, ESC 처리, 배경 클릭 등)을 관리하는 베이스 모듈입니다.
|
||||
*/
|
||||
export function initBaseModal() {
|
||||
const closeAllModals = () => {
|
||||
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 };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,7 @@ export function openDashboardDetail(title: string, list: HardwareAsset[]) {
|
||||
if (!thead) return;
|
||||
|
||||
titleEl.textContent = title;
|
||||
thead.innerHTML = `<tr><th>No</th><th>유형</th><th>자산코드</th><th>명칭/모델</th><th>위치</th><th>담당/사용자</th><th>구매일</th><th>금액</th></tr>`;
|
||||
thead.innerHTML = `<tr><th>No</th><th>유형</th><th>자산코드</th><th>명칭/모델</th><th>위치</th><th>담당/사용자</th><th>구매연월</th><th>금액</th></tr>`;
|
||||
tbody.innerHTML = '';
|
||||
if (list.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="8" style="text-align:center; padding: 2rem;">해당 조건의 자산이 없습니다.</td></tr>`;
|
||||
@@ -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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { state, saveHardwareAsset, deleteHardwareAsset } from '../../core/state';
|
||||
import { HardwareAsset, MasterAssetData } from '../../core/excelHandler';
|
||||
import { openModal, closeModals } from './BaseModal';
|
||||
import { createIcons, Paperclip } from 'lucide';
|
||||
import { HardwareAsset, HardwareLog } from '../../core/excelHandler';
|
||||
import { closeModals } from './BaseModal';
|
||||
import { createIcons, History, Plus, X, Save, Edit2, RotateCcw, Paperclip } from 'lucide';
|
||||
import { CORP_LIST, ORG_LIST, HW_TYPE_LIST, LOCATION_DATA, TYPE_PREFIX_MAP } from './SharedData';
|
||||
import {
|
||||
generateOptionsHTML,
|
||||
@@ -10,37 +10,67 @@ import {
|
||||
parseAndSetLocation,
|
||||
bindLocationEvents,
|
||||
getCombinedLocation,
|
||||
setEditLock
|
||||
setEditLock,
|
||||
createModalFrameHTML,
|
||||
autoFillForm,
|
||||
autoExtractForm
|
||||
} from './ModalUtils';
|
||||
|
||||
let currentAsset: HardwareAsset | null = null;
|
||||
let isEditMode = false;
|
||||
|
||||
const HW_MODAL_HTML = `
|
||||
<div id="hw-asset-modal" class="modal-overlay hidden">
|
||||
<div class="modal-content wide">
|
||||
<div class="modal-header">
|
||||
<h2 id="hw-modal-title">자산 상세 정보</h2>
|
||||
<button id="btn-close-hw-modal" class="btn-icon" aria-label="닫기"><i data-lucide="x"></i></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="hw-asset-form" class="grid-form">
|
||||
<input type="hidden" id="hw-asset-id" />
|
||||
<input type="hidden" id="hw-asset-type" />
|
||||
const STATUS_LIST = ['대여중', '보관중', '수리중', '기타'];
|
||||
|
||||
<!-- Group 1: 기본 정보 (Identity) -->
|
||||
// 필드 ID ↔ 데이터 Key 매핑 (유지보수 시 이 부분만 수정)
|
||||
const HW_FIELD_MAP: Record<string, string> = {
|
||||
'유형': 'type',
|
||||
'법인': '법인',
|
||||
'자산코드': '자산코드',
|
||||
'현사용조직': '현사용조직',
|
||||
'이전사용조직': '이전사용조직',
|
||||
'상세용도': '상세용도',
|
||||
'모델명': '모델명',
|
||||
'명칭': '명칭',
|
||||
'보관위치': '보관위치',
|
||||
'현재상태': '현재상태',
|
||||
'IP주소': 'IP주소',
|
||||
'IP2': 'IP2',
|
||||
'원격접속': '원격접속',
|
||||
'서버ID': '서버ID',
|
||||
'서버PW': '서버PW',
|
||||
'모니터링': '모니터링',
|
||||
'OS': 'OS',
|
||||
'CPU': 'CPU',
|
||||
'RAM': 'RAM',
|
||||
'SSD1': 'SSD1',
|
||||
'SSD2': 'SSD2',
|
||||
'HW사양': 'HW사양',
|
||||
'담당자_정': '담당자_정',
|
||||
'담당자_부': '담당자_부',
|
||||
'구매일': '구매연월',
|
||||
'금액': '금액',
|
||||
'비고': '비고',
|
||||
'사용자': '사용자'
|
||||
};
|
||||
|
||||
const HW_FORM_HTML = `
|
||||
<!-- Group 1: 기본 정보 -->
|
||||
<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" style="white-space:nowrap; padding:0 10px; font-size:0.8rem;">번호 생성</button>
|
||||
<label for="hw-자산코드">자산번호</label>
|
||||
<div class="input-with-btn">
|
||||
<input type="text" id="hw-자산코드" readonly class="is-readonly-field" placeholder="번호 생성을 클릭하세요" required />
|
||||
<button type="button" id="btn-generate-hw-code" class="btn btn-outline btn-sm">생성</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group pc-only">
|
||||
<label for="hw-사용자">사용자</label>
|
||||
<input type="text" id="hw-사용자" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="hw-현사용조직">현 사용조직</label>
|
||||
<select id="hw-현사용조직">${generateOptionsHTML(ORG_LIST)}</select>
|
||||
@@ -53,125 +83,52 @@ const HW_MODAL_HTML = `
|
||||
<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>
|
||||
<div class="form-group" id="hw-상세용도-group">
|
||||
<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 class="form-section-title op-only" id="hw-op-title">운영 및 상태 관리</div>
|
||||
<div class="form-group op-only">
|
||||
<label for="hw-보관위치">보관위치</label>
|
||||
<input type="text" id="hw-보관위치" placeholder="예: 7층 비품창고" />
|
||||
</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 class="form-group op-only">
|
||||
<label for="hw-현재상태">현재상태</label>
|
||||
<select id="hw-현재상태">${generateOptionsHTML(STATUS_LIST)}</select>
|
||||
</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>
|
||||
<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>
|
||||
|
||||
<!-- 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>
|
||||
<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>
|
||||
|
||||
<!-- 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-section-title" id="hw-loc-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-구매일" placeholder="YYYYMM" maxlength="6" /></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>
|
||||
<div class="form-group full-width">
|
||||
<label>품의서 (파일 증빙)</label>
|
||||
<div style="display:flex; align-items:center; gap:0.5rem;">
|
||||
@@ -179,21 +136,23 @@ const HW_MODAL_HTML = `
|
||||
<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>
|
||||
<div class="footer-actions">
|
||||
<button id="btn-revert-hw-edit" class="btn btn-outline hidden">수정 취소</button>
|
||||
<button id="btn-cancel-hw-modal" class="btn btn-outline">닫기</button>
|
||||
<button id="btn-save-hw-asset" class="btn btn-primary">수정</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view') {
|
||||
<<<<<<< HEAD
|
||||
function renderHwHistory(assetId: string) {
|
||||
const container = document.getElementById('hw-history-list');
|
||||
if (!container) return;
|
||||
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) { 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.replace(/\n/g, '<br>')}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
=======
|
||||
export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' | 'edit' = 'view') {
|
||||
currentAsset = asset;
|
||||
const modal = document.getElementById('hw-asset-modal')!;
|
||||
|
||||
@@ -204,7 +163,7 @@ export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view')
|
||||
generateBtnId: 'btn-generate-hw-code'
|
||||
});
|
||||
|
||||
isEditMode = (mode === 'add');
|
||||
isEditMode = (mode === 'add' || mode === 'edit');
|
||||
|
||||
// 2. 데이터 바인딩
|
||||
fillHwFormData(asset);
|
||||
@@ -212,145 +171,149 @@ export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view')
|
||||
modal.classList.remove('hidden');
|
||||
applyTypeSpecificUI(asset.type);
|
||||
createIcons({ icons: { Paperclip } });
|
||||
>>>>>>> origin/SW_Table
|
||||
}
|
||||
|
||||
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 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'),
|
||||
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')
|
||||
monitoring: document.getElementById('hw-monitoring-group'),
|
||||
user: document.querySelector('.pc-only') as HTMLElement
|
||||
};
|
||||
|
||||
// 1. 초기화 (모든 유동 섹션 숨김)
|
||||
const serverOnly = document.querySelectorAll('.server-only');
|
||||
const nonServer = document.querySelectorAll('.non-server');
|
||||
const opOnly = document.querySelectorAll('.op-only');
|
||||
const standardLoc = document.querySelectorAll('.loc-standard');
|
||||
|
||||
// 초기화
|
||||
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');
|
||||
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'; });
|
||||
|
||||
if (groups.type) groups.type.style.display = 'flex';
|
||||
if (groups.opTitle) groups.opTitle.style.display = 'flex';
|
||||
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. 유형별 정밀 규칙 적용 (사용자 정의 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';
|
||||
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 === '노트북';
|
||||
|
||||
if (groups.opTitle) groups.opTitle.style.display = isOpType ? 'flex' : 'none';
|
||||
|
||||
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';
|
||||
if (groups.ssd1) groups.ssd1.style.display = 'flex';
|
||||
if (groups.ssd2) groups.ssd2.style.display = 'flex';
|
||||
|
||||
if (['CPU', 'GPU'].some(t => upperType.includes(t))) {
|
||||
if (groups.os && osLabel) { osLabel.innerText = '출시연월'; groups.os.style.display = 'flex'; }
|
||||
} else if (['RAM', 'HDD'].some(t => upperType.includes(t))) {
|
||||
if (groups.ram && ramLabel) { ramLabel.innerText = '용량'; groups.ram.style.display = 'flex'; }
|
||||
if (upperType.includes('HDD') && modelLabel) modelLabel.innerText = 'S/N';
|
||||
} else {
|
||||
if (groups.hwSpec) groups.hwSpec.style.display = 'flex';
|
||||
}
|
||||
else if (type === 'PC' || type === '노트북') {
|
||||
if (type === 'PC' && groups.detailPurpose) groups.detailPurpose.style.display = 'flex';
|
||||
}
|
||||
else if (isPcType) {
|
||||
if (groups.user) groups.user.style.display = 'flex';
|
||||
if (groups.specTitle) groups.specTitle.style.display = 'flex';
|
||||
|
||||
// 노트북은 상세유형 선택창 숨김
|
||||
if (upperType === '노트북') {
|
||||
if (groups.detailPurpose) groups.detailPurpose.style.display = 'none';
|
||||
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');
|
||||
['model', 'os', 'cpu', 'ram', 'ssd1', 'ssd2', 'hwSpec'].forEach(k => { if (groups[k]) groups[k]!.style.display = 'flex'; });
|
||||
} else {
|
||||
if (groups.detailPurpose) groups.detailPurpose.style.display = 'flex';
|
||||
if (detailPurpose === '서버') {
|
||||
serverOnly.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';
|
||||
['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 (['CPU', 'GPU', '모바일'].includes(type)) {
|
||||
}
|
||||
else {
|
||||
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';
|
||||
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';
|
||||
['model', 'os', 'cpu', 'ram', 'ssd1', 'ssd2', 'monitoring'].forEach(k => { if (groups[k]) groups[k]!.style.display = 'flex'; });
|
||||
}
|
||||
}
|
||||
|
||||
function fillHwFormData(asset: HardwareAsset) {
|
||||
setFieldValue('hw-asset-id', asset.id);
|
||||
setFieldValue('hw-asset-type', asset.type);
|
||||
setFieldValue('hw-법인', asset.법인);
|
||||
setFieldValue('hw-자산코드', asset.자산코드);
|
||||
setFieldValue('hw-현사용조직', asset.현사용조직);
|
||||
setFieldValue('hw-이전사용조직', asset.이전사용조직);
|
||||
setFieldValue('hw-상세용도', (asset as any).상세용도);
|
||||
export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view') {
|
||||
currentAsset = asset;
|
||||
const modal = document.getElementById('hw-asset-modal')!;
|
||||
|
||||
setEditLock('hw-asset-form', mode, {
|
||||
saveBtnId: 'btn-save-hw-asset',
|
||||
revertBtnId: 'btn-revert-hw-edit',
|
||||
generateBtnId: 'btn-generate-hw-code',
|
||||
addLogBtnId: 'btn-add-hw-log'
|
||||
});
|
||||
|
||||
isEditMode = (mode === 'add');
|
||||
|
||||
// 데이터 채우기 (자동 매핑)
|
||||
autoFillForm('hw', asset, HW_FIELD_MAP);
|
||||
setFieldValue('hw-명칭', asset.명칭 || asset.모델명);
|
||||
if (!asset.구매연월 && asset.구매일) setFieldValue('hw-구매일', asset.구매일);
|
||||
|
||||
parseAndSetLocation(asset.위치, 'hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타-group', 'hw-위치-기타');
|
||||
applyTypeSpecificUI(asset.type);
|
||||
renderHwHistory(asset.id);
|
||||
|
||||
setFieldValue('hw-모델명', asset.모델명);
|
||||
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-담당자_정', asset.담당자_정 || asset.관리자);
|
||||
setFieldValue('hw-담당자_부', asset.담당자_부);
|
||||
|
||||
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);
|
||||
}
|
||||
modal.classList.remove('hidden');
|
||||
createIcons({ icons: { X, Save, Edit2, RotateCcw, History, Plus, Paperclip } });
|
||||
}
|
||||
|
||||
export function initHwModal(onSave: () => void, closeModals: () => void) {
|
||||
export function initHwModal(onSave: () => void, closeModalsCb: () => void) {
|
||||
if (!document.getElementById('hw-asset-modal')) {
|
||||
document.body.insertAdjacentHTML('beforeend', HW_MODAL_HTML);
|
||||
const html = createModalFrameHTML('hw', '자산 상세 정보', HW_FORM_HTML, {
|
||||
historyTitle: '분출 및 변경 이력',
|
||||
addLogBtnId: 'btn-add-hw-log'
|
||||
});
|
||||
document.body.insertAdjacentHTML('beforeend', html);
|
||||
|
||||
// 이력 추가 모달 HTML도 함께 추가
|
||||
const logModalHTML = `
|
||||
<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>
|
||||
`;
|
||||
document.body.insertAdjacentHTML('beforeend', logModalHTML);
|
||||
}
|
||||
|
||||
const form = document.getElementById('hw-asset-form') as HTMLFormElement;
|
||||
@@ -359,6 +322,8 @@ 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));
|
||||
@@ -366,7 +331,7 @@ export function initHwModal(onSave: () => void, closeModals: () => void) {
|
||||
|
||||
bindLocationEvents('hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타-group', 'hw-위치-기타');
|
||||
|
||||
const closeModalAction = () => { closeModals(); isEditMode = false; };
|
||||
const closeModalAction = () => { closeModalsCb(); isEditMode = false; };
|
||||
document.getElementById('btn-close-hw-modal')?.addEventListener('click', closeModalAction);
|
||||
document.getElementById('btn-cancel-hw-modal')?.addEventListener('click', closeModalAction);
|
||||
|
||||
@@ -374,10 +339,11 @@ export function initHwModal(onSave: () => void, closeModals: () => void) {
|
||||
setEditLock('hw-asset-form', 'view', {
|
||||
saveBtnId: 'btn-save-hw-asset',
|
||||
revertBtnId: 'btn-revert-hw-edit',
|
||||
generateBtnId: 'btn-generate-hw-code'
|
||||
generateBtnId: 'btn-generate-hw-code',
|
||||
addLogBtnId: 'btn-add-hw-log'
|
||||
});
|
||||
isEditMode = false;
|
||||
if (currentAsset) fillHwFormData(currentAsset);
|
||||
if (currentAsset) openHwModal(currentAsset, 'view');
|
||||
});
|
||||
|
||||
document.getElementById('btn-generate-hw-code')?.addEventListener('click', async () => {
|
||||
@@ -385,8 +351,8 @@ export function initHwModal(onSave: () => void, closeModals: () => void) {
|
||||
const purchaseDate = getFieldValue('hw-구매일');
|
||||
const typeCode = TYPE_PREFIX_MAP[typeValue] || 'ETC';
|
||||
const dateStr = purchaseDate.replace(/[^0-9]/g, '');
|
||||
if (dateStr.length < 4) { alert('올바른 구매일(연월)을 입력해주세요.'); return; }
|
||||
const prefix = `${typeCode}-${dateStr.substring(2, 6)}-`;
|
||||
if (dateStr.length < 6) { alert('올바른 구매연월(YYYYMM)을 입력해주세요.'); return; }
|
||||
const prefix = `${typeCode}-${dateStr.substring(0, 6)}-`;
|
||||
try {
|
||||
const res = await fetch(`http://localhost:3000/api/generate-asset-code?prefix=${prefix}`);
|
||||
const data = await res.json();
|
||||
@@ -394,74 +360,156 @@ export function initHwModal(onSave: () => void, closeModals: () => void) {
|
||||
} catch (err) { alert('자산번호 생성에 실패했습니다.'); }
|
||||
});
|
||||
|
||||
// YYYYMM 입력 제한 로직 (숫자 6자리)
|
||||
['hw-구매일', 'hw-OS'].forEach(id => {
|
||||
const el = document.getElementById(id) as HTMLInputElement;
|
||||
el?.addEventListener('input', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
const label = document.querySelector(`label[for="${id}"]`) as HTMLElement;
|
||||
// OS 필드의 경우 라벨이 '출시연월'일 때만 숫자 제한 적용
|
||||
if (id === 'hw-OS' && label?.innerText !== '출시연월') return;
|
||||
|
||||
target.value = target.value.replace(/[^0-9]/g, '').substring(0, 6);
|
||||
});
|
||||
});
|
||||
|
||||
saveBtn.addEventListener('click', () => {
|
||||
if (!currentAsset) return;
|
||||
if (!isEditMode) {
|
||||
setEditLock('hw-asset-form', 'edit', {
|
||||
saveBtnId: 'btn-save-hw-asset',
|
||||
revertBtnId: 'btn-revert-hw-edit'
|
||||
revertBtnId: 'btn-revert-hw-edit',
|
||||
generateBtnId: 'btn-generate-hw-code',
|
||||
addLogBtnId: 'btn-add-hw-log'
|
||||
});
|
||||
isEditMode = true;
|
||||
applyTypeSpecificUI(getFieldValue('hw-유형'));
|
||||
return;
|
||||
}
|
||||
|
||||
const type = typeSelect.value;
|
||||
const detailPurpose = detailPurposeSelect.value;
|
||||
// 데이터 추출 (자동 매핑)
|
||||
const extracted = autoExtractForm('hw', HW_FIELD_MAP);
|
||||
|
||||
if (!extracted.자산코드) {
|
||||
alert('자산번호가 없습니다. [생성] 버튼을 눌러 자산번호를 먼저 부여해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
const upperType = (extracted.type || '').toUpperCase();
|
||||
const isOpType = ['CPU', 'RAM', 'HDD', 'GPU'].some(t => upperType.includes(t)) || upperType.includes('비품') || ['모바일', '태블릿', '휴대폰'].some(t => upperType.includes(t));
|
||||
|
||||
// --- 자동 변경 이력 생성 로직 ---
|
||||
// 모든 하드웨어 유형에 대해 자동 로깅 적용
|
||||
if (HW_TYPE_LIST.includes(extracted.type) || extracted.type === '개인PC') {
|
||||
const diffLogs: string[] = [];
|
||||
const compareFields = [
|
||||
{ key: '현사용조직', label: '현사용조직' },
|
||||
{ key: '위치', label: '설치위치' },
|
||||
{ key: '관리자', label: '담당자' },
|
||||
{ key: '현재상태', label: '상태' },
|
||||
{ key: 'IP주소', label: 'IP' },
|
||||
{ key: '상세용도', label: '상세유형' },
|
||||
{ key: '모델명', label: '모델명' }
|
||||
];
|
||||
|
||||
const currentIp = currentAsset.IP주소 || '';
|
||||
const newIp = getFieldValue('hw-IP주소') || getFieldValue('hw-IP주소-non-server');
|
||||
const currentLocation = currentAsset.위치 || '';
|
||||
const newLocation = isOpType ? extracted.보관위치 : getCombinedLocation('hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타');
|
||||
|
||||
compareFields.forEach(f => {
|
||||
let oldVal = '';
|
||||
let newVal = '';
|
||||
|
||||
if (f.key === 'IP주소') {
|
||||
oldVal = currentIp;
|
||||
newVal = newIp;
|
||||
} else if (f.key === '위치') {
|
||||
oldVal = currentLocation;
|
||||
newVal = newLocation;
|
||||
} else if (f.key === '관리자') {
|
||||
oldVal = currentAsset.담당자_정 || '';
|
||||
newVal = extracted.담당자_정 || '';
|
||||
} else if (f.key === '상세용도') {
|
||||
oldVal = currentAsset.상세용도 || '';
|
||||
// 비 PC 자산은 유형을 상세유형으로 간주
|
||||
newVal = (extracted.type !== 'PC' && extracted.type !== '개인PC') ? extracted.type : (extracted.상세용도 || '');
|
||||
} else {
|
||||
oldVal = (currentAsset as any)[f.key] || '';
|
||||
newVal = extracted[f.key] || '';
|
||||
}
|
||||
|
||||
if (oldVal !== newVal) {
|
||||
diffLogs.push(`${f.label}: ${oldVal || '(없음)'} → ${newVal || '(없음)'}`);
|
||||
}
|
||||
});
|
||||
|
||||
if (diffLogs.length > 0) {
|
||||
state.masterData.logs = state.masterData.logs || [];
|
||||
state.masterData.logs.push({
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
assetId: currentAsset.id,
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
user: '관리자',
|
||||
details: diffLogs.join('\n')
|
||||
});
|
||||
}
|
||||
}
|
||||
// ----------------------------
|
||||
|
||||
const updated: any = {
|
||||
...currentAsset,
|
||||
법인: getFieldValue('hw-법인'),
|
||||
자산코드: getFieldValue('hw-자산코드'),
|
||||
현사용조직: 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'),
|
||||
담당자_정: getFieldValue('hw-담당자_정'),
|
||||
관리자: getFieldValue('hw-담당자_정'),
|
||||
담당자_부: getFieldValue('hw-담당자_부'),
|
||||
type: type,
|
||||
상세용도: detailPurpose
|
||||
...extracted,
|
||||
IP주소: getFieldValue('hw-IP주소') || getFieldValue('hw-IP주소-non-server'),
|
||||
관리자: extracted.담당자_정,
|
||||
위치: isOpType ? extracted.보관위치 : getCombinedLocation('hw-위치-빌딩', 'hw-위치-상세', 'hw-위치-기타')
|
||||
};
|
||||
|
||||
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');
|
||||
// 현 사용조직 변경 시 이전 사용조직 자동 업데이트
|
||||
if (currentAsset.현사용조직 && currentAsset.현사용조직 !== extracted.현사용조직) {
|
||||
updated.이전사용조직 = currentAsset.현사용조직;
|
||||
}
|
||||
|
||||
// 비 PC 자산에 대해 상세유형(상세용도)을 유형과 동기화
|
||||
if (updated.type !== 'PC') {
|
||||
updated.상세용도 = updated.type;
|
||||
}
|
||||
|
||||
saveHardwareAsset(updated);
|
||||
onSave();
|
||||
setEditLock('hw-asset-form', 'view', {
|
||||
saveBtnId: 'btn-save-hw-asset',
|
||||
revertBtnId: 'btn-revert-hw-edit'
|
||||
revertBtnId: 'btn-revert-hw-edit',
|
||||
generateBtnId: 'btn-generate-hw-code',
|
||||
addLogBtnId: 'btn-add-hw-log'
|
||||
});
|
||||
isEditMode = false;
|
||||
});
|
||||
|
||||
deleteBtn.addEventListener('click', () => {
|
||||
if (!currentAsset) return;
|
||||
if (confirm('정말로 이 자산을 삭제하시겠습니까?')) {
|
||||
if (currentAsset && confirm('정말로 삭제하시겠습니까?')) {
|
||||
deleteHardwareAsset(currentAsset.id);
|
||||
onSave();
|
||||
closeModals();
|
||||
closeModalAction();
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,135 +1,180 @@
|
||||
import { LOCATION_DATA } from './SharedData';
|
||||
import { createIcons, Save, Edit2, RotateCcw } from 'lucide';
|
||||
|
||||
/**
|
||||
* 모달 조작 및 UI 생성을 위한 공통 유틸리티
|
||||
*/
|
||||
// 공통 옵션 생성 함수
|
||||
export const generateOptionsHTML = (options: string[]) =>
|
||||
options.map(opt => `<option value="${opt}">${opt}</option>`).join('');
|
||||
|
||||
// 1. Select 박스의 Option HTML 생성
|
||||
export function generateOptionsHTML(list: string[], defaultValue: string = '', includeSelectHint: boolean = true): string {
|
||||
let html = includeSelectHint ? '<option value="">선택</option>' : '';
|
||||
html += list.map(item => `<option value="${item}" ${item === defaultValue ? 'selected' : ''}>${item}</option>`).join('');
|
||||
return html;
|
||||
}
|
||||
|
||||
// 2. 안전하게 폼 필드 값 설정 (Null 에러 방지)
|
||||
// 필드 값 설정 유틸리티
|
||||
export function setFieldValue(id: string, value: any) {
|
||||
const el = document.getElementById(id) as HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
||||
if (el) {
|
||||
el.value = value || '';
|
||||
if (el.type === 'checkbox') (el as HTMLInputElement).checked = !!value;
|
||||
else el.value = value || '';
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 안전하게 폼 필드 값 읽기
|
||||
// 필드 값 가져오기 유틸리티
|
||||
export function getFieldValue(id: string): string {
|
||||
const el = document.getElementById(id) as HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
||||
return el ? el.value : '';
|
||||
if (!el) return '';
|
||||
if (el.type === 'checkbox') return (el as HTMLInputElement).checked ? 'Y' : 'N';
|
||||
return el.value || '';
|
||||
}
|
||||
|
||||
// 4. 위치 정보 파싱 및 UI 세팅
|
||||
// 폼 자동 채우기
|
||||
export function autoFillForm(prefix: string, data: any, fieldMap: Record<string, string>) {
|
||||
Object.keys(fieldMap).forEach(fieldId => {
|
||||
const dataKey = fieldMap[fieldId];
|
||||
setFieldValue(`${prefix}-${fieldId}`, data[dataKey]);
|
||||
});
|
||||
}
|
||||
|
||||
// 폼 데이터 자동 추출
|
||||
export function autoExtractForm(prefix: string, fieldMap: Record<string, string>): any {
|
||||
const extracted: any = {};
|
||||
Object.keys(fieldMap).forEach(fieldId => {
|
||||
const dataKey = fieldMap[fieldId];
|
||||
extracted[dataKey] = getFieldValue(`${prefix}-${fieldId}`);
|
||||
});
|
||||
return extracted;
|
||||
}
|
||||
|
||||
// 모달 편집 잠금/해제 유틸리티
|
||||
export function setEditLock(formId: string, mode: 'view' | 'edit' | 'add', options: {
|
||||
saveBtnId: string,
|
||||
revertBtnId: string,
|
||||
generateBtnId?: string,
|
||||
addLogBtnId?: string
|
||||
}) {
|
||||
const form = document.getElementById(formId) as HTMLFormElement;
|
||||
if (!form) return;
|
||||
|
||||
const isView = mode === 'view';
|
||||
const inputs = form.querySelectorAll('input, select, textarea');
|
||||
|
||||
inputs.forEach(input => {
|
||||
const el = input as HTMLInputElement;
|
||||
if (el.id.includes('자산코드') || el.id.includes('asset-id') || el.classList.contains('is-readonly-field')) {
|
||||
el.readOnly = true;
|
||||
el.disabled = false;
|
||||
} else {
|
||||
if (el.tagName === 'SELECT') (el as HTMLSelectElement).disabled = isView;
|
||||
else (el as HTMLInputElement).readOnly = isView;
|
||||
}
|
||||
});
|
||||
|
||||
const saveBtn = document.getElementById(options.saveBtnId);
|
||||
const revertBtn = document.getElementById(options.revertBtnId);
|
||||
const generateBtn = options.generateBtnId ? document.getElementById(options.generateBtnId) : null;
|
||||
const addLogBtn = options.addLogBtnId ? document.getElementById(options.addLogBtnId) : null;
|
||||
|
||||
if (saveBtn) {
|
||||
saveBtn.innerHTML = isView
|
||||
? `<i data-lucide="edit-2" style="width:16px; height:16px;"></i> 수정`
|
||||
: `<i data-lucide="save" style="width:16px; height:16px;"></i> 저장`;
|
||||
saveBtn.className = isView ? 'btn btn-primary' : 'btn btn-success';
|
||||
}
|
||||
|
||||
if (revertBtn) revertBtn.classList.toggle('hidden', isView);
|
||||
if (generateBtn) generateBtn.classList.toggle('hidden', isView);
|
||||
if (addLogBtn) addLogBtn.classList.toggle('hidden', isView);
|
||||
|
||||
createIcons({ icons: { Save, Edit2, RotateCcw } });
|
||||
}
|
||||
|
||||
// 위치 정보 파싱 및 설정
|
||||
export function parseAndSetLocation(locationStr: string, bldgId: string, detailId: string, etcGroupId: string, etcInputId: string) {
|
||||
const bldgSelect = document.getElementById(bldgId) as HTMLSelectElement;
|
||||
const detailSelect = document.getElementById(detailId) as HTMLSelectElement;
|
||||
const etcGroup = document.getElementById(etcGroupId);
|
||||
const etcInput = document.getElementById(etcInputId) as HTMLInputElement;
|
||||
|
||||
if (!bldgSelect || !detailSelect) return;
|
||||
|
||||
// 초기화
|
||||
bldgSelect.value = '';
|
||||
detailSelect.innerHTML = '<option value="">선택</option>';
|
||||
if (etcGroup) etcGroup.style.display = 'none';
|
||||
|
||||
if (!locationStr) return;
|
||||
|
||||
const parts = locationStr.split(' ');
|
||||
const bldg = parts[0];
|
||||
|
||||
if (LOCATION_DATA[bldg]) {
|
||||
bldgSelect.value = bldg;
|
||||
// 상세 목록 갱신
|
||||
detailSelect.innerHTML = generateOptionsHTML(LOCATION_DATA[bldg]);
|
||||
|
||||
const detail = parts[1];
|
||||
if (detail) {
|
||||
detailSelect.value = detail;
|
||||
if (detail === '기타' && etcGroup && etcInput) {
|
||||
etcGroup.style.display = 'flex';
|
||||
etcInput.value = parts.slice(2).join(' ');
|
||||
const parts = locationStr.split(' > ');
|
||||
if (parts.length >= 1) {
|
||||
bldgSelect.value = parts[0];
|
||||
bldgSelect.dispatchEvent(new Event('change'));
|
||||
if (parts.length >= 2) {
|
||||
setTimeout(() => {
|
||||
detailSelect.value = parts[1];
|
||||
if (parts[1] === '기타' && parts[2]) {
|
||||
if (etcGroup) etcGroup.style.display = 'flex';
|
||||
etcInput.value = parts[2];
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 위치 종속성(Cascade) 이벤트 바인딩
|
||||
// 위치 정보 취합
|
||||
export function getCombinedLocation(bldgId: string, detailId: string, etcId: string): string {
|
||||
const bldg = getFieldValue(bldgId);
|
||||
const detail = getFieldValue(detailId);
|
||||
const etc = getFieldValue(etcId);
|
||||
|
||||
if (!bldg) return '';
|
||||
if (detail === '기타') return `${bldg} > 기타 > ${etc}`;
|
||||
return detail ? `${bldg} > ${detail}` : bldg;
|
||||
}
|
||||
|
||||
// 위치 이벤트 바인딩
|
||||
import { LOCATION_DATA } from './SharedData';
|
||||
export function bindLocationEvents(bldgId: string, detailId: string, etcGroupId: string, etcInputId: string) {
|
||||
const bldgSelect = document.getElementById(bldgId) as HTMLSelectElement;
|
||||
const detailSelect = document.getElementById(detailId) as HTMLSelectElement;
|
||||
const etcGroup = document.getElementById(etcGroupId);
|
||||
const etcInput = document.getElementById(etcInputId) as HTMLInputElement;
|
||||
|
||||
if (!bldgSelect || !detailSelect) return;
|
||||
|
||||
bldgSelect.addEventListener('change', () => {
|
||||
bldgSelect?.addEventListener('change', () => {
|
||||
const bldg = bldgSelect.value;
|
||||
detailSelect.innerHTML = generateOptionsHTML(LOCATION_DATA[bldg] || []);
|
||||
const details = LOCATION_DATA[bldg] || [];
|
||||
detailSelect.innerHTML = `<option value="">선택</option>` + generateOptionsHTML(details) + `<option value="기타">직접 입력(기타)</option>`;
|
||||
if (etcGroup) etcGroup.style.display = 'none';
|
||||
if (etcInput) etcInput.value = '';
|
||||
});
|
||||
|
||||
detailSelect.addEventListener('change', () => {
|
||||
if (etcGroup) {
|
||||
etcGroup.style.display = detailSelect.value === '기타' ? 'flex' : 'none';
|
||||
}
|
||||
detailSelect?.addEventListener('change', () => {
|
||||
if (etcGroup) etcGroup.style.display = detailSelect.value === '기타' ? 'flex' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// 6. 위치 문자열 조합 (저장용)
|
||||
export function getCombinedLocation(bldgId: string, detailId: string, etcInputId: string): string {
|
||||
const bldg = getFieldValue(bldgId);
|
||||
const detail = getFieldValue(detailId);
|
||||
const etc = getFieldValue(etcInputId);
|
||||
|
||||
let combined = bldg;
|
||||
if (detail) combined += ` ${detail}`;
|
||||
if (detail === '기타' && etc) combined += ` ${etc}`;
|
||||
|
||||
return combined.trim();
|
||||
}
|
||||
|
||||
// 7. 조회/수정 모드 UI 통합 제어
|
||||
export function setEditLock(
|
||||
formId: string,
|
||||
mode: 'view' | 'add' | 'edit',
|
||||
options: {
|
||||
saveBtnId: string,
|
||||
revertBtnId: string,
|
||||
generateBtnId?: string
|
||||
}
|
||||
) {
|
||||
const form = document.getElementById(formId) as HTMLFormElement;
|
||||
const saveBtn = document.getElementById(options.saveBtnId);
|
||||
const revertBtn = document.getElementById(options.revertBtnId);
|
||||
const generateBtn = options.generateBtnId ? document.getElementById(options.generateBtnId) : null;
|
||||
|
||||
if (!form || !saveBtn || !revertBtn) return;
|
||||
|
||||
if (mode === 'add' || mode === 'edit') {
|
||||
// 편집 모드 활성화
|
||||
form.classList.remove('is-view-mode');
|
||||
form.classList.add('is-edit-mode');
|
||||
saveBtn.textContent = '저장';
|
||||
revertBtn.classList.toggle('hidden', mode === 'add'); // 신규 추가 시에는 취소 버튼 숨김 (닫기가 대신함)
|
||||
|
||||
// 번호 생성 버튼은 '추가' 시에만 노출
|
||||
if (generateBtn) generateBtn.classList.toggle('hidden', mode !== 'add');
|
||||
} else {
|
||||
// 조회 모드 (잠금)
|
||||
form.classList.remove('is-edit-mode');
|
||||
form.classList.add('is-view-mode');
|
||||
saveBtn.textContent = '수정';
|
||||
revertBtn.classList.add('hidden');
|
||||
|
||||
// 조회 모드에서는 번호 생성 버튼 무조건 숨김
|
||||
if (generateBtn) generateBtn.classList.add('hidden');
|
||||
}
|
||||
// 모달 프레임 HTML 생성 (2열 그리드 표준 레이아웃)
|
||||
export function createModalFrameHTML(id: string, title: string, formHTML: string, options: { historyTitle?: string, addLogBtnId?: string }) {
|
||||
return `
|
||||
<div id="${id}-asset-modal" class="modal-overlay hidden">
|
||||
<div class="modal-content modal-lg">
|
||||
<div class="modal-header">
|
||||
<h2 id="${id}-modal-title">${title}</h2>
|
||||
<button id="btn-close-${id}-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="${id}-asset-form" class="grid-form">
|
||||
<input type="hidden" id="${id}-asset-id" />
|
||||
<input type="hidden" id="${id}-asset-type" />
|
||||
${formHTML}
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-history-area">
|
||||
<div class="history-header">
|
||||
<h3><i data-lucide="history" style="width:16px; height:16px;"></i> ${options.historyTitle || '변경 이력'}</h3>
|
||||
<button type="button" id="${options.addLogBtnId || 'btn-add-log'}" class="btn btn-outline btn-sm">
|
||||
이력 추가 <i data-lucide="plus" style="width:14px; height:14px;"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="${id}-history-list" class="history-timeline"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="btn-delete-${id}-asset" class="btn btn-outline btn-danger">삭제</button>
|
||||
<div class="footer-actions">
|
||||
<button id="btn-revert-${id}-edit" class="btn btn-outline hidden">취소</button>
|
||||
<button id="btn-save-${id}-asset" class="btn btn-primary">수정</button>
|
||||
<button id="btn-cancel-${id}-modal" class="btn btn-outline">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -1,362 +0,0 @@
|
||||
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 { CORP_LIST, ORG_LIST, HW_TYPE_LIST, LOCATION_DATA } from './SharedData';
|
||||
import {
|
||||
generateOptionsHTML,
|
||||
setFieldValue,
|
||||
getFieldValue,
|
||||
parseAndSetLocation,
|
||||
bindLocationEvents,
|
||||
getCombinedLocation
|
||||
} from './ModalUtils';
|
||||
|
||||
let currentAsset: HardwareAsset | null = null;
|
||||
let isEditMode = false;
|
||||
|
||||
const PC_MODAL_HTML = `
|
||||
<div id="pc-asset-modal" class="modal-overlay hidden">
|
||||
<div class="modal-content wide">
|
||||
<div class="modal-header">
|
||||
<h2 id="pc-modal-title">개인PC 상세 정보</h2>
|
||||
<button id="btn-close-pc-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="pc-asset-form" class="grid-form">
|
||||
<input type="hidden" id="pc-asset-id" />
|
||||
<input type="hidden" id="pc-asset-type" value="개인PC" />
|
||||
|
||||
<div class="form-section-title">기본 정보 (Identity)</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-법인">구매법인</label>
|
||||
<select id="pc-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-자산코드">자산번호/코드</label>
|
||||
<input type="text" id="pc-자산코드" readonly placeholder="자동 생성됩니다" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-유형">유형</label>
|
||||
<select id="pc-유형">${generateOptionsHTML(HW_TYPE_LIST)}</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-상세용도">상세용도</label>
|
||||
<select id="pc-상세용도">
|
||||
<option value="개인PC">개인PC</option>
|
||||
<option value="서버">서버</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-사용자">사용자</label>
|
||||
<input type="text" id="pc-사용자" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-현사용조직">현 사용조직</label>
|
||||
<select id="pc-현사용조직">${generateOptionsHTML(ORG_LIST)}</select>
|
||||
</div>
|
||||
<div class="form-group" id="pc-이전사용조직-group">
|
||||
<label for="pc-이전사용조직">이전 사용조직</label>
|
||||
<input type="text" id="pc-이전사용조직" readonly />
|
||||
</div>
|
||||
|
||||
<div class="form-section-title">시스템 사양 (Specifications)</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" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-CPU">CPU 사양</label>
|
||||
<input type="text" id="pc-CPU" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-RAM">RAM 용량</label>
|
||||
<input type="text" id="pc-RAM" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-SSD1">Storage 1 (SSD/HDD)</label>
|
||||
<input type="text" id="pc-SSD1" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-SSD2">Storage 2 (SSD/HDD)</label>
|
||||
<input type="text" id="pc-SSD2" />
|
||||
</div>
|
||||
|
||||
<div class="form-section-title" id="pc-location-title">관리 및 운영 (Operation)</div>
|
||||
<div class="form-group pc-location-field">
|
||||
<label for="pc-위치-빌딩">설치위치 (건물)</label>
|
||||
<select id="pc-위치-빌딩">${generateOptionsHTML(Object.keys(LOCATION_DATA))}</select>
|
||||
</div>
|
||||
<div class="form-group pc-location-field">
|
||||
<label for="pc-위치-상세">상세 위치</label>
|
||||
<select id="pc-위치-상세">
|
||||
<option value="">건물을 먼저 선택하세요</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="pc-위치-기타-group" style="display:none;">
|
||||
<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-금액">금액</label>
|
||||
<input type="text" id="pc-금액" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/\\\\B(?=(\\\\d{3})+(?!\d))/g, ',')" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pc-납품업체">납품업체</label>
|
||||
<input type="text" id="pc-납품업체" />
|
||||
</div>
|
||||
<div class="form-group full-width">
|
||||
<label>품의서 (파일)</label>
|
||||
<div style="display:flex; align-items:center; gap:0.5rem;">
|
||||
<input type="file" id="pc-품의서" />
|
||||
<span id="pc-품의서명" style="font-size:0.75rem; color:var(--text-light)"></span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-history-area">
|
||||
<div class="history-header">
|
||||
<h3><i data-lucide="history" style="width:16px; height:16px;"></i> 수정 이력</h3>
|
||||
</div>
|
||||
<div id="pc-history-list" class="history-timeline">
|
||||
<div class="empty-history">이력이 없습니다.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="btn-delete-pc-asset" class="btn btn-outline btn-danger">삭제</button>
|
||||
<div class="footer-actions">
|
||||
<button id="btn-revert-pc-edit" class="btn btn-outline hidden">수정 취소</button>
|
||||
<button id="btn-cancel-pc-modal" class="btn btn-outline">닫기</button>
|
||||
<button id="btn-save-pc-asset" class="btn btn-primary">수정</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export function openPcModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view') {
|
||||
currentAsset = asset;
|
||||
const modal = document.getElementById('pc-asset-modal');
|
||||
if (!modal) return;
|
||||
|
||||
const form = document.getElementById('pc-asset-form') as HTMLFormElement;
|
||||
const saveBtn = document.getElementById('btn-save-pc-asset')!;
|
||||
const revertBtn = document.getElementById('btn-revert-pc-edit')!;
|
||||
|
||||
if (form) form.reset();
|
||||
|
||||
if (mode === 'add') {
|
||||
isEditMode = true;
|
||||
if (form) {
|
||||
form.classList.remove('is-view-mode');
|
||||
form.classList.add('is-edit-mode');
|
||||
}
|
||||
saveBtn.textContent = '저장';
|
||||
revertBtn.classList.add('hidden');
|
||||
const prevOrgGroup = document.getElementById('pc-이전사용조직-group');
|
||||
if (prevOrgGroup) prevOrgGroup.style.display = 'none';
|
||||
} else {
|
||||
isEditMode = false;
|
||||
if (form) {
|
||||
form.classList.remove('is-edit-mode');
|
||||
form.classList.add('is-view-mode');
|
||||
}
|
||||
saveBtn.textContent = '수정';
|
||||
revertBtn.classList.add('hidden');
|
||||
const prevOrgGroup = document.getElementById('pc-이전사용조직-group');
|
||||
if (prevOrgGroup) prevOrgGroup.style.display = 'flex';
|
||||
}
|
||||
|
||||
fillFormData(asset);
|
||||
renderHistory(asset.id);
|
||||
|
||||
modal.classList.remove('hidden');
|
||||
applyPcTypeSpecificUI();
|
||||
createIcons({ icons: { X, History, Paperclip } });
|
||||
}
|
||||
|
||||
function applyPcTypeSpecificUI() {
|
||||
const type = getFieldValue('pc-유형');
|
||||
const detailPurpose = getFieldValue('pc-상세용도');
|
||||
|
||||
const modelGroup = document.getElementById('pc-모델명')?.closest('.form-group') as HTMLElement;
|
||||
const osGroup = document.getElementById('pc-OS')?.closest('.form-group') as HTMLElement;
|
||||
const cpuGroup = document.getElementById('pc-CPU')?.closest('.form-group') as HTMLElement;
|
||||
const ramGroup = document.getElementById('pc-RAM')?.closest('.form-group') as HTMLElement;
|
||||
const ssd1Group = document.getElementById('pc-SSD1')?.closest('.form-group') as HTMLElement;
|
||||
const ssd2Group = document.getElementById('pc-SSD2')?.closest('.form-group') as HTMLElement;
|
||||
const locationFields = document.querySelectorAll('.pc-location-field');
|
||||
const etcGroup = document.getElementById('pc-위치-기타-group');
|
||||
|
||||
// 초기화 (숨김)
|
||||
[modelGroup, osGroup, cpuGroup, ramGroup, ssd1Group, ssd2Group].forEach(g => { if(g) g.style.display = 'none'; });
|
||||
locationFields.forEach(el => (el as HTMLElement).style.display = 'none');
|
||||
if (etcGroup) etcGroup.style.display = 'none';
|
||||
|
||||
if (type === '서버') {
|
||||
[modelGroup, osGroup, cpuGroup, ramGroup, ssd1Group, ssd2Group].forEach(g => { if(g) g.style.display = 'flex'; });
|
||||
locationFields.forEach(el => (el as HTMLElement).style.display = 'flex');
|
||||
}
|
||||
else if (['스토리지', 'NAS', 'DAS'].includes(type)) {
|
||||
[modelGroup, ssd1Group, ssd2Group].forEach(g => { if(g) g.style.display = 'flex'; });
|
||||
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'; });
|
||||
if (detailPurpose === '서버') {
|
||||
locationFields.forEach(el => (el as HTMLElement).style.display = 'flex');
|
||||
}
|
||||
}
|
||||
else if (['CPU', 'GPU', '모바일'].includes(type)) {
|
||||
if (modelGroup) modelGroup.style.display = 'flex';
|
||||
}
|
||||
else if (type === 'RAM') {
|
||||
if (ramGroup) ramGroup.style.display = 'flex';
|
||||
}
|
||||
else if (type === 'HDD') {
|
||||
if (ssd1Group) ssd1Group.style.display = 'flex';
|
||||
}
|
||||
else if (type === '태블릿') {
|
||||
if (modelGroup) modelGroup.style.display = 'flex';
|
||||
if (ssd1Group) ssd1Group.style.display = 'flex';
|
||||
}
|
||||
}
|
||||
|
||||
function fillFormData(asset: HardwareAsset) {
|
||||
setFieldValue('pc-asset-id', asset.id);
|
||||
setFieldValue('pc-법인', asset.법인);
|
||||
setFieldValue('pc-자산코드', asset.자산코드);
|
||||
setFieldValue('pc-유형', asset.type);
|
||||
setFieldValue('pc-사용자', asset.사용자);
|
||||
setFieldValue('pc-현사용조직', asset.현사용조직);
|
||||
setFieldValue('pc-이전사용조직', asset.이전사용조직);
|
||||
setFieldValue('pc-상세용도', (asset as any).상세용도);
|
||||
|
||||
parseAndSetLocation(asset.위치, 'pc-위치-빌딩', 'pc-위치-상세', 'pc-위치-기타-group', 'pc-위치-기타');
|
||||
|
||||
setFieldValue('pc-모델명', asset.모델명);
|
||||
setFieldValue('pc-OS', asset.OS);
|
||||
setFieldValue('pc-CPU', asset.CPU);
|
||||
setFieldValue('pc-RAM', asset.RAM);
|
||||
setFieldValue('pc-SSD1', asset.SSD1);
|
||||
setFieldValue('pc-SSD2', asset.SSD2);
|
||||
setFieldValue('pc-구매일', asset.구매일);
|
||||
setFieldValue('pc-금액', asset.금액);
|
||||
setFieldValue('pc-납품업체', asset.납품업체);
|
||||
setFieldValue('pc-품의서명', asset.품의서명);
|
||||
}
|
||||
|
||||
export function initPcModal(onSave: () => void, closeModalsCb: () => void) {
|
||||
if (!document.getElementById('pc-asset-modal')) {
|
||||
document.body.insertAdjacentHTML('beforeend', PC_MODAL_HTML);
|
||||
}
|
||||
|
||||
const pcForm = document.getElementById('pc-asset-form') as HTMLFormElement;
|
||||
const saveBtn = document.getElementById('btn-save-pc-asset');
|
||||
const revertBtn = document.getElementById('btn-revert-pc-edit');
|
||||
const deleteBtn = document.getElementById('btn-delete-pc-asset');
|
||||
|
||||
// 유형 및 상세용도 리스너
|
||||
const typeSelect = document.getElementById('pc-유형') as HTMLSelectElement;
|
||||
const detailPurposeSelect = document.getElementById('pc-상세용도') as HTMLSelectElement;
|
||||
|
||||
[typeSelect, detailPurposeSelect].forEach(el => {
|
||||
el?.addEventListener('change', () => applyPcTypeSpecificUI());
|
||||
});
|
||||
|
||||
bindLocationEvents('pc-위치-빌딩', 'pc-위치-상세', 'pc-위치-기타-group', 'pc-위치-기타');
|
||||
|
||||
const handleClose = () => { closeModalsCb(); isEditMode = false; };
|
||||
document.getElementById('btn-close-pc-modal')?.addEventListener('click', handleClose);
|
||||
document.getElementById('btn-cancel-pc-modal')?.addEventListener('click', handleClose);
|
||||
revertBtn?.addEventListener('click', () => {
|
||||
isEditMode = false;
|
||||
pcForm.classList.replace('is-edit-mode', 'is-view-mode');
|
||||
if (saveBtn) saveBtn.textContent = '수정';
|
||||
revertBtn.classList.add('hidden');
|
||||
if (currentAsset) fillFormData(currentAsset);
|
||||
});
|
||||
|
||||
saveBtn?.addEventListener('click', () => {
|
||||
if (!currentAsset) return;
|
||||
if (!isEditMode) {
|
||||
isEditMode = true;
|
||||
pcForm.classList.replace('is-view-mode', 'is-edit-mode');
|
||||
saveBtn.textContent = '저장';
|
||||
revertBtn?.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
const type = getFieldValue('pc-유형');
|
||||
const detailPurpose = getFieldValue('pc-상세용도');
|
||||
|
||||
const updated: any = {
|
||||
...currentAsset,
|
||||
법인: getFieldValue('pc-법인'),
|
||||
자산코드: getFieldValue('pc-자산코드'),
|
||||
현사용조직: getFieldValue('pc-현사용조직'),
|
||||
이전사용조직: getFieldValue('pc-이전사용조직'),
|
||||
사용자: getFieldValue('pc-사용자'),
|
||||
상세용도: detailPurpose,
|
||||
위치: getCombinedLocation('pc-위치-빌딩', 'pc-위치-상세', 'pc-위치-기타'),
|
||||
모델명: getFieldValue('pc-모델명'),
|
||||
OS: getFieldValue('pc-OS'),
|
||||
CPU: getFieldValue('pc-CPU'),
|
||||
RAM: getFieldValue('pc-RAM'),
|
||||
SSD1: getFieldValue('pc-SSD1'),
|
||||
SSD2: getFieldValue('pc-SSD2'),
|
||||
구매일: getFieldValue('pc-구매일'),
|
||||
금액: getFieldValue('pc-금액'),
|
||||
납품업체: getFieldValue('pc-납품업체'),
|
||||
type: type || 'PC'
|
||||
};
|
||||
|
||||
saveHardwareAsset(updated);
|
||||
onSave();
|
||||
isEditMode = false;
|
||||
pcForm.classList.replace('is-edit-mode', 'is-view-mode');
|
||||
saveBtn.textContent = '수정';
|
||||
revertBtn?.classList.add('hidden');
|
||||
});
|
||||
|
||||
deleteBtn?.addEventListener('click', () => {
|
||||
if (!currentAsset) return;
|
||||
if (confirm('삭제하시겠습니까?')) {
|
||||
deleteHardwareAsset(currentAsset.id);
|
||||
onSave();
|
||||
handleClose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderHistory(assetId: string) {
|
||||
const historyList = document.getElementById('pc-history-list');
|
||||
if (!historyList) return;
|
||||
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('');
|
||||
}
|
||||
@@ -1,424 +1,209 @@
|
||||
import { state } from '../../core/state';
|
||||
import { state, saveSoftwareAsset, deleteSoftwareAsset } 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 { CORP_LIST } from './SharedData';
|
||||
import { createIcons, History, Plus, X, Save, Edit2, RotateCcw, UserPlus } from 'lucide';
|
||||
import { CORP_LIST, ORG_LIST } from './SharedData';
|
||||
import {
|
||||
generateOptionsHTML,
|
||||
setFieldValue,
|
||||
getFieldValue,
|
||||
setEditLock
|
||||
setEditLock,
|
||||
createModalFrameHTML,
|
||||
autoFillForm,
|
||||
autoExtractForm
|
||||
} from './ModalUtils';
|
||||
import { openSwUserModal } from './SWUserModal';
|
||||
|
||||
let currentSwAsset: SoftwareAsset | null = null;
|
||||
let currentAsset: SoftwareAsset | null = null;
|
||||
let isEditMode = false;
|
||||
|
||||
const SW_MODAL_HTML = `
|
||||
<div id="sw-asset-modal" class="modal-overlay hidden">
|
||||
<div class="modal-content wide">
|
||||
<div class="modal-header">
|
||||
<h2 id="sw-modal-title">소프트웨어 상세 정보</h2>
|
||||
<button id="btn-close-sw-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="sw-asset-form" class="grid-form">
|
||||
<input type="hidden" id="sw-asset-id" />
|
||||
<input type="hidden" id="sw-asset-type" />
|
||||
const SW_FIELD_MAP: Record<string, string> = {
|
||||
'유형': 'type',
|
||||
'법인': '법인',
|
||||
'부서': '부서',
|
||||
'제품명': '소프트웨어명',
|
||||
'구매일': '구매일',
|
||||
'만료일': '만료일',
|
||||
'수량': '수량',
|
||||
'금액': '금액',
|
||||
'비고': '비고',
|
||||
'자산번호': '자산번호'
|
||||
};
|
||||
|
||||
<!-- Group 1: 기본 정보 (Identity) -->
|
||||
<div class="form-section-title">기본 정보 (Identity)</div>
|
||||
const SW_FORM_HTML = `
|
||||
<div class="form-section-title">소프트웨어 기본 정보</div>
|
||||
<div class="form-group">
|
||||
<label for="sw-법인">구매법인</label>
|
||||
<select id="sw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
|
||||
</div>
|
||||
<div class="form-group sw-standard-field">
|
||||
<label for="sw-자산번호">자산번호</label>
|
||||
<input type="text" id="sw-자산번호" readonly placeholder="자동 생성" />
|
||||
</div>
|
||||
<div class="form-group full-width">
|
||||
<label for="sw-제품명">제품명 / 서비스명</label>
|
||||
<input type="text" id="sw-제품명" required />
|
||||
</div>
|
||||
<div class="form-group cloud-only">
|
||||
<label for="sw-플랫폼명">플랫폼명</label>
|
||||
<input type="text" id="sw-플랫폼명" placeholder="예: AWS, Cafe24" />
|
||||
</div>
|
||||
<div class="form-group cloud-only">
|
||||
<label for="sw-부서">담당부서</label>
|
||||
<input type="text" id="sw-부서" />
|
||||
</div>
|
||||
|
||||
<!-- Group 2: 라이선스 및 계약 (License/Contract) -->
|
||||
<div class="form-section-title">라이선스 및 계약 정보</div>
|
||||
<div class="form-group sw-standard-field" id="sw-license-type-group">
|
||||
<label for="sw-라이선스유형">라이선스 유형</label>
|
||||
<input type="text" id="sw-라이선스유형" />
|
||||
</div>
|
||||
<div class="form-group sw-standard-field" id="sw-license-key-group">
|
||||
<label for="sw-라이선스키">라이선스 키</label>
|
||||
<input type="text" id="sw-라이선스키" />
|
||||
</div>
|
||||
<div class="form-group sw-standard-field">
|
||||
<label for="sw-수량">보유 수량</label>
|
||||
<input type="number" id="sw-수량" min="0" />
|
||||
</div>
|
||||
<div class="form-group sw-standard-field">
|
||||
<label for="sw-금액">도입 금액</label>
|
||||
<input type="text" id="sw-금액" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')" />
|
||||
</div>
|
||||
|
||||
<!-- Group 3: 클라우드 전용 정보 (Cloud Specific) -->
|
||||
<div class="form-group cloud-only">
|
||||
<label for="sw-계정명">계정명 (이메일)</label>
|
||||
<input type="text" id="sw-계정명" />
|
||||
</div>
|
||||
<div class="form-group cloud-only">
|
||||
<label for="sw-결제수단">결제수단</label>
|
||||
<select id="sw-결제수단">
|
||||
<option value="">선택안함</option>
|
||||
<option value="법인카드">법인카드</option>
|
||||
<option value="인보이스">인보이스</option>
|
||||
<label for="sw-유형">라이선스 유형</label>
|
||||
<select id="sw-유형">
|
||||
<option value="구독SW">구독 라이선스</option>
|
||||
<option value="영구SW">영구 라이선스</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group cloud-only">
|
||||
<label for="sw-연결카드번호">연결카드번호(뒷4자리)</label>
|
||||
<input type="text" id="sw-연결카드번호" maxlength="4" />
|
||||
<div class="form-group">
|
||||
<label for="sw-법인">구매법인</label>
|
||||
<select id="sw-법인">${generateOptionsHTML(CORP_LIST)}</select>
|
||||
</div>
|
||||
<div class="form-group cloud-only">
|
||||
<label for="sw-결제일">결제일 (기준일)</label>
|
||||
<input type="number" id="sw-결제일" min="1" max="31" />
|
||||
<div class="form-group">
|
||||
<label for="sw-부서">관리부서</label>
|
||||
<select id="sw-부서">${generateOptionsHTML(ORG_LIST)}</select>
|
||||
</div>
|
||||
<div class="form-group cloud-only">
|
||||
<label for="sw-당월청구액">당월 청구액(원)</label>
|
||||
<input type="text" id="sw-당월청구액" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')" />
|
||||
<div class="form-group">
|
||||
<label for="sw-제품명">제품명 (S/W명)</label>
|
||||
<input type="text" id="sw-제품명" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sw-자산번호">자산번호</label>
|
||||
<input type="text" id="sw-자산번호" placeholder="관리번호 입력" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sw-수량">총 라이선스 수량</label>
|
||||
<input type="number" id="sw-수량" value="1" />
|
||||
</div>
|
||||
|
||||
<!-- Group 4: 관리 정보 (Management) -->
|
||||
<div class="form-section-title">관리 및 비고</div>
|
||||
<div class="form-group sw-standard-field">
|
||||
<label for="sw-구매일">구매일</label>
|
||||
<input type="text" id="sw-구매일" />
|
||||
<div class="form-section-title">계약 및 금액</div>
|
||||
<div class="form-group">
|
||||
<label for="sw-구매일">구매일 (계약시작)</label>
|
||||
<input type="date" id="sw-구매일" />
|
||||
</div>
|
||||
<div class="form-group sw-standard-field" id="sw-expiry-group">
|
||||
<label for="sw-만료일">만료일 (구독)</label>
|
||||
<input type="text" id="sw-만료일" />
|
||||
<div class="form-group sw-sub-only">
|
||||
<label for="sw-만료일">만료일 (계약종료)</label>
|
||||
<input type="date" id="sw-만료일" />
|
||||
</div>
|
||||
<div class="form-group sw-standard-field">
|
||||
<label for="sw-납품업체">납품업체</label>
|
||||
<input type="text" id="sw-납품업체" />
|
||||
<div class="form-group">
|
||||
<label for="sw-금액">금액 (단가/총액)</label>
|
||||
<input type="text" id="sw-금액" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/\\B(?=(\\d{3})+(?!\d))/g, ',')" />
|
||||
</div>
|
||||
<div class="form-group full-width">
|
||||
<label for="sw-비고">비고</label>
|
||||
<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>
|
||||
<div class="form-section-title">
|
||||
사용자 할당 현황
|
||||
<button type="button" id="btn-add-sw-user" class="btn btn-outline btn-xs" style="margin-left: 0.5rem;">
|
||||
<i data-lucide="user-plus" style="width:12px; height:12px;"></i> 할당 추가
|
||||
</button>
|
||||
</div>
|
||||
<div id="sw-assigned-users-summary" class="user-summary-grid"></div>
|
||||
</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>
|
||||
</div>
|
||||
<div id="sw-history-list" class="history-timeline"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="btn-delete-sw-asset" class="btn btn-outline btn-danger">삭제</button>
|
||||
<div class="footer-actions">
|
||||
<button id="btn-revert-sw-edit" class="btn btn-outline hidden">수정 취소</button>
|
||||
<button id="btn-cancel-sw-modal" class="btn btn-outline">닫기</button>
|
||||
<button id="btn-save-sw-asset" class="btn btn-primary">수정</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 클라우드 이력 추가를 위한 간이 모달 -->
|
||||
<div id="sw-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-sw-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-log-date" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>상세 내용</label>
|
||||
<textarea id="new-log-details" rows="3" placeholder="예: 결제 금액 변동, 담당자 변경 등"></textarea>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="full-width">
|
||||
<div id="sw-user-list-container" class="mini-table-container">
|
||||
<table class="itam-table mini">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>부서</th>
|
||||
<th>이름</th>
|
||||
<th>사번</th>
|
||||
<th>사용기간</th>
|
||||
<th>삭제</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="sw-user-list-body"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
function applySwTypeUI(type: string) {
|
||||
const cloudFields = document.querySelectorAll('.cloud-only');
|
||||
const swFields = document.querySelectorAll('.sw-standard-field');
|
||||
const userSection = document.getElementById('sw-user-section');
|
||||
const keyGroup = document.getElementById('sw-license-key-group');
|
||||
const typeGroup = document.getElementById('sw-license-type-group');
|
||||
const expiryGroup = document.getElementById('sw-expiry-group');
|
||||
function renderSwUsers(swId: string) {
|
||||
const body = document.getElementById('sw-user-list-body');
|
||||
if (!body) return;
|
||||
const users = (state.masterData.swUsers || []).filter(u => u.swId === swId || u.sw_id === swId);
|
||||
|
||||
if (type === '클라우드') {
|
||||
cloudFields.forEach(el => (el as HTMLElement).style.display = 'flex');
|
||||
swFields.forEach(el => (el as HTMLElement).style.display = 'none');
|
||||
if (userSection) userSection.style.display = 'none';
|
||||
} else {
|
||||
cloudFields.forEach(el => (el as HTMLElement).style.display = 'none');
|
||||
swFields.forEach(el => (el as HTMLElement).style.display = 'flex');
|
||||
if (userSection) userSection.style.display = 'block';
|
||||
|
||||
if (type === '구독SW') {
|
||||
if (keyGroup) keyGroup.style.display = 'none';
|
||||
if (typeGroup) typeGroup.style.display = 'flex';
|
||||
if (expiryGroup) expiryGroup.style.display = 'flex';
|
||||
} else {
|
||||
if (keyGroup) keyGroup.style.display = 'flex';
|
||||
if (typeGroup) typeGroup.style.display = 'none';
|
||||
if (expiryGroup) expiryGroup.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.비고 || '');
|
||||
|
||||
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).연결카드번호 || '');
|
||||
setFieldValue('sw-결제일', (asset as any).결제일 || '');
|
||||
setFieldValue('sw-당월청구액', (asset as any).당월청구액 || '');
|
||||
} else if (asset.type === '구독SW') {
|
||||
setFieldValue('sw-라이선스유형', (asset as any).라이선스유형 || '');
|
||||
setFieldValue('sw-만료일', (asset as any).만료일 || '');
|
||||
} else {
|
||||
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>';
|
||||
if (users.length === 0) {
|
||||
body.innerHTML = '<tr><td colspan="5" class="empty-row">할당된 사용자가 없습니다.</td></tr>';
|
||||
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>
|
||||
|
||||
body.innerHTML = users.map(u => `
|
||||
<tr>
|
||||
<td>${u.부서 || '-'}</td>
|
||||
<td>${u.이름 || '-'}</td>
|
||||
<td>${u.사번 || '-'}</td>
|
||||
<td><small>${u.사용기간 || '-'}</small></td>
|
||||
<td><button class="btn-icon text-danger btn-delete-user" data-id="${u.id}"><i data-lucide="x" style="width:14px; height:14px;"></i></button></td>
|
||||
</tr>
|
||||
`).join('');
|
||||
|
||||
createIcons({ icons: { X } });
|
||||
|
||||
body.querySelectorAll('.btn-delete-user').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
const id = btn.getAttribute('data-id');
|
||||
state.masterData.swUsers = state.masterData.swUsers.filter(u => u.id !== id);
|
||||
renderSwUsers(swId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function renderSwHistory(swId: string) {
|
||||
const container = document.getElementById('sw-history-list');
|
||||
if (!container) return;
|
||||
const logs = (state.masterData.logs || []).filter(l => l.assetId === swId);
|
||||
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('');
|
||||
}
|
||||
|
||||
export function openSwModal(asset: SoftwareAsset, mode: 'view' | 'add' = 'view') {
|
||||
currentSwAsset = asset;
|
||||
export function openSwModal(asset: SoftwareAsset) {
|
||||
currentAsset = asset;
|
||||
const modal = document.getElementById('sw-asset-modal')!;
|
||||
|
||||
// 수정 잠금 상태 제어
|
||||
setEditLock('sw-asset-form', mode, {
|
||||
saveBtnId: 'btn-save-sw-asset',
|
||||
revertBtnId: 'btn-revert-sw-edit'
|
||||
});
|
||||
|
||||
isEditMode = (mode === 'add');
|
||||
|
||||
fillSwFormData(asset);
|
||||
applySwTypeUI(asset.type);
|
||||
|
||||
modal.classList.remove('hidden');
|
||||
createIcons({ icons: { X, History, Plus } });
|
||||
}
|
||||
|
||||
export function initSwModal(onSave: () => void, closeModals: () => void) {
|
||||
if (!document.getElementById('sw-asset-modal')) {
|
||||
document.body.insertAdjacentHTML('beforeend', SW_MODAL_HTML);
|
||||
}
|
||||
|
||||
const form = document.getElementById('sw-asset-form') as HTMLFormElement;
|
||||
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 closeModalAction = () => { closeModals(); isEditMode = false; };
|
||||
document.getElementById('btn-close-sw-modal')?.addEventListener('click', closeModalAction);
|
||||
document.getElementById('btn-cancel-sw-modal')?.addEventListener('click', closeModalAction);
|
||||
|
||||
revertBtn.addEventListener('click', () => {
|
||||
setEditLock('sw-asset-form', 'view', {
|
||||
saveBtnId: 'btn-save-sw-asset',
|
||||
revertBtnId: 'btn-revert-sw-edit'
|
||||
});
|
||||
|
||||
isEditMode = false;
|
||||
if (currentSwAsset) fillSwFormData(currentSwAsset);
|
||||
autoFillForm('sw', asset, SW_FIELD_MAP);
|
||||
|
||||
const subOnly = document.querySelectorAll('.sw-sub-only');
|
||||
subOnly.forEach(el => (el as HTMLElement).style.display = asset.type === '구독SW' ? 'block' : 'none');
|
||||
|
||||
renderSwUsers(asset.id);
|
||||
|
||||
modal.classList.remove('hidden');
|
||||
createIcons({ icons: { X, Save, Edit2, RotateCcw, UserPlus } });
|
||||
}
|
||||
|
||||
export function initSwModal(onSave: () => void, closeModalsCb: () => void) {
|
||||
if (!document.getElementById('sw-asset-modal')) {
|
||||
const html = createModalFrameHTML('sw', '소프트웨어 상세 정보', SW_FORM_HTML, {
|
||||
historyTitle: '라이선스 변경 이력',
|
||||
addLogBtnId: 'btn-add-sw-log'
|
||||
});
|
||||
document.body.insertAdjacentHTML('beforeend', html);
|
||||
}
|
||||
|
||||
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 typeSelect = document.getElementById('sw-유형') as HTMLSelectElement;
|
||||
|
||||
typeSelect?.addEventListener('change', () => {
|
||||
const subOnly = document.querySelectorAll('.sw-sub-only');
|
||||
subOnly.forEach(el => (el as HTMLElement).style.display = typeSelect.value === '구독SW' ? 'block' : 'none');
|
||||
});
|
||||
|
||||
const handleClose = () => { closeModalsCb(); isEditMode = false; };
|
||||
document.getElementById('btn-close-sw-modal')?.addEventListener('click', handleClose);
|
||||
document.getElementById('btn-cancel-sw-modal')?.addEventListener('click', handleClose);
|
||||
|
||||
saveBtn.addEventListener('click', () => {
|
||||
if (!currentSwAsset) return;
|
||||
if (!currentAsset) return;
|
||||
if (!isEditMode) {
|
||||
setEditLock('sw-asset-form', 'edit', {
|
||||
saveBtnId: 'btn-save-sw-asset',
|
||||
revertBtnId: 'btn-revert-sw-edit'
|
||||
});
|
||||
setEditLock('sw-asset-form', 'edit', { saveBtnId: 'btn-save-sw-asset', revertBtnId: 'btn-revert-sw-edit' });
|
||||
isEditMode = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const type = getFieldValue('sw-asset-type');
|
||||
const updated: any = {
|
||||
...currentSwAsset,
|
||||
법인: getFieldValue('sw-법인'),
|
||||
자산번호: getFieldValue('sw-자산번호'),
|
||||
제품명: getFieldValue('sw-제품명'),
|
||||
수량: parseInt(getFieldValue('sw-수량') || '0'),
|
||||
금액: getFieldValue('sw-금액'),
|
||||
구매일: getFieldValue('sw-구매일'),
|
||||
납품업체: getFieldValue('sw-납품업체'),
|
||||
비고: getFieldValue('sw-비고'),
|
||||
type: type
|
||||
};
|
||||
|
||||
if (type === '클라우드') {
|
||||
updated.플랫폼명 = getFieldValue('sw-플랫폼명');
|
||||
updated.부서 = getFieldValue('sw-부서');
|
||||
updated.계정명 = getFieldValue('sw-계정명');
|
||||
updated.결제수단 = getFieldValue('sw-결제수단');
|
||||
updated.연결카드번호 = getFieldValue('sw-연결카드번호');
|
||||
updated.결제일 = getFieldValue('sw-결제일');
|
||||
updated.당월청구액 = getFieldValue('sw-당월청구액');
|
||||
} else if (type === '구독SW') {
|
||||
updated.라이선스유형 = getFieldValue('sw-라이선스유형');
|
||||
updated.만료일 = getFieldValue('sw-만료일');
|
||||
} else {
|
||||
updated.라이선스키 = getFieldValue('sw-라이선스키');
|
||||
}
|
||||
|
||||
// 데이터 저장 로직 (state 업데이트)
|
||||
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;
|
||||
|
||||
const idx = targetList.findIndex(a => a.id === updated.id);
|
||||
if (idx > -1) targetList[idx] = updated;
|
||||
else targetList.push(updated);
|
||||
const extracted = autoExtractForm('sw', SW_FIELD_MAP);
|
||||
const updated = { ...currentAsset, ...extracted };
|
||||
|
||||
saveSoftwareAsset(updated);
|
||||
onSave();
|
||||
setEditLock('sw-asset-form', 'view', {
|
||||
saveBtnId: 'btn-save-sw-asset',
|
||||
revertBtnId: 'btn-revert-sw-edit'
|
||||
});
|
||||
isEditMode = false;
|
||||
setEditLock('sw-asset-form', 'view', { saveBtnId: 'btn-save-sw-asset', revertBtnId: 'btn-revert-sw-edit' });
|
||||
});
|
||||
|
||||
deleteBtn.addEventListener('click', () => {
|
||||
if (!currentSwAsset) return;
|
||||
if (confirm('삭제하시겠습니까?')) {
|
||||
const type = currentSwAsset.type;
|
||||
if (type === '구독SW') state.masterData.subSw = state.masterData.subSw.filter(a => a.id !== currentSwAsset!.id);
|
||||
else if (type === '영구SW') state.masterData.permSw = state.masterData.permSw.filter(a => a.id !== currentSwAsset!.id);
|
||||
else if (type === '클라우드') state.masterData.cloud = state.masterData.cloud.filter(a => a.id !== currentSwAsset!.id);
|
||||
if (currentAsset && confirm('이 소프트웨어 자산을 삭제하시겠습니까?')) {
|
||||
deleteSoftwareAsset(currentAsset.id, currentAsset.type);
|
||||
onSave();
|
||||
closeModalAction();
|
||||
handleClose();
|
||||
}
|
||||
});
|
||||
|
||||
userUpdateBtn.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 = '';
|
||||
});
|
||||
|
||||
document.getElementById('btn-close-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
|
||||
document.getElementById('btn-cancel-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
|
||||
|
||||
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;
|
||||
|
||||
if (!date || !details) { alert('날짜와 내용을 입력해주세요.'); return; }
|
||||
|
||||
state.masterData.logs = state.masterData.logs || [];
|
||||
state.masterData.logs.push({
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
assetId: currentSwAsset.id,
|
||||
date,
|
||||
user: '관리자',
|
||||
details
|
||||
});
|
||||
|
||||
logModal.classList.add('hidden');
|
||||
renderSwHistory(currentSwAsset.id);
|
||||
document.getElementById('btn-add-sw-user')?.addEventListener('click', () => {
|
||||
if (!currentAsset) return;
|
||||
openSwUserModal(currentAsset.id, () => renderSwUsers(currentAsset!.id));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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">
|
||||
@@ -74,8 +74,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 +121,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');
|
||||
@@ -124,7 +142,7 @@ function renderUserList() {
|
||||
tempSwUsers.forEach((user, idx) => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.innerHTML = `
|
||||
<td>${user.구매법인 || user.법인 || ''}</td>
|
||||
<td>${user.법인 || ''}</td>
|
||||
<td>${user.부서 || ''}</td>
|
||||
<td>${user.직위 || ''}</td>
|
||||
<td>${user.이름 || ''}</td>
|
||||
@@ -169,11 +187,20 @@ 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.이름);
|
||||
setFieldValue('new-user-사용기간', user.사용기간);
|
||||
|
||||
// 사용기간 파싱 (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-종료일', '');
|
||||
}
|
||||
} else {
|
||||
setFieldValue('new-user-법인', currentSwUserAsset?.법인);
|
||||
}
|
||||
@@ -190,6 +217,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 +236,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.사용기간, u.신청서명])
|
||||
};
|
||||
|
||||
if (existingIdx > -1) state.masterData.swUsers[existingIdx] = newMapping as any;
|
||||
@@ -233,11 +266,11 @@ 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-시작일')} ~ ${getFieldValue('new-user-종료일')}`,
|
||||
신청서명
|
||||
};
|
||||
|
||||
|
||||
@@ -29,5 +29,6 @@ export const TYPE_PREFIX_MAP: Record<string, string> = {
|
||||
'서버': 'SVR', 'PC': 'PC', 'NAS': 'NAS', 'DAS': 'DAS', '스토리지': 'STO',
|
||||
'CPU': 'CPU', 'HDD': 'HDD', 'RAM': 'RAM', 'GPU': 'GPU',
|
||||
'모바일': 'MOB', '노트북': 'PC', '태블릿': 'TAB',
|
||||
'개인PC': 'PC', '모바일기기': 'MOB'
|
||||
'개인PC': 'PC', '모바일기기': 'MOB',
|
||||
'구독SW': 'SSW', '영구SW': 'PSW'
|
||||
};
|
||||
|
||||
@@ -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: [] };
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface HardwareAsset {
|
||||
용량?: string;
|
||||
담당자_정?: string;
|
||||
담당자_부?: string;
|
||||
구매일?: string;
|
||||
구매연월?: string;
|
||||
금액?: string;
|
||||
납품업체: string;
|
||||
품의서명: string;
|
||||
@@ -40,6 +40,12 @@ export interface HardwareAsset {
|
||||
비고?: string;
|
||||
현사용조직?: string;
|
||||
이전사용조직?: string;
|
||||
<<<<<<< HEAD
|
||||
보관위치?: string;
|
||||
현재상태?: string;
|
||||
=======
|
||||
detail_purpose?: string;
|
||||
>>>>>>> origin/SW_Table
|
||||
}
|
||||
|
||||
export interface SoftwareAsset {
|
||||
@@ -49,7 +55,7 @@ export interface SoftwareAsset {
|
||||
법인: string;
|
||||
부서?: string;
|
||||
제품명: string;
|
||||
구매일: string;
|
||||
구매연월: string;
|
||||
구독일?: string;
|
||||
만료일?: string;
|
||||
라이선스유형?: string;
|
||||
@@ -60,11 +66,13 @@ export interface SoftwareAsset {
|
||||
계정명: string;
|
||||
납품업체: string;
|
||||
비고: string;
|
||||
자산번호?: string;
|
||||
플랫폼명?: string;
|
||||
결제수단?: string;
|
||||
결제일?: string;
|
||||
연결카드번호?: string;
|
||||
당월청구액?: string;
|
||||
시작일?: string;
|
||||
}
|
||||
|
||||
export interface SWUser {
|
||||
@@ -96,21 +104,24 @@ 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 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', '구매일', '금액', '납품업체', '품의서명', '비고'];
|
||||
const MOBILE_HEADERS = ['구매법인', '자산코드', '명칭', '위치', '관리자', '기기유형', 'OS', '구매일', '금액', '납품업체', '품의서명', '비고'];
|
||||
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', '구매연월', '금액', '납품업체', '품의서명', '비고'];
|
||||
const MOBILE_HEADERS = ['구매법인', '자산코드', '명칭', '위치', '관리자', '기기유형', 'OS', '구매연월', '금액', '납품업체', '품의서명', '비고'];
|
||||
|
||||
const SUB_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매일', '만료일', '라이선스유형', '금액', '수량', '계정명', '납품업체', '비고'];
|
||||
const PERM_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매일', '라이선스키', '금액', '수량', '계정명', '납품업체', '비고'];
|
||||
const SUB_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매연월', '만료일', '라이선스유형', '금액', '수량', '계정명', '납품업체', '비고'];
|
||||
const PERM_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매연월', '라이선스키', '금액', '수량', '계정명', '납품업체', '비고'];
|
||||
const CLOUD_HEADERS = ['ID', '플랫폼명', '법인', '부서', '사용용도(제품명)', '계정명', '결제수단', '결제일', '연결카드번호', '당월청구액', '비고'];
|
||||
|
||||
export function downloadTemplate() {
|
||||
@@ -142,13 +153,13 @@ 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: '서버', 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.비고] },
|
||||
{ tab: '모바일기기', list: masterData.mobile, headers: MOBILE_HEADERS, map: (a: any) => [a.법인, a.자산코드, a.명칭, a.위치, a.관리자, a.type, a.OS, a.구매일, a.금액, a.납품업체, a.품의서명, a.비고] },
|
||||
{ tab: '구독SW', list: masterData.subSw, headers: SUB_SW_HEADERS, map: (a: any) => [a.id, a.분야, a.법인, a.부서, a.제품명, a.구매일, a.만료일, a.라이선스유형, a.금액, a.수량, a.계정명, a.납품업체, a.비고] },
|
||||
{ tab: '영구SW', list: masterData.permSw, headers: PERM_SW_HEADERS, map: (a: any) => [a.id, a.분야, a.법인, a.부서, a.제품명, a.구매일, a.라이선스키, a.금액, a.수량, a.계정명, a.납품업체, a.비고] }
|
||||
{ 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: '서버', 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.비고] },
|
||||
{ tab: '모바일기기', list: masterData.mobile, headers: MOBILE_HEADERS, map: (a: any) => [a.법인, a.자산코드, a.명칭, a.위치, a.관리자, a.type, a.OS, a.구매연월, a.금액, a.납품업체, a.품의서명, a.비고] },
|
||||
{ tab: '구독SW', list: masterData.subSw, headers: SUB_SW_HEADERS, map: (a: any) => [a.id, a.분야, a.법인, a.부서, a.제품명, a.구매연월, a.만료일, a.라이선스유형, a.금액, a.수량, a.계정명, a.납품업체, a.비고] },
|
||||
{ tab: '영구SW', list: masterData.permSw, headers: PERM_SW_HEADERS, map: (a: any) => [a.id, a.분야, a.법인, a.부서, a.제품명, a.구매연월, a.라이선스키, a.금액, a.수량, a.계정명, a.납품업체, a.비고] }
|
||||
];
|
||||
|
||||
exportMap.forEach(m => {
|
||||
@@ -164,23 +175,23 @@ 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['위치']||'', 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['품의서명']||'', 비고: 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사양: '', 금액: '', 납품업체: '', 품의서명: '' }));
|
||||
rows.forEach(r => data.server.push({ id: Math.random().toString(36).substring(2, 9), type: '서버', 법인: r['구매법인']||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 === '스토리지') {
|
||||
rows.forEach(r => data.storage.push({ id: Math.random().toString(36).substring(2, 9), type: '스토리지', 법인: r['구매법인']||r['법인']||'', storage유형: r['유형']||'', 자산코드: r['자산코드']||'', 명칭: r['명칭']||'', 위치: r['위치']||'', 모델명: r['모델명']||'', 용량: r['용량']||'', 담당자_정: r['담당자(정)']||'', 담당자_부: r['담당자(부)']||'', IP주소: r['IP주소']||'', MACaddress: r['MAC주소']||'', 구매일: r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'', HW사양: '', OS: '', 관리자: '' }));
|
||||
rows.forEach(r => data.storage.push({ id: Math.random().toString(36).substring(2, 9), type: '스토리지', 법인: r['구매법인']||r['법인']||'', storage유형: r['유형']||'', 자산코드: r['자산코드']||'', 명칭: r['명칭']||'', 위치: r['위치']||'', 모델명: r['모델명']||'', 용량: r['용량']||'', 담당자_정: r['담당자(정)']||'', 담당자_부: r['담당자(부)']||'', IP주소: r['IP주소']||'', MACaddress: r['MAC주소']||'', 구매연월: r['구매연월']||r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'', HW사양: '', OS: '', 관리자: '' }));
|
||||
} else if (sheetName === '전산비품') {
|
||||
rows.forEach(r => data.equip.push({ id: Math.random().toString(36).substring(2, 9), type: '전산비품', 법인: r['구매법인']||r['법인']||'', 비품유형: r['비품유형']||r['유형']||'', 자산코드: r['자산코드']||'', 명칭: r['명칭']||'', 위치: r['위치']||'', 관리자: r['관리자']||'', IP주소: r['IP주소']||'', MACaddress: r['MACaddress']||'', HW사양: r['HW사양']||'', OS: r['OS']||'', 구매일: r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'' }));
|
||||
rows.forEach(r => data.equip.push({ id: Math.random().toString(36).substring(2, 9), type: '전산비품', 법인: r['구매법인']||r['법인']||'', 비품유형: r['비품유형']||r['유형']||'', 자산코드: r['자산코드']||'', 명칭: r['명칭']||'', 위치: r['위치']||'', 관리자: r['관리자']||'', IP주소: r['IP주소']||'', MACaddress: r['MACaddress']||'', HW사양: r['HW사양']||'', OS: r['OS']||'', 구매연월: r['구매연월']||r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'' }));
|
||||
} else if (sheetName === '모바일기기') {
|
||||
rows.forEach(r => data.mobile.push({ id: Math.random().toString(36).substring(2, 9), type: '모바일기기', 법인: r['구매법인']||r['법인']||'', 자산코드: r['자산코드']||'', 명칭: r['명칭']||'', 위치: r['위치']||'', 관리자: r['관리자']||'', OS: r['OS']||'', 구매일: r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'', IP주소: '', MACaddress: '', HW사양: '' }));
|
||||
rows.forEach(r => data.mobile.push({ id: Math.random().toString(36).substring(2, 9), type: '모바일기기', 법인: r['구매법인']||r['법인']||'', 자산코드: r['자산코드']||'', 명칭: r['명칭']||'', 위치: r['위치']||'', 관리자: r['관리자']||'', OS: r['OS']||'', 구매연월: r['구매연월']||r['구매일']||'', 금액: r['금액']||'', 납품업체: r['납품업체']||'', 품의서명: r['품의서명']||'', 비고: r['비고']||'', IP주소: '', MACaddress: '', HW사양: '' }));
|
||||
} else if (sheetName === '구독SW') {
|
||||
rows.forEach(r => data.subSw.push({ id: r['ID']||Math.random().toString(36).substring(2, 9), type: '구독SW', 분야: r['분야']||'', 법인: r['법인']||'', 부서: r['부서']||'', 제품명: r['제품명']||'', 구매일: r['구매일']||'', 만료일: r['만료일']||'', 라이선스유형: r['라이선스유형']||'', 금액: r['금액']||'', 수량: parseInt(r['수량']||'1'), 계정명: r['계정명']||'', 납품업체: r['납품업체']||'', 비고: r['비고']||'' }));
|
||||
rows.forEach(r => data.subSw.push({ id: r['ID']||Math.random().toString(36).substring(2, 9), type: '구독SW', 분야: r['분야']||'', 법인: r['법인']||'', 부서: r['부서']||'', 제품명: r['제품명']||'', 구매연월: r['구매연월']||r['구매일']||'', 만료일: r['만료일']||'', 라이선스유형: r['라이선스유형']||'', 금액: r['금액']||'', 수량: parseInt(r['수량']||'1'), 계정명: r['계정명']||'', 납품업체: r['납품업체']||'', 비고: r['비고']||'' }));
|
||||
} else if (sheetName === '영구SW') {
|
||||
rows.forEach(r => data.permSw.push({ id: r['ID']||Math.random().toString(36).substring(2, 9), type: '영구SW', 분야: r['분야']||'', 법인: r['법인']||'', 부서: r['부서']||'', 제품명: r['제품명']||'', 구매일: r['구매일']||'', 라이선스키: r['라이선스키']||'', 금액: r['금액']||'', 수량: parseInt(r['수량']||'1'), 계정명: r['계정명']||'', 납품업체: r['납품업체']||'', 비고: r['비고']||'' }));
|
||||
rows.forEach(r => data.permSw.push({ id: r['ID']||Math.random().toString(36).substring(2, 9), type: '영구SW', 분야: r['분야']||'', 법인: r['법인']||'', 부서: r['부서']||'', 제품명: r['제품명']||'', 구매연월: r['구매연월']||r['구매일']||'', 라이선스키: r['라이선스키']||'', 금액: r['금액']||'', 수량: parseInt(r['수량']||'1'), 계정명: r['계정명']||'', 납품업체: r['납품업체']||'', 비고: r['비고']||'' }));
|
||||
}
|
||||
});
|
||||
resolve(data);
|
||||
|
||||
@@ -16,12 +16,14 @@ export interface MasterAssetData {
|
||||
// 동료 코드 호환용 통합 배열 (프론트엔드 로직용)
|
||||
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[];
|
||||
}
|
||||
|
||||
// 초기 상태
|
||||
@@ -40,8 +42,10 @@ export const state: AppState = {
|
||||
hw: [], // 호환용
|
||||
sw: [], // 호환용
|
||||
swUsers: [],
|
||||
logs: []
|
||||
}
|
||||
logs: [],
|
||||
hw: []
|
||||
},
|
||||
activeCharts: []
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -85,12 +89,19 @@ 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,
|
||||
...state.masterData.storage,
|
||||
...state.masterData.equip,
|
||||
...state.masterData.mobile
|
||||
];
|
||||
|
||||
// 하드웨어 통합 배열 생성 (대시보드 등에서 사용)
|
||||
state.masterData.hw = [
|
||||
@@ -121,18 +132,25 @@ export function saveHardwareAsset(updatedAsset: HardwareAsset) {
|
||||
const type = updatedAsset.type || '';
|
||||
const detailPurpose = (updatedAsset as any).상세용도 || updatedAsset.detail_purpose || '';
|
||||
|
||||
// 1. 타겟 카테고리 결정 (유연한 검색)
|
||||
// 1. 타겟 카테고리 결정 (사용자 정의 그룹 기준)
|
||||
let targetKey: keyof MasterAssetData = 'equip';
|
||||
|
||||
if (type.includes('서버') || detailPurpose.includes('서버')) {
|
||||
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) {
|
||||
targetKey = 'server';
|
||||
} else if (['NAS', 'DAS', '스토리지'].some(t => type.includes(t))) {
|
||||
} else if (isStorage) {
|
||||
targetKey = 'storage';
|
||||
} else if (['모바일', '태블릿', '휴대폰', '핸드폰', '노트북'].some(t => type.includes(t))) {
|
||||
} else if (isMobileGroup) {
|
||||
targetKey = 'mobile';
|
||||
} else if (type === 'PC' || type === '개인PC' || detailPurpose === '개인PC') {
|
||||
} else if (isPc) {
|
||||
targetKey = 'pc';
|
||||
} else if (['CPU', 'GPU', 'RAM', 'HDD'].some(t => type.toUpperCase().includes(t))) {
|
||||
} else if (isEquipGroup) {
|
||||
targetKey = 'equip';
|
||||
}
|
||||
|
||||
|
||||
18
src/main.ts
18
src/main.ts
@@ -4,12 +4,12 @@ import { renderDashboard } from './views/DashboardView';
|
||||
import { renderSWTable } from './views/SW_Table';
|
||||
import { downloadTemplate, exportToExcel, parseExcel, HardwareAsset, SoftwareAsset, SWUser } from './core/excelHandler';
|
||||
import { initBaseModal } from './components/Modal/BaseModal';
|
||||
import { initPcModal } from './components/Modal/PCModal';
|
||||
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) {
|
||||
@@ -75,7 +75,6 @@ function initApp() {
|
||||
});
|
||||
|
||||
// 모달 초기화
|
||||
initPcModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
|
||||
initHwModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
|
||||
|
||||
initSwModal(() => {
|
||||
@@ -89,6 +88,7 @@ function initApp() {
|
||||
}, closeAllModals);
|
||||
|
||||
initDashboardDetailModal();
|
||||
initGuide();
|
||||
} catch (e) { console.error('❌ Initialization failed:', e); }
|
||||
|
||||
// 초기 로드 시 대시보드 렌더링
|
||||
@@ -125,8 +125,14 @@ function initApp() {
|
||||
const cat = state.activeCategory;
|
||||
|
||||
if (cat === 'hw') {
|
||||
// 하드웨어 대시보드 또는 개별 탭에서 추가
|
||||
const defaultType = (tab === '대시보드') ? '' : tab;
|
||||
// 탭 명칭을 실제 유형명으로 매핑
|
||||
let defaultType = '';
|
||||
if (tab === '개인PC') defaultType = 'PC';
|
||||
else if (tab === '서버') defaultType = '서버';
|
||||
else if (tab === '스토리지') defaultType = '스토리지';
|
||||
else if (tab === '전산비품') defaultType = 'CPU';
|
||||
else if (tab === '모바일기기') defaultType = '모바일';
|
||||
|
||||
openHwModal({
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
type: defaultType,
|
||||
@@ -145,7 +151,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 }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
349
src/styles/guide.css
Normal 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; }
|
||||
@@ -102,7 +102,8 @@
|
||||
/* Modal Readonly/Edit Mode Interaction */
|
||||
.grid-form.is-view-mode input,
|
||||
.grid-form.is-view-mode select,
|
||||
.grid-form.is-view-mode textarea {
|
||||
.grid-form.is-view-mode textarea,
|
||||
.grid-form.is-view-mode button {
|
||||
border: none !important;
|
||||
background-color: transparent !important;
|
||||
padding-left: 0 !important;
|
||||
@@ -167,6 +168,10 @@
|
||||
background-color: var(--white);
|
||||
}
|
||||
|
||||
.form-group textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group select:focus,
|
||||
.form-group textarea:focus {
|
||||
@@ -213,6 +218,9 @@
|
||||
}
|
||||
|
||||
.history-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
@@ -225,6 +233,35 @@
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
/* 읽기 전용 필드 (자산번호 등) 통일 스타일 */
|
||||
.is-readonly-field {
|
||||
border-color: transparent !important;
|
||||
background-color: transparent !important;
|
||||
pointer-events: none !important;
|
||||
color: var(--text-main) !important;
|
||||
font-weight: 600 !important;
|
||||
cursor: default;
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
|
||||
/* 입력 필드 + 버튼 그룹 (자산번호 생성 등) */
|
||||
.input-with-btn {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-with-btn input {
|
||||
flex: 1;
|
||||
min-width: 0; /* flex 컨테이너 안에서 너비 압축 방지 */
|
||||
}
|
||||
|
||||
.input-with-btn .btn {
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.history-timeline {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
|
||||
@@ -62,7 +62,8 @@
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
overflow: auto;
|
||||
max-height: calc(100vh - 240px);
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
table {
|
||||
|
||||
@@ -105,7 +105,7 @@ export function renderHwDashboard(container: HTMLElement) {
|
||||
<th>유형</th>
|
||||
<th>모델명</th>
|
||||
<th>사용자/담당자</th>
|
||||
<th>구매일</th>
|
||||
<th>구매연월</th>
|
||||
<th>연령</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -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>
|
||||
`;
|
||||
|
||||
|
||||
@@ -1,85 +1,75 @@
|
||||
import { state } from '../../core/state';
|
||||
import { openHwModal } from '../../components/Modal/HWModal';
|
||||
import { formatInline, sortAssets } from '../../core/utils';
|
||||
import { createIcons, RefreshCcw } from 'lucide';
|
||||
|
||||
export function renderEquipmentList(container: HTMLElement) {
|
||||
const fullList = sortAssets(state.masterData.equip);
|
||||
export function renderEquipmentList(filterKeyword: string = '') {
|
||||
const container = document.getElementById('view-container');
|
||||
if (!container) return;
|
||||
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'search-bar';
|
||||
const corps = Array.from(new Set(fullList.map(a => a.법인))).filter(Boolean).sort();
|
||||
const items = state.masterData.equip.filter(i =>
|
||||
i.자산코드?.includes(filterKeyword) ||
|
||||
i.명칭?.includes(filterKeyword) ||
|
||||
i.자산구분?.includes(filterKeyword)
|
||||
);
|
||||
|
||||
filterBar.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>통합 검색 (자산코드/명칭)</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div class="header-left">
|
||||
<h2>전산비품 자산 현황</h2>
|
||||
<span class="count-badge">총 ${items.length}개</span>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>구매법인</label>
|
||||
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
|
||||
<div class="header-actions">
|
||||
<button id="btn-add-equip" class="btn btn-primary"><i data-lucide="plus"></i> 비품 등록</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<table class="itam-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>구분</th>
|
||||
<th>자산번호</th>
|
||||
<th>비품명</th>
|
||||
<th>모델명/상세</th>
|
||||
<th>위치</th>
|
||||
<th>사용자/관리자</th>
|
||||
<th>상태</th>
|
||||
<th>관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${items.length === 0 ? '<tr><td colspan="8" class="empty-row">데이터가 없습니다.</td></tr>' :
|
||||
items.map(i => `
|
||||
<tr class="asset-row" data-id="${i.id}">
|
||||
<td>${i.자산구분 || '기타'}</td>
|
||||
<td><span class="code-link">${i.자산코드 || '미부여'}</span></td>
|
||||
<td>${i.명칭 || '-'}</td>
|
||||
<td>${i.모델명 || i.HW사양 || '-'}</td>
|
||||
<td>${i.위치 || '-'}</td>
|
||||
<td>${i.사용자 || i.관리자 || '-'}</td>
|
||||
<td><span class="status-badge ${i.상태 === '사용중' ? 'active' : ''}">${i.상태 || '정상'}</span></td>
|
||||
<td><button class="btn btn-sm btn-outline btn-detail" data-id="${i.id}">상세</button></td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
|
||||
<i data-lucide="refresh-ccw"></i> 필터 초기화
|
||||
</button>
|
||||
`;
|
||||
container.appendChild(filterBar);
|
||||
|
||||
const tableWrapper = document.createElement('div');
|
||||
tableWrapper.className = 'table-container';
|
||||
const table = document.createElement('table');
|
||||
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>유형</th><th>자산번호</th><th>모델명</th><th>관리자</th><th>구매일</th><th>금액</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
|
||||
|
||||
tableWrapper.appendChild(table);
|
||||
container.appendChild(tableWrapper);
|
||||
const tbody = table.querySelector('tbody')!;
|
||||
|
||||
const updateTable = () => {
|
||||
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
|
||||
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
|
||||
|
||||
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
||||
const corp = corpSelect ? corpSelect.value : '';
|
||||
|
||||
const filtered = fullList.filter(asset => {
|
||||
const matchKeyword = !keyword || String(asset.자산코드||'').toLowerCase().includes(keyword) || String(asset.모델명||'').toLowerCase().includes(keyword) || String(asset.현사용조직||'').toLowerCase().includes(keyword);
|
||||
const matchCorp = !corp || asset.법인 === corp;
|
||||
return matchKeyword && matchCorp;
|
||||
container.querySelectorAll('.asset-row, .btn-detail').forEach(el => {
|
||||
el.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const id = (el as HTMLElement).getAttribute('data-id');
|
||||
const asset = state.masterData.equip.find(a => a.id === id);
|
||||
if (asset) openHwModal(asset, 'view');
|
||||
});
|
||||
});
|
||||
|
||||
tbody.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="10" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach((asset, idx) => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.style.cursor = 'pointer';
|
||||
tr.innerHTML = `
|
||||
<td>${idx+1}</td>
|
||||
<td>${asset.법인}</td>
|
||||
<td>${asset.현사용조직||''}</td>
|
||||
<td>${asset.type}</td>
|
||||
<td>${asset.자산코드}</td>
|
||||
<td>${formatInline(asset.모델명)}</td>
|
||||
<td>${formatInline(asset.담당자_정 || asset.관리자)}</td>
|
||||
<td>${asset.구매일||''}</td>
|
||||
<td>${asset.금액||''}</td>
|
||||
<td><button class="btn btn-outline btn-sm">수정</button></td>
|
||||
`;
|
||||
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
document.getElementById('btn-add-equip')?.addEventListener('click', () => {
|
||||
const newItem: any = {
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
type: '전산비품',
|
||||
법인: 'HM',
|
||||
상태: '사용중'
|
||||
};
|
||||
|
||||
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
|
||||
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
|
||||
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
|
||||
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
|
||||
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
|
||||
updateTable();
|
||||
openHwModal(newItem, 'add');
|
||||
});
|
||||
|
||||
updateTable();
|
||||
}
|
||||
|
||||
@@ -1,85 +1,75 @@
|
||||
import { state } from '../../core/state';
|
||||
import { openHwModal } from '../../components/Modal/HWModal';
|
||||
import { formatInline, sortAssets } from '../../core/utils';
|
||||
import { createIcons, RefreshCcw } from 'lucide';
|
||||
|
||||
export function renderMobileList(container: HTMLElement) {
|
||||
const fullList = sortAssets(state.masterData.mobile);
|
||||
export function renderMobileList(filterKeyword: string = '') {
|
||||
const container = document.getElementById('view-container');
|
||||
if (!container) return;
|
||||
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'search-bar';
|
||||
const corps = Array.from(new Set(fullList.map(a => a.법인))).filter(Boolean).sort();
|
||||
const items = state.masterData.mobile.filter(i =>
|
||||
i.자산코드?.includes(filterKeyword) ||
|
||||
i.사용자?.includes(filterKeyword) ||
|
||||
i.명칭?.includes(filterKeyword)
|
||||
);
|
||||
|
||||
filterBar.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>통합 검색 (자산코드/명칭)</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div class="header-left">
|
||||
<h2>모바일 자산 현황</h2>
|
||||
<span class="count-badge">총 ${items.length}대</span>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>구매법인</label>
|
||||
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
|
||||
<div class="header-actions">
|
||||
<button id="btn-add-mobile" class="btn btn-primary"><i data-lucide="plus"></i> 기기 등록</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<table class="itam-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>구분</th>
|
||||
<th>자산번호</th>
|
||||
<th>기기명</th>
|
||||
<th>사용자</th>
|
||||
<th>OS</th>
|
||||
<th>도입일</th>
|
||||
<th>상태</th>
|
||||
<th>관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${items.length === 0 ? '<tr><td colspan="8" class="empty-row">데이터가 없습니다.</td></tr>' :
|
||||
items.map(i => `
|
||||
<tr class="asset-row" data-id="${i.id}">
|
||||
<td>${i.법인 || 'HM'}</td>
|
||||
<td><span class="code-link">${i.자산코드 || '미부여'}</span></td>
|
||||
<td>${i.명칭 || '-'}</td>
|
||||
<td>${i.사용자 || i.관리자 || '-'}</td>
|
||||
<td>${i.OS || '-'}</td>
|
||||
<td>${i.도입일 || '-'}</td>
|
||||
<td><span class="status-badge ${i.상태 === '사용중' ? 'active' : ''}">${i.상태 || '사용중'}</span></td>
|
||||
<td><button class="btn btn-sm btn-outline btn-detail" data-id="${i.id}">상세</button></td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
|
||||
<i data-lucide="refresh-ccw"></i> 필터 초기화
|
||||
</button>
|
||||
`;
|
||||
container.appendChild(filterBar);
|
||||
|
||||
const tableWrapper = document.createElement('div');
|
||||
tableWrapper.className = 'table-container';
|
||||
const table = document.createElement('table');
|
||||
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>유형</th><th>자산번호</th><th>모델명</th><th>관리자</th><th>구매일</th><th>금액</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
|
||||
|
||||
tableWrapper.appendChild(table);
|
||||
container.appendChild(tableWrapper);
|
||||
const tbody = table.querySelector('tbody')!;
|
||||
|
||||
const updateTable = () => {
|
||||
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
|
||||
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
|
||||
|
||||
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
||||
const corp = corpSelect ? corpSelect.value : '';
|
||||
|
||||
const filtered = fullList.filter(asset => {
|
||||
const matchKeyword = !keyword || String(asset.자산코드||'').toLowerCase().includes(keyword) || String(asset.모델명||'').toLowerCase().includes(keyword) || String(asset.현사용조직||'').toLowerCase().includes(keyword);
|
||||
const matchCorp = !corp || asset.법인 === corp;
|
||||
return matchKeyword && matchCorp;
|
||||
container.querySelectorAll('.asset-row, .btn-detail').forEach(el => {
|
||||
el.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const id = (el as HTMLElement).getAttribute('data-id');
|
||||
const asset = state.masterData.mobile.find(a => a.id === id);
|
||||
if (asset) openHwModal(asset, 'view');
|
||||
});
|
||||
});
|
||||
|
||||
tbody.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="10" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach((asset, idx) => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.style.cursor = 'pointer';
|
||||
tr.innerHTML = `
|
||||
<td>${idx+1}</td>
|
||||
<td>${asset.법인}</td>
|
||||
<td>${asset.현사용조직||''}</td>
|
||||
<td>${asset.type}</td>
|
||||
<td>${asset.자산코드}</td>
|
||||
<td>${formatInline(asset.모델명)}</td>
|
||||
<td>${formatInline(asset.담당자_정 || asset.관리자)}</td>
|
||||
<td>${asset.구매일||''}</td>
|
||||
<td>${asset.금액||''}</td>
|
||||
<td><button class="btn btn-outline btn-sm">수정</button></td>
|
||||
`;
|
||||
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
document.getElementById('btn-add-mobile')?.addEventListener('click', () => {
|
||||
const newItem: any = {
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
type: '모바일기기',
|
||||
법인: 'HM',
|
||||
상태: '사용중'
|
||||
};
|
||||
|
||||
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
|
||||
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
|
||||
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
|
||||
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
|
||||
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
|
||||
updateTable();
|
||||
openHwModal(newItem, 'add');
|
||||
});
|
||||
|
||||
updateTable();
|
||||
}
|
||||
|
||||
@@ -1,92 +1,78 @@
|
||||
import { state } from '../../core/state';
|
||||
import { openPcModal } from '../../components/Modal/PCModal';
|
||||
import { formatInline, sortAssets } from '../../core/utils';
|
||||
import { createIcons, Paperclip, RefreshCcw } from 'lucide';
|
||||
import { openHwModal } from '../../components/Modal/HWModal';
|
||||
|
||||
export function renderPcList(container: HTMLElement) {
|
||||
const fullList = sortAssets(state.masterData.pc);
|
||||
export function renderPcList(filterKeyword: string = '') {
|
||||
const container = document.getElementById('view-container');
|
||||
if (!container) return;
|
||||
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'search-bar';
|
||||
const corps = Array.from(new Set(fullList.map(a => a.법인))).filter(Boolean).sort();
|
||||
const pcs = state.masterData.pc.filter(pc =>
|
||||
pc.자산코드?.includes(filterKeyword) ||
|
||||
pc.사용자?.includes(filterKeyword) ||
|
||||
pc.모델명?.includes(filterKeyword) ||
|
||||
pc.실사용조직?.includes(filterKeyword)
|
||||
);
|
||||
|
||||
filterBar.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>통합 검색 (자산코드/사용자)</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div class="header-left">
|
||||
<h2>개인PC 자산 현황</h2>
|
||||
<span class="count-badge">총 ${pcs.length}대</span>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>구매법인</label>
|
||||
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
|
||||
<div class="header-actions">
|
||||
<button id="btn-add-pc" class="btn btn-primary"><i data-lucide="plus"></i> 신규 등록</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<table class="itam-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>구매법인</th>
|
||||
<th>자산번호</th>
|
||||
<th>실사용조직</th>
|
||||
<th>사용자</th>
|
||||
<th>모델명</th>
|
||||
<th>사양 (CPU/RAM)</th>
|
||||
<th>도입일</th>
|
||||
<th>관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${pcs.length === 0 ? '<tr><td colspan="8" class="empty-row">데이터가 없습니다.</td></tr>' :
|
||||
pcs.map(pc => `
|
||||
<tr class="asset-row" data-id="${pc.id}">
|
||||
<td>${pc.법인 || '-'}</td>
|
||||
<td><span class="code-link">${pc.자산코드 || pc.관리번호 || '미부여'}</span></td>
|
||||
<td>${pc.실사용조직 || pc.현사용조직 || '-'}</td>
|
||||
<td>${pc.사용자 || '-'}</td>
|
||||
<td>${pc.모델명 || '-'}</td>
|
||||
<td><small>${pc.CPU || '-'} / ${pc.RAM || '-'}</small></td>
|
||||
<td>${pc.도입일 || pc.구매일 || '-'}</td>
|
||||
<td><button class="btn btn-sm btn-outline btn-detail" data-id="${pc.id}">상세</button></td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
|
||||
<i data-lucide="refresh-ccw"></i> 필터 초기화
|
||||
</button>
|
||||
`;
|
||||
container.appendChild(filterBar);
|
||||
|
||||
const tableWrapper = document.createElement('div');
|
||||
tableWrapper.className = 'table-container';
|
||||
const table = document.createElement('table');
|
||||
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>자산코드</th><th>사용자</th><th>위치</th><th>CPU</th><th>RAM</th><th>Storage</th><th>구매일</th><th>금액</th><th>품의서</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
|
||||
|
||||
tableWrapper.appendChild(table);
|
||||
container.appendChild(tableWrapper);
|
||||
|
||||
const tbody = table.querySelector('tbody')!;
|
||||
|
||||
const updateTable = () => {
|
||||
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
|
||||
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
|
||||
|
||||
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
||||
const corp = corpSelect ? corpSelect.value : '';
|
||||
|
||||
const filtered = fullList.filter(asset => {
|
||||
const matchKeyword = !keyword || String(asset.자산코드||'').toLowerCase().includes(keyword) || String(asset.사용자||'').toLowerCase().includes(keyword) || String(asset.현사용조직||'').toLowerCase().includes(keyword);
|
||||
const matchCorp = !corp || asset.법인 === corp;
|
||||
return matchKeyword && matchCorp;
|
||||
// 이벤트 바인딩
|
||||
container.querySelectorAll('.asset-row, .btn-detail').forEach(el => {
|
||||
el.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const id = (el as HTMLElement).getAttribute('data-id');
|
||||
const asset = state.masterData.pc.find(a => a.id === id);
|
||||
if (asset) openHwModal(asset, 'view');
|
||||
});
|
||||
});
|
||||
|
||||
tbody.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="13" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach((asset, idx) => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.style.cursor = 'pointer';
|
||||
const storage = [asset.SSD1, asset.SSD2, asset.HDD1].filter(v => v).join(' / ');
|
||||
|
||||
tr.innerHTML = `
|
||||
<td>${idx+1}</td>
|
||||
<td>${asset.법인}</td>
|
||||
<td>${asset.현사용조직||''}</td>
|
||||
<td>${asset.자산코드}</td>
|
||||
<td>${asset.사용자||''}</td>
|
||||
<td>${asset.위치||''}</td>
|
||||
<td>${asset.CPU||''}</td>
|
||||
<td>${asset.RAM||''}</td>
|
||||
<td>${formatInline(storage)}</td>
|
||||
<td>${asset.구매일||''}</td>
|
||||
<td>${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>
|
||||
`;
|
||||
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openPcModal(asset, 'view'); });
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
createIcons({ icons: { Paperclip } });
|
||||
document.getElementById('btn-add-pc')?.addEventListener('click', () => {
|
||||
const newPc: any = {
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
type: '개인PC',
|
||||
법인: 'HM',
|
||||
관리조직: '전산팀',
|
||||
상태: '사용중'
|
||||
};
|
||||
|
||||
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
|
||||
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
|
||||
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
|
||||
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
|
||||
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
|
||||
updateTable();
|
||||
openHwModal(newPc, 'add');
|
||||
});
|
||||
|
||||
updateTable();
|
||||
}
|
||||
|
||||
@@ -1,108 +1,77 @@
|
||||
import { state } from '../../core/state';
|
||||
import { openHwModal } from '../../components/Modal/HWModal';
|
||||
import { formatInline, createBadge, sortAssets } from '../../core/utils';
|
||||
import { createIcons, RefreshCcw } from 'lucide';
|
||||
|
||||
export function renderServerList(container: HTMLElement) {
|
||||
const fullList = sortAssets(state.masterData.server);
|
||||
export function renderServerList(filterKeyword: string = '') {
|
||||
const container = document.getElementById('view-container');
|
||||
if (!container) return;
|
||||
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'search-bar';
|
||||
const corps = Array.from(new Set(fullList.map(a => a.법인))).filter(Boolean).sort();
|
||||
const orgUnits = Array.from(new Set(fullList.map(a => a.현사용조직))).filter(Boolean).sort();
|
||||
const servers = state.masterData.server.filter(s =>
|
||||
s.자산코드?.includes(filterKeyword) ||
|
||||
s.모델명?.includes(filterKeyword) ||
|
||||
s.IP주소?.includes(filterKeyword) ||
|
||||
s.실사용조직?.includes(filterKeyword)
|
||||
);
|
||||
|
||||
filterBar.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>통합 검색 (자산번호/조직/모델명)</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div class="header-left">
|
||||
<h2>서버 자산 현황</h2>
|
||||
<span class="count-badge">총 ${servers.length}대</span>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>구매법인</label>
|
||||
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
|
||||
<div class="header-actions">
|
||||
<button id="btn-add-server" class="btn btn-primary"><i data-lucide="plus"></i> 서버 등록</button>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>현 사용조직</label>
|
||||
<select id="filter-org-unit"><option value="">전체 조직</option>${orgUnits.map(o => `<option value="${o}">${o}</option>`).join('')}</select>
|
||||
</div>
|
||||
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
|
||||
<i data-lucide="refresh-ccw"></i> 필터 초기화
|
||||
</button>
|
||||
<div class="table-container">
|
||||
<table class="itam-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>구분</th>
|
||||
<th>자산번호</th>
|
||||
<th>용도</th>
|
||||
<th>실사용조직</th>
|
||||
<th>IP 주소</th>
|
||||
<th>모델명</th>
|
||||
<th>상태</th>
|
||||
<th>관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${servers.length === 0 ? '<tr><td colspan="8" class="empty-row">데이터가 없습니다.</td></tr>' :
|
||||
servers.map(s => `
|
||||
<tr class="asset-row" data-id="${s.id}">
|
||||
<td>${s.법인 || 'HM'}</td>
|
||||
<td><span class="code-link">${s.자산코드 || '미부여'}</span></td>
|
||||
<td>${s.서버용도 || '-'}</td>
|
||||
<td>${s.실사용조직 || '-'}</td>
|
||||
<td><code>${s.IP주소 || '-'}</code></td>
|
||||
<td>${s.모델명 || '-'}</td>
|
||||
<td><span class="status-badge ${s.상태 === '사용중' ? 'active' : ''}">${s.상태 || '운영'}</span></td>
|
||||
<td><button class="btn btn-sm btn-outline btn-detail" data-id="${s.id}">상세</button></td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(filterBar);
|
||||
|
||||
const tableWrapper = document.createElement('div');
|
||||
tableWrapper.className = 'table-container';
|
||||
const table = document.createElement('table');
|
||||
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>자산번호</th><th>용도</th><th>상세</th><th>설치위치</th><th>담당자</th><th>IP주소</th><th>모델명</th><th>OS</th><th>CPU/RAM</th><th>Storage</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
|
||||
|
||||
tableWrapper.appendChild(table);
|
||||
container.appendChild(tableWrapper);
|
||||
const tbody = table.querySelector('tbody')!;
|
||||
|
||||
const updateTable = () => {
|
||||
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
|
||||
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
|
||||
const orgSelect = document.getElementById('filter-org-unit') as HTMLSelectElement;
|
||||
|
||||
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
||||
const corp = corpSelect ? corpSelect.value : '';
|
||||
const orgUnit = orgSelect ? orgSelect.value : '';
|
||||
|
||||
const filtered = fullList.filter(asset => {
|
||||
const matchKeyword = !keyword || String(asset.자산코드||'').toLowerCase().includes(keyword) || String(asset.현사용조직||'').toLowerCase().includes(keyword) || String(asset.모델명||'').toLowerCase().includes(keyword);
|
||||
const matchCorp = !corp || asset.법인 === corp;
|
||||
const matchOrg = !orgUnit || asset.현사용조직 === orgUnit;
|
||||
return matchKeyword && matchCorp && matchOrg;
|
||||
container.querySelectorAll('.asset-row, .btn-detail').forEach(el => {
|
||||
el.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const id = (el as HTMLElement).getAttribute('data-id');
|
||||
const asset = state.masterData.server.find(a => a.id === id);
|
||||
if (asset) openHwModal(asset, 'view');
|
||||
});
|
||||
});
|
||||
|
||||
tbody.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="14" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach((asset, idx) => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.style.cursor = 'pointer';
|
||||
|
||||
const mainManager = asset.담당자_정 || '';
|
||||
const subManager = asset.담당자_부 || '';
|
||||
const managerHtml = [mainManager ? `${createBadge('정', '#1E5149')} ${mainManager}` : '', subManager ? `${createBadge('부', '#9CA3AF')} ${subManager}` : ''].filter(v => v !== '').join(' / ');
|
||||
|
||||
const ipInfo = [asset.IP주소, asset.IP2].filter(v => v).join(' / ');
|
||||
const cpuRam = [asset.CPU, asset.RAM].filter(v => v).join(' / ');
|
||||
const storage = [asset.SSD1, asset.SSD2].filter(v => v).join(' / ');
|
||||
|
||||
tr.innerHTML = `
|
||||
<td>${idx+1}</td>
|
||||
<td>${asset.법인}</td>
|
||||
<td>${asset.현사용조직||''}</td>
|
||||
<td>${asset.자산코드}</td>
|
||||
<td>${formatInline(asset.용도)}</td>
|
||||
<td>${formatInline(asset.상세)}</td>
|
||||
<td>${formatInline(asset.위치)}</td>
|
||||
<td>${managerHtml}</td>
|
||||
<td>${formatInline(ipInfo)}</td>
|
||||
<td>${asset.모델명||''}</td>
|
||||
<td>${asset.OS||''}</td>
|
||||
<td>${formatInline(cpuRam)}</td>
|
||||
<td>${formatInline(storage)}</td>
|
||||
<td><button class="btn btn-outline btn-sm">수정</button></td>
|
||||
`;
|
||||
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
document.getElementById('btn-add-server')?.addEventListener('click', () => {
|
||||
const newServer: any = {
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
type: '서버',
|
||||
법인: 'HM',
|
||||
관리조직: '전산팀',
|
||||
상태: '사용중'
|
||||
};
|
||||
|
||||
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
|
||||
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
|
||||
document.getElementById('filter-org-unit')?.addEventListener('change', updateTable);
|
||||
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
|
||||
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
|
||||
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
|
||||
(document.getElementById('filter-org-unit') as HTMLSelectElement).value = '';
|
||||
updateTable();
|
||||
openHwModal(newServer, 'add');
|
||||
});
|
||||
|
||||
updateTable();
|
||||
}
|
||||
|
||||
@@ -1,160 +1,78 @@
|
||||
import { state } from '../../core/state';
|
||||
import { openSwModal } from '../../components/Modal/SWModal';
|
||||
import { openSwUserModal } from '../../components/Modal/SWUserModal';
|
||||
import { sortAssets } from '../../core/utils';
|
||||
import { CORP_LIST } from '../../components/Modal/SharedData';
|
||||
import { generateOptionsHTML } from '../../components/Modal/ModalUtils';
|
||||
import { createIcons, Edit2, Users, RefreshCcw } from 'lucide';
|
||||
|
||||
export function renderSwList(container: HTMLElement) {
|
||||
const isSub = state.activeSubTab === '구독SW';
|
||||
const fullList = sortAssets(isSub ? state.masterData.subSw : state.masterData.permSw);
|
||||
export function renderSwList(filterKeyword: string = '') {
|
||||
const container = document.getElementById('view-container');
|
||||
if (!container) return;
|
||||
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'search-bar';
|
||||
filterBar.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>통합 검색 (제품명/부서)</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>분야</label>
|
||||
<select id="filter-field">
|
||||
<option value="">전체 분야</option>
|
||||
<option value="업무공통">업무공통</option>
|
||||
<option value="개발S/W">개발S/W</option>
|
||||
<option value="디자인">디자인</option>
|
||||
<option value="설계S/W">설계S/W</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>구매법인</label>
|
||||
<select id="filter-corp">${generateOptionsHTML(CORP_LIST, '', true)}</select>
|
||||
</div>
|
||||
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
|
||||
<i data-lucide="refresh-ccw"></i> 필터 초기화
|
||||
</button>
|
||||
`;
|
||||
container.appendChild(filterBar);
|
||||
const allSw = [...state.masterData.subSw, ...state.masterData.permSw].filter(sw =>
|
||||
sw.제품명?.includes(filterKeyword) ||
|
||||
sw.소프트웨어명?.includes(filterKeyword) ||
|
||||
sw.부서?.includes(filterKeyword)
|
||||
);
|
||||
|
||||
const tableWrapper = document.createElement('div');
|
||||
tableWrapper.className = 'table-container';
|
||||
const table = document.createElement('table');
|
||||
table.innerHTML = `
|
||||
container.innerHTML = `
|
||||
<div class="view-header">
|
||||
<div class="header-left">
|
||||
<h2>소프트웨어 자산 현황</h2>
|
||||
<span class="count-badge">총 ${allSw.length}건</span>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<button id="btn-add-sw" class="btn btn-primary"><i data-lucide="plus"></i> S/W 등록</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<table class="itam-table">
|
||||
<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>
|
||||
${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>구분</th>
|
||||
<th>제품명</th>
|
||||
<th>관리조직</th>
|
||||
<th>수량</th>
|
||||
<th>구매일</th>
|
||||
<th>만료일</th>
|
||||
<th>금액</th>
|
||||
<th>비고</th>
|
||||
<th>관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dynamic-tbody"></tbody>
|
||||
<tbody>
|
||||
${allSw.length === 0 ? '<tr><td colspan="9" class="empty-row">데이터가 없습니다.</td></tr>' :
|
||||
allSw.map(sw => `
|
||||
<tr class="asset-row" data-id="${sw.id}" data-type="${sw.type}">
|
||||
<td><span class="type-badge ${sw.type === '구독SW' ? 'sub' : 'perm'}">${sw.type}</span></td>
|
||||
<td><strong>${sw.소프트웨어명 || sw.제품명 || '-'}</strong></td>
|
||||
<td>${sw.부서 || '-'}</td>
|
||||
<td>${sw.수량 || '1'}</td>
|
||||
<td>${sw.구매일 || '-'}</td>
|
||||
<td>${sw.만료일 || '-'}</td>
|
||||
<td>${sw.금액 || '-'}</td>
|
||||
<td><small>${sw.비고 || ''}</small></td>
|
||||
<td><button class="btn btn-sm btn-outline btn-detail" data-id="${sw.id}" data-type="${sw.type}">상세</button></td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
tableWrapper.appendChild(table);
|
||||
container.appendChild(tableWrapper);
|
||||
const tbody = table.querySelector('tbody')!;
|
||||
|
||||
const updateTable = () => {
|
||||
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
|
||||
const fieldSelect = document.getElementById('filter-field') as HTMLSelectElement;
|
||||
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
|
||||
|
||||
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
||||
const field = fieldSelect ? fieldSelect.value : '';
|
||||
const corp = corpSelect ? corpSelect.value : '';
|
||||
|
||||
const filtered = fullList.filter(asset => {
|
||||
const matchKeyword = !keyword || (asset.제품명 || '').toLowerCase().includes(keyword) || (asset.부서 || '').toLowerCase().includes(keyword);
|
||||
const matchField = !field || asset.분야 === field;
|
||||
const matchCorp = !corp || asset.법인 === corp;
|
||||
return matchKeyword && matchField && matchCorp;
|
||||
});
|
||||
|
||||
tbody.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="${isSub ? 12 : 11}" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach((asset, idx) => {
|
||||
const assigned = state.masterData.swUsers.filter(u => u.sw_id === asset.id).length;
|
||||
const qty = typeof asset.수량 === 'number' ? asset.수량 : parseInt(asset.수량||'0', 10);
|
||||
const avail = qty - assigned;
|
||||
|
||||
let statusHtml = '';
|
||||
if (isSub) {
|
||||
let isExpired = false;
|
||||
if (asset.구독일) {
|
||||
const parts = asset.구독일.split('~');
|
||||
const endDateStr = parts[parts.length - 1].trim().replace(/\./g, '-');
|
||||
const endDate = new Date(endDateStr);
|
||||
if (!isNaN(endDate.getTime())) {
|
||||
endDate.setHours(23, 59, 59, 999);
|
||||
if (endDate < new Date()) isExpired = true;
|
||||
}
|
||||
}
|
||||
if (isExpired) statusHtml = `<span style="background: var(--danger, #ef4444); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">만료</span>`;
|
||||
else statusHtml = `<span style="background: var(--primary-color, #1E5149); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">사용중</span>`;
|
||||
} else {
|
||||
if (asset.유지보수여부) statusHtml = `<span style="background: #3b82f6; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">유효</span>`;
|
||||
else statusHtml = `<span style="background: #6b7280; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; white-space: nowrap;">없음</span>`;
|
||||
}
|
||||
|
||||
const tr = document.createElement('tr');
|
||||
tr.style.cursor = 'pointer';
|
||||
|
||||
tr.innerHTML = `
|
||||
<td style="text-align:center;">${idx+1}</td>
|
||||
<td style="text-align:center;">${statusHtml}</td>
|
||||
<td>${asset.분야||''}</td>
|
||||
<td>${asset.법인}</td>
|
||||
<td>${asset.부서||''}</td>
|
||||
<td>${asset.제품명}</td>
|
||||
<td style="text-align:center;">${asset.구매일||''}</td>
|
||||
${isSub ? `<td style="text-align:center;">${asset.구독일||''}</td>` : ''}
|
||||
<td style="text-align:right;">${asset.금액||'0'}</td>
|
||||
<td style="text-align:center;">${qty}</td>
|
||||
<td style="text-align:center;"><strong style="color: ${avail > 0 ? 'var(--primary-color)' : 'var(--danger)'}">${avail}</strong></td>
|
||||
<td style="display:flex; justify-content:center; align-items:center; gap:0.5rem;">
|
||||
<button type="button" class="btn-icon btn-edit" title="수정" style="color: var(--text-muted);"><i data-lucide="edit-2"></i></button>
|
||||
<button type="button" class="btn-icon btn-users" title="사용자 관리" style="color: var(--primary-color);"><i data-lucide="users"></i></button>
|
||||
</td>
|
||||
`;
|
||||
|
||||
tr.addEventListener('click', (e) => {
|
||||
if (!(e.target as HTMLElement).closest('button')) {
|
||||
openSwModal(asset, 'view');
|
||||
}
|
||||
});
|
||||
tr.querySelector('.btn-edit')?.addEventListener('click', (e) => {
|
||||
container.querySelectorAll('.asset-row, .btn-detail').forEach(el => {
|
||||
el.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
openSwModal(asset, 'edit');
|
||||
const id = (el as HTMLElement).getAttribute('data-id');
|
||||
const type = (el as HTMLElement).getAttribute('data-type');
|
||||
const asset = [...state.masterData.subSw, ...state.masterData.permSw].find(a => a.id === id);
|
||||
if (asset) openSwModal(asset);
|
||||
});
|
||||
tr.querySelector('.btn-users')?.addEventListener('click', (e) => { e.stopPropagation(); openSwUserModal(asset); });
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
createIcons({ icons: { Edit2, Users, RefreshCcw } });
|
||||
|
||||
document.getElementById('btn-add-sw')?.addEventListener('click', () => {
|
||||
const newSw: any = {
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
type: '구독SW',
|
||||
수량: 1,
|
||||
부서: '전산팀'
|
||||
};
|
||||
|
||||
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
|
||||
document.getElementById('filter-field')?.addEventListener('change', updateTable);
|
||||
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
|
||||
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
|
||||
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
|
||||
(document.getElementById('filter-field') as HTMLSelectElement).value = '';
|
||||
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
|
||||
updateTable();
|
||||
openSwModal(newSw);
|
||||
});
|
||||
|
||||
updateTable();
|
||||
}
|
||||
|
||||
@@ -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
47
start_server.ps1
Normal 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..."
|
||||
@@ -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
BIN
temp_sw.txt
Normal file
Binary file not shown.
Reference in New Issue
Block a user