feat: SW 통합 모달 구현 및 대시보드 자산 추가 기능 고도화
- SW 모달(구독, 영구, 클라우드) 통합 및 레이아웃 최적화 - 모든 자산 상세 모달에 '조회/수정 모드' 전환 로직(Edit Lock) 적용 - 하드웨어/소프트웨어 대시보드에서 '자산 추가' 버튼 연동 및 기본값 설정 - 클라우드 자산 리스트의 데이터 소스를 DB 직결(cloud_assets) 방식으로 변경 - 클라우드 자산 저장 API 연동 및 불필요한 구형 모달(CloudModal) 제거 - 리스트 뷰에서 상세 보기 시 '조회 모드'로 열리도록 호출 로직 수정
This commit is contained in:
@@ -2,9 +2,14 @@ import { state } from '../../core/state';
|
|||||||
import { SoftwareAsset } from '../../core/excelHandler';
|
import { SoftwareAsset } from '../../core/excelHandler';
|
||||||
import { openModal, closeModals } from './BaseModal';
|
import { openModal, closeModals } from './BaseModal';
|
||||||
import { openSwUserModal } from './SWUserModal';
|
import { openSwUserModal } from './SWUserModal';
|
||||||
import { createIcons, History, Plus, X } from 'lucide';
|
import { createIcons, History, Plus, X, Save, Edit2, RotateCcw } from 'lucide';
|
||||||
import { CORP_LIST } from './SharedData';
|
import { CORP_LIST } from './SharedData';
|
||||||
import { generateOptionsHTML, setFieldValue, getFieldValue } from './ModalUtils';
|
import {
|
||||||
|
generateOptionsHTML,
|
||||||
|
setFieldValue,
|
||||||
|
getFieldValue,
|
||||||
|
setEditLock
|
||||||
|
} from './ModalUtils';
|
||||||
|
|
||||||
let currentSwAsset: SoftwareAsset | null = null;
|
let currentSwAsset: SoftwareAsset | null = null;
|
||||||
let isEditMode = false;
|
let isEditMode = false;
|
||||||
@@ -14,7 +19,7 @@ const SW_MODAL_HTML = `
|
|||||||
<div class="modal-content wide">
|
<div class="modal-content wide">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h2 id="sw-modal-title">소프트웨어 상세 정보</h2>
|
<h2 id="sw-modal-title">소프트웨어 상세 정보</h2>
|
||||||
<button id="btn-close-sw-modal" class="btn-icon"><i data-lucide="x"></i></button>
|
<button id="btn-close-sw-modal" class="btn-icon" aria-label="닫기"><i data-lucide="x"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="modal-body-split">
|
<div class="modal-body-split">
|
||||||
@@ -23,48 +28,85 @@ const SW_MODAL_HTML = `
|
|||||||
<input type="hidden" id="sw-asset-id" />
|
<input type="hidden" id="sw-asset-id" />
|
||||||
<input type="hidden" id="sw-asset-type" />
|
<input type="hidden" id="sw-asset-type" />
|
||||||
|
|
||||||
<div class="form-section-title">기본 정보 (Basic Info)</div>
|
<!-- Group 1: 기본 정보 (Identity) -->
|
||||||
|
<div class="form-section-title">기본 정보 (Identity)</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="sw-법인">구매법인</label>
|
<label for="sw-법인">구매법인</label>
|
||||||
<select id="sw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
|
<select id="sw-법인" required>${generateOptionsHTML(CORP_LIST)}</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group sw-standard-field">
|
||||||
<label for="sw-자산번호">자산번호</label>
|
<label for="sw-자산번호">자산번호</label>
|
||||||
<input type="text" id="sw-자산번호" readonly placeholder="자동 생성" />
|
<input type="text" id="sw-자산번호" readonly placeholder="자동 생성" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group full-width">
|
<div class="form-group full-width">
|
||||||
<label for="sw-제품명">제품명</label>
|
<label for="sw-제품명">제품명 / 서비스명</label>
|
||||||
<input type="text" id="sw-제품명" required />
|
<input type="text" id="sw-제품명" required />
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<div class="form-section-title">라이선스 정보 (License)</div>
|
<!-- Group 2: 라이선스 및 계약 (License/Contract) -->
|
||||||
<div class="form-group" id="sw-license-type-group">
|
<div class="form-section-title">라이선스 및 계약 정보</div>
|
||||||
|
<div class="form-group sw-standard-field" id="sw-license-type-group">
|
||||||
<label for="sw-라이선스유형">라이선스 유형</label>
|
<label for="sw-라이선스유형">라이선스 유형</label>
|
||||||
<input type="text" id="sw-라이선스유형" />
|
<input type="text" id="sw-라이선스유형" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" id="sw-license-key-group">
|
<div class="form-group sw-standard-field" id="sw-license-key-group">
|
||||||
<label for="sw-라이선스키">라이선스 키</label>
|
<label for="sw-라이선스키">라이선스 키</label>
|
||||||
<input type="text" id="sw-라이선스키" />
|
<input type="text" id="sw-라이선스키" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group sw-standard-field">
|
||||||
<label for="sw-수량">보유 수량</label>
|
<label for="sw-수량">보유 수량</label>
|
||||||
<input type="number" id="sw-수량" min="0" />
|
<input type="number" id="sw-수량" min="0" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group sw-standard-field">
|
||||||
<label for="sw-금액">도입 금액</label>
|
<label for="sw-금액">도입 금액</label>
|
||||||
<input type="text" id="sw-금액" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')" />
|
<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-section-title">구매 및 계약 (Purchase)</div>
|
<!-- Group 3: 클라우드 전용 정보 (Cloud Specific) -->
|
||||||
<div class="form-group">
|
<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>
|
<label for="sw-구매일">구매일</label>
|
||||||
<input type="text" id="sw-구매일" />
|
<input type="text" id="sw-구매일" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" id="sw-expiry-group">
|
<div class="form-group sw-standard-field" id="sw-expiry-group">
|
||||||
<label for="sw-만료일">만료일 (구독)</label>
|
<label for="sw-만료일">만료일 (구독)</label>
|
||||||
<input type="text" id="sw-만료일" />
|
<input type="text" id="sw-만료일" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group sw-standard-field">
|
||||||
<label for="sw-납품업체">납품업체</label>
|
<label for="sw-납품업체">납품업체</label>
|
||||||
<input type="text" id="sw-납품업체" />
|
<input type="text" id="sw-납품업체" />
|
||||||
</div>
|
</div>
|
||||||
@@ -74,22 +116,23 @@ const SW_MODAL_HTML = `
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="user-management-section" style="margin-top: 2rem;">
|
<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;">
|
<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>
|
<h3 style="font-size:1rem; font-weight:600;">사용자 할당 현황</h3>
|
||||||
<button type="button" id="btn-open-sw-update" class="btn btn-outline btn-sm">
|
<button type="button" id="btn-open-sw-update" class="btn btn-outline btn-sm">
|
||||||
할당 관리 <i data-lucide="plus" style="width:14px; height:14px;"></i>
|
할당 관리 <i data-lucide="plus" style="width:14px; height:14px;"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="sw-assigned-users-summary" class="user-summary-grid">
|
<div id="sw-assigned-users-summary" class="user-summary-grid"></div>
|
||||||
<!-- User summary list -->
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-history-area">
|
<div class="modal-history-area">
|
||||||
<div class="history-header">
|
<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>
|
<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>
|
||||||
<div id="sw-history-list" class="history-timeline"></div>
|
<div id="sw-history-list" class="history-timeline"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -105,39 +148,95 @@ const SW_MODAL_HTML = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 클라우드 이력 추가를 위한 간이 모달 -->
|
||||||
|
<div id="sw-log-modal" class="modal-overlay hidden" style="z-index: 1100;">
|
||||||
|
<div class="modal-content" style="max-width: 400px;">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h2>업데이트 내역 추가</h2>
|
||||||
|
<button id="btn-close-sw-log" class="btn-icon"><i data-lucide="x"></i></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="grid-form" style="grid-template-columns: 1fr;">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>날짜</label>
|
||||||
|
<input type="date" id="new-log-date" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>상세 내용</label>
|
||||||
|
<textarea id="new-log-details" rows="3" placeholder="예: 결제 금액 변동, 담당자 변경 등"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div></div>
|
||||||
|
<div class="footer-actions">
|
||||||
|
<button id="btn-cancel-sw-log" class="btn btn-outline">취소</button>
|
||||||
|
<button id="btn-confirm-sw-log" class="btn btn-primary">추가</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function fillSwFormData(asset: SoftwareAsset) {
|
function applySwTypeUI(type: string) {
|
||||||
setFieldValue('sw-asset-id', asset.id);
|
const cloudFields = document.querySelectorAll('.cloud-only');
|
||||||
setFieldValue('sw-asset-type', asset.type);
|
const swFields = document.querySelectorAll('.sw-standard-field');
|
||||||
setFieldValue('sw-법인', asset.법인);
|
const userSection = document.getElementById('sw-user-section');
|
||||||
setFieldValue('sw-자산번호', asset.자산번호);
|
|
||||||
setFieldValue('sw-제품명', asset.제품명);
|
|
||||||
setFieldValue('sw-수량', asset.수량);
|
|
||||||
setFieldValue('sw-금액', asset.금액);
|
|
||||||
setFieldValue('sw-구매일', asset.구매일);
|
|
||||||
setFieldValue('sw-납품업체', asset.납품업체);
|
|
||||||
setFieldValue('sw-비고', asset.비고);
|
|
||||||
|
|
||||||
const type = asset.type;
|
|
||||||
const keyGroup = document.getElementById('sw-license-key-group');
|
const keyGroup = document.getElementById('sw-license-key-group');
|
||||||
const typeGroup = document.getElementById('sw-license-type-group');
|
const typeGroup = document.getElementById('sw-license-type-group');
|
||||||
const expiryGroup = document.getElementById('sw-expiry-group');
|
const expiryGroup = document.getElementById('sw-expiry-group');
|
||||||
|
|
||||||
|
if (type === '클라우드') {
|
||||||
|
cloudFields.forEach(el => (el as HTMLElement).style.display = 'flex');
|
||||||
|
swFields.forEach(el => (el as HTMLElement).style.display = 'none');
|
||||||
|
if (userSection) userSection.style.display = 'none';
|
||||||
|
} else {
|
||||||
|
cloudFields.forEach(el => (el as HTMLElement).style.display = 'none');
|
||||||
|
swFields.forEach(el => (el as HTMLElement).style.display = 'flex');
|
||||||
|
if (userSection) userSection.style.display = 'block';
|
||||||
|
|
||||||
if (type === '구독SW') {
|
if (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';
|
||||||
if (expiryGroup) expiryGroup.style.display = 'flex';
|
if (expiryGroup) expiryGroup.style.display = 'flex';
|
||||||
setFieldValue('sw-라이선스유형', (asset as any).라이선스유형 || '');
|
|
||||||
setFieldValue('sw-만료일', (asset as any).만료일 || '');
|
|
||||||
} else {
|
} else {
|
||||||
if (keyGroup) keyGroup.style.display = 'flex';
|
if (keyGroup) keyGroup.style.display = 'flex';
|
||||||
if (typeGroup) typeGroup.style.display = 'none';
|
if (typeGroup) typeGroup.style.display = 'none';
|
||||||
if (expiryGroup) expiryGroup.style.display = 'none';
|
if (expiryGroup) expiryGroup.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillSwFormData(asset: SoftwareAsset) {
|
||||||
|
setFieldValue('sw-asset-id', asset.id);
|
||||||
|
setFieldValue('sw-asset-type', asset.type);
|
||||||
|
setFieldValue('sw-법인', asset.법인);
|
||||||
|
setFieldValue('sw-자산번호', asset.자산번호 || '');
|
||||||
|
setFieldValue('sw-제품명', asset.제품명);
|
||||||
|
setFieldValue('sw-수량', asset.수량);
|
||||||
|
setFieldValue('sw-금액', asset.금액);
|
||||||
|
setFieldValue('sw-구매일', asset.구매일 || '');
|
||||||
|
setFieldValue('sw-납품업체', asset.납품업체 || '');
|
||||||
|
setFieldValue('sw-비고', asset.비고 || '');
|
||||||
|
|
||||||
|
if (asset.type === '클라우드') {
|
||||||
|
setFieldValue('sw-플랫폼명', (asset as any).플랫폼명 || '');
|
||||||
|
setFieldValue('sw-부서', (asset as any).부서 || '');
|
||||||
|
setFieldValue('sw-계정명', (asset as any).계정명 || '');
|
||||||
|
setFieldValue('sw-결제수단', (asset as any).결제수단 || '');
|
||||||
|
setFieldValue('sw-연결카드번호', (asset as any).연결카드번호 || '');
|
||||||
|
setFieldValue('sw-결제일', (asset as any).결제일 || '');
|
||||||
|
setFieldValue('sw-당월청구액', (asset as any).당월청구액 || '');
|
||||||
|
} else if (asset.type === '구독SW') {
|
||||||
|
setFieldValue('sw-라이선스유형', (asset as any).라이선스유형 || '');
|
||||||
|
setFieldValue('sw-만료일', (asset as any).만료일 || '');
|
||||||
|
} else {
|
||||||
setFieldValue('sw-라이선스키', (asset as any).라이선스키 || '');
|
setFieldValue('sw-라이선스키', (asset as any).라이선스키 || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
renderUserSummary(asset.id);
|
renderUserSummary(asset.id);
|
||||||
|
renderSwHistory(asset.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderUserSummary(swId: string) {
|
function renderUserSummary(swId: string) {
|
||||||
@@ -161,7 +260,7 @@ function renderSwHistory(swId: string) {
|
|||||||
if (!container) return;
|
if (!container) return;
|
||||||
const logs = (state.masterData.logs || []).filter(l => l.assetId === swId);
|
const logs = (state.masterData.logs || []).filter(l => l.assetId === swId);
|
||||||
if (logs.length === 0) {
|
if (logs.length === 0) {
|
||||||
container.innerHTML = '<div class="empty-history">이력이 없습니다.</div>';
|
container.innerHTML = '<div class="empty-history">수정 이력이 없습니다.</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.innerHTML = logs.map(l => `
|
container.innerHTML = logs.map(l => `
|
||||||
@@ -173,32 +272,21 @@ function renderSwHistory(swId: string) {
|
|||||||
`).join('');
|
`).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openSwModal(asset: SoftwareAsset) {
|
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')!;
|
||||||
const form = document.getElementById('sw-asset-form') as HTMLFormElement;
|
|
||||||
const saveBtn = document.getElementById('btn-save-sw-asset')!;
|
|
||||||
const revertBtn = document.getElementById('btn-revert-sw-edit')!;
|
|
||||||
|
|
||||||
form.reset();
|
// 수정 잠금 상태 제어
|
||||||
const isNew = !asset.자산번호;
|
setEditLock('sw-asset-form', mode, {
|
||||||
|
saveBtnId: 'btn-save-sw-asset',
|
||||||
|
revertBtnId: 'btn-revert-sw-edit'
|
||||||
|
});
|
||||||
|
|
||||||
if (isNew) {
|
isEditMode = (mode === 'add');
|
||||||
isEditMode = true;
|
|
||||||
form.classList.remove('is-view-mode');
|
|
||||||
form.classList.add('is-edit-mode');
|
|
||||||
saveBtn.textContent = '저장';
|
|
||||||
revertBtn.classList.add('hidden');
|
|
||||||
} else {
|
|
||||||
isEditMode = false;
|
|
||||||
form.classList.remove('is-edit-mode');
|
|
||||||
form.classList.add('is-view-mode');
|
|
||||||
saveBtn.textContent = '수정';
|
|
||||||
revertBtn.classList.add('hidden');
|
|
||||||
}
|
|
||||||
|
|
||||||
fillSwFormData(asset);
|
fillSwFormData(asset);
|
||||||
renderSwHistory(asset.id);
|
applySwTypeUI(asset.type);
|
||||||
|
|
||||||
modal.classList.remove('hidden');
|
modal.classList.remove('hidden');
|
||||||
createIcons({ icons: { X, History, Plus } });
|
createIcons({ icons: { X, History, Plus } });
|
||||||
}
|
}
|
||||||
@@ -213,26 +301,29 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
|
|||||||
const revertBtn = document.getElementById('btn-revert-sw-edit')!;
|
const revertBtn = document.getElementById('btn-revert-sw-edit')!;
|
||||||
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 closeModalAction = () => { closeModals(); isEditMode = false; };
|
const closeModalAction = () => { closeModals(); 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', {
|
||||||
|
saveBtnId: 'btn-save-sw-asset',
|
||||||
|
revertBtnId: 'btn-revert-sw-edit'
|
||||||
|
});
|
||||||
isEditMode = false;
|
isEditMode = false;
|
||||||
form.classList.replace('is-edit-mode', 'is-view-mode');
|
|
||||||
saveBtn.textContent = '수정';
|
|
||||||
revertBtn.classList.add('hidden');
|
|
||||||
if (currentSwAsset) fillSwFormData(currentSwAsset);
|
if (currentSwAsset) fillSwFormData(currentSwAsset);
|
||||||
});
|
});
|
||||||
|
|
||||||
saveBtn.addEventListener('click', () => {
|
saveBtn.addEventListener('click', () => {
|
||||||
if (!currentSwAsset) return;
|
if (!currentSwAsset) return;
|
||||||
if (!isEditMode) {
|
if (!isEditMode) {
|
||||||
|
setEditLock('sw-asset-form', 'edit', {
|
||||||
|
saveBtnId: 'btn-save-sw-asset',
|
||||||
|
revertBtnId: 'btn-revert-sw-edit'
|
||||||
|
});
|
||||||
isEditMode = true;
|
isEditMode = true;
|
||||||
form.classList.replace('is-view-mode', 'is-edit-mode');
|
|
||||||
saveBtn.textContent = '저장';
|
|
||||||
revertBtn.classList.remove('hidden');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,23 +341,37 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
|
|||||||
type: type
|
type: type
|
||||||
};
|
};
|
||||||
|
|
||||||
if (type === '구독SW') {
|
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-라이선스유형');
|
||||||
updated.만료일 = getFieldValue('sw-만료일');
|
updated.만료일 = getFieldValue('sw-만료일');
|
||||||
} else {
|
} else {
|
||||||
updated.라이선스키 = getFieldValue('sw-라이선스키');
|
updated.라이선스키 = getFieldValue('sw-라이선스키');
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetList = type === '구독SW' ? state.masterData.subSw : state.masterData.permSw;
|
// 데이터 저장 로직 (state 업데이트)
|
||||||
|
let targetList: SoftwareAsset[] = [];
|
||||||
|
if (type === '구독SW') targetList = state.masterData.subSw;
|
||||||
|
else if (type === '영구SW') targetList = state.masterData.permSw;
|
||||||
|
else if (type === '클라우드') targetList = state.masterData.cloud;
|
||||||
|
|
||||||
const idx = targetList.findIndex(a => a.id === updated.id);
|
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', {
|
||||||
|
saveBtnId: 'btn-save-sw-asset',
|
||||||
|
revertBtnId: 'btn-revert-sw-edit'
|
||||||
|
});
|
||||||
isEditMode = false;
|
isEditMode = false;
|
||||||
form.classList.replace('is-edit-mode', 'is-view-mode');
|
|
||||||
saveBtn.textContent = '수정';
|
|
||||||
revertBtn.classList.add('hidden');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteBtn.addEventListener('click', () => {
|
deleteBtn.addEventListener('click', () => {
|
||||||
@@ -274,7 +379,8 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
|
|||||||
if (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 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();
|
onSave();
|
||||||
closeModalAction();
|
closeModalAction();
|
||||||
}
|
}
|
||||||
@@ -283,4 +389,36 @@ export function initSwModal(onSave: () => void, closeModals: () => void) {
|
|||||||
userUpdateBtn.addEventListener('click', () => {
|
userUpdateBtn.addEventListener('click', () => {
|
||||||
if (currentSwAsset) openSwUserModal(currentSwAsset);
|
if (currentSwAsset) openSwUserModal(currentSwAsset);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 이력 추가 모달 로직
|
||||||
|
const logModal = document.getElementById('sw-log-modal')!;
|
||||||
|
logAddBtn.addEventListener('click', () => {
|
||||||
|
logModal.classList.remove('hidden');
|
||||||
|
(document.getElementById('new-log-date') as HTMLInputElement).value = new Date().toISOString().split('T')[0];
|
||||||
|
(document.getElementById('new-log-details') as HTMLTextAreaElement).value = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('btn-close-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
|
||||||
|
document.getElementById('btn-cancel-sw-log')?.addEventListener('click', () => logModal.classList.add('hidden'));
|
||||||
|
|
||||||
|
document.getElementById('btn-confirm-sw-log')?.addEventListener('click', () => {
|
||||||
|
if (!currentSwAsset) return;
|
||||||
|
const date = (document.getElementById('new-log-date') as HTMLInputElement).value;
|
||||||
|
const details = (document.getElementById('new-log-details') as HTMLTextAreaElement).value;
|
||||||
|
|
||||||
|
if (!date || !details) { alert('날짜와 내용을 입력해주세요.'); return; }
|
||||||
|
|
||||||
|
state.masterData.logs = state.masterData.logs || [];
|
||||||
|
state.masterData.logs.push({
|
||||||
|
id: Math.random().toString(36).substring(2, 9),
|
||||||
|
assetId: currentSwAsset.id,
|
||||||
|
date,
|
||||||
|
user: '관리자',
|
||||||
|
details
|
||||||
|
});
|
||||||
|
|
||||||
|
logModal.classList.add('hidden');
|
||||||
|
renderSwHistory(currentSwAsset.id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
50
src/main.ts
50
src/main.ts
@@ -7,12 +7,11 @@ import { initBaseModal } from './components/Modal/BaseModal';
|
|||||||
import { initPcModal } from './components/Modal/PCModal';
|
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 { initCloudModal, openCloudModal } from './components/Modal/CloudModal';
|
|
||||||
import { initSwUserModal } from './components/Modal/SWUserModal';
|
import { initSwUserModal } from './components/Modal/SWUserModal';
|
||||||
import { initDashboardDetailModal } from './components/Modal/DashboardDetailModal';
|
import { initDashboardDetailModal } from './components/Modal/DashboardDetailModal';
|
||||||
import { createIcons, Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw } from 'lucide';
|
import { createIcons, Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw } from 'lucide';
|
||||||
|
|
||||||
// --- DB 저장을 위한 세분화된 헬퍼 함수들 (setting 브랜치 기반) ---
|
// --- DB 저장을 위한 세분화된 헬퍼 함수들 ---
|
||||||
async function apiBatchSave(url: string, data: any[], label: string) {
|
async function apiBatchSave(url: string, data: any[], label: string) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
@@ -34,6 +33,7 @@ const saveEquipToDB = () => apiBatchSave('http://localhost:3000/api/equip/batch'
|
|||||||
const saveMobileToDB = () => apiBatchSave('http://localhost:3000/api/mobile/batch', state.masterData.mobile, '모바일기기');
|
const saveMobileToDB = () => apiBatchSave('http://localhost:3000/api/mobile/batch', state.masterData.mobile, '모바일기기');
|
||||||
const saveSubSwToDB = () => apiBatchSave('http://localhost:3000/api/sw/sub/batch', state.masterData.subSw, '구독SW');
|
const saveSubSwToDB = () => apiBatchSave('http://localhost:3000/api/sw/sub/batch', state.masterData.subSw, '구독SW');
|
||||||
const savePermSwToDB = () => apiBatchSave('http://localhost:3000/api/sw/perm/batch', state.masterData.permSw, '영구SW');
|
const savePermSwToDB = () => apiBatchSave('http://localhost:3000/api/sw/perm/batch', state.masterData.permSw, '영구SW');
|
||||||
|
const saveCloudToDB = () => apiBatchSave('http://localhost:3000/api/cloud/batch', state.masterData.cloud, '클라우드');
|
||||||
const saveSwUsersToDB = () => apiBatchSave('http://localhost:3000/api/sw-users/batch', state.masterData.swUsers, 'SW사용자');
|
const saveSwUsersToDB = () => apiBatchSave('http://localhost:3000/api/sw-users/batch', state.masterData.swUsers, 'SW사용자');
|
||||||
|
|
||||||
// 모든 하드웨어 DB 동기화
|
// 모든 하드웨어 DB 동기화
|
||||||
@@ -47,6 +47,16 @@ async function saveAllHardwareToDB() {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 모든 소프트웨어 DB 동기화
|
||||||
|
async function saveAllSoftwareToDB() {
|
||||||
|
await Promise.all([
|
||||||
|
saveSubSwToDB(),
|
||||||
|
savePermSwToDB(),
|
||||||
|
saveCloudToDB(),
|
||||||
|
saveSwUsersToDB()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// --- App Initialization ---
|
// --- App Initialization ---
|
||||||
function initApp() {
|
function initApp() {
|
||||||
console.log('🚀 ITAM Dedicated System Initializing...');
|
console.log('🚀 ITAM Dedicated System Initializing...');
|
||||||
@@ -64,23 +74,20 @@ function initApp() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 모달 초기화: StorageModal은 HWModal에 통합됨
|
// 모달 초기화
|
||||||
initPcModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
|
initPcModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
|
||||||
initHwModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
|
initHwModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
|
||||||
|
|
||||||
initSwModal(() => {
|
initSwModal(() => {
|
||||||
if (state.activeSubTab === '구독SW') saveSubSwToDB();
|
saveAllSoftwareToDB();
|
||||||
else savePermSwToDB();
|
|
||||||
renderSWTable(mainContent);
|
renderSWTable(mainContent);
|
||||||
}, closeAllModals);
|
}, closeAllModals);
|
||||||
|
|
||||||
initCloudModal(() => {
|
initSwUserModal(() => {
|
||||||
// 클라우드 저장 로직 (필요 시 API 추가 구현 가능)
|
saveSwUsersToDB();
|
||||||
renderSWTable(mainContent);
|
renderSWTable(mainContent);
|
||||||
}, closeAllModals);
|
}, closeAllModals);
|
||||||
|
|
||||||
initSwUserModal(() => { saveSwUsersToDB(); renderSWTable(mainContent); }, closeAllModals);
|
|
||||||
|
|
||||||
initDashboardDetailModal();
|
initDashboardDetailModal();
|
||||||
} catch (e) { console.error('❌ Initialization failed:', e); }
|
} catch (e) { console.error('❌ Initialization failed:', e); }
|
||||||
|
|
||||||
@@ -107,7 +114,7 @@ function initApp() {
|
|||||||
state.masterData = data;
|
state.masterData = data;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
saveAllHardwareToDB(),
|
saveAllHardwareToDB(),
|
||||||
saveSubSwToDB(), savePermSwToDB(), saveSwUsersToDB()
|
saveAllSoftwareToDB()
|
||||||
]);
|
]);
|
||||||
renderSWTable(mainContent);
|
renderSWTable(mainContent);
|
||||||
}
|
}
|
||||||
@@ -115,16 +122,25 @@ function initApp() {
|
|||||||
|
|
||||||
document.getElementById('btn-add-asset')?.addEventListener('click', () => {
|
document.getElementById('btn-add-asset')?.addEventListener('click', () => {
|
||||||
const tab = state.activeSubTab;
|
const tab = state.activeSubTab;
|
||||||
if (['개인PC', '서버', '전산비품', '스토리지', '모바일기기'].includes(tab)) {
|
const cat = state.activeCategory;
|
||||||
|
|
||||||
|
if (cat === 'hw') {
|
||||||
|
// 하드웨어 대시보드 또는 개별 탭에서 추가
|
||||||
|
const defaultType = (tab === '대시보드') ? '' : tab;
|
||||||
openHwModal({
|
openHwModal({
|
||||||
id: Math.random().toString(36).substring(2, 9),
|
id: Math.random().toString(36).substring(2, 9),
|
||||||
type: tab,
|
type: defaultType,
|
||||||
법인: '한맥', 자산코드: '', 명칭: '', 위치: '', 관리자: '', IP주소: '', MACaddress: '', HW사양: '', OS: '', 납품업체: '', 품의서명: ''
|
법인: '한맥', 자산코드: '', 명칭: '', 설치위치: '', MACaddress: '', HW사양: '', OS: '', 연락처: '', 담당부서: ''
|
||||||
|
} as any, 'add');
|
||||||
|
} else if (cat === 'sw') {
|
||||||
|
// 소프트웨어 대시보드 또는 개별 탭에서 추가
|
||||||
|
let defaultType = tab;
|
||||||
|
if (tab === '대시보드') defaultType = '구독SW'; // SW는 기본 레이아웃을 위해 하나 지정하되 필드는 빈값
|
||||||
|
|
||||||
|
openSwModal({
|
||||||
|
id: Math.random().toString(36).substring(2, 9),
|
||||||
|
type: defaultType, 제품명: '', 금액: '', 수량: 1, 계정명: '', 납품업체: '', 비고: '', 법인: '한맥'
|
||||||
} as any, 'add');
|
} as any, 'add');
|
||||||
} else if (tab === '클라우드') {
|
|
||||||
openCloudModal({ type: '클라우드', 플랫폼명: '', 법인: '한맥', 부서: '', 제품명: '', 계정명: '', 결제수단: '', 결제일: '', 연결카드번호: '', 당월청구액: '', 비고: '' } as any);
|
|
||||||
} else if (tab === '구독SW' || tab === '영구SW') {
|
|
||||||
openSwModal({ type: tab, 제품명: '', 금액: '', 수량: 1, 계정명: '', 납품업체: '', 비고: '', 법인: '한맥' } as any);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { state } from '../../core/state';
|
import { state } from '../../core/state';
|
||||||
import { openCloudModal } from '../../components/Modal/CloudModal';
|
import { openSwModal } from '../../components/Modal/SWModal';
|
||||||
import { createIcons, Cloud, CreditCard, DollarSign } from 'lucide';
|
import { createIcons, Cloud, CreditCard, DollarSign } from 'lucide';
|
||||||
|
|
||||||
export function renderCloudList(container: HTMLElement) {
|
export function renderCloudList(container: HTMLElement) {
|
||||||
const fullList = state.masterData.sw.filter(a => a.type === '클라우드');
|
// DB에서 직접 로드된 전용 배열을 사용하여 데이터 소스를 일원화함
|
||||||
|
const getFullList = () => state.masterData.cloud || [];
|
||||||
|
|
||||||
const filterBar = document.createElement('div');
|
const filterBar = document.createElement('div');
|
||||||
filterBar.className = 'search-bar';
|
filterBar.className = 'search-bar';
|
||||||
@@ -58,7 +59,7 @@ export function renderCloudList(container: HTMLElement) {
|
|||||||
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
||||||
const payment = paymentSelect ? paymentSelect.value : '';
|
const payment = paymentSelect ? paymentSelect.value : '';
|
||||||
|
|
||||||
const filtered = fullList.filter(asset => {
|
const filtered = getFullList().filter(asset => {
|
||||||
const kwMatch = !keyword ||
|
const kwMatch = !keyword ||
|
||||||
(asset.제품명 || '').toLowerCase().includes(keyword) ||
|
(asset.제품명 || '').toLowerCase().includes(keyword) ||
|
||||||
(asset.부서 || '').toLowerCase().includes(keyword) ||
|
(asset.부서 || '').toLowerCase().includes(keyword) ||
|
||||||
@@ -96,7 +97,7 @@ export function renderCloudList(container: HTMLElement) {
|
|||||||
<td>${asset.비고||''}</td>
|
<td>${asset.비고||''}</td>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
tr.addEventListener('click', () => openCloudModal(asset));
|
tr.addEventListener('click', () => openSwModal(asset, 'view'));
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
});
|
});
|
||||||
createIcons({ icons: { Cloud, CreditCard, DollarSign } });
|
createIcons({ icons: { Cloud, CreditCard, DollarSign } });
|
||||||
|
|||||||
@@ -131,8 +131,15 @@ export function renderSwList(container: HTMLElement) {
|
|||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openSwModal(asset); });
|
tr.addEventListener('click', (e) => {
|
||||||
tr.querySelector('.btn-edit')?.addEventListener('click', (e) => { e.stopPropagation(); openSwModal(asset); });
|
if (!(e.target as HTMLElement).closest('button')) {
|
||||||
|
openSwModal(asset, 'view');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tr.querySelector('.btn-edit')?.addEventListener('click', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
openSwModal(asset, 'edit');
|
||||||
|
});
|
||||||
tr.querySelector('.btn-users')?.addEventListener('click', (e) => { e.stopPropagation(); openSwUserModal(asset); });
|
tr.querySelector('.btn-users')?.addEventListener('click', (e) => { e.stopPropagation(); openSwUserModal(asset); });
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user