BARON-SSO 로그인 연동
All checks were successful
ITAM Code Check / build-and-config-check (push) Successful in 12s
ITAM Docker Build Check / docker-build-check (push) Successful in 33s

This commit is contained in:
2026-06-30 15:35:51 +09:00
20 changed files with 578 additions and 86 deletions

View File

@@ -133,6 +133,7 @@ class DomainAssetModal extends BaseModal {
revertBtn.addEventListener('click', () => {
this.setEditLockMode('view');
this.isEditMode = false;
if (this.currentAsset) this.fillFormData(this.currentAsset);
});
@@ -202,7 +203,57 @@ class DomainAssetModal extends BaseModal {
if (logs.length === 0) {
container.innerHTML = '<div style="color:var(--mute); padding:1rem; text-align:center;">이력이 없습니다.</div>';
} else {
container.innerHTML = logs.map(l => `<div class="history-item"><div class="history-date">${l.log_date || ''}</div><div class="history-user">${l.log_user || '시스템'}</div><div class="history-details">${l.details}</div></div>`).join('');
const createdDate = this.currentAsset?.created_at ? this.currentAsset.created_at.substring(0, 10) : '';
const grouped: Record<string, typeof logs> = {};
logs.forEach(l => {
const date = l.log_date || '날짜 미지정';
if (!grouped[date]) grouped[date] = [];
grouped[date].push(l);
});
container.innerHTML = Object.entries(grouped).map(([date, dateLogs]) => {
const entriesHtml = dateLogs.map((l, idx) => {
const isLast = idx === dateLogs.length - 1;
const borderStyle = isLast ? '' : 'border-bottom: 1px dashed var(--hairline); padding-bottom: 8px; margin-bottom: 8px;';
let displayDetails = l.details;
if (l.details && l.details.trim().startsWith('{')) {
try {
const data = JSON.parse(l.details);
if (data.type === 'checkout') {
displayDetails = `[불출] ${data.user || ''} (${data.dept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
} else if (data.type === 'return') {
displayDetails = `[반납] ${data.user || ''} (${data.dept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
} else if (data.type === 'move') {
displayDetails = `[이동] ${data.user || ''} (${data.dept || ''}) ➔ ${data.targetUser || ''} (${data.targetDept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
}
} catch (e) {}
}
return `
<div class="history-entry" style="${borderStyle}">
<div style="font-weight: 600; color: var(--primary); opacity: 0.8; margin-bottom: 4px; display: flex; align-items: center; gap: 6px;">
<span style="display: inline-block; width: 4px; height: 4px; background-color: var(--primary); border-radius: 50%;"></span>
${l.log_user || '시스템'}
</div>
<div style="color: var(--primary); padding-left: 10px; line-height: 1.5;">${displayDetails}</div>
</div>
`;
}).join('');
const isInitialReg = date === createdDate;
const regBadge = isInitialReg ? `<span class="badge-reg" style="font-size: 10px; padding: 1px 5px; margin-left: 6px; background-color: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); border-radius: 4px; font-weight: 600;">최초등록</span>` : '';
return `
<div class="history-item">
<div class="history-date" style="display: flex; align-items: center;">${date} ${regBadge}</div>
<div class="history-details" style="display: flex; flex-direction: column; gap: 4px;">
${entriesHtml}
</div>
</div>
`;
}).join('');
}
}
}

View File

@@ -98,6 +98,9 @@ class HwAssetModal extends BaseModal {
<!-- [SECTION 2] 조직 및 사용자 정보 -->
<div class="form-section-title">사용자 및 조직 정보</div>
<div id="hw-pc-workflow-notice" class="form-group full-width hidden" style="background-color: rgba(59, 130, 246, 0.05); border: 1px solid rgba(59, 130, 246, 0.15); padding: 8px 12px; border-radius: 6px; font-size: 11px; color: var(--primary); line-height: 1.5; margin-bottom: 12px;">
💡 PC 자산은 데이터 정합성을 위해 '사용자 및 조직 정보'만 수정이 제한되며, 사양 및 기타 정보는 수정창에서 수정할 수 있습니다.
</div>
<div class="form-group">
<label>${ASSET_SCHEMA.CURRENT_DEPT.ui}</label>
<select id="hw-current_dept" name="current_dept">${generateOptionsHTML(ORG_LIST)}</select>
@@ -138,6 +141,10 @@ class HwAssetModal extends BaseModal {
<label>${ASSET_SCHEMA.SERIAL_NUM.ui}</label>
<input type="text" id="hw-serial_num" name="serial_num" />
</div>
<div class="form-group mainboard-only">
<label>${ASSET_SCHEMA.MAINBOARD.ui}</label>
<input type="text" id="hw-mainboard" name="mainboard" />
</div>
<div class="form-group spec-only">
<label>${ASSET_SCHEMA.OS.ui}</label>
<input type="text" id="hw-os" name="os" />
@@ -265,6 +272,7 @@ class HwAssetModal extends BaseModal {
protected initChildLogic(onSave: () => void, closeModals: () => void): void {
const saveBtn = document.getElementById('btn-save-hw-asset')!;
const revertBtn = document.getElementById('btn-revert-hw-edit')!;
const deleteBtn = document.getElementById('btn-delete-hw-asset')!;
const categorySelect = document.getElementById('hw-category') as HTMLSelectElement;
const typeSelect = document.getElementById('hw-asset_type') as HTMLSelectElement;
@@ -309,6 +317,12 @@ class HwAssetModal extends BaseModal {
typeSelect.addEventListener('change', () => {
this.applyRoleVisibility();
this.updateHeaderIdentity(this.currentAsset);
if (typeSelect.value === '공용PC') {
setFieldValue('hw-user_current', '');
setFieldValue('hw-emp_no', '');
setFieldValue('hw-user_position', '공용PC');
}
});
bindLocationEvents('hw-bldg-select', 'hw-location_detail', '', '');
@@ -320,9 +334,15 @@ class HwAssetModal extends BaseModal {
document.getElementById('btn-gen-hw-code')?.addEventListener('click', async () => {
const cat = categorySelect.value;
if (!cat) { alert('구분을 먼저 선택해주세요.'); return; }
const purchaseDate = (document.getElementById('hw-purchase_date') as HTMLInputElement)?.value || '';
if (!purchaseDate.trim()) {
alert('구매일자를 먼저 입력해 주세요. 구매일자가 없으면 자산번호를 생성할 수 없습니다.');
return;
}
const type = (document.getElementById('hw-asset_type') as HTMLSelectElement)?.value || '';
const prefix = TYPE_PREFIX_MAP[type] || TYPE_PREFIX_MAP[cat] || 'ETC';
const purchaseDate = (document.getElementById('hw-purchase_date') as HTMLInputElement)?.value || '';
try {
const res = await fetch(`/api/generate-asset-code?prefix=${prefix}&purchaseDate=${purchaseDate}`);
const data = await res.json();
@@ -393,6 +413,12 @@ class HwAssetModal extends BaseModal {
}
});
revertBtn.addEventListener('click', () => {
if (this.currentAsset) {
this.open(this.currentAsset, 'view');
}
});
saveBtn.addEventListener('click', async () => {
if (!this.currentAsset) return;
@@ -749,7 +775,8 @@ class HwAssetModal extends BaseModal {
const hasSpec = specCategories.includes(category) || type.includes('서버PC');
const noNetCategories = ['저장매체', '네트워크', '공간정보장비', 'PC부품', '사무가구'];
const showNet = (isInfra || isPersonal) && !noNetCategories.includes(category);
const hasSN = !['사무가구', 'PC부품'].includes(category);
const hasSN = ['외부SW', '내부SW'].includes(category);
const showMainboard = category === 'PC';
const isParts = ['PC부품', '사무가구'].includes(category);
const showRemote = category === '서버' || type.includes('서버');
const showServiceType = category === '서버' || type === '서버PC';
@@ -762,9 +789,83 @@ class HwAssetModal extends BaseModal {
document.querySelectorAll('.org-user-section, .org-user-field').forEach(el => (el as HTMLElement).style.display = (isPersonal || isParts || category === '업무지원장비') ? '' : 'none');
document.querySelectorAll('.personal-only').forEach(el => (el as HTMLElement).style.display = isPersonal ? '' : 'none');
document.querySelectorAll('.sn-only').forEach(el => (el as HTMLElement).style.display = hasSN ? '' : 'none');
document.querySelectorAll('.mainboard-only').forEach(el => (el as HTMLElement).style.display = showMainboard ? '' : 'none');
document.querySelectorAll('.monitor-only').forEach(el => (el as HTMLElement).style.display = type.includes('모니터') ? '' : 'none');
document.querySelectorAll('.parts-only').forEach(el => (el as HTMLElement).style.display = isParts ? '' : 'none');
document.querySelectorAll('.hardware-section').forEach(el => (el as HTMLElement).style.display = (hasSpec || isParts) ? '' : 'none');
// Lock only User and Organization Information for PC category during edit mode
const isEditMode = this.currentMode === 'edit';
const isPC = category === 'PC';
const noticeEl = document.getElementById('hw-pc-workflow-notice');
if (noticeEl) {
if (isPC && isEditMode) {
noticeEl.classList.remove('hidden');
} else {
noticeEl.classList.add('hidden');
}
}
const lockedUserFields = [
'hw-current_dept',
'hw-manager_primary',
'hw-manager_secondary',
'hw-user_current',
'hw-emp_no',
'hw-user_position',
'hw-previous_user'
];
const allFormControls = this.formEl ? this.formEl.querySelectorAll('input, select, textarea, button') : [];
allFormControls.forEach(control => {
const el = control as HTMLElement;
const id = el.id;
if (el.tagName === 'INPUT' && (el as HTMLInputElement).type === 'hidden') return;
if (id === 'hw-asset_code' || id === 'btn-gen-hw-code') return;
if (isPC && isEditMode && lockedUserFields.includes(id)) {
// Lock user information fields for PC in edit mode
if (el.tagName === 'SELECT') {
el.setAttribute('disabled', 'true');
} else if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') {
el.setAttribute('readonly', 'true');
(el as HTMLInputElement).style.backgroundColor = '#f1f5f9';
(el as HTMLInputElement).style.cursor = 'not-allowed';
} else if (el.tagName === 'BUTTON') {
el.setAttribute('disabled', 'true');
}
} else {
// Normal behavior based on modal edit/view mode (includes add mode which has this.isEditMode = true)
if (!this.isEditMode) {
if (el.tagName === 'SELECT') {
el.setAttribute('disabled', 'true');
} else if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') {
el.setAttribute('readonly', 'true');
(el as HTMLInputElement).style.backgroundColor = '';
(el as HTMLInputElement).style.cursor = '';
} else if (el.tagName === 'BUTTON') {
if (id !== 'btn-print-hw-qr' && id !== 'btn-close-hw-modal') {
el.setAttribute('disabled', 'true');
}
}
} else {
if (el.tagName === 'SELECT') {
el.removeAttribute('disabled');
} else if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') {
if (id !== 'hw-emp_no') {
el.removeAttribute('readonly');
(el as HTMLInputElement).style.backgroundColor = '';
(el as HTMLInputElement).style.cursor = '';
}
} else if (el.tagName === 'BUTTON') {
el.removeAttribute('disabled');
}
}
}
});
}
private updateMapButtonVisibility() {
@@ -976,6 +1077,8 @@ class HwAssetModal extends BaseModal {
const showList = (filterText: string = '') => {
if (!this.isEditMode) return;
const category = (document.getElementById('hw-category') as HTMLSelectElement)?.value || '';
if (category === 'PC') return;
const users = state.masterData.users || [];
const query = filterText.trim().toLowerCase();
@@ -1053,7 +1156,58 @@ class HwAssetModal extends BaseModal {
if (!container) return;
const logs = (state.masterData.logs || []).filter(l => l.asset_id === assetId);
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.log_date || ''}</div><div class="history-user">${l.log_user || '시스템'}</div><div class="history-details">${l.details}</div></div>`).join('');
const createdDate = this.currentAsset?.created_at ? this.currentAsset.created_at.substring(0, 10) : '';
const grouped: Record<string, typeof logs> = {};
logs.forEach(l => {
const date = l.log_date || '날짜 미지정';
if (!grouped[date]) grouped[date] = [];
grouped[date].push(l);
});
container.innerHTML = Object.entries(grouped).map(([date, dateLogs]) => {
const entriesHtml = dateLogs.map((l, idx) => {
const isLast = idx === dateLogs.length - 1;
const borderStyle = isLast ? '' : 'border-bottom: 1px dashed var(--hairline); padding-bottom: 8px; margin-bottom: 8px;';
let displayDetails = l.details;
if (l.details && l.details.trim().startsWith('{')) {
try {
const data = JSON.parse(l.details);
if (data.type === 'checkout') {
displayDetails = `[불출] ${data.user || ''} (${data.dept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
} else if (data.type === 'return') {
displayDetails = `[반납] ${data.user || ''} (${data.dept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
} else if (data.type === 'move') {
displayDetails = `[이동] ${data.user || ''} (${data.dept || ''}) ➔ ${data.targetUser || ''} (${data.targetDept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
}
} catch (e) {}
}
return `
<div class="history-entry" style="${borderStyle}">
<div style="font-weight: 600; color: var(--primary); opacity: 0.8; margin-bottom: 4px; display: flex; align-items: center; gap: 6px;">
<span style="display: inline-block; width: 4px; height: 4px; background-color: var(--primary); border-radius: 50%;"></span>
${l.log_user || '시스템'}
</div>
<div style="color: var(--primary); padding-left: 10px; line-height: 1.5;">${displayDetails}</div>
</div>
`;
}).join('');
const isInitialReg = date === createdDate;
const regBadge = isInitialReg ? `<span class="badge-reg" style="font-size: 10px; padding: 1px 5px; margin-left: 6px; background-color: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); border-radius: 4px; font-weight: 600;">최초등록</span>` : '';
return `
<div class="history-item">
<div class="history-date" style="display: flex; align-items: center;">${date} ${regBadge}</div>
<div class="history-details" style="display: flex; flex-direction: column; gap: 4px;">
${entriesHtml}
</div>
</div>
`;
}).join('');
}
private getCategoryKey(asset: any): string {

View File

@@ -144,6 +144,7 @@ class JobSpecModal extends BaseModal {
revertBtn.addEventListener('click', () => {
this.setEditLockMode('view');
this.isEditMode = false;
if (this.currentAsset) this.fillFormData(this.currentAsset);
});

View File

@@ -101,6 +101,7 @@ class PartsMasterModal extends BaseModal {
revertBtn.addEventListener('click', () => {
this.setEditLockMode('view');
this.isEditMode = false;
if (this.currentAsset) this.fillFormData(this.currentAsset);
});

View File

@@ -278,6 +278,7 @@ class SwAssetModal extends BaseModal {
revertBtn.addEventListener('click', () => {
this.setEditLockMode('view');
this.isEditMode = false;
if (this.currentAsset) this.fillFormData(this.currentAsset);
});
@@ -389,7 +390,58 @@ class SwAssetModal extends BaseModal {
if (!container) return;
const logs = (state.masterData.logs || []).filter(l => l.asset_id === 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.log_date || ''}</div><div class="history-user">${l.log_user || '시스템'}</div><div class="history-details">${l.details}</div></div>`).join('');
const createdDate = this.currentAsset?.created_at ? this.currentAsset.created_at.substring(0, 10) : '';
const grouped: Record<string, typeof logs> = {};
logs.forEach(l => {
const date = l.log_date || '날짜 미지정';
if (!grouped[date]) grouped[date] = [];
grouped[date].push(l);
});
container.innerHTML = Object.entries(grouped).map(([date, dateLogs]) => {
const entriesHtml = dateLogs.map((l, idx) => {
const isLast = idx === dateLogs.length - 1;
const borderStyle = isLast ? '' : 'border-bottom: 1px dashed var(--hairline); padding-bottom: 8px; margin-bottom: 8px;';
let displayDetails = l.details;
if (l.details && l.details.trim().startsWith('{')) {
try {
const data = JSON.parse(l.details);
if (data.type === 'checkout') {
displayDetails = `[불출] ${data.user || ''} (${data.dept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
} else if (data.type === 'return') {
displayDetails = `[반납] ${data.user || ''} (${data.dept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
} else if (data.type === 'move') {
displayDetails = `[이동] ${data.user || ''} (${data.dept || ''}) ➔ ${data.targetUser || ''} (${data.targetDept || ''}) ${data.memo ? `| 메모: ${data.memo}` : ''}`;
}
} catch (e) {}
}
return `
<div class="history-entry" style="${borderStyle}">
<div style="font-weight: 600; color: var(--primary); opacity: 0.8; margin-bottom: 4px; display: flex; align-items: center; gap: 6px;">
<span style="display: inline-block; width: 4px; height: 4px; background-color: var(--primary); border-radius: 50%;"></span>
${l.log_user || '시스템'}
</div>
<div style="color: var(--primary); padding-left: 10px; line-height: 1.5;">${displayDetails}</div>
</div>
`;
}).join('');
const isInitialReg = date === createdDate;
const regBadge = isInitialReg ? `<span class="badge-reg" style="font-size: 10px; padding: 1px 5px; margin-left: 6px; background-color: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); border-radius: 4px; font-weight: 600;">최초등록</span>` : '';
return `
<div class="history-item">
<div class="history-date" style="display: flex; align-items: center;">${date} ${regBadge}</div>
<div class="history-details" style="display: flex; flex-direction: column; gap: 4px;">
${entriesHtml}
</div>
</div>
`;
}).join('');
}
}

View File

@@ -107,6 +107,7 @@ class UserModal extends BaseModal {
revertBtn.addEventListener('click', () => {
this.setEditLockMode('view');
this.isEditMode = false;
if (this.currentAsset) this.fillFormData(this.currentAsset);
});

View File

@@ -3,7 +3,7 @@ import { state } from '../core/state';
const MENU_CONFIG: any = {
hw: {
label: '하드웨어',
tabs: ['대시보드', '서버', 'PC', '스토리지', '공간정보장비', 'PC부품', '부품 마스터', '네트워크', '업무지원장비']
tabs: ['대시보드', '서버', 'PC', '스토리지', '공간정보장비', 'PC부품', '네트워크', '업무지원장비']
},
sw: {
label: '소프트웨어',
@@ -65,39 +65,45 @@ export function renderNavigation(onTabChange: (tab: string) => void) {
});
if (state.currentUserRole === 'admin' && catKey === 'hw') {
visibleTabs = ['대시보드', '실사 승인'];
visibleTabs = ['대시보드', '관리도구', '실사 승인', '위치지정', '부품 마스터'];
}
if (visibleTabs.length === 0) return;
visibleTabs.forEach((tab: string) => {
if (tab === '부품 마스터') return;
const item = document.createElement('div');
const isActive = state.activeSubTab === tab;
item.className = `gnb-trigger ${isActive ? 'active' : ''}`;
item.textContent = tab;
item.style.fontSize = 'var(--fs-sm)'; // Ensure small but standard font
const isSubMenu = tab === '실사 승인' || tab === '위치지정' || tab === '부품 마스터';
if (isSubMenu) {
item.innerHTML = `<span style="opacity: 0.5; margin-right: 3px; font-family: sans-serif;">↳</span>${tab}`;
item.style.fontSize = '11px';
item.style.fontWeight = '500';
item.style.marginLeft = '6px';
if (!isActive) {
item.style.color = 'var(--mute)';
}
} else {
item.textContent = tab;
item.style.fontSize = 'var(--fs-sm)';
}
item.addEventListener('click', (e) => {
e.stopPropagation();
state.activeCategory = catKey as any;
state.activeSubTab = tab;
if (tab === '관리도구') {
state.activeSubTab = '실사 승인';
} else {
state.activeSubTab = tab;
}
render();
onTabChange(tab);
onTabChange(state.activeSubTab);
});
navList.appendChild(item);
});
});
// 3. 관리자 전용 '관리도구'
if (state.currentUserRole === 'admin') {
const adminTrigger = document.createElement('div');
adminTrigger.className = 'gnb-trigger admin-trigger';
adminTrigger.innerHTML = '관리도구';
adminTrigger.addEventListener('click', () => window.open('/map_editor.html', '_blank'));
navList.appendChild(adminTrigger);
}
// 4. 이벤트 바인딩
document.getElementById('btn-home-logo')?.addEventListener('click', () => location.reload());

View File

@@ -15,6 +15,8 @@ export interface FilterOptions {
showField?: boolean;
showType?: boolean;
showStatus?: boolean;
showPartCategory?: boolean;
showPartTier?: boolean;
extraHTML?: string;
onFilterChange: (filters: any) => void;
initialFilters?: any;
@@ -37,9 +39,11 @@ export function renderFilterBar(container: HTMLElement, options: FilterOptions)
showField = false,
showType = false,
showStatus = false,
showPartCategory = false,
showPartTier = false,
extraHTML = '',
onFilterChange,
initialFilters = { keyword: '', corp: '', dept: '', loc: '', field: '', type: '', status: '' },
initialFilters = { keyword: '', corp: '', dept: '', loc: '', field: '', type: '', status: '', partCategory: '', partTier: '' },
fullList = []
} = options;
@@ -104,6 +108,22 @@ export function renderFilterBar(container: HTMLElement, options: FilterOptions)
${getUnique('CURRENT_DEPT').map(v => `<option value="${v}" ${initialFilters.dept === v ? 'selected' : ''}>${v}</option>`).join('')}
</select>
</div>` : ''}
${showPartCategory ? `
<div class="search-item">
<label>분류</label>
<select id="filter-part-category">
<option value="">전체 분류</option>
${getUnique('category').map(v => `<option value="${v}" ${initialFilters.partCategory === v ? 'selected' : ''}>${v}</option>`).join('')}
</select>
</div>` : ''}
${showPartTier ? `
<div class="search-item">
<label>성능등급</label>
<select id="filter-part-tier">
<option value="">전체 등급</option>
${getUnique('score_tier').map(v => `<option value="${v}" ${initialFilters.partTier === v ? 'selected' : ''}>${v}</option>`).join('')}
</select>
</div>` : ''}
${extraHTML}
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
<i data-lucide="refresh-ccw" class="icon-sm"></i> ${UI_TEXT.ACTION.RESET_FILTER}
@@ -126,7 +146,9 @@ export function renderFilterBar(container: HTMLElement, options: FilterOptions)
loc: (container.querySelector('#filter-loc') as HTMLSelectElement)?.value || '',
field: (container.querySelector('#filter-field') as HTMLSelectElement)?.value || '',
type: (container.querySelector('#filter-type') as HTMLSelectElement)?.value || '',
status: (container.querySelector('#filter-status') as HTMLSelectElement)?.value || ''
status: (container.querySelector('#filter-status') as HTMLSelectElement)?.value || '',
partCategory: (container.querySelector('#filter-part-category') as HTMLSelectElement)?.value || '',
partTier: (container.querySelector('#filter-part-tier') as HTMLSelectElement)?.value || ''
};
onFilterChange(filters);
};
@@ -138,9 +160,11 @@ export function renderFilterBar(container: HTMLElement, options: FilterOptions)
container.querySelector('#filter-field')?.addEventListener('change', triggerChange);
container.querySelector('#filter-type')?.addEventListener('change', triggerChange);
container.querySelector('#filter-status')?.addEventListener('change', triggerChange);
container.querySelector('#filter-part-category')?.addEventListener('change', triggerChange);
container.querySelector('#filter-part-tier')?.addEventListener('change', triggerChange);
container.querySelector('#btn-reset-filters')?.addEventListener('click', () => {
['filter-keyword', 'filter-corp', 'filter-dept', 'filter-loc', 'filter-field', 'filter-type', 'filter-status'].forEach(id => {
['filter-keyword', 'filter-corp', 'filter-dept', 'filter-loc', 'filter-field', 'filter-type', 'filter-status', 'filter-part-category', 'filter-part-tier'].forEach(id => {
const el = container.querySelector(`#${id}`);
if (el) (el as any).value = '';
});
@@ -153,16 +177,20 @@ export function renderFilterBar(container: HTMLElement, options: FilterOptions)
*/
export function applyCommonFilters(list: any[], filters: any, searchKeys: (keyof typeof ASSET_SCHEMA)[]) {
return list.filter(item => {
const matchKeyword = !filters.keyword || searchKeys.some(key =>
String(item[ASSET_SCHEMA[key].key] || item[ASSET_SCHEMA[key].db] || '').toLowerCase().includes(filters.keyword)
);
const matchKeyword = !filters.keyword || searchKeys.some(key => {
const schema = ASSET_SCHEMA[key];
const val = schema ? (item[schema.key] || item[schema.db]) : item[key];
return String(val || '').toLowerCase().includes(filters.keyword);
});
const matchCorp = !filters.corp || (item[ASSET_SCHEMA.PURCHASE_CORP.key] || item[ASSET_SCHEMA.PURCHASE_CORP.db]) === filters.corp;
const matchDept = !filters.dept || (item[ASSET_SCHEMA.CURRENT_DEPT.key] || item[ASSET_SCHEMA.CURRENT_DEPT.db]) === filters.dept;
const matchLoc = !filters.loc || (item[ASSET_SCHEMA.LOCATION.key] || item[ASSET_SCHEMA.LOCATION.db]) === filters.loc;
const matchField = !filters.field || (item[ASSET_SCHEMA.SW_FIELD.key] || item[ASSET_SCHEMA.SW_FIELD.db]) === filters.field;
const matchType = !filters.type || (item[ASSET_SCHEMA.ASSET_TYPE.key] || item[ASSET_SCHEMA.ASSET_TYPE.db]) === filters.type;
const matchStatus = !filters.status || (item[ASSET_SCHEMA.HW_STATUS.key] || item[ASSET_SCHEMA.HW_STATUS.db]) === filters.status;
const matchPartCategory = !filters.partCategory || item.category === filters.partCategory;
const matchPartTier = !filters.partTier || item.score_tier === filters.partTier;
return matchKeyword && matchCorp && matchDept && matchLoc && matchField && matchType && matchStatus;
return matchKeyword && matchCorp && matchDept && matchLoc && matchField && matchType && matchStatus && matchPartCategory && matchPartTier;
});
}

View File

@@ -6,6 +6,7 @@ import { renderDashboard } from './views/DashboardView';
import { renderSWTable } from './views/SW_Table';
import { renderLocationView } from './views/LocationView';
import { renderAuditApprovalView } from './views/AuditApprovalView';
import { MapEditor } from './views/MapEditor';
import { initBaseModal } from './components/Modal/BaseModal';
import { initHwModal, openHwModal } from './components/Modal/HWModal';
import { initSwModal, openSwModal } from './components/Modal/SWModal';
@@ -28,11 +29,19 @@ interface AuthSessionResponse {
let phoneLoginPollTimer: number | undefined;
let activeMapEditorInstance: MapEditor | null = null;
// 화면 갱신 통합 핸들러
function refreshView(tab?: string) {
async function refreshView(tab?: string) {
const mainContent = document.getElementById('main-content')!;
if (!mainContent) return;
// Clean up any active MapEditor instance when navigating away
if (activeMapEditorInstance) {
activeMapEditorInstance.destroy();
activeMapEditorInstance = null;
}
const activeTab = tab || state.activeSubTab;
if (activeTab === '대시보드') {
@@ -41,7 +50,48 @@ function refreshView(tab?: string) {
}
if (activeTab === '실사 승인') {
renderAuditApprovalView(mainContent);
await renderAuditApprovalView(mainContent);
return;
}
if (activeTab === '위치지정') {
// Render Map Editor directly into main content to maximize working area
mainContent.innerHTML = `
<div class="map-editor-page-wrapper" style="display: flex; flex: 1; height: calc(100vh - var(--header-height) - 48px); overflow: hidden; width: 100%;">
<!-- Left: File Selector -->
<div class="file-sidebar" id="file-sidebar"></div>
<!-- Center: Main Editor -->
<div class="editor-container" id="container">
<div class="img-wrapper" id="wrapper">
<img src="" id="target-img" alt="Map Image">
</div>
</div>
<!-- Right: Control Panel -->
<div class="sidebar">
<h2>Map Editor <small class="editor-version">v3.0</small></h2>
<div class="current-path" id="current-path">파일을 선택하세요</div>
<p>
드래그하여 구역을 정의하세요. 저장 버튼을 누르면 즉시 시스템에 반영됩니다.
</p>
<div class="box-list" id="box-list"></div>
<div class="actions" style="display: flex; flex-direction: column; gap: 0.5rem;">
<button id="btn-clear-all" class="btn btn-outline">전체 삭제</button>
<button id="btn-print-map-qrs" class="btn btn-outline btn-primary">이 도면 QR 일괄인쇄</button>
<button id="btn-save-server" class="btn btn-primary">서버에 즉시 저장</button>
<div id="save-status"></div>
</div>
</div>
</div>
`;
// Initialize MapEditor instance
const editor = new MapEditor();
await editor.init();
activeMapEditorInstance = editor;
return;
}

View File

@@ -11,7 +11,15 @@ document.addEventListener('DOMContentLoaded', () => {
const manualInput = document.getElementById('manual-code-input') as HTMLInputElement;
const manualSubmitBtn = document.getElementById('btn-submit-manual') as HTMLButtonElement;
// 확인 모달 관련 셀렉터 및 상태 변수
const confirmModal = document.getElementById('scan-confirm-modal')!;
const confirmModalMsg = document.getElementById('confirm-modal-msg')!;
const btnConfirmCancel = document.getElementById('btn-confirm-cancel') as HTMLButtonElement;
const btnConfirmOk = document.getElementById('btn-confirm-ok') as HTMLButtonElement;
let html5QrcodeScanner: any = null;
let isModalOpen = false;
let pendingAssetCode = '';
// Initialize UI based on current session lock
updateLocationUI();
@@ -42,6 +50,33 @@ document.addEventListener('DOMContentLoaded', () => {
manualInput.value = '';
});
// 확인 모달 버튼 이벤트 바인딩
btnConfirmCancel.addEventListener('click', () => {
closeConfirmModal();
});
btnConfirmOk.addEventListener('click', () => {
const lockedLoc = sessionStorage.getItem(SESSION_LOC_KEY);
if (pendingAssetCode && lockedLoc) {
submitAssetAudit(pendingAssetCode, lockedLoc);
}
closeConfirmModal();
});
function openConfirmModal(assetCode: string, locationCode: string) {
isModalOpen = true;
pendingAssetCode = assetCode;
confirmModalMsg.innerHTML = `자산 <strong>[${assetCode}]</strong>을<br>현재 위치 <strong>[${locationCode}]</strong>에 실사 등록하시겠습니까?`;
confirmModal.style.display = 'flex';
vibrateDevice(50);
}
function closeConfirmModal() {
confirmModal.style.display = 'none';
isModalOpen = false;
pendingAssetCode = '';
}
// --- Core Scanner Functions ---
function initScanner() {
@@ -80,8 +115,24 @@ document.addEventListener('DOMContentLoaded', () => {
}
function processScannedCode(rawCode: string) {
if (isModalOpen) return; // 모달이 이미 열려 있는 경우 추가 스캔 차단
// QR 코드 인쇄 폼 등으로 인한 개행 문자(\r, \n) 및 모든 공백 문자(\s)를 제거
const code = rawCode.replace(/[\r\n]/g, '').replace(/\s+/g, '').trim();
let code = rawCode.replace(/[\r\n]/g, '').replace(/\s+/g, '').trim();
// 만약 스캔된 텍스트가 전체 URL 주소 형식이라면 파라미터 값만 추출하여 정제
if (code.includes('http://') || code.includes('https://') || code.includes('/mobile')) {
try {
const urlObj = new URL(code, window.location.origin);
const locParam = urlObj.searchParams.get('loc');
const assetParam = urlObj.searchParams.get('asset');
if (locParam) code = locParam;
else if (assetParam) code = assetParam;
} catch (e) {
console.error("URL 파싱 에러:", e);
}
}
// 1. Check if the code is a physical location code
if (code.startsWith('LOC-')) {
@@ -100,8 +151,8 @@ document.addEventListener('DOMContentLoaded', () => {
return;
}
// Submit matching info to server
submitAssetAudit(code, lockedLoc);
// 바로 전송하는 대신 확인 모달 팝업을 띄움
openConfirmModal(code, lockedLoc);
}
async function submitAssetAudit(assetCode: string, locationCode: string) {

View File

@@ -4,6 +4,7 @@ import { setupTableSorting, SortState } from '../../core/tableHandler';
import { renderFilterBar, applyCommonFilters } from '../../core/filterHandler';
import { state } from '../../core/state';
import { IMAGE_LOCATIONS } from '../../components/Modal/SharedData';
import { createIcons, Plus, Settings, RefreshCcw } from 'lucide';
import './table.css';
declare var Chart: any;
@@ -31,6 +32,8 @@ export interface ListViewConfig {
showType?: boolean;
showStatus?: boolean;
showPosition?: boolean;
showPartCategory?: boolean;
showPartTier?: boolean;
};
columns: ColumnDef[];
onRowClick?: (asset: any) => void;
@@ -50,7 +53,10 @@ export function createListView(container: HTMLElement, config: ListViewConfig) {
}
const filterKey = config.title;
if (!(state as any).listFilters[filterKey]) {
(state as any).listFilters[filterKey] = { keyword: '', corp: '', dept: '', loc: '', field: '', type: '', status: '' };
(state as any).listFilters[filterKey] = {
keyword: '', corp: '', dept: '', loc: '', field: '', type: '', status: '',
partCategory: '', partTier: ''
};
}
let currentFilters: any = (state as any).listFilters[filterKey];
@@ -708,7 +714,7 @@ export function createListView(container: HTMLElement, config: ListViewConfig) {
function makeColumnsResizable(tableElement: HTMLTableElement) {
const headers = tableElement.querySelectorAll('th');
headers.forEach(th => {
headers.forEach((th, index) => {
const resizer = th.querySelector('.resizer') as HTMLElement;
if (!resizer) return;
@@ -733,28 +739,44 @@ export function createListView(container: HTMLElement, config: ListViewConfig) {
resizer.classList.remove('resizing');
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', onMouseUp);
// Save the widths of all columns back to the config so they persist on re-render
headers.forEach((hdr, idx) => {
if (config.columns[idx]) {
config.columns[idx].width = hdr.style.width;
}
});
};
resizer.addEventListener('mousedown', (e: MouseEvent) => {
// Prevents header click sorting trigger from firing
// Prevents header click sorting trigger from firing on mousedown
e.stopPropagation();
e.preventDefault();
// Freeze all columns at their current pixel width before dragging
// Freeze all columns at their current precise pixel width before dragging
headers.forEach(header => {
header.style.width = `${header.offsetWidth}px`;
header.style.width = `${header.getBoundingClientRect().width}px`;
});
// Freeze the table at its current precise pixel width immediately
tableElement.style.width = `${tableElement.getBoundingClientRect().width}px`;
startX = e.clientX;
startWidth = th.offsetWidth;
startWidth = th.getBoundingClientRect().width;
// Capture the initial physical width of the entire table
startTableWidth = tableElement.offsetWidth;
startTableWidth = tableElement.getBoundingClientRect().width;
resizer.classList.add('resizing');
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', onMouseUp);
});
// Prevents header click sorting trigger from firing on mouseup/click
resizer.addEventListener('click', (e: MouseEvent) => {
e.stopPropagation();
e.preventDefault();
});
});
}
@@ -833,5 +855,9 @@ export function createListView(container: HTMLElement, config: ListViewConfig) {
chkBox?.addEventListener('change', handleToggle);
}
createIcons({
icons: { Plus, Settings, RefreshCcw }
});
switchView();
}

View File

@@ -16,7 +16,9 @@ export function renderPartsMasterList(container: HTMLElement) {
keywordLabel: '부품명 / 등급 검색',
showLoc: false,
showDept: false,
showType: false
showType: false,
showPartCategory: true,
showPartTier: true
},
onRowClick: (component) => openPartsMasterModal(component, 'view'),
columns: [
@@ -72,6 +74,7 @@ export function renderPartsMasterList(container: HTMLElement) {
title: '직무별 기준 사양',
dataSource: () => state.masterData.jobSpecs || [],
searchKeys: ['job_name', 'cpu_standard', 'ram_standard', 'gpu_standard', 'remarks'],
persistentSortState: { key: 'id', direction: 'asc' },
filterOptions: {
keywordLabel: '직무명 / 사양 검색',
showLoc: false,
@@ -130,9 +133,6 @@ export function renderPartsMasterList(container: HTMLElement) {
}
function renderSubTabs(container: HTMLElement) {
const header = container.querySelector('.page-header');
if (!header) return;
// 기존에 생성된 탭 바가 있다면 제거하여 중복 방지 (스타일만 수정하는 최소 침습 방식)
const existingTabs = container.querySelector('.sub-tab-container');
if (existingTabs) existingTabs.remove();
@@ -153,7 +153,12 @@ function renderSubTabs(container: HTMLElement) {
</button>
`;
header.parentNode!.insertBefore(tabContainer, header.nextSibling);
const header = container.querySelector('.page-header');
if (header) {
header.parentNode!.insertBefore(tabContainer, header.nextSibling);
} else {
container.insertBefore(tabContainer, container.firstChild);
}
const tabPartsMaster = tabContainer.querySelector('#tab-parts-master')!;
const tabJobSpec = tabContainer.querySelector('#tab-job-spec')!;

View File

@@ -1,6 +1,7 @@
import { IMAGE_LOCATIONS } from '../components/Modal/SharedData';
import { createIcons, X, Save, Trash2, ChevronLeft, ChevronRight } from 'lucide';
import { QRPrinter } from '../core/qr_print';
import './map-editor.css';
export class MapEditor {
private container: HTMLElement;
@@ -114,6 +115,45 @@ export class MapEditor {
this.render();
}
private onWindowMouseMove = (e: MouseEvent) => {
if (!this.isDrawing || !this.currentBox) return;
const rect = this.wrapper.getBoundingClientRect();
const currentX = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
const currentY = Math.max(0, Math.min(e.clientY - rect.top, rect.height));
const width = currentX - this.startX;
const height = currentY - this.startY;
this.currentBox.style.width = Math.abs(width) + 'px';
this.currentBox.style.height = Math.abs(height) + 'px';
this.currentBox.style.left = (width > 0 ? this.startX : currentX) + 'px';
this.currentBox.style.top = (height > 0 ? this.startY : currentY) + 'px';
};
private onWindowMouseUp = () => {
if (!this.isDrawing || !this.currentBox) return;
this.isDrawing = false;
const width = parseFloat(this.currentBox.style.width);
const height = parseFloat(this.currentBox.style.height);
if (width > 3 && height > 3) {
const rect = this.wrapper.getBoundingClientRect();
const boxData = {
x: (parseFloat(this.currentBox.style.left) / rect.width * 100).toFixed(2),
y: (parseFloat(this.currentBox.style.top) / rect.height * 100).toFixed(2),
w: (width / rect.width * 100).toFixed(2),
h: (height / rect.height * 100).toFixed(2),
asset_id: null
};
this.boxes.push(boxData);
this.render();
}
this.currentBox.remove();
this.currentBox = null;
};
private bindEvents() {
this.wrapper.addEventListener('mousedown', (e) => {
if (e.button !== 0) return;
@@ -135,44 +175,8 @@ export class MapEditor {
this.wrapper.appendChild(this.currentBox);
});
window.addEventListener('mousemove', (e) => {
if (!this.isDrawing || !this.currentBox) return;
const rect = this.wrapper.getBoundingClientRect();
const currentX = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
const currentY = Math.max(0, Math.min(e.clientY - rect.top, rect.height));
const width = currentX - this.startX;
const height = currentY - this.startY;
this.currentBox.style.width = Math.abs(width) + 'px';
this.currentBox.style.height = Math.abs(height) + 'px';
this.currentBox.style.left = (width > 0 ? this.startX : currentX) + 'px';
this.currentBox.style.top = (height > 0 ? this.startY : currentY) + 'px';
});
window.addEventListener('mouseup', () => {
if (!this.isDrawing || !this.currentBox) return;
this.isDrawing = false;
const width = parseFloat(this.currentBox.style.width);
const height = parseFloat(this.currentBox.style.height);
if (width > 3 && height > 3) {
const rect = this.wrapper.getBoundingClientRect();
const boxData = {
x: (parseFloat(this.currentBox.style.left) / rect.width * 100).toFixed(2),
y: (parseFloat(this.currentBox.style.top) / rect.height * 100).toFixed(2),
w: (width / rect.width * 100).toFixed(2),
h: (height / rect.height * 100).toFixed(2),
asset_id: null
};
this.boxes.push(boxData);
this.render();
}
this.currentBox.remove();
this.currentBox = null;
});
window.addEventListener('mousemove', this.onWindowMouseMove);
window.addEventListener('mouseup', this.onWindowMouseUp);
(window as any).removeBox = (index: number) => {
this.boxes.splice(index, 1);
@@ -341,6 +345,13 @@ export class MapEditor {
}]);
};
}
public destroy() {
window.removeEventListener('mousemove', this.onWindowMouseMove);
window.removeEventListener('mouseup', this.onWindowMouseUp);
delete (window as any).removeBox;
delete (window as any).printBoxQR;
}
}
function getCleanMapKey(path: string) {