feat: 하드웨어 자동 변경 이력 생성 및 자산 관리 프로세스 고도화

This commit is contained in:
2026-04-22 17:15:58 +09:00
parent af37df7f2d
commit e1cdcfd93a
18 changed files with 730 additions and 1200 deletions

49
db_fix_data.js Normal file
View 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);
});

View File

@@ -32,7 +32,7 @@ async function initDB() {
id VARCHAR(50) PRIMARY KEY, id VARCHAR(50) PRIMARY KEY,
corp VARCHAR(100) COMMENT '구매법인', corp VARCHAR(100) COMMENT '구매법인',
asset_code VARCHAR(100) COMMENT '자산번호', asset_code VARCHAR(100) COMMENT '자산번호',
purchase_date VARCHAR(50) COMMENT '구매일자', purchase_date VARCHAR(50) COMMENT '구매연월',
type VARCHAR(50) COMMENT '유형', type VARCHAR(50) COMMENT '유형',
detail_purpose VARCHAR(50) COMMENT '상세용도', detail_purpose VARCHAR(50) COMMENT '상세용도',
purpose VARCHAR(255) COMMENT '용도', purpose VARCHAR(255) COMMENT '용도',
@@ -57,6 +57,8 @@ async function initDB() {
monitoring VARCHAR(100), monitoring VARCHAR(100),
price VARCHAR(100) COMMENT '금액', price VARCHAR(100) COMMENT '금액',
remarks TEXT, remarks TEXT,
storage_location VARCHAR(255) COMMENT '보관위치',
status VARCHAR(50) COMMENT '현재상태',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='${comment}'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='${comment}';
`; `;
@@ -77,7 +79,7 @@ async function initDB() {
license_type VARCHAR(100) COMMENT '라이선스 유형', license_type VARCHAR(100) COMMENT '라이선스 유형',
quantity INT COMMENT '수량', quantity INT COMMENT '수량',
price VARCHAR(100) COMMENT '금액', price VARCHAR(100) COMMENT '금액',
purchase_date VARCHAR(50) COMMENT '구매', purchase_date VARCHAR(50) COMMENT '구매연월',
expiry_date VARCHAR(50) COMMENT '만료일', expiry_date VARCHAR(50) COMMENT '만료일',
vendor VARCHAR(255) COMMENT '납품업체', vendor VARCHAR(255) COMMENT '납품업체',
remarks TEXT COMMENT '비고', remarks TEXT COMMENT '비고',
@@ -95,7 +97,7 @@ async function initDB() {
license_key VARCHAR(255) COMMENT '라이선스 키', license_key VARCHAR(255) COMMENT '라이선스 키',
quantity INT COMMENT '수량', quantity INT COMMENT '수량',
price VARCHAR(100) COMMENT '금액', price VARCHAR(100) COMMENT '금액',
purchase_date VARCHAR(50) COMMENT '구매', purchase_date VARCHAR(50) COMMENT '구매연월',
vendor VARCHAR(255) COMMENT '납품업체', vendor VARCHAR(255) COMMENT '납품업체',
remarks TEXT COMMENT '비고', remarks TEXT COMMENT '비고',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

View File

@@ -90,22 +90,48 @@ const hardwareInsertSQL = (table) => `
`; `;
const getHardwareValues = (a) => [ const getHardwareValues = (a) => [
a.id, a.법인||'', a.자산코드||'', a.구매||'', a.type||'', a.상세용도||'', a.용도||'', a.상세||'', a.id, a.법인||'', a.자산코드||'', a.구매연월||'', a.type||'', a.상세용도||'', a.용도||'', a.상세||'',
a.현사용조직||'', a.이전사용조직||'', a.위치||'', a.담당자_정||'', a.담당자_부||'', a.IP주소||'', a.현사용조직||'', a.이전사용조직||'', a.위치||'', a.담당자_정||'', a.담당자_부||'', a.IP주소||'',
a.원격접속||'', a.서버ID||'', a.서버PW||'', a.모델명||'', a.OS||'', a.CPU||'', a.RAM||'', a.GPU||'', a.원격접속||'', a.서버ID||'', a.서버PW||'', a.모델명||'', a.OS||'', a.CPU||'', a.RAM||'', a.GPU||'',
a.SSD1||'', a.SSD2||'', a.HDD1||'', a.모니터링||'', a.금액||'', a.비고||'', a.SSD1||'', a.SSD2||'', a.HDD1||'', a.모니터링||'', a.금액||'', a.비고||'',
a.보관위치||'', a.현재상태||'' a.보관위치||'', a.현재상태||''
]; ];
const mapHardware = (r, defaultType) => ({ const mapHardware = (r, defaultType) => {
id: r.id, 법인: r.corp, 자산코드: r.asset_code, 구매일: r.purchase_date, type: r.type || defaultType, const type = r.type || defaultType;
상세용도: r.detail_purpose, 용도: r.purpose, 상세: r.details, 현사용조직: r.current_org, return {
이전사용조직: r.prev_org, 위치: r.location, 담당자_정: r.manager_main, 담당자_부: r.manager_sub, id: r.id,
IP주소: r.ip_address, 원격접속: r.remote_tool, 서버ID: r.server_id, 서버PW: r.server_pw, 법인: r.corp,
모델명: r.model_name, OS: r.os, CPU: r.cpu, RAM: r.ram, GPU: r.gpu, SSD1: r.storage1, 자산코드: r.asset_code,
SSD2: r.storage2, HDD1: r.storage3, 모니터링: r.monitoring, 금액: r.price, 비고: r.remarks, 구매연월: r.purchase_date,
보관위치: r.storage_location, 현재상태: r.status type: type,
}); 상세용도: (type !== '개인PC' && !r.detail_purpose) ? type : r.detail_purpose,
용도: r.purpose,
상세: r.details,
현사용조직: r.current_org,
이전사용조직: r.prev_org,
위치: r.location,
담당자_정: r.manager_main,
담당자_부: r.manager_sub,
IP주소: r.ip_address,
원격접속: r.remote_tool,
서버ID: r.server_id,
서버PW: r.server_pw,
모델명: r.model_name,
OS: r.os,
CPU: r.cpu,
RAM: r.ram,
GPU: r.gpu,
SSD1: r.storage1,
SSD2: r.storage2,
HDD1: r.storage3,
모니터링: r.monitoring,
금액: r.price,
비고: r.remarks,
보관위치: r.storage_location,
현재상태: r.status
};
};
// --- API 라우트 정의 --- // --- API 라우트 정의 ---

View File

@@ -49,7 +49,7 @@ export function openDashboardDetail(title: string, list: HardwareAsset[]) {
if (!thead) return; if (!thead) return;
titleEl.textContent = title; 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 = ''; tbody.innerHTML = '';
if (list.length === 0) { if (list.length === 0) {
tbody.innerHTML = `<tr><td colspan="8" style="text-align:center; padding: 2rem;">해당 조건의 자산이 없습니다.</td></tr>`; tbody.innerHTML = `<tr><td colspan="8" style="text-align:center; padding: 2rem;">해당 조건의 자산이 없습니다.</td></tr>`;

View File

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

View File

@@ -103,13 +103,15 @@ export function setEditLock(
options: { options: {
saveBtnId: string, saveBtnId: string,
revertBtnId: string, revertBtnId: string,
generateBtnId?: string generateBtnId?: string,
addLogBtnId?: string
} }
) { ) {
const form = document.getElementById(formId) as HTMLFormElement; const form = document.getElementById(formId) as HTMLFormElement;
const saveBtn = document.getElementById(options.saveBtnId); const saveBtn = document.getElementById(options.saveBtnId);
const revertBtn = document.getElementById(options.revertBtnId); const revertBtn = document.getElementById(options.revertBtnId);
const generateBtn = options.generateBtnId ? document.getElementById(options.generateBtnId) : null; const generateBtn = options.generateBtnId ? document.getElementById(options.generateBtnId) : null;
const addLogBtn = options.addLogBtnId ? document.getElementById(options.addLogBtnId) : null;
if (!form || !saveBtn || !revertBtn) return; if (!form || !saveBtn || !revertBtn) return;
@@ -118,10 +120,14 @@ export function setEditLock(
form.classList.remove('is-view-mode'); form.classList.remove('is-view-mode');
form.classList.add('is-edit-mode'); form.classList.add('is-edit-mode');
saveBtn.textContent = '저장'; saveBtn.textContent = '저장';
revertBtn.classList.toggle('hidden', mode === 'add'); // 신규 추가 시에는 취소 버튼 숨김 (닫기가 대신함) revertBtn.classList.toggle('hidden', mode === 'add'); // 신규 추가 시에는 취소 버튼 숨김
// 번호 생성 버튼은 '추가' 시에만 노출 // 번호 생성 버튼은 '추가(add)' 시에만 노출
if (generateBtn) generateBtn.classList.toggle('hidden', mode !== 'add'); if (generateBtn) {
generateBtn.style.display = mode === 'add' ? 'flex' : 'none';
}
// 내역 추가 버튼 노출
if (addLogBtn) addLogBtn.style.display = 'flex';
} else { } else {
// 조회 모드 (잠금) // 조회 모드 (잠금)
form.classList.remove('is-edit-mode'); form.classList.remove('is-edit-mode');
@@ -129,7 +135,79 @@ export function setEditLock(
saveBtn.textContent = '수정'; saveBtn.textContent = '수정';
revertBtn.classList.add('hidden'); revertBtn.classList.add('hidden');
// 조회 모드에서는 번호 생성 버튼 무조건 숨김 // 조회 모드에서는 버튼들 숨김
if (generateBtn) generateBtn.classList.add('hidden'); if (generateBtn) generateBtn.style.display = 'none';
if (addLogBtn) addLogBtn.style.display = 'none';
} }
} }
/**
* 8. 공통 모달 프레임 템플릿 생성
* @param idPrefix 필드 ID의 접두사 (예: 'hw', 'sw', 'pc')
* @param title 모달 제목
* @param formContent 각 모달마다 다른 폼 본문 HTML
* @param options 설정 (이력 영역 제목 등)
*/
export function createModalFrameHTML(
idPrefix: string,
title: string,
formContent: string,
options: { historyTitle: string, addLogBtnId: string }
): string {
return `
<div id="${idPrefix}-asset-modal" class="modal-overlay hidden">
<div class="modal-content wide">
<div class="modal-header">
<h2 id="${idPrefix}-modal-title">${title}</h2>
<button id="btn-close-${idPrefix}-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="${idPrefix}-asset-form" class="grid-form">
<input type="hidden" id="${idPrefix}-asset-id" />
<input type="hidden" id="${idPrefix}-asset-type" />
${formContent}
</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}" class="btn btn-outline btn-sm">
내역 추가 <i data-lucide="plus" style="width:14px; height:14px;"></i>
</button>
</div>
<div id="${idPrefix}-history-list" class="history-timeline"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button id="btn-delete-${idPrefix}-asset" class="btn btn-outline btn-danger">삭제</button>
<div class="footer-actions">
<button id="btn-revert-${idPrefix}-edit" class="btn btn-outline hidden">수정 취소</button>
<button id="btn-cancel-${idPrefix}-modal" class="btn btn-outline">닫기</button>
<button id="btn-save-${idPrefix}-asset" class="btn btn-primary">수정</button>
</div>
</div>
</div>
</div>
`;
}
/**
* 9. 데이터 ↔ 폼 자동 매핑 (유지보수 핵심)
*/
export function autoFillForm(idPrefix: string, data: any, fieldMap: Record<string, string>) {
Object.entries(fieldMap).forEach(([fieldId, dataKey]) => {
setFieldValue(`${idPrefix}-${fieldId}`, data[dataKey]);
});
}
export function autoExtractForm(idPrefix: string, fieldMap: Record<string, string>): any {
const result: any = {};
Object.entries(fieldMap).forEach(([fieldId, dataKey]) => {
result[dataKey] = getFieldValue(`${idPrefix}-${fieldId}`);
});
return result;
}

View File

@@ -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('');
}

View File

@@ -1,184 +1,120 @@
import { state } from '../../core/state'; import { state } from '../../core/state';
import { SoftwareAsset } from '../../core/excelHandler'; import { SoftwareAsset } from '../../core/excelHandler';
import { openModal, closeModals } from './BaseModal'; import { closeModals } from './BaseModal';
import { openSwUserModal } from './SWUserModal'; import { openSwUserModal } from './SWUserModal';
import { createIcons, History, Plus, X, Save, Edit2, RotateCcw } from 'lucide'; import { createIcons, History, Plus, X, Save, Edit2, RotateCcw } from 'lucide';
import { CORP_LIST } from './SharedData'; import { CORP_LIST, TYPE_PREFIX_MAP } from './SharedData';
import { import {
generateOptionsHTML, generateOptionsHTML,
setFieldValue, setFieldValue,
getFieldValue, getFieldValue,
setEditLock setEditLock,
createModalFrameHTML,
autoFillForm,
autoExtractForm
} from './ModalUtils'; } from './ModalUtils';
let currentSwAsset: SoftwareAsset | null = null; let currentSwAsset: SoftwareAsset | null = null;
let isEditMode = false; let isEditMode = false;
const SW_MODAL_HTML = ` const SW_FIELD_MAP: Record<string, string> = {
<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" /> '결제수단': '결제수단',
'연결카드번호': '연결카드번호',
'결제일': '결제일',
'당월청구액': '당월청구액',
'라이선스유형': '라이선스유형',
'만료일': '만료일',
'라이선스키': '라이선스키'
};
<!-- Group 1: 기본 정보 (Identity) --> const SW_FORM_HTML = `
<div class="form-section-title">기본 정보 (Identity)</div> <!-- Group 1: 기본 정보 -->
<div class="form-group"> <div class="form-section-title">기본 정보 (Identity)</div>
<label for="sw-법인">구매법인</label> <div class="form-group">
<select id="sw-법인" required>${generateOptionsHTML(CORP_LIST)}</select> <label for="sw-법인">구매법인</label>
</div> <select id="sw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
<div class="form-group sw-standard-field"> </div>
<label for="sw-자산번호">자산번호</label> <div class="form-group sw-standard-field">
<input type="text" id="sw-자산번호" readonly placeholder="자동 생성" /> <label for="sw-자산번호">자산번호</label>
</div> <div class="input-with-btn">
<div class="form-group full-width"> <input type="text" id="sw-자산번호" readonly class="is-readonly-field" placeholder="번호 생성을 클릭하세요" />
<label for="sw-제품명">제품명 / 서비스명</label> <button type="button" id="btn-generate-sw-code" class="btn btn-outline btn-sm">생성</button>
<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>
</select>
</div>
<div class="form-group cloud-only">
<label for="sw-연결카드번호">연결카드번호(뒷4자리)</label>
<input type="text" id="sw-연결카드번호" maxlength="4" />
</div>
<div class="form-group cloud-only">
<label for="sw-결제일">결제일 (기준일)</label>
<input type="number" id="sw-결제일" min="1" max="31" />
</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>
<!-- 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>
<div class="form-group sw-standard-field" id="sw-expiry-group">
<label for="sw-만료일">만료일 (구독)</label>
<input type="text" id="sw-만료일" />
</div>
<div class="form-group sw-standard-field">
<label for="sw-납품업체">납품업체</label>
<input type="text" id="sw-납품업체" />
</div>
<div class="form-group full-width">
<label for="sw-비고">비고</label>
<textarea id="sw-비고" rows="2"></textarea>
</div>
</form>
<div id="sw-user-section" class="user-management-section" style="margin-top: 2rem;">
<div class="section-header" style="display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem;">
<h3 style="font-size:1rem; font-weight:600;">사용자 할당 현황</h3>
<button type="button" id="btn-open-sw-update" class="btn btn-outline btn-sm">
할당 관리 <i data-lucide="plus" style="width:14px; height:14px;"></i>
</button>
</div>
<div id="sw-assigned-users-summary" class="user-summary-grid"></div>
</div>
</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> </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: 라이선스 및 계약 -->
<div id="sw-log-modal" class="modal-overlay hidden" style="z-index: 1100;"> <div class="form-section-title">라이선스 및 계약 정보</div>
<div class="modal-content" style="max-width: 400px;"> <div class="form-group sw-standard-field" id="sw-license-type-group"><label for="sw-라이선스유형">라이선스 유형</label><input type="text" id="sw-라이선스유형" /></div>
<div class="modal-header"> <div class="form-group sw-standard-field" id="sw-license-key-group"><label for="sw-라이선스키">라이선스 키</label><input type="text" id="sw-라이선스키" /></div>
<h2>업데이트 내역 추가</h2> <div class="form-group sw-standard-field"><label for="sw-수량">보유 수량</label><input type="number" id="sw-수량" min="0" /></div>
<button id="btn-close-sw-log" class="btn-icon"><i data-lucide="x"></i></button> <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>
</div>
<div class="modal-body"> <div class="form-group cloud-only"><label for="sw-계정명">계정명 (이메일)</label><input type="text" id="sw-계정명" /></div>
<div class="grid-form" style="grid-template-columns: 1fr;"> <div class="form-group cloud-only"><label for="sw-결제수단">결제수단</label><select id="sw-결제수단"><option value="">선택안함</option><option value="법인카드">법인카드</option><option value="인보이스">인보이스</option></select></div>
<div class="form-group"> <div class="form-group cloud-only"><label for="sw-연결카드번호">연결카드번호(뒷4자리)</label><input type="text" id="sw-연결카드번호" maxlength="4" /></div>
<label>날짜</label> <div class="form-group cloud-only"><label for="sw-결제일">결제일 (기준일)</label><input type="number" id="sw-결제일" min="1" max="31" /></div>
<input type="date" id="new-log-date" /> <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>
</div>
<div class="form-group"> <!-- Group 4: 관리 정보 -->
<label>상세 내용</label> <div class="form-section-title">관리 및 비고</div>
<textarea id="new-log-details" rows="3" placeholder="예: 결제 금액 변동, 담당자 변경 등"></textarea> <div class="form-group sw-standard-field"><label for="sw-구매일">구매연월</label><input type="text" id="sw-구매일" placeholder="YYYYMM" maxlength="6" /></div>
</div> <div class="form-group sw-standard-field" id="sw-expiry-group"><label for="sw-만료일">만료일 (구독)</label><input type="text" id="sw-만료일" /></div>
</div> <div class="form-group sw-standard-field"><label for="sw-납품업체">납품업체</label><input type="text" id="sw-납품업체" /></div>
</div> <div class="form-group full-width"><label for="sw-비고">비고</label><textarea id="sw-비고" rows="2"></textarea></div>
<div class="modal-footer">
<div></div> <div id="sw-user-section" class="user-management-section" style="margin-top: 2rem;">
<div class="footer-actions"> <div class="section-header" style="display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem;">
<button id="btn-cancel-sw-log" class="btn btn-outline">취소</button> <h3 style="font-size:1rem; font-weight:600;">사용자 할당 현황</h3>
<button id="btn-confirm-sw-log" class="btn btn-primary">추가</button> <button type="button" id="btn-open-sw-update" class="btn btn-outline btn-sm">할당 관리 <i data-lucide="plus" style="width:14px; height:14px;"></i></button>
</div>
</div>
</div> </div>
<div id="sw-assigned-users-summary" class="user-summary-grid"></div>
</div> </div>
`; `;
function renderSwHistory(swId: string) {
const container = document.getElementById('sw-history-list');
if (!container) return;
const logs = (state.masterData.logs || []).filter(l => l.assetId === swId).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('');
}
function renderUserSummary(swId: string) {
const container = document.getElementById('sw-assigned-users-summary');
if (!container) return;
const userMapping = state.masterData.swUsers.find(u => u.sw_id === swId);
if (!userMapping || !userMapping.userData || userMapping.userData.length === 0) {
container.innerHTML = '<div class="empty-summary">할당된 사용자가 없습니다.</div>';
return;
}
container.innerHTML = userMapping.userData.map(u => `
<div class="user-badge-item"><span class="u-name">${u[3] || '이름없음'}</span><span class="u-dept">${u[1] || '부서없음'}</span></div>
`).join('');
}
function applySwTypeUI(type: string) { function applySwTypeUI(type: string) {
const cloudFields = document.querySelectorAll('.cloud-only'); const cloudFields = document.querySelectorAll('.cloud-only');
const swFields = document.querySelectorAll('.sw-standard-field'); const swFields = document.querySelectorAll('.sw-standard-field');
@@ -195,7 +131,6 @@ function applySwTypeUI(type: string) {
cloudFields.forEach(el => (el as HTMLElement).style.display = 'none'); cloudFields.forEach(el => (el as HTMLElement).style.display = 'none');
swFields.forEach(el => (el as HTMLElement).style.display = 'flex'); swFields.forEach(el => (el as HTMLElement).style.display = 'flex');
if (userSection) userSection.style.display = 'block'; if (userSection) userSection.style.display = 'block';
if (type === '구독SW') { if (type === '구독SW') {
if (keyGroup) keyGroup.style.display = 'none'; if (keyGroup) keyGroup.style.display = 'none';
if (typeGroup) typeGroup.style.display = 'flex'; if (typeGroup) typeGroup.style.display = 'flex';
@@ -208,92 +143,41 @@ function applySwTypeUI(type: string) {
} }
} }
function fillSwFormData(asset: SoftwareAsset) {
setFieldValue('sw-asset-id', asset.id);
setFieldValue('sw-asset-type', asset.type);
setFieldValue('sw-법인', asset.);
setFieldValue('sw-자산번호', asset. || '');
setFieldValue('sw-제품명', asset.);
setFieldValue('sw-수량', asset.);
setFieldValue('sw-금액', asset.);
setFieldValue('sw-구매일', asset. || '');
setFieldValue('sw-납품업체', asset. || '');
setFieldValue('sw-비고', asset. || '');
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>';
return;
}
container.innerHTML = userMapping.userData.map(u => `
<div class="user-badge-item">
<span class="u-name">${u[3] || '이름없음'}</span>
<span class="u-dept">${u[1] || '부서없음'}</span>
</div>
`).join('');
}
function renderSwHistory(swId: string) {
const container = document.getElementById('sw-history-list');
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') { export function openSwModal(asset: SoftwareAsset, mode: 'view' | 'add' = 'view') {
currentSwAsset = asset; currentSwAsset = asset;
const modal = document.getElementById('sw-asset-modal')!; const modal = document.getElementById('sw-asset-modal')!;
// 수정 잠금 상태 제어
setEditLock('sw-asset-form', mode, { setEditLock('sw-asset-form', mode, {
saveBtnId: 'btn-save-sw-asset', saveBtnId: 'btn-save-sw-asset',
revertBtnId: 'btn-revert-sw-edit' revertBtnId: 'btn-revert-sw-edit',
generateBtnId: 'btn-generate-sw-code',
addLogBtnId: 'btn-add-sw-log'
}); });
isEditMode = (mode === 'add'); isEditMode = (mode === 'add');
autoFillForm('sw', asset, SW_FIELD_MAP);
fillSwFormData(asset);
applySwTypeUI(asset.type); applySwTypeUI(asset.type);
renderUserSummary(asset.id);
renderSwHistory(asset.id);
modal.classList.remove('hidden'); modal.classList.remove('hidden');
createIcons({ icons: { X, History, Plus } }); createIcons({ icons: { X, History, Plus } });
} }
export function initSwModal(onSave: () => void, closeModals: () => void) { export function initSwModal(onSave: () => void, closeModalsCb: () => void) {
if (!document.getElementById('sw-asset-modal')) { if (!document.getElementById('sw-asset-modal')) {
document.body.insertAdjacentHTML('beforeend', SW_MODAL_HTML); const html = createModalFrameHTML('sw', '소프트웨어 상세 정보', SW_FORM_HTML, {
historyTitle: '업데이트 내역',
addLogBtnId: 'btn-add-sw-log'
});
document.body.insertAdjacentHTML('beforeend', html);
const logModalHTML = `
<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"></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>
</div>
`;
document.body.insertAdjacentHTML('beforeend', logModalHTML);
} }
const form = document.getElementById('sw-asset-form') as HTMLFormElement; const form = document.getElementById('sw-asset-form') as HTMLFormElement;
@@ -302,123 +186,100 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
const deleteBtn = document.getElementById('btn-delete-sw-asset')!; const deleteBtn = document.getElementById('btn-delete-sw-asset')!;
const userUpdateBtn = document.getElementById('btn-open-sw-update')!; const userUpdateBtn = document.getElementById('btn-open-sw-update')!;
const logAddBtn = document.getElementById('btn-add-sw-log')!; const logAddBtn = document.getElementById('btn-add-sw-log')!;
const logModal = document.getElementById('sw-log-modal')!;
const closeModalAction = () => { closeModals(); isEditMode = false; }; const closeModalAction = () => { closeModalsCb(); isEditMode = false; };
document.getElementById('btn-close-sw-modal')?.addEventListener('click', closeModalAction); document.getElementById('btn-close-sw-modal')?.addEventListener('click', closeModalAction);
document.getElementById('btn-cancel-sw-modal')?.addEventListener('click', closeModalAction); document.getElementById('btn-cancel-sw-modal')?.addEventListener('click', closeModalAction);
revertBtn.addEventListener('click', () => { revertBtn.addEventListener('click', () => {
setEditLock('sw-asset-form', 'view', { setEditLock('sw-asset-form', 'view', {
saveBtnId: 'btn-save-sw-asset', saveBtnId: 'btn-save-sw-asset',
revertBtnId: 'btn-revert-sw-edit' revertBtnId: 'btn-revert-sw-edit',
generateBtnId: 'btn-generate-sw-code',
addLogBtnId: 'btn-add-sw-log'
}); });
isEditMode = false; isEditMode = false;
if (currentSwAsset) fillSwFormData(currentSwAsset); if (currentSwAsset) openSwModal(currentSwAsset, 'view');
});
document.getElementById('btn-generate-sw-code')?.addEventListener('click', async () => {
const typeValue = getFieldValue('sw-asset-type');
const purchaseDate = getFieldValue('sw-구매일');
const typeCode = TYPE_PREFIX_MAP[typeValue] || 'SW';
const dateStr = purchaseDate.replace(/[^0-9]/g, '');
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();
if (data.nextCode) setFieldValue('sw-자산번호', data.nextCode);
} catch (err) { alert('자산번호 생성에 실패했습니다.'); }
});
// YYYYMM 입력 제한 로직 (숫자 6자리)
document.getElementById('sw-구매일')?.addEventListener('input', (e) => {
const target = e.target as HTMLInputElement;
target.value = target.value.replace(/[^0-9]/g, '').substring(0, 6);
}); });
saveBtn.addEventListener('click', () => { saveBtn.addEventListener('click', () => {
if (!currentSwAsset) return; if (!currentSwAsset) return;
if (!isEditMode) { if (!isEditMode) {
setEditLock('sw-asset-form', 'edit', { setEditLock('sw-asset-form', 'edit', {
saveBtnId: 'btn-save-sw-asset', saveBtnId: 'btn-save-sw-asset',
revertBtnId: 'btn-revert-sw-edit' revertBtnId: 'btn-revert-sw-edit',
generateBtnId: 'btn-generate-sw-code',
addLogBtnId: 'btn-add-sw-log'
}); });
isEditMode = true; isEditMode = true;
return; return;
} }
const extracted = autoExtractForm('sw', SW_FIELD_MAP);
const updated = { ...currentSwAsset, ...extracted, 수량: parseInt(extracted. || '0') };
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[] = []; let targetList: SoftwareAsset[] = [];
if (type === '구독SW') targetList = state.masterData.subSw; if (updated.type === '구독SW') targetList = state.masterData.subSw;
else if (type === '영구SW') targetList = state.masterData.permSw; else if (updated.type === '영구SW') targetList = state.masterData.permSw;
else if (type === '클라우드') targetList = state.masterData.cloud; else targetList = (state.masterData as any).cloud || [];
const idx = targetList.findIndex(a => a.id === updated.id); const idx = targetList.findIndex(a => a.id === updated.id);
if (idx > -1) targetList[idx] = updated; if (idx > -1) targetList[idx] = updated; else targetList.push(updated);
else targetList.push(updated);
onSave(); onSave();
setEditLock('sw-asset-form', 'view', { setEditLock('sw-asset-form', 'view', {
saveBtnId: 'btn-save-sw-asset', saveBtnId: 'btn-save-sw-asset',
revertBtnId: 'btn-revert-sw-edit' revertBtnId: 'btn-revert-sw-edit',
generateBtnId: 'btn-generate-sw-code',
addLogBtnId: 'btn-add-sw-log'
}); });
isEditMode = false; isEditMode = false;
}); });
deleteBtn.addEventListener('click', () => { deleteBtn.addEventListener('click', () => {
if (!currentSwAsset) return; if (currentSwAsset && confirm('삭제하시겠습니까?')) {
if (confirm('삭제하시겠습니까?')) {
const type = currentSwAsset.type; const type = currentSwAsset.type;
if (type === '구독SW') state.masterData.subSw = state.masterData.subSw.filter(a => a.id !== currentSwAsset!.id); 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 === '영구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); onSave(); closeModalAction();
onSave();
closeModalAction();
} }
}); });
userUpdateBtn.addEventListener('click', () => { userUpdateBtn.addEventListener('click', () => { if (currentSwAsset) openSwUserModal(currentSwAsset); });
if (currentSwAsset) openSwUserModal(currentSwAsset);
});
// 이력 추가 모달 로직
const logModal = document.getElementById('sw-log-modal')!;
logAddBtn.addEventListener('click', () => { logAddBtn.addEventListener('click', () => {
logModal.classList.remove('hidden'); logModal.classList.remove('hidden');
(document.getElementById('new-log-date') as HTMLInputElement).value = new Date().toISOString().split('T')[0]; (document.getElementById('new-log-date') as HTMLInputElement).value = new Date().toISOString().split('T')[0];
(document.getElementById('new-log-details') as HTMLTextAreaElement).value = ''; (document.getElementById('new-log-details') as HTMLTextAreaElement).value = '';
}); });
document.getElementById('btn-close-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden')); 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-cancel-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
document.getElementById('btn-confirm-sw-log')?.addEventListener('click', () => { document.getElementById('btn-confirm-sw-log')?.addEventListener('click', () => {
if (!currentSwAsset) return; if (!currentSwAsset) return;
const date = (document.getElementById('new-log-date') as HTMLInputElement).value; const date = (document.getElementById('new-log-date') as HTMLInputElement).value;
const details = (document.getElementById('new-log-details') as HTMLTextAreaElement).value; const details = (document.getElementById('new-log-details') as HTMLTextAreaElement).value;
if (!date || !details) return;
if (!date || !details) { alert('날짜와 내용을 입력해주세요.'); return; }
state.masterData.logs = state.masterData.logs || []; state.masterData.logs = state.masterData.logs || [];
state.masterData.logs.push({ state.masterData.logs.push({ id: Math.random().toString(36).substring(2, 9), assetId: currentSwAsset.id, date, user: '관리자', details });
id: Math.random().toString(36).substring(2, 9), logModal.classList.add('hidden'); renderSwHistory(currentSwAsset.id);
assetId: currentSwAsset.id,
date,
user: '관리자',
details
});
logModal.classList.add('hidden');
renderSwHistory(currentSwAsset.id);
}); });
} }

View File

@@ -29,5 +29,6 @@ export const TYPE_PREFIX_MAP: Record<string, string> = {
'서버': 'SVR', 'PC': 'PC', 'NAS': 'NAS', 'DAS': 'DAS', '스토리지': 'STO', '서버': 'SVR', 'PC': 'PC', 'NAS': 'NAS', 'DAS': 'DAS', '스토리지': 'STO',
'CPU': 'CPU', 'HDD': 'HDD', 'RAM': 'RAM', 'GPU': 'GPU', 'CPU': 'CPU', 'HDD': 'HDD', 'RAM': 'RAM', 'GPU': 'GPU',
'모바일': 'MOB', '노트북': 'PC', '태블릿': 'TAB', '모바일': 'MOB', '노트북': 'PC', '태블릿': 'TAB',
'개인PC': 'PC', '모바일기기': 'MOB' '개인PC': 'PC', '모바일기기': 'MOB',
'구독SW': 'SSW', '영구SW': 'PSW'
}; };

View File

@@ -27,7 +27,7 @@ export interface HardwareAsset {
용량?: string; 용량?: string;
담당자_정?: string; 담당자_정?: string;
담당자_부?: string; 담당자_부?: string;
구매?: string; 구매연월?: string;
금액?: string; 금액?: string;
납품업체: string; 납품업체: string;
품의서명: string; 품의서명: string;
@@ -51,7 +51,7 @@ export interface SoftwareAsset {
법인: string; 법인: string;
부서?: string; 부서?: string;
제품명: string; 제품명: string;
구매: string; 구매연월: string;
구독일?: string; 구독일?: string;
만료일?: string; 만료일?: string;
라이선스유형?: string; 라이선스유형?: string;
@@ -105,14 +105,14 @@ export interface MasterAssetData {
const HW_TABS = ['개인PC', '서버', '스토리지', '전산비품', '모바일기기']; const HW_TABS = ['개인PC', '서버', '스토리지', '전산비품', '모바일기기'];
const SW_TABS = ['구독SW', '영구SW', '클라우드']; const SW_TABS = ['구독SW', '영구SW', '클라우드'];
const PC_HEADERS = ['법인', '자산코드', '사용자', '위치', 'CPU', 'GPU', 'RAM', 'SSD1', 'SSD2', 'HDD1', 'HDD2', 'IP주소', 'HW사양', '구매', '금액', '납품업체', '품의서명', '비고']; const PC_HEADERS = ['법인', '자산코드', '사용자', '위치', 'CPU', 'GPU', 'RAM', 'SSD1', 'SSD2', 'HDD1', 'HDD2', 'IP주소', 'HW사양', '구매연월', '금액', '납품업체', '품의서명', '비고'];
const SERVER_HEADERS = ['구매법인', '자산번호', '구매일자', '유형', '용도', '상세내용', '현사용조직', '이전사용조직', '설치위치', '담당자(정)', '담당자(부)', 'IP 주소 1', 'IP 주소 2', '원격도구', '서버 ID', '서버 PW', '모델명', 'OS', 'CPU', 'RAM', 'GPU', 'Storage 1', 'Storage 2', 'Storage 3', '모니터링', '비고']; const SERVER_HEADERS = ['구매법인', '자산번호', '구매연월', '유형', '용도', '상세내용', '현사용조직', '이전사용조직', '설치위치', '담당자(정)', '담당자(부)', 'IP 주소 1', 'IP 주소 2', '원격도구', '서버 ID', '서버 PW', '모델명', 'OS', 'CPU', 'RAM', 'GPU', 'Storage 1', 'Storage 2', 'Storage 3', '모니터링', '비고'];
const STORAGE_HEADERS = ['구매법인', '유형', '자산코드', '명칭', '위치', '모델명', '용량', '담당자(정)', '담당자(부)', 'IP주소', 'MAC주소', '구매', '금액', '납품업체', '품의서명', '비고']; const STORAGE_HEADERS = ['구매법인', '유형', '자산코드', '명칭', '위치', '모델명', '용량', '담당자(정)', '담당자(부)', 'IP주소', 'MAC주소', '구매연월', '금액', '납품업체', '품의서명', '비고'];
const EQUIP_HEADERS = ['구매법인', '비품유형', '자산코드', '명칭', '위치', '관리자', 'IP주소', 'MACaddress', 'HW사양', 'OS', '구매', '금액', '납품업체', '품의서명', '비고']; const EQUIP_HEADERS = ['구매법인', '비품유형', '자산코드', '명칭', '위치', '관리자', 'IP주소', 'MACaddress', 'HW사양', 'OS', '구매연월', '금액', '납품업체', '품의서명', '비고'];
const MOBILE_HEADERS = ['구매법인', '자산코드', '명칭', '위치', '관리자', '기기유형', 'OS', '구매', '금액', '납품업체', '품의서명', '비고']; const MOBILE_HEADERS = ['구매법인', '자산코드', '명칭', '위치', '관리자', '기기유형', 'OS', '구매연월', '금액', '납품업체', '품의서명', '비고'];
const SUB_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매', '만료일', '라이선스유형', '금액', '수량', '계정명', '납품업체', '비고']; const SUB_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매연월', '만료일', '라이선스유형', '금액', '수량', '계정명', '납품업체', '비고'];
const PERM_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매', '라이선스키', '금액', '수량', '계정명', '납품업체', '비고']; const PERM_SW_HEADERS = ['ID', '분야', '법인', '부서', '제품명', '구매연월', '라이선스키', '금액', '수량', '계정명', '납품업체', '비고'];
const CLOUD_HEADERS = ['ID', '플랫폼명', '법인', '부서', '사용용도(제품명)', '계정명', '결제수단', '결제일', '연결카드번호', '당월청구액', '비고']; const CLOUD_HEADERS = ['ID', '플랫폼명', '법인', '부서', '사용용도(제품명)', '계정명', '결제수단', '결제일', '연결카드번호', '당월청구액', '비고'];
export function downloadTemplate() { export function downloadTemplate() {
@@ -144,13 +144,13 @@ export function downloadTemplate() {
export function exportToExcel(masterData: MasterAssetData) { export function exportToExcel(masterData: MasterAssetData) {
const wb = XLSX.utils.book_new(); const wb = XLSX.utils.book_new();
const exportMap = [ const exportMap = [
{ tab: '개인PC', list: masterData.pc, headers: PC_HEADERS, map: (a: any) => [a., a., a., a., a.CPU, a.GPU, a.RAM, a.SSD1, a.SSD2, a.HDD1, a.HDD2, a.IP주소, a.HW사양, a., a., a., a., a.] }, { tab: '개인PC', list: masterData.pc, headers: PC_HEADERS, map: (a: any) => [a., a., a., a., a.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.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.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.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: '모바일기기', 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.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: '영구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 => { exportMap.forEach(m => {
@@ -170,19 +170,19 @@ export async function parseExcel(file: File): Promise<MasterAssetData> {
workbook.SheetNames.forEach(sheetName => { workbook.SheetNames.forEach(sheetName => {
const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]) as any[]; const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]) as any[];
if (sheetName === '개인PC') { 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 === '서버') { } 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 === '스토리지') { } 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 === '전산비품') { } 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 === '모바일기기') { } 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') { } 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') { } 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); resolve(data);

View File

@@ -4,7 +4,6 @@ import { renderDashboard } from './views/DashboardView';
import { renderSWTable } from './views/SW_Table'; import { renderSWTable } from './views/SW_Table';
import { downloadTemplate, exportToExcel, parseExcel, HardwareAsset, SoftwareAsset, SWUser } from './core/excelHandler'; import { downloadTemplate, exportToExcel, parseExcel, HardwareAsset, SoftwareAsset, SWUser } from './core/excelHandler';
import { initBaseModal } from './components/Modal/BaseModal'; import { initBaseModal } from './components/Modal/BaseModal';
import { initPcModal } from './components/Modal/PCModal';
import { initHwModal, openHwModal } from './components/Modal/HWModal'; import { initHwModal, openHwModal } from './components/Modal/HWModal';
import { initSwModal, openSwModal } from './components/Modal/SWModal'; import { initSwModal, openSwModal } from './components/Modal/SWModal';
import { initSwUserModal } from './components/Modal/SWUserModal'; import { initSwUserModal } from './components/Modal/SWUserModal';
@@ -75,7 +74,6 @@ function initApp() {
}); });
// 모달 초기화 // 모달 초기화
initPcModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
initHwModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals); initHwModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
initSwModal(() => { initSwModal(() => {
@@ -125,8 +123,14 @@ function initApp() {
const cat = state.activeCategory; const cat = state.activeCategory;
if (cat === 'hw') { 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({ openHwModal({
id: Math.random().toString(36).substring(2, 9), id: Math.random().toString(36).substring(2, 9),
type: defaultType, type: defaultType,

View File

@@ -167,6 +167,10 @@
background-color: var(--white); background-color: var(--white);
} }
.form-group textarea {
resize: none;
}
.form-group input:focus, .form-group input:focus,
.form-group select:focus, .form-group select:focus,
.form-group textarea:focus { .form-group textarea:focus {
@@ -213,6 +217,9 @@
} }
.history-header { .history-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
@@ -225,6 +232,35 @@
color: var(--text-main); 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 { .history-timeline {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;

View File

@@ -105,7 +105,7 @@ export function renderHwDashboard(container: HTMLElement) {
<th>유형</th> <th>유형</th>
<th>모델명</th> <th>모델명</th>
<th>사용자/담당자</th> <th>사용자/담당자</th>
<th>구매</th> <th>구매연월</th>
<th>연령</th> <th>연령</th>
</tr> </tr>
</thead> </thead>

View File

@@ -22,6 +22,9 @@ export function renderEquipmentList(container: HTMLElement) {
<button id="btn-reset-filters" class="btn btn-outline btn-reset"> <button id="btn-reset-filters" class="btn btn-outline btn-reset">
<i data-lucide="refresh-ccw"></i> 필터 초기화 <i data-lucide="refresh-ccw"></i> 필터 초기화
</button> </button>
<button id="btn-add-equip" class="btn btn-primary" style="margin-left: auto;">
<i data-lucide="plus"></i> 자산 추가
</button>
`; `;
container.appendChild(filterBar); container.appendChild(filterBar);
@@ -39,7 +42,7 @@ export function renderEquipmentList(container: HTMLElement) {
<th style="text-align:center;">모델명</th> <th style="text-align:center;">모델명</th>
<th style="text-align:center;">보관위치</th> <th style="text-align:center;">보관위치</th>
<th style="text-align:center;">관리자</th> <th style="text-align:center;">관리자</th>
<th style="text-align:center;">구매</th> <th style="text-align:center;">구매연월</th>
<th style="text-align:center;">금액</th> <th style="text-align:center;">금액</th>
</tr> </tr>
</thead> </thead>

View File

@@ -22,6 +22,9 @@ export function renderMobileList(container: HTMLElement) {
<button id="btn-reset-filters" class="btn btn-outline btn-reset"> <button id="btn-reset-filters" class="btn btn-outline btn-reset">
<i data-lucide="refresh-ccw"></i> 필터 초기화 <i data-lucide="refresh-ccw"></i> 필터 초기화
</button> </button>
<button id="btn-add-mobile" class="btn btn-primary" style="margin-left: auto;">
<i data-lucide="plus"></i> 자산 추가
</button>
`; `;
container.appendChild(filterBar); container.appendChild(filterBar);
@@ -38,7 +41,7 @@ export function renderMobileList(container: HTMLElement) {
<th style="text-align:center;">명칭</th> <th style="text-align:center;">명칭</th>
<th style="text-align:center;">보관위치</th> <th style="text-align:center;">보관위치</th>
<th style="text-align:center;">관리자</th> <th style="text-align:center;">관리자</th>
<th style="text-align:center;">구매</th> <th style="text-align:center;">구매연월</th>
<th style="text-align:center;">금액</th> <th style="text-align:center;">금액</th>
</tr> </tr>
</thead> </thead>
@@ -106,7 +109,8 @@ export function renderMobileList(container: HTMLElement) {
(document.getElementById('filter-keyword') as HTMLInputElement).value = ''; (document.getElementById('filter-keyword') as HTMLInputElement).value = '';
(document.getElementById('filter-corp') as HTMLSelectElement).value = ''; (document.getElementById('filter-corp') as HTMLSelectElement).value = '';
updateTable(); updateTable();
}); });
updateTable();
}
updateTable();
}

View File

@@ -1,5 +1,5 @@
import { state } from '../../core/state'; import { state } from '../../core/state';
import { openPcModal } from '../../components/Modal/PCModal'; import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, sortAssets } from '../../core/utils'; import { formatInline, sortAssets } from '../../core/utils';
import { createIcons, Paperclip, RefreshCcw } from 'lucide'; import { createIcons, Paperclip, RefreshCcw } from 'lucide';
@@ -28,7 +28,7 @@ export function renderPcList(container: HTMLElement) {
const tableWrapper = document.createElement('div'); const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container'; tableWrapper.className = 'table-container';
const table = document.createElement('table'); 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>`; 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); tableWrapper.appendChild(table);
container.appendChild(tableWrapper); container.appendChild(tableWrapper);
@@ -69,12 +69,12 @@ export function renderPcList(container: HTMLElement) {
<td>${asset.CPU||''}</td> <td>${asset.CPU||''}</td>
<td>${asset.RAM||''}</td> <td>${asset.RAM||''}</td>
<td>${formatInline(storage)}</td> <td>${formatInline(storage)}</td>
<td>${asset.||''}</td> <td>${asset. || asset. || ''}</td>
<td>${asset.||''}</td> <td>${asset.||''}</td>
<td style="text-align:center;">${asset. ? '<i data-lucide="paperclip" class="text-primary"></i>' : '-'}</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> <td><button class="btn btn-outline btn-sm">수정</button></td>
`; `;
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openPcModal(asset, 'view'); }); tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr); tbody.appendChild(tr);
}); });
createIcons({ icons: { Paperclip } }); createIcons({ icons: { Paperclip } });

View File

@@ -102,7 +102,8 @@ export function renderServerList(container: HTMLElement) {
(document.getElementById('filter-corp') as HTMLSelectElement).value = ''; (document.getElementById('filter-corp') as HTMLSelectElement).value = '';
(document.getElementById('filter-org-unit') as HTMLSelectElement).value = ''; (document.getElementById('filter-org-unit') as HTMLSelectElement).value = '';
updateTable(); updateTable();
}); });
updateTable();
}
updateTable();
}

View File

@@ -49,7 +49,7 @@ export function renderSwList(container: HTMLElement) {
<th style="text-align:center;">구매법인</th> <th style="text-align:center;">구매법인</th>
<th style="text-align:center;">부서</th> <th style="text-align:center;">부서</th>
<th style="text-align:center;">제품명</th> <th style="text-align:center;">제품명</th>
<th style="text-align:center;">구매</th> <th style="text-align:center;">구매연월</th>
${isSub ? '<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>