import { state, saveHardwareAsset, deleteHardwareAsset } from '../../core/state'; import { HardwareAsset, MasterAssetData } from '../../core/excelHandler'; import { openModal, closeModals } from './BaseModal'; import { createIcons, Paperclip } from 'lucide'; import { CORP_LIST, ORG_LIST, HW_TYPE_LIST, LOCATION_DATA, TYPE_PREFIX_MAP } from './SharedData'; import { generateOptionsHTML, setFieldValue, getFieldValue, parseAndSetLocation, bindLocationEvents, getCombinedLocation, setEditLock } from './ModalUtils'; let currentAsset: HardwareAsset | null = null; let isEditMode = false; const HW_MODAL_HTML = `
`; export function openHwModal(asset: HardwareAsset, mode: 'view' | 'add' = 'view') { currentAsset = asset; const modal = document.getElementById('hw-asset-modal')!; // 1. 잠금 상태 통합 제어 (데이터 유무가 아닌 호출 mode에만 의존) setEditLock('hw-asset-form', mode, { saveBtnId: 'btn-save-hw-asset', revertBtnId: 'btn-revert-hw-edit', generateBtnId: 'btn-generate-hw-code' }); isEditMode = (mode === 'add'); // 2. 데이터 바인딩 fillHwFormData(asset); modal.classList.remove('hidden'); applyTypeSpecificUI(asset.type); createIcons({ icons: { Paperclip } }); } function applyTypeSpecificUI(type: string) { const detailPurpose = getFieldValue('hw-상세용도'); const form = document.getElementById('hw-asset-form') as HTMLFormElement; if (!form) return; const serverOnly = document.querySelectorAll('.server-only'); const nonServer = document.querySelectorAll('.non-server'); const locationFields = document.querySelectorAll('.hw-location-field'); const groups: Record