feat: improve asset code generation and re-sequence assets by year
- Enhanced backend asset code generation logic to handle multiple tables - Integrated asset code generation button in HWModal - Included utility scripts for asset code migration and DB synchronization - Resolved issues with missing purchase dates and duplicate asset codes
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
bindLocationEvents,
|
||||
applyDateMask
|
||||
} from './ModalUtils';
|
||||
import { CORP_LIST, LOCATION_DATA, CATEGORY_TYPE_MAP, HW_STATUS_LIST, ORG_LIST, IMAGE_LOCATIONS } from './SharedData';
|
||||
import { CORP_LIST, LOCATION_DATA, CATEGORY_TYPE_MAP, HW_STATUS_LIST, ORG_LIST, IMAGE_LOCATIONS, TYPE_PREFIX_MAP } from './SharedData';
|
||||
import { BaseModal } from './BaseModal';
|
||||
import { createIcons, X, History, Plus, Save, Paperclip, Calendar, Monitor, Cpu, Network, ShieldCheck } from 'lucide';
|
||||
|
||||
@@ -278,6 +278,23 @@ class HwAssetModal extends BaseModal {
|
||||
: '<option value="">구분을 먼저 선택하세요</option>';
|
||||
});
|
||||
|
||||
document.getElementById('btn-gen-hw-code')?.addEventListener('click', async () => {
|
||||
const cat = categorySelect.value;
|
||||
if (!cat) { alert('구분을 먼저 선택해주세요.'); return; }
|
||||
|
||||
const prefix = TYPE_PREFIX_MAP[cat] || 'ETC';
|
||||
|
||||
try {
|
||||
const res = await fetch(`http://${location.hostname}:3000/api/generate-asset-code?prefix=${prefix}`);
|
||||
const data = await res.json();
|
||||
if (data.nextCode) {
|
||||
setFieldValue('hw-asset_code', data.nextCode);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('코드 생성 실패:', err);
|
||||
}
|
||||
});
|
||||
|
||||
bldgSelect.addEventListener('change', () => setTimeout(() => this.updateMapButtonVisibility(), 100));
|
||||
detailSelect.addEventListener('change', () => this.updateMapButtonVisibility());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user