chore: clean up build artifacts, temporary excel locks, duplicate plans, and commit current project state
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/**
|
||||
* ITAM 엑셀 핸들러 (지정 날짜 포맷팅 유틸리티)
|
||||
*/
|
||||
|
||||
export function formatExcelDate(val: any): string {
|
||||
if (!val) return '';
|
||||
if (typeof val === 'number') {
|
||||
const date = new Date(Math.round((val - 25569) * 86400 * 1000));
|
||||
return date.toISOString().split('T')[0];
|
||||
}
|
||||
if (typeof val === 'string') {
|
||||
return val.replace(/\./g, '-').trim();
|
||||
}
|
||||
return String(val);
|
||||
}
|
||||
/**
|
||||
* ITAM 엑셀 핸들러 (지정 날짜 포맷팅 유틸리티)
|
||||
*/
|
||||
|
||||
export function formatExcelDate(val: any): string {
|
||||
if (!val) return '';
|
||||
if (typeof val === 'number') {
|
||||
const date = new Date(Math.round((val - 25569) * 86400 * 1000));
|
||||
return date.toISOString().split('T')[0];
|
||||
}
|
||||
if (typeof val === 'string') {
|
||||
return val.replace(/\./g, '-').trim();
|
||||
}
|
||||
return String(val);
|
||||
}
|
||||
|
||||
@@ -1,162 +1,162 @@
|
||||
import { ASSET_SCHEMA, UI_TEXT } from './schema';
|
||||
import { generateOptionsHTML } from '../components/Modal/ModalUtils';
|
||||
import { CORP_LIST } from '../components/Modal/SharedData';
|
||||
|
||||
/**
|
||||
* ITAM Unified Filter Bar Component
|
||||
* 검색 UI를 표준화하고 한 곳에서 관리합니다.
|
||||
*/
|
||||
|
||||
export interface FilterOptions {
|
||||
keywordLabel?: string;
|
||||
showCorp?: boolean;
|
||||
showDept?: boolean;
|
||||
showLoc?: boolean;
|
||||
showField?: boolean;
|
||||
showType?: boolean;
|
||||
showStatus?: boolean;
|
||||
extraHTML?: string;
|
||||
onFilterChange: (filters: any) => void;
|
||||
initialFilters?: any;
|
||||
fullList?: any[]; // For populating dynamic filters
|
||||
}
|
||||
|
||||
/**
|
||||
* 전역 액션 버튼 그룹 생성 (자산 추가 등)
|
||||
*/
|
||||
export function getActionButtonsHTML(): string {
|
||||
return `<div id="filter-bar-actions" class="header-action-group"></div>`;
|
||||
}
|
||||
|
||||
export function renderFilterBar(container: HTMLElement, options: FilterOptions) {
|
||||
const {
|
||||
keywordLabel = '통합 검색',
|
||||
showCorp = false,
|
||||
showDept = false,
|
||||
showLoc = false,
|
||||
showField = false,
|
||||
showType = false,
|
||||
showStatus = false,
|
||||
extraHTML = '',
|
||||
onFilterChange,
|
||||
initialFilters = { keyword: '', corp: '', dept: '', loc: '', field: '', type: '', status: '' },
|
||||
fullList = []
|
||||
} = options;
|
||||
|
||||
container.classList.add('search-bar'); // Restored class
|
||||
|
||||
// Helper to get unique sorted values
|
||||
const getUnique = (key: keyof typeof ASSET_SCHEMA | string) => {
|
||||
const fieldKey = (ASSET_SCHEMA as any)[key]?.key || key;
|
||||
return Array.from(new Set(fullList.map(item => item[fieldKey] || item[(ASSET_SCHEMA as any)[key]?.db]).filter(Boolean))).sort();
|
||||
};
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>${keywordLabel}</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off" value="${initialFilters.keyword || ''}">
|
||||
</div>
|
||||
${showType ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.ASSET_TYPE.ui}</label>
|
||||
<select id="filter-type">
|
||||
<option value="">전체 유형</option>
|
||||
${getUnique('ASSET_TYPE').map(v => `<option value="${v}" ${initialFilters.type === v ? 'selected' : ''}>${v}</option>`).join('')}
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showStatus ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.HW_STATUS.ui}</label>
|
||||
<select id="filter-status">
|
||||
<option value="">전체 상태</option>
|
||||
${getUnique('HW_STATUS').map(v => `<option value="${v}" ${initialFilters.status === v ? 'selected' : ''}>${v}</option>`).join('')}
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showField ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.SW_FIELD.ui}</label>
|
||||
<select id="filter-field">
|
||||
<option value="">전체 분야</option>
|
||||
<option value="업무공통" ${initialFilters.field === '업무공통' ? 'selected' : ''}>업무공통</option>
|
||||
<option value="개발S/W" ${initialFilters.field === '개발S/W' ? 'selected' : ''}>개발S/W</option>
|
||||
<option value="디자인" ${initialFilters.field === '디자인' ? 'selected' : ''}>디자인</option>
|
||||
<option value="설계S/W" ${initialFilters.field === '설계S/W' ? 'selected' : ''}>설계S/W</option>
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showCorp ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.PURCHASE_CORP.ui}</label>
|
||||
<select id="filter-corp">${generateOptionsHTML(CORP_LIST, initialFilters.corp || '', true)}</select>
|
||||
</div>` : ''}
|
||||
${showLoc ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.LOCATION.ui}</label>
|
||||
<select id="filter-loc">
|
||||
<option value="">전체 위치</option>
|
||||
${getUnique('LOCATION').map(v => `<option value="${v}" ${initialFilters.loc === v ? 'selected' : ''}>${v}</option>`).join('')}
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showDept ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.CURRENT_DEPT.ui}</label>
|
||||
<select id="filter-dept">
|
||||
<option value="">전체 조직</option>
|
||||
${getUnique('CURRENT_DEPT').map(v => `<option value="${v}" ${initialFilters.dept === 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}
|
||||
</button>
|
||||
${getActionButtonsHTML()}
|
||||
`;
|
||||
|
||||
// Bind Events
|
||||
const triggerChange = () => {
|
||||
const filters = {
|
||||
keyword: (container.querySelector('#filter-keyword') as HTMLInputElement)?.value.toLowerCase().trim() || '',
|
||||
corp: (container.querySelector('#filter-corp') as HTMLSelectElement)?.value || '',
|
||||
dept: (container.querySelector('#filter-dept') as HTMLSelectElement)?.value || '',
|
||||
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 || ''
|
||||
};
|
||||
onFilterChange(filters);
|
||||
};
|
||||
|
||||
container.querySelector('#filter-keyword')?.addEventListener('input', triggerChange);
|
||||
container.querySelector('#filter-corp')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-dept')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-loc')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-field')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-type')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-status')?.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 => {
|
||||
const el = container.querySelector(`#${id}`);
|
||||
if (el) (el as any).value = '';
|
||||
});
|
||||
triggerChange();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 공통 필터링 로직
|
||||
*/
|
||||
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 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;
|
||||
|
||||
return matchKeyword && matchCorp && matchDept && matchLoc && matchField && matchType && matchStatus;
|
||||
});
|
||||
}
|
||||
import { ASSET_SCHEMA, UI_TEXT } from './schema';
|
||||
import { generateOptionsHTML } from '../components/Modal/ModalUtils';
|
||||
import { CORP_LIST } from '../components/Modal/SharedData';
|
||||
|
||||
/**
|
||||
* ITAM Unified Filter Bar Component
|
||||
* 검색 UI를 표준화하고 한 곳에서 관리합니다.
|
||||
*/
|
||||
|
||||
export interface FilterOptions {
|
||||
keywordLabel?: string;
|
||||
showCorp?: boolean;
|
||||
showDept?: boolean;
|
||||
showLoc?: boolean;
|
||||
showField?: boolean;
|
||||
showType?: boolean;
|
||||
showStatus?: boolean;
|
||||
extraHTML?: string;
|
||||
onFilterChange: (filters: any) => void;
|
||||
initialFilters?: any;
|
||||
fullList?: any[]; // For populating dynamic filters
|
||||
}
|
||||
|
||||
/**
|
||||
* 전역 액션 버튼 그룹 생성 (자산 추가 등)
|
||||
*/
|
||||
export function getActionButtonsHTML(): string {
|
||||
return `<div id="filter-bar-actions" class="header-action-group"></div>`;
|
||||
}
|
||||
|
||||
export function renderFilterBar(container: HTMLElement, options: FilterOptions) {
|
||||
const {
|
||||
keywordLabel = '통합 검색',
|
||||
showCorp = false,
|
||||
showDept = false,
|
||||
showLoc = false,
|
||||
showField = false,
|
||||
showType = false,
|
||||
showStatus = false,
|
||||
extraHTML = '',
|
||||
onFilterChange,
|
||||
initialFilters = { keyword: '', corp: '', dept: '', loc: '', field: '', type: '', status: '' },
|
||||
fullList = []
|
||||
} = options;
|
||||
|
||||
container.classList.add('search-bar'); // Restored class
|
||||
|
||||
// Helper to get unique sorted values
|
||||
const getUnique = (key: keyof typeof ASSET_SCHEMA | string) => {
|
||||
const fieldKey = (ASSET_SCHEMA as any)[key]?.key || key;
|
||||
return Array.from(new Set(fullList.map(item => item[fieldKey] || item[(ASSET_SCHEMA as any)[key]?.db]).filter(Boolean))).sort();
|
||||
};
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>${keywordLabel}</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off" value="${initialFilters.keyword || ''}">
|
||||
</div>
|
||||
${showType ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.ASSET_TYPE.ui}</label>
|
||||
<select id="filter-type">
|
||||
<option value="">전체 유형</option>
|
||||
${getUnique('ASSET_TYPE').map(v => `<option value="${v}" ${initialFilters.type === v ? 'selected' : ''}>${v}</option>`).join('')}
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showStatus ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.HW_STATUS.ui}</label>
|
||||
<select id="filter-status">
|
||||
<option value="">전체 상태</option>
|
||||
${getUnique('HW_STATUS').map(v => `<option value="${v}" ${initialFilters.status === v ? 'selected' : ''}>${v}</option>`).join('')}
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showField ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.SW_FIELD.ui}</label>
|
||||
<select id="filter-field">
|
||||
<option value="">전체 분야</option>
|
||||
<option value="업무공통" ${initialFilters.field === '업무공통' ? 'selected' : ''}>업무공통</option>
|
||||
<option value="개발S/W" ${initialFilters.field === '개발S/W' ? 'selected' : ''}>개발S/W</option>
|
||||
<option value="디자인" ${initialFilters.field === '디자인' ? 'selected' : ''}>디자인</option>
|
||||
<option value="설계S/W" ${initialFilters.field === '설계S/W' ? 'selected' : ''}>설계S/W</option>
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showCorp ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.PURCHASE_CORP.ui}</label>
|
||||
<select id="filter-corp">${generateOptionsHTML(CORP_LIST, initialFilters.corp || '', true)}</select>
|
||||
</div>` : ''}
|
||||
${showLoc ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.LOCATION.ui}</label>
|
||||
<select id="filter-loc">
|
||||
<option value="">전체 위치</option>
|
||||
${getUnique('LOCATION').map(v => `<option value="${v}" ${initialFilters.loc === v ? 'selected' : ''}>${v}</option>`).join('')}
|
||||
</select>
|
||||
</div>` : ''}
|
||||
${showDept ? `
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.CURRENT_DEPT.ui}</label>
|
||||
<select id="filter-dept">
|
||||
<option value="">전체 조직</option>
|
||||
${getUnique('CURRENT_DEPT').map(v => `<option value="${v}" ${initialFilters.dept === 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}
|
||||
</button>
|
||||
${getActionButtonsHTML()}
|
||||
`;
|
||||
|
||||
// Bind Events
|
||||
const triggerChange = () => {
|
||||
const filters = {
|
||||
keyword: (container.querySelector('#filter-keyword') as HTMLInputElement)?.value.toLowerCase().trim() || '',
|
||||
corp: (container.querySelector('#filter-corp') as HTMLSelectElement)?.value || '',
|
||||
dept: (container.querySelector('#filter-dept') as HTMLSelectElement)?.value || '',
|
||||
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 || ''
|
||||
};
|
||||
onFilterChange(filters);
|
||||
};
|
||||
|
||||
container.querySelector('#filter-keyword')?.addEventListener('input', triggerChange);
|
||||
container.querySelector('#filter-corp')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-dept')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-loc')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-field')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-type')?.addEventListener('change', triggerChange);
|
||||
container.querySelector('#filter-status')?.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 => {
|
||||
const el = container.querySelector(`#${id}`);
|
||||
if (el) (el as any).value = '';
|
||||
});
|
||||
triggerChange();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 공통 필터링 로직
|
||||
*/
|
||||
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 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;
|
||||
|
||||
return matchKeyword && matchCorp && matchDept && matchLoc && matchField && matchType && matchStatus;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,195 +1,195 @@
|
||||
/**
|
||||
* ITAM 통합 스키마 매퍼 (Unified Schema Mapper)
|
||||
*
|
||||
* key: 애플리케이션 내부 로직에서 사용하는 속성명
|
||||
* db: MySQL 데이터베이스 컬럼명
|
||||
* ui: 사용자에게 보여지는 UI 레이블
|
||||
*/
|
||||
|
||||
export const ASSET_SCHEMA = {
|
||||
// ─── 공통 필드 (Common) ───
|
||||
ID: { key: 'id', db: 'id', ui: 'ID' },
|
||||
ASSET_CODE: { key: 'asset_code', db: 'asset_code', ui: '자산번호' },
|
||||
CATEGORY: { key: 'category', db: 'category', ui: '구분' },
|
||||
ASSET_TYPE: { key: 'asset_type', db: 'asset_type', ui: '유형' },
|
||||
PURCHASE_CORP: { key: 'purchase_corp',db: 'purchase_corp', ui: '구매법인' },
|
||||
PURCHASE_DATE: { key: 'purchase_date',db: 'purchase_date', ui: '구매일자' },
|
||||
PURCHASE_AMOUNT:{ key: 'purchase_amount', db: 'purchase_amount', ui: '구매금액' },
|
||||
PURCHASE_VENDOR:{ key: 'purchase_vendor', db: 'purchase_vendor', ui: '구매업체' },
|
||||
APPROVAL_DOC: { key: 'approval_document', db: 'approval_document', ui: '품의서' },
|
||||
SERVICE_TYPE: { key: 'service_type', db: 'service_type', ui: '서비스 구분' },
|
||||
MANAGER_MAIN: { key: 'manager_primary', db: 'manager_primary', ui: '담당자(정)' },
|
||||
MANAGER_SUB: { key: 'manager_secondary', db: 'manager_secondary', ui: '담당자(부)' },
|
||||
LOCATION: { key: 'location', db: 'location', ui: '자산위치' },
|
||||
LOC_DETAIL: { key: 'location_detail', db: 'location_detail', ui: '상세위치' },
|
||||
LOCATION_PHOTO: { key: 'location_photo', db: 'location_photo', ui: '배치도이미지' },
|
||||
LOC_X: { key: 'loc_x', db: 'loc_x', ui: '위치X' },
|
||||
LOC_Y: { key: 'loc_y', db: 'loc_y', ui: '위치Y' },
|
||||
MEMO: { key: 'memo', db: 'memo', ui: '메모' },
|
||||
|
||||
// ─── 하드웨어 상세 (Hardware) ───
|
||||
HW_STATUS: { key: 'hw_status', db: 'hw_status', ui: '상태' },
|
||||
MODEL_NAME: { key: 'model_name', db: 'model_name', ui: '모델명' },
|
||||
ASSET_NAME: { key: 'asset_name', db: 'asset_name', ui: '자산명' },
|
||||
ASSET_MFR: { key: 'asset_mfr', db: 'asset_mfr', ui: '제조사' },
|
||||
CURRENT_DEPT: { key: 'current_dept', db: 'current_dept', ui: '현 사용조직' },
|
||||
PREV_DEPT: { key: 'previous_dept',db: 'previous_dept', ui: '직전 사용조직' },
|
||||
CURRENT_USER: { key: 'user_current', db: 'user_current', ui: '현 사용자' },
|
||||
EMP_NO: { key: 'emp_no', db: 'emp_no', ui: '사번' },
|
||||
USER_POSITION: { key: 'user_position', db: 'user_position', ui: '직무' },
|
||||
PREV_USER: { key: 'previous_user',db: 'previous_user', ui: '직전 사용자' },
|
||||
CPU: { key: 'cpu', db: 'cpu', ui: 'CPU' },
|
||||
RAM: { key: 'ram', db: 'ram', ui: 'RAM' },
|
||||
GPU: { key: 'gpu', db: 'gpu', ui: 'GPU' },
|
||||
SSD1: { key: 'ssd_1', db: 'ssd_1', ui: 'SSD1' },
|
||||
SSD2: { key: 'ssd_2', db: 'ssd_2', ui: 'SSD2' },
|
||||
HDD1: { key: 'hdd_1', db: 'hdd_1', ui: 'HDD1' },
|
||||
HDD2: { key: 'hdd_2', db: 'hdd_2', ui: 'HDD2' },
|
||||
HDD3: { key: 'hdd_3', db: 'hdd_3', ui: 'HDD3' },
|
||||
HDD4: { key: 'hdd_4', db: 'hdd_4', ui: 'HDD4' },
|
||||
MAINBOARD: { key: 'mainboard', db: 'mainboard', ui: '메인보드' },
|
||||
OS: { key: 'os', db: 'os', ui: 'OS' },
|
||||
IP_ADDR: { key: 'ip_address', db: 'ip_address', ui: 'IP 주소' },
|
||||
IP_ADDR2: { key: 'ip_address_2', db: 'ip_address_2', ui: 'IP 주소 2' },
|
||||
MAC_ADDR: { key: 'mac_address', db: 'mac_address', ui: 'MAC 주소' },
|
||||
REMOTE_TOOL: { key: 'remote_tool', db: 'remote_tool', ui: '원격도구' },
|
||||
REMOTE_ID: { key: 'remote_id', db: 'remote_id', ui: '원격 ID' },
|
||||
REMOTE_PW: { key: 'remote_pw', db: 'remote_pw', ui: '원격 PW' },
|
||||
MONITORING: { key: 'monitoring', db: 'monitoring', ui: '모니터링' },
|
||||
VOLUME: { key: 'volume', db: 'volume', ui: '용량' },
|
||||
MONITOR_INCH: { key: 'monitor_inch', db: 'monitor_inch', ui: '인치' },
|
||||
ASSET_COUNT: { key: 'asset_count', db: 'asset_count', ui: '수량' },
|
||||
SERIAL_NUM: { key: 'serial_num', db: 'serial_num', ui: 'S/N' },
|
||||
|
||||
// ─── 소프트웨어/클라우드 상세 (SW/Cloud/Domain) ───
|
||||
SW_STATUS: { key: 'sw_status', db: 'sw_status', ui: '상태' },
|
||||
SW_FIELD: { key: 'sw_field', db: 'sw_field', ui: '분야' },
|
||||
SW_TYPE: { key: 'sw_type', db: 'sw_type', ui: '유형' },
|
||||
DEV_OBJ: { key: 'dev_objective',db: 'dev_objective', ui: '목적' },
|
||||
DEV_MGR: { key: 'dev_manager', db: 'dev_manager', ui: '개발담당자' },
|
||||
PLANNING_MGR: { key: 'planning_manager', db: 'planning_manager', ui: '기획담당자' },
|
||||
SALES_MGR: { key: 'sales_manager',db: 'sales_manager', ui: '영업담당자' },
|
||||
PRODUCT_NAME: { key: 'product_name', db: 'product_name', ui: '제품명' },
|
||||
DOMAIN_ADDR: { key: 'domain_address', db: 'domain_address',ui: '도메인주소' },
|
||||
EMAIL_ACCOUNT: { key: 'email_account', db: 'email_account', ui: '이메일주소' },
|
||||
EMAIL_PW: { key: 'email_pw', db: 'email_pw', ui: '이메일비밀번호' },
|
||||
SW_ID: { key: 'sw_id', db: 'sw_id', ui: '계정ID' },
|
||||
SW_PW: { key: 'sw_pw', db: 'sw_pw', ui: '비밀번호' },
|
||||
PURCHASE_METHOD:{ key: 'purchase_method', db: 'purchase_method', ui: '결제수단' },
|
||||
ASSET_PURPOSE: { key: 'asset_purpose', db: 'asset_purpose', ui: '용도' },
|
||||
ASSET_STATUS: { key: 'asset_status', db: 'asset_status', ui: '상태' },
|
||||
START_DATE: { key: 'start_date', db: 'start_date', ui: '시작일' },
|
||||
EXPIRED_DATE: { key: 'expired_date', db: 'expired_date', ui: '만료일' }
|
||||
};
|
||||
|
||||
/**
|
||||
* 페이지별 헤더 정보 (타이틀, 설명, 아이콘)
|
||||
*/
|
||||
export const PAGE_DESCRIPTIONS: Record<string, { title: string; description: string; icon: string }> = {
|
||||
'PC': {
|
||||
title: '개인PC 자산 관리',
|
||||
description: '임직원에게 지급된 데스크톱 및 노트북 자산의 할당 현황과 하드웨어 사양을 통합 관리합니다.',
|
||||
icon: 'laptop'
|
||||
},
|
||||
'서버': {
|
||||
title: '서버 자산 관리',
|
||||
description: 'IDC 및 사내 서버실에 운영 중인 물리 서버 장비의 도입, 운영, 폐기 현황을 관리합니다.',
|
||||
icon: 'server'
|
||||
},
|
||||
'스토리지': {
|
||||
title: '스토리지 자산 관리',
|
||||
description: '데이터 저장 및 백업을 위한 NAS, DAS 등 스토리지 장비의 용량과 연결 상태를 관리합니다.',
|
||||
icon: 'database'
|
||||
},
|
||||
'네트워크': {
|
||||
title: '네트워크 장비 관리',
|
||||
description: '스위치, 방화벽, 공유기 등 사내 네트워크 인프라를 구성하는 주요 장비 현황을 관리합니다.',
|
||||
icon: 'layers'
|
||||
},
|
||||
'업무지원장비': {
|
||||
title: '업무 지원 장비 관리',
|
||||
description: '모니터, 프린터, 스캐너 등 원활한 업무 수행을 보조하는 전산 비품들을 관리합니다.',
|
||||
icon: 'monitor'
|
||||
},
|
||||
'PC부품': {
|
||||
title: 'PC 부품 자산 관리',
|
||||
description: 'CPU, RAM, GPU 등 PC 조립 및 유지보수를 위해 보유 중인 주요 부품 재고를 관리합니다.',
|
||||
icon: 'cpu'
|
||||
},
|
||||
'공간정보장비': {
|
||||
title: '공간 정보 장비 관리',
|
||||
description: '측량 및 공간 정보 수집에 사용되는 특수 정밀 장비들의 이력과 상태를 관리합니다.',
|
||||
icon: 'map'
|
||||
},
|
||||
'내부SW': {
|
||||
title: '사내 개발 S/W 관리',
|
||||
description: '사내에서 자체 개발하거나 운영 중인 시스템 및 소프트웨어 서비스 현황을 관리합니다.',
|
||||
icon: 'code'
|
||||
},
|
||||
'외부SW': {
|
||||
title: '외부 상용 S/W 관리',
|
||||
description: '상용 소프트웨어의 라이선스 보유 현황, 사용자 할당 및 만료 일정을 관리합니다.',
|
||||
icon: 'package'
|
||||
},
|
||||
'도메인': {
|
||||
title: '도메인 자산 관리',
|
||||
description: '운영 중인 서비스 도메인의 등록 정보, 관리 업체 및 갱신 만료일을 관리합니다.',
|
||||
icon: 'globe'
|
||||
},
|
||||
'클라우드': {
|
||||
title: '클라우드 자산 관리',
|
||||
description: 'AWS, Azure, GCP 등 클라우드 인프라 자원 및 구독 서비스 이용 현황을 관리합니다.',
|
||||
icon: 'cloud'
|
||||
},
|
||||
'비용관리': {
|
||||
title: 'IT 비용 집행 관리',
|
||||
description: '전산 자산 도입 및 유지보수에 소요되는 정기/비정기 지출 비용을 통합 관리합니다.',
|
||||
icon: 'credit-card'
|
||||
},
|
||||
'선물': {
|
||||
title: '내빈/외빈 선물 관리',
|
||||
description: '내외빈 방문 시 지급되는 기념품 및 선물용 자산의 재고와 지급 이력을 관리합니다.',
|
||||
icon: 'gift'
|
||||
},
|
||||
'사무가구': {
|
||||
title: '사무용 가구 관리',
|
||||
description: '책상, 의자, 캐비닛 등 사무 환경 구성을 위한 가구 자산의 배치 현황을 관리합니다.',
|
||||
icon: 'armchair'
|
||||
},
|
||||
'사용자': {
|
||||
title: '임직원 사용자 관리',
|
||||
description: 'IT 자산 할당 및 관리의 기준이 되는 사내 임직원(사용자) 정보를 데이터베이스 기반으로 직접 등록하고 수정합니다.',
|
||||
icon: 'users'
|
||||
},
|
||||
'부품 마스터': {
|
||||
title: '부품 표준 정보 관리',
|
||||
description: 'PC 사양 적정성 평가의 기준이 되는 부품 표준 정보 및 등급별 감점 점수를 관리합니다.',
|
||||
icon: 'cpu'
|
||||
},
|
||||
'직무별 기준 사양': {
|
||||
title: '직무별 기준 사양 관리',
|
||||
description: 'BIM 모델러, 개발자, 엔지니어 등 사내 직무별 권장 하드웨어 기준 및 성능 합격 점수를 관리합니다.',
|
||||
icon: 'sliders'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 용어 사전 (UI 텍스트 전용)
|
||||
*/
|
||||
export const UI_TEXT = {
|
||||
ACTION: {
|
||||
ADD: '신규 등록',
|
||||
EDIT: '수정',
|
||||
SAVE: '저장',
|
||||
DELETE: '삭제',
|
||||
CANCEL: '취소',
|
||||
CLOSE: '닫기',
|
||||
HISTORY_ADD: '이력 추가',
|
||||
RESET_FILTER: '필터 초기화'
|
||||
},
|
||||
MESSAGES: {
|
||||
CONFIRM_DELETE: '정말로 삭제하시겠습니까?',
|
||||
SAVE_SUCCESS: '성공적으로 저장되었습니다.',
|
||||
NO_DATA: '검색 결과가 없습니다.'
|
||||
}
|
||||
};
|
||||
/**
|
||||
* ITAM 통합 스키마 매퍼 (Unified Schema Mapper)
|
||||
*
|
||||
* key: 애플리케이션 내부 로직에서 사용하는 속성명
|
||||
* db: MySQL 데이터베이스 컬럼명
|
||||
* ui: 사용자에게 보여지는 UI 레이블
|
||||
*/
|
||||
|
||||
export const ASSET_SCHEMA = {
|
||||
// ─── 공통 필드 (Common) ───
|
||||
ID: { key: 'id', db: 'id', ui: 'ID' },
|
||||
ASSET_CODE: { key: 'asset_code', db: 'asset_code', ui: '자산번호' },
|
||||
CATEGORY: { key: 'category', db: 'category', ui: '구분' },
|
||||
ASSET_TYPE: { key: 'asset_type', db: 'asset_type', ui: '유형' },
|
||||
PURCHASE_CORP: { key: 'purchase_corp',db: 'purchase_corp', ui: '구매법인' },
|
||||
PURCHASE_DATE: { key: 'purchase_date',db: 'purchase_date', ui: '구매일자' },
|
||||
PURCHASE_AMOUNT:{ key: 'purchase_amount', db: 'purchase_amount', ui: '구매금액' },
|
||||
PURCHASE_VENDOR:{ key: 'purchase_vendor', db: 'purchase_vendor', ui: '구매업체' },
|
||||
APPROVAL_DOC: { key: 'approval_document', db: 'approval_document', ui: '품의서' },
|
||||
SERVICE_TYPE: { key: 'service_type', db: 'service_type', ui: '서비스 구분' },
|
||||
MANAGER_MAIN: { key: 'manager_primary', db: 'manager_primary', ui: '담당자(정)' },
|
||||
MANAGER_SUB: { key: 'manager_secondary', db: 'manager_secondary', ui: '담당자(부)' },
|
||||
LOCATION: { key: 'location', db: 'location', ui: '자산위치' },
|
||||
LOC_DETAIL: { key: 'location_detail', db: 'location_detail', ui: '상세위치' },
|
||||
LOCATION_PHOTO: { key: 'location_photo', db: 'location_photo', ui: '배치도이미지' },
|
||||
LOC_X: { key: 'loc_x', db: 'loc_x', ui: '위치X' },
|
||||
LOC_Y: { key: 'loc_y', db: 'loc_y', ui: '위치Y' },
|
||||
MEMO: { key: 'memo', db: 'memo', ui: '메모' },
|
||||
|
||||
// ─── 하드웨어 상세 (Hardware) ───
|
||||
HW_STATUS: { key: 'hw_status', db: 'hw_status', ui: '상태' },
|
||||
MODEL_NAME: { key: 'model_name', db: 'model_name', ui: '모델명' },
|
||||
ASSET_NAME: { key: 'asset_name', db: 'asset_name', ui: '자산명' },
|
||||
ASSET_MFR: { key: 'asset_mfr', db: 'asset_mfr', ui: '제조사' },
|
||||
CURRENT_DEPT: { key: 'current_dept', db: 'current_dept', ui: '현 사용조직' },
|
||||
PREV_DEPT: { key: 'previous_dept',db: 'previous_dept', ui: '직전 사용조직' },
|
||||
CURRENT_USER: { key: 'user_current', db: 'user_current', ui: '현 사용자' },
|
||||
EMP_NO: { key: 'emp_no', db: 'emp_no', ui: '사번' },
|
||||
USER_POSITION: { key: 'user_position', db: 'user_position', ui: '직무' },
|
||||
PREV_USER: { key: 'previous_user',db: 'previous_user', ui: '직전 사용자' },
|
||||
CPU: { key: 'cpu', db: 'cpu', ui: 'CPU' },
|
||||
RAM: { key: 'ram', db: 'ram', ui: 'RAM' },
|
||||
GPU: { key: 'gpu', db: 'gpu', ui: 'GPU' },
|
||||
SSD1: { key: 'ssd_1', db: 'ssd_1', ui: 'SSD1' },
|
||||
SSD2: { key: 'ssd_2', db: 'ssd_2', ui: 'SSD2' },
|
||||
HDD1: { key: 'hdd_1', db: 'hdd_1', ui: 'HDD1' },
|
||||
HDD2: { key: 'hdd_2', db: 'hdd_2', ui: 'HDD2' },
|
||||
HDD3: { key: 'hdd_3', db: 'hdd_3', ui: 'HDD3' },
|
||||
HDD4: { key: 'hdd_4', db: 'hdd_4', ui: 'HDD4' },
|
||||
MAINBOARD: { key: 'mainboard', db: 'mainboard', ui: '메인보드' },
|
||||
OS: { key: 'os', db: 'os', ui: 'OS' },
|
||||
IP_ADDR: { key: 'ip_address', db: 'ip_address', ui: 'IP 주소' },
|
||||
IP_ADDR2: { key: 'ip_address_2', db: 'ip_address_2', ui: 'IP 주소 2' },
|
||||
MAC_ADDR: { key: 'mac_address', db: 'mac_address', ui: 'MAC 주소' },
|
||||
REMOTE_TOOL: { key: 'remote_tool', db: 'remote_tool', ui: '원격도구' },
|
||||
REMOTE_ID: { key: 'remote_id', db: 'remote_id', ui: '원격 ID' },
|
||||
REMOTE_PW: { key: 'remote_pw', db: 'remote_pw', ui: '원격 PW' },
|
||||
MONITORING: { key: 'monitoring', db: 'monitoring', ui: '모니터링' },
|
||||
VOLUME: { key: 'volume', db: 'volume', ui: '용량' },
|
||||
MONITOR_INCH: { key: 'monitor_inch', db: 'monitor_inch', ui: '인치' },
|
||||
ASSET_COUNT: { key: 'asset_count', db: 'asset_count', ui: '수량' },
|
||||
SERIAL_NUM: { key: 'serial_num', db: 'serial_num', ui: 'S/N' },
|
||||
|
||||
// ─── 소프트웨어/클라우드 상세 (SW/Cloud/Domain) ───
|
||||
SW_STATUS: { key: 'sw_status', db: 'sw_status', ui: '상태' },
|
||||
SW_FIELD: { key: 'sw_field', db: 'sw_field', ui: '분야' },
|
||||
SW_TYPE: { key: 'sw_type', db: 'sw_type', ui: '유형' },
|
||||
DEV_OBJ: { key: 'dev_objective',db: 'dev_objective', ui: '목적' },
|
||||
DEV_MGR: { key: 'dev_manager', db: 'dev_manager', ui: '개발담당자' },
|
||||
PLANNING_MGR: { key: 'planning_manager', db: 'planning_manager', ui: '기획담당자' },
|
||||
SALES_MGR: { key: 'sales_manager',db: 'sales_manager', ui: '영업담당자' },
|
||||
PRODUCT_NAME: { key: 'product_name', db: 'product_name', ui: '제품명' },
|
||||
DOMAIN_ADDR: { key: 'domain_address', db: 'domain_address',ui: '도메인주소' },
|
||||
EMAIL_ACCOUNT: { key: 'email_account', db: 'email_account', ui: '이메일주소' },
|
||||
EMAIL_PW: { key: 'email_pw', db: 'email_pw', ui: '이메일비밀번호' },
|
||||
SW_ID: { key: 'sw_id', db: 'sw_id', ui: '계정ID' },
|
||||
SW_PW: { key: 'sw_pw', db: 'sw_pw', ui: '비밀번호' },
|
||||
PURCHASE_METHOD:{ key: 'purchase_method', db: 'purchase_method', ui: '결제수단' },
|
||||
ASSET_PURPOSE: { key: 'asset_purpose', db: 'asset_purpose', ui: '용도' },
|
||||
ASSET_STATUS: { key: 'asset_status', db: 'asset_status', ui: '상태' },
|
||||
START_DATE: { key: 'start_date', db: 'start_date', ui: '시작일' },
|
||||
EXPIRED_DATE: { key: 'expired_date', db: 'expired_date', ui: '만료일' }
|
||||
};
|
||||
|
||||
/**
|
||||
* 페이지별 헤더 정보 (타이틀, 설명, 아이콘)
|
||||
*/
|
||||
export const PAGE_DESCRIPTIONS: Record<string, { title: string; description: string; icon: string }> = {
|
||||
'PC': {
|
||||
title: '개인PC 자산 관리',
|
||||
description: '임직원에게 지급된 데스크톱 및 노트북 자산의 할당 현황과 하드웨어 사양을 통합 관리합니다.',
|
||||
icon: 'laptop'
|
||||
},
|
||||
'서버': {
|
||||
title: '서버 자산 관리',
|
||||
description: 'IDC 및 사내 서버실에 운영 중인 물리 서버 장비의 도입, 운영, 폐기 현황을 관리합니다.',
|
||||
icon: 'server'
|
||||
},
|
||||
'스토리지': {
|
||||
title: '스토리지 자산 관리',
|
||||
description: '데이터 저장 및 백업을 위한 NAS, DAS 등 스토리지 장비의 용량과 연결 상태를 관리합니다.',
|
||||
icon: 'database'
|
||||
},
|
||||
'네트워크': {
|
||||
title: '네트워크 장비 관리',
|
||||
description: '스위치, 방화벽, 공유기 등 사내 네트워크 인프라를 구성하는 주요 장비 현황을 관리합니다.',
|
||||
icon: 'layers'
|
||||
},
|
||||
'업무지원장비': {
|
||||
title: '업무 지원 장비 관리',
|
||||
description: '모니터, 프린터, 스캐너 등 원활한 업무 수행을 보조하는 전산 비품들을 관리합니다.',
|
||||
icon: 'monitor'
|
||||
},
|
||||
'PC부품': {
|
||||
title: 'PC 부품 자산 관리',
|
||||
description: 'CPU, RAM, GPU 등 PC 조립 및 유지보수를 위해 보유 중인 주요 부품 재고를 관리합니다.',
|
||||
icon: 'cpu'
|
||||
},
|
||||
'공간정보장비': {
|
||||
title: '공간 정보 장비 관리',
|
||||
description: '측량 및 공간 정보 수집에 사용되는 특수 정밀 장비들의 이력과 상태를 관리합니다.',
|
||||
icon: 'map'
|
||||
},
|
||||
'내부SW': {
|
||||
title: '사내 개발 S/W 관리',
|
||||
description: '사내에서 자체 개발하거나 운영 중인 시스템 및 소프트웨어 서비스 현황을 관리합니다.',
|
||||
icon: 'code'
|
||||
},
|
||||
'외부SW': {
|
||||
title: '외부 상용 S/W 관리',
|
||||
description: '상용 소프트웨어의 라이선스 보유 현황, 사용자 할당 및 만료 일정을 관리합니다.',
|
||||
icon: 'package'
|
||||
},
|
||||
'도메인': {
|
||||
title: '도메인 자산 관리',
|
||||
description: '운영 중인 서비스 도메인의 등록 정보, 관리 업체 및 갱신 만료일을 관리합니다.',
|
||||
icon: 'globe'
|
||||
},
|
||||
'클라우드': {
|
||||
title: '클라우드 자산 관리',
|
||||
description: 'AWS, Azure, GCP 등 클라우드 인프라 자원 및 구독 서비스 이용 현황을 관리합니다.',
|
||||
icon: 'cloud'
|
||||
},
|
||||
'비용관리': {
|
||||
title: 'IT 비용 집행 관리',
|
||||
description: '전산 자산 도입 및 유지보수에 소요되는 정기/비정기 지출 비용을 통합 관리합니다.',
|
||||
icon: 'credit-card'
|
||||
},
|
||||
'선물': {
|
||||
title: '내빈/외빈 선물 관리',
|
||||
description: '내외빈 방문 시 지급되는 기념품 및 선물용 자산의 재고와 지급 이력을 관리합니다.',
|
||||
icon: 'gift'
|
||||
},
|
||||
'사무가구': {
|
||||
title: '사무용 가구 관리',
|
||||
description: '책상, 의자, 캐비닛 등 사무 환경 구성을 위한 가구 자산의 배치 현황을 관리합니다.',
|
||||
icon: 'armchair'
|
||||
},
|
||||
'사용자': {
|
||||
title: '임직원 사용자 관리',
|
||||
description: 'IT 자산 할당 및 관리의 기준이 되는 사내 임직원(사용자) 정보를 데이터베이스 기반으로 직접 등록하고 수정합니다.',
|
||||
icon: 'users'
|
||||
},
|
||||
'부품 마스터': {
|
||||
title: '부품 표준 정보 관리',
|
||||
description: 'PC 사양 적정성 평가의 기준이 되는 부품 표준 정보 및 등급별 감점 점수를 관리합니다.',
|
||||
icon: 'cpu'
|
||||
},
|
||||
'직무별 기준 사양': {
|
||||
title: '직무별 기준 사양 관리',
|
||||
description: 'BIM 모델러, 개발자, 엔지니어 등 사내 직무별 권장 하드웨어 기준 및 성능 합격 점수를 관리합니다.',
|
||||
icon: 'sliders'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 용어 사전 (UI 텍스트 전용)
|
||||
*/
|
||||
export const UI_TEXT = {
|
||||
ACTION: {
|
||||
ADD: '신규 등록',
|
||||
EDIT: '수정',
|
||||
SAVE: '저장',
|
||||
DELETE: '삭제',
|
||||
CANCEL: '취소',
|
||||
CLOSE: '닫기',
|
||||
HISTORY_ADD: '이력 추가',
|
||||
RESET_FILTER: '필터 초기화'
|
||||
},
|
||||
MESSAGES: {
|
||||
CONFIRM_DELETE: '정말로 삭제하시겠습니까?',
|
||||
SAVE_SUCCESS: '성공적으로 저장되었습니다.',
|
||||
NO_DATA: '검색 결과가 없습니다.'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,293 +1,293 @@
|
||||
import { HardwareAsset, SoftwareAsset, SWUser, HardwareLog, MasterAssetData, SystemUser } from './types';
|
||||
import { API_BASE_URL } from './utils';
|
||||
import { HardwareAsset, SoftwareAsset, SWUser, HardwareLog, MasterAssetData, SystemUser } from './types';
|
||||
import { API_BASE_URL } from './utils';
|
||||
|
||||
// --- State Definitions ---
|
||||
export interface AppState {
|
||||
activeCategory: 'dashboard' | 'hw' | 'sw' | 'ops' | 'vip' | 'fac' | 'users' | 'etc';
|
||||
activeSubTab: string;
|
||||
viewMode: 'location' | 'legacy' | 'list';
|
||||
masterData: MasterAssetData;
|
||||
activeCharts: any[];
|
||||
currentUserRole: 'admin' | 'user';
|
||||
listFilters?: Record<string, any>;
|
||||
}
|
||||
|
||||
// 초기 상태
|
||||
export const state: AppState = {
|
||||
activeCategory: 'hw',
|
||||
activeSubTab: '대시보드',
|
||||
viewMode: 'location',
|
||||
activeCharts: [],
|
||||
currentUserRole: 'user',
|
||||
listFilters: {},
|
||||
masterData: {
|
||||
users: [],
|
||||
pc: [], server: [], storage: [], network: [],
|
||||
survey: [], pcParts: [], partsMaster: [], equipment: [], officeSupplies: [],
|
||||
swInternal: [], swExternal: [], cloud: [], domain: [],
|
||||
cost: [], vip: [],
|
||||
hw: [], sw: [],
|
||||
swUsers: [], logs: [],
|
||||
jobSpecs: [],
|
||||
mobile: []
|
||||
}
|
||||
};
|
||||
|
||||
(window as any).__itam_state = state;
|
||||
|
||||
/**
|
||||
* 통합 V2 스키마에 맞춘 데이터 로드
|
||||
*/
|
||||
export async function loadMasterDataFromDB() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/assets/master`);
|
||||
if (!response.ok) throw new Error('Failed to fetch master data');
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// DB의 쪼개진 asset_remote 데이터로부터 가상 대표 속성(IP, MAC, 원격도구)을 주입해주는 전처리 함수
|
||||
const preprocessAssets = (assets: any[]) => {
|
||||
if (!Array.isArray(assets)) return;
|
||||
assets.forEach((asset: any) => {
|
||||
let ip = '';
|
||||
let mac = '';
|
||||
let remoteTool = '';
|
||||
let remoteId = '';
|
||||
// --- State Definitions ---
|
||||
export interface AppState {
|
||||
activeCategory: 'dashboard' | 'hw' | 'sw' | 'ops' | 'vip' | 'fac' | 'users' | 'etc';
|
||||
activeSubTab: string;
|
||||
viewMode: 'location' | 'legacy' | 'list';
|
||||
masterData: MasterAssetData;
|
||||
activeCharts: any[];
|
||||
currentUserRole: 'admin' | 'user';
|
||||
listFilters?: Record<string, any>;
|
||||
}
|
||||
|
||||
// 초기 상태
|
||||
export const state: AppState = {
|
||||
activeCategory: 'hw',
|
||||
activeSubTab: '대시보드',
|
||||
viewMode: 'location',
|
||||
activeCharts: [],
|
||||
currentUserRole: 'user',
|
||||
listFilters: {},
|
||||
masterData: {
|
||||
users: [],
|
||||
pc: [], server: [], storage: [], network: [],
|
||||
survey: [], pcParts: [], partsMaster: [], equipment: [], officeSupplies: [],
|
||||
swInternal: [], swExternal: [], cloud: [], domain: [],
|
||||
cost: [], vip: [],
|
||||
hw: [], sw: [],
|
||||
swUsers: [], logs: [],
|
||||
jobSpecs: [],
|
||||
mobile: []
|
||||
}
|
||||
};
|
||||
|
||||
(window as any).__itam_state = state;
|
||||
|
||||
/**
|
||||
* 통합 V2 스키마에 맞춘 데이터 로드
|
||||
*/
|
||||
export async function loadMasterDataFromDB() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/assets/master`);
|
||||
if (!response.ok) throw new Error('Failed to fetch master data');
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// DB의 쪼개진 asset_remote 데이터로부터 가상 대표 속성(IP, MAC, 원격도구)을 주입해주는 전처리 함수
|
||||
const preprocessAssets = (assets: any[]) => {
|
||||
if (!Array.isArray(assets)) return;
|
||||
assets.forEach((asset: any) => {
|
||||
let ip = '';
|
||||
let mac = '';
|
||||
let remoteTool = '';
|
||||
let remoteId = '';
|
||||
let remotePw = '';
|
||||
|
||||
let rems: any[] = [];
|
||||
try {
|
||||
rems = asset.remotes ? (typeof asset.remotes === 'string' ? JSON.parse(asset.remotes) : asset.remotes) : [];
|
||||
} catch(e) {}
|
||||
|
||||
if (Array.isArray(rems)) {
|
||||
rems.forEach((r: any) => {
|
||||
if (r.type === 'IP') {
|
||||
if (!ip) ip = r.val1 || '';
|
||||
if (r.val2) {
|
||||
if (String(r.val2).trim().startsWith('{')) {
|
||||
try {
|
||||
const parsed = JSON.parse(r.val2);
|
||||
remoteTool = r.name || '원격접속';
|
||||
remoteId = parsed.id || '';
|
||||
remotePw = parsed.pw || '';
|
||||
} catch(e) {}
|
||||
} else {
|
||||
if (!mac) mac = r.val2 || '';
|
||||
}
|
||||
}
|
||||
} else if (r.type === 'MAC') {
|
||||
if (!mac) mac = r.val1 || '';
|
||||
} else if (r.type === 'REMOTE') {
|
||||
if (!remoteTool) remoteTool = r.name || '';
|
||||
if (!remoteId) remoteId = r.val1 || '';
|
||||
if (!remotePw) remotePw = r.val2 || '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 최상위 가상 속성 바인딩 (목록 및 위치보기 뷰어 매핑용)
|
||||
asset.ip_address = ip;
|
||||
asset.mac_address = mac;
|
||||
asset.remote_tool = remoteTool;
|
||||
asset.remote_id = remoteId;
|
||||
asset.remote_pw = remotePw;
|
||||
});
|
||||
};
|
||||
|
||||
if (data) {
|
||||
const keys = ['pc', 'server', 'storage', 'network', 'survey', 'equipment', 'officeSupplies'];
|
||||
keys.forEach(k => {
|
||||
if (data[k]) preprocessAssets(data[k]);
|
||||
});
|
||||
}
|
||||
|
||||
// 전역 상태 업데이트
|
||||
state.masterData = {
|
||||
...state.masterData,
|
||||
...data,
|
||||
jobSpecs: data.jobSpecs || [],
|
||||
logs: (data.logs || []).map((l: any) => ({
|
||||
...l,
|
||||
assetId: l.asset_id || l.assetId,
|
||||
date: l.log_date || l.date,
|
||||
user: l.log_user || l.user,
|
||||
log_date: l.log_date || l.date,
|
||||
log_user: l.log_user || l.user
|
||||
}))
|
||||
};
|
||||
|
||||
// Mapping for backward compatibility
|
||||
(state.masterData as any).equip = state.masterData.equipment;
|
||||
(state.masterData as any).subSw = state.masterData.swExternal;
|
||||
(state.masterData as any).permSw = state.masterData.swInternal;
|
||||
|
||||
// 하드웨어 통합 (대시보드 호환용)
|
||||
state.masterData.hw = [
|
||||
...state.masterData.pc,
|
||||
...state.masterData.server,
|
||||
...state.masterData.storage,
|
||||
...state.masterData.network,
|
||||
...state.masterData.survey,
|
||||
...state.masterData.equipment,
|
||||
...state.masterData.officeSupplies
|
||||
];
|
||||
|
||||
// 소프트웨어 통합
|
||||
state.masterData.sw = [
|
||||
...state.masterData.swInternal,
|
||||
...state.masterData.swExternal,
|
||||
...(state.masterData.cloud || [])
|
||||
];
|
||||
|
||||
console.log('✅ V2 Normalized data loaded successfully');
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.warn('⚠️ Dummy 로드 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function updateState(newState: Partial<AppState>) {
|
||||
Object.assign(state, newState);
|
||||
}
|
||||
|
||||
/**
|
||||
* 자산 저장 (V2 Normalized API)
|
||||
*/
|
||||
export async function saveAsset(category: string, asset: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/asset/${category}/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(asset)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('자산 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 자산 삭제 (V2 API)
|
||||
*/
|
||||
export async function deleteAsset(category: string, assetId: string) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/asset/${category}/${assetId}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('자산 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function savePartsMaster(component: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/hardware-components/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(component)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('부품 마스터 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function deletePartsMaster(id: number) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/hardware-components/${id}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('부품 마스터 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function saveSystemUser(user: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/system-users/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(user)
|
||||
});
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('사용자 정보 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function deleteSystemUser(id: string) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/system-users/${id}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('사용자 정보 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function saveJobSpec(spec: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/job-specs/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(spec)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('직무별 기준 사양 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function deleteJobSpec(id: number) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/job-specs/${id}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('직무별 기준 사양 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
let rems: any[] = [];
|
||||
try {
|
||||
rems = asset.remotes ? (typeof asset.remotes === 'string' ? JSON.parse(asset.remotes) : asset.remotes) : [];
|
||||
} catch(e) {}
|
||||
|
||||
if (Array.isArray(rems)) {
|
||||
rems.forEach((r: any) => {
|
||||
if (r.type === 'IP') {
|
||||
if (!ip) ip = r.val1 || '';
|
||||
if (r.val2) {
|
||||
if (String(r.val2).trim().startsWith('{')) {
|
||||
try {
|
||||
const parsed = JSON.parse(r.val2);
|
||||
remoteTool = r.name || '원격접속';
|
||||
remoteId = parsed.id || '';
|
||||
remotePw = parsed.pw || '';
|
||||
} catch(e) {}
|
||||
} else {
|
||||
if (!mac) mac = r.val2 || '';
|
||||
}
|
||||
}
|
||||
} else if (r.type === 'MAC') {
|
||||
if (!mac) mac = r.val1 || '';
|
||||
} else if (r.type === 'REMOTE') {
|
||||
if (!remoteTool) remoteTool = r.name || '';
|
||||
if (!remoteId) remoteId = r.val1 || '';
|
||||
if (!remotePw) remotePw = r.val2 || '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 최상위 가상 속성 바인딩 (목록 및 위치보기 뷰어 매핑용)
|
||||
asset.ip_address = ip;
|
||||
asset.mac_address = mac;
|
||||
asset.remote_tool = remoteTool;
|
||||
asset.remote_id = remoteId;
|
||||
asset.remote_pw = remotePw;
|
||||
});
|
||||
};
|
||||
|
||||
if (data) {
|
||||
const keys = ['pc', 'server', 'storage', 'network', 'survey', 'equipment', 'officeSupplies'];
|
||||
keys.forEach(k => {
|
||||
if (data[k]) preprocessAssets(data[k]);
|
||||
});
|
||||
}
|
||||
|
||||
// 전역 상태 업데이트
|
||||
state.masterData = {
|
||||
...state.masterData,
|
||||
...data,
|
||||
jobSpecs: data.jobSpecs || [],
|
||||
logs: (data.logs || []).map((l: any) => ({
|
||||
...l,
|
||||
assetId: l.asset_id || l.assetId,
|
||||
date: l.log_date || l.date,
|
||||
user: l.log_user || l.user,
|
||||
log_date: l.log_date || l.date,
|
||||
log_user: l.log_user || l.user
|
||||
}))
|
||||
};
|
||||
|
||||
// Mapping for backward compatibility
|
||||
(state.masterData as any).equip = state.masterData.equipment;
|
||||
(state.masterData as any).subSw = state.masterData.swExternal;
|
||||
(state.masterData as any).permSw = state.masterData.swInternal;
|
||||
|
||||
// 하드웨어 통합 (대시보드 호환용)
|
||||
state.masterData.hw = [
|
||||
...state.masterData.pc,
|
||||
...state.masterData.server,
|
||||
...state.masterData.storage,
|
||||
...state.masterData.network,
|
||||
...state.masterData.survey,
|
||||
...state.masterData.equipment,
|
||||
...state.masterData.officeSupplies
|
||||
];
|
||||
|
||||
// 소프트웨어 통합
|
||||
state.masterData.sw = [
|
||||
...state.masterData.swInternal,
|
||||
...state.masterData.swExternal,
|
||||
...(state.masterData.cloud || [])
|
||||
];
|
||||
|
||||
console.log('✅ V2 Normalized data loaded successfully');
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.warn('⚠️ Dummy 로드 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function updateState(newState: Partial<AppState>) {
|
||||
Object.assign(state, newState);
|
||||
}
|
||||
|
||||
/**
|
||||
* 자산 저장 (V2 Normalized API)
|
||||
*/
|
||||
export async function saveAsset(category: string, asset: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/asset/${category}/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(asset)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('자산 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 자산 삭제 (V2 API)
|
||||
*/
|
||||
export async function deleteAsset(category: string, assetId: string) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/asset/${category}/${assetId}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('자산 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function savePartsMaster(component: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/hardware-components/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(component)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('부품 마스터 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function deletePartsMaster(id: number) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/hardware-components/${id}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('부품 마스터 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function saveSystemUser(user: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/system-users/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(user)
|
||||
});
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('사용자 정보 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function deleteSystemUser(id: string) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/system-users/${id}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('사용자 정보 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function saveJobSpec(spec: any) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/job-specs/save`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(spec)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('직무별 기준 사양 저장 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function deleteJobSpec(id: number) {
|
||||
try {
|
||||
const url = `${API_BASE_URL}/api/job-specs/${id}`;
|
||||
const response = await fetch(url, { method: 'DELETE' });
|
||||
|
||||
if (response.ok) {
|
||||
await loadMasterDataFromDB(); // 전역 상태 갱신
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('직무별 기준 사양 삭제 실패:', err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
/**
|
||||
* 공통 테이블 핸들러
|
||||
*/
|
||||
|
||||
export type SortDirection = 'asc' | 'desc';
|
||||
|
||||
export interface SortState {
|
||||
key: string;
|
||||
direction: SortDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 테이블 헤더에 정렬 이벤트를 바인딩합니다.
|
||||
* @param table 대상 테이블 요소
|
||||
* @param currentState 현재 정렬 상태
|
||||
* @param onSort 정렬 변경 시 호출될 콜백
|
||||
*/
|
||||
export function setupTableSorting(
|
||||
table: HTMLTableElement,
|
||||
currentState: SortState,
|
||||
onSort: (key: string, direction: SortDirection) => void
|
||||
) {
|
||||
const headers = table.querySelectorAll('th[data-sort]');
|
||||
|
||||
headers.forEach(th => {
|
||||
const key = th.getAttribute('data-sort')!;
|
||||
th.classList.add('sortable');
|
||||
|
||||
// 현재 정렬 상태 표시
|
||||
if (currentState.key === key) {
|
||||
th.classList.add(currentState.direction);
|
||||
} else {
|
||||
th.classList.remove('asc', 'desc');
|
||||
}
|
||||
|
||||
(th as HTMLElement).onclick = () => {
|
||||
let nextDirection: SortDirection = 'asc';
|
||||
|
||||
if (currentState.key === key) {
|
||||
nextDirection = currentState.direction === 'asc' ? 'desc' : 'asc';
|
||||
}
|
||||
|
||||
onSort(key, nextDirection);
|
||||
};
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 공통 테이블 핸들러
|
||||
*/
|
||||
|
||||
export type SortDirection = 'asc' | 'desc';
|
||||
|
||||
export interface SortState {
|
||||
key: string;
|
||||
direction: SortDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 테이블 헤더에 정렬 이벤트를 바인딩합니다.
|
||||
* @param table 대상 테이블 요소
|
||||
* @param currentState 현재 정렬 상태
|
||||
* @param onSort 정렬 변경 시 호출될 콜백
|
||||
*/
|
||||
export function setupTableSorting(
|
||||
table: HTMLTableElement,
|
||||
currentState: SortState,
|
||||
onSort: (key: string, direction: SortDirection) => void
|
||||
) {
|
||||
const headers = table.querySelectorAll('th[data-sort]');
|
||||
|
||||
headers.forEach(th => {
|
||||
const key = th.getAttribute('data-sort')!;
|
||||
th.classList.add('sortable');
|
||||
|
||||
// 현재 정렬 상태 표시
|
||||
if (currentState.key === key) {
|
||||
th.classList.add(currentState.direction);
|
||||
} else {
|
||||
th.classList.remove('asc', 'desc');
|
||||
}
|
||||
|
||||
(th as HTMLElement).onclick = () => {
|
||||
let nextDirection: SortDirection = 'asc';
|
||||
|
||||
if (currentState.key === key) {
|
||||
nextDirection = currentState.direction === 'asc' ? 'desc' : 'asc';
|
||||
}
|
||||
|
||||
onSort(key, nextDirection);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,155 +1,155 @@
|
||||
/**
|
||||
* ITAM Global Type Definitions
|
||||
*/
|
||||
|
||||
export interface BaseAsset {
|
||||
id: string;
|
||||
asset_code?: string;
|
||||
category?: string;
|
||||
asset_type?: string;
|
||||
purchase_corp?: string;
|
||||
purchase_date?: string;
|
||||
purchase_amount?: number | string;
|
||||
purchase_vendor?: string;
|
||||
approval_document?: string;
|
||||
service_type?: string;
|
||||
manager_primary?: string;
|
||||
manager_secondary?: string;
|
||||
location?: string;
|
||||
location_detail?: string;
|
||||
location_photo?: string;
|
||||
loc_x?: number;
|
||||
loc_y?: number;
|
||||
memo?: string;
|
||||
updated_at?: string;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface HardwareAsset extends BaseAsset {
|
||||
hw_status?: string;
|
||||
model_name?: string;
|
||||
asset_name?: string;
|
||||
asset_mfr?: string;
|
||||
current_dept?: string;
|
||||
previous_dept?: string;
|
||||
user_current?: string;
|
||||
emp_no?: string;
|
||||
user_position?: string;
|
||||
previous_user?: string;
|
||||
cpu?: string;
|
||||
ram?: string;
|
||||
gpu?: string;
|
||||
ssd_1?: string;
|
||||
ssd_2?: string;
|
||||
hdd_1?: string;
|
||||
hdd_2?: string;
|
||||
hdd_3?: string;
|
||||
hdd_4?: string;
|
||||
mainboard?: string;
|
||||
os?: string;
|
||||
ip_address?: string;
|
||||
ip_address_2?: string;
|
||||
mac_address?: string;
|
||||
remote_tool?: string;
|
||||
remote_id?: string;
|
||||
remote_pw?: string;
|
||||
monitoring?: string;
|
||||
volume?: string;
|
||||
monitor_inch?: string;
|
||||
asset_count?: number | string;
|
||||
serial_num?: string;
|
||||
// Normalized V3 fields
|
||||
volumes?: any[];
|
||||
remotes?: any[];
|
||||
}
|
||||
|
||||
export interface SoftwareAsset extends BaseAsset {
|
||||
sw_status?: string;
|
||||
sw_field?: string;
|
||||
sw_type?: string;
|
||||
dev_objective?: string;
|
||||
dev_manager?: string;
|
||||
planning_manager?: string;
|
||||
sales_manager?: string;
|
||||
product_name?: string;
|
||||
domain_address?: string;
|
||||
email_account?: string;
|
||||
email_pw?: string;
|
||||
sw_id?: string;
|
||||
sw_pw?: string;
|
||||
purchase_method?: string;
|
||||
asset_purpose?: string;
|
||||
asset_status?: string;
|
||||
start_date?: string;
|
||||
expired_date?: string;
|
||||
}
|
||||
|
||||
export interface SWUser {
|
||||
id: string;
|
||||
sw_id: string;
|
||||
user_name: string;
|
||||
dept: string;
|
||||
corp: string;
|
||||
emp_no?: string;
|
||||
created_at?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface HardwareLog {
|
||||
id: string;
|
||||
asset_id: string;
|
||||
log_date: string;
|
||||
log_user: string;
|
||||
event_type: string;
|
||||
details: string;
|
||||
old_dept?: string;
|
||||
new_dept?: string;
|
||||
old_user?: string;
|
||||
new_user?: string;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface SystemUser {
|
||||
id: string;
|
||||
emp_no: string;
|
||||
user_name: string;
|
||||
dept_name: string;
|
||||
position: string;
|
||||
status: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface PartsMaster {
|
||||
id: number | string;
|
||||
category: string;
|
||||
component_name: string;
|
||||
score_tier: string;
|
||||
deduction: number;
|
||||
}
|
||||
|
||||
export interface MasterAssetData {
|
||||
users: SystemUser[];
|
||||
pc: HardwareAsset[];
|
||||
server: HardwareAsset[];
|
||||
storage: HardwareAsset[];
|
||||
network: HardwareAsset[];
|
||||
survey: HardwareAsset[];
|
||||
pcParts: HardwareAsset[];
|
||||
partsMaster: PartsMaster[];
|
||||
equipment: HardwareAsset[];
|
||||
officeSupplies: HardwareAsset[];
|
||||
swInternal: SoftwareAsset[];
|
||||
swExternal: SoftwareAsset[];
|
||||
cloud: SoftwareAsset[];
|
||||
domain: SoftwareAsset[];
|
||||
cost: any[];
|
||||
vip: HardwareAsset[];
|
||||
swUsers: SWUser[];
|
||||
logs: HardwareLog[];
|
||||
jobSpecs?: any[];
|
||||
mobile?: HardwareAsset[];
|
||||
// Integrated arrays
|
||||
hw: HardwareAsset[];
|
||||
sw: SoftwareAsset[];
|
||||
}
|
||||
/**
|
||||
* ITAM Global Type Definitions
|
||||
*/
|
||||
|
||||
export interface BaseAsset {
|
||||
id: string;
|
||||
asset_code?: string;
|
||||
category?: string;
|
||||
asset_type?: string;
|
||||
purchase_corp?: string;
|
||||
purchase_date?: string;
|
||||
purchase_amount?: number | string;
|
||||
purchase_vendor?: string;
|
||||
approval_document?: string;
|
||||
service_type?: string;
|
||||
manager_primary?: string;
|
||||
manager_secondary?: string;
|
||||
location?: string;
|
||||
location_detail?: string;
|
||||
location_photo?: string;
|
||||
loc_x?: number;
|
||||
loc_y?: number;
|
||||
memo?: string;
|
||||
updated_at?: string;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface HardwareAsset extends BaseAsset {
|
||||
hw_status?: string;
|
||||
model_name?: string;
|
||||
asset_name?: string;
|
||||
asset_mfr?: string;
|
||||
current_dept?: string;
|
||||
previous_dept?: string;
|
||||
user_current?: string;
|
||||
emp_no?: string;
|
||||
user_position?: string;
|
||||
previous_user?: string;
|
||||
cpu?: string;
|
||||
ram?: string;
|
||||
gpu?: string;
|
||||
ssd_1?: string;
|
||||
ssd_2?: string;
|
||||
hdd_1?: string;
|
||||
hdd_2?: string;
|
||||
hdd_3?: string;
|
||||
hdd_4?: string;
|
||||
mainboard?: string;
|
||||
os?: string;
|
||||
ip_address?: string;
|
||||
ip_address_2?: string;
|
||||
mac_address?: string;
|
||||
remote_tool?: string;
|
||||
remote_id?: string;
|
||||
remote_pw?: string;
|
||||
monitoring?: string;
|
||||
volume?: string;
|
||||
monitor_inch?: string;
|
||||
asset_count?: number | string;
|
||||
serial_num?: string;
|
||||
// Normalized V3 fields
|
||||
volumes?: any[];
|
||||
remotes?: any[];
|
||||
}
|
||||
|
||||
export interface SoftwareAsset extends BaseAsset {
|
||||
sw_status?: string;
|
||||
sw_field?: string;
|
||||
sw_type?: string;
|
||||
dev_objective?: string;
|
||||
dev_manager?: string;
|
||||
planning_manager?: string;
|
||||
sales_manager?: string;
|
||||
product_name?: string;
|
||||
domain_address?: string;
|
||||
email_account?: string;
|
||||
email_pw?: string;
|
||||
sw_id?: string;
|
||||
sw_pw?: string;
|
||||
purchase_method?: string;
|
||||
asset_purpose?: string;
|
||||
asset_status?: string;
|
||||
start_date?: string;
|
||||
expired_date?: string;
|
||||
}
|
||||
|
||||
export interface SWUser {
|
||||
id: string;
|
||||
sw_id: string;
|
||||
user_name: string;
|
||||
dept: string;
|
||||
corp: string;
|
||||
emp_no?: string;
|
||||
created_at?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface HardwareLog {
|
||||
id: string;
|
||||
asset_id: string;
|
||||
log_date: string;
|
||||
log_user: string;
|
||||
event_type: string;
|
||||
details: string;
|
||||
old_dept?: string;
|
||||
new_dept?: string;
|
||||
old_user?: string;
|
||||
new_user?: string;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface SystemUser {
|
||||
id: string;
|
||||
emp_no: string;
|
||||
user_name: string;
|
||||
dept_name: string;
|
||||
position: string;
|
||||
status: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface PartsMaster {
|
||||
id: number | string;
|
||||
category: string;
|
||||
component_name: string;
|
||||
score_tier: string;
|
||||
deduction: number;
|
||||
}
|
||||
|
||||
export interface MasterAssetData {
|
||||
users: SystemUser[];
|
||||
pc: HardwareAsset[];
|
||||
server: HardwareAsset[];
|
||||
storage: HardwareAsset[];
|
||||
network: HardwareAsset[];
|
||||
survey: HardwareAsset[];
|
||||
pcParts: HardwareAsset[];
|
||||
partsMaster: PartsMaster[];
|
||||
equipment: HardwareAsset[];
|
||||
officeSupplies: HardwareAsset[];
|
||||
swInternal: SoftwareAsset[];
|
||||
swExternal: SoftwareAsset[];
|
||||
cloud: SoftwareAsset[];
|
||||
domain: SoftwareAsset[];
|
||||
cost: any[];
|
||||
vip: HardwareAsset[];
|
||||
swUsers: SWUser[];
|
||||
logs: HardwareLog[];
|
||||
jobSpecs?: any[];
|
||||
mobile?: HardwareAsset[];
|
||||
// Integrated arrays
|
||||
hw: HardwareAsset[];
|
||||
sw: SoftwareAsset[];
|
||||
}
|
||||
|
||||
@@ -1,359 +1,359 @@
|
||||
import { PAGE_DESCRIPTIONS } from './schema';
|
||||
|
||||
export const API_BASE_URL = '';
|
||||
|
||||
/**
|
||||
* ITAM 공통 유틸리티 함수
|
||||
*/
|
||||
|
||||
/**
|
||||
* 페이지 헤더(타이틀 및 설명) 렌더링
|
||||
*/
|
||||
export function renderPageHeader(container: HTMLElement, pageId: string) {
|
||||
const config = PAGE_DESCRIPTIONS[pageId];
|
||||
if (!config) return;
|
||||
|
||||
const header = document.createElement('div');
|
||||
header.className = 'page-header';
|
||||
header.innerHTML = `
|
||||
<div class="page-title-group">
|
||||
<h2 class="page-title">${config.title}</h2>
|
||||
<p class="page-description">${config.description}</p>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(header);
|
||||
}
|
||||
|
||||
/**
|
||||
* 숫자에 천 단위 콤마 추가 (금액 표시용)
|
||||
*/
|
||||
export function formatPrice(value: string | number): string {
|
||||
if (value === undefined || value === null) return '';
|
||||
const num = String(value).replace(/[^0-9]/g, '');
|
||||
if (!num) return '';
|
||||
return num.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML 배지 생성 (정/부 담당자, 원격도구 등)
|
||||
*/
|
||||
export function createBadge(text: string, type: 'primary' | 'muted' | 'success' | 'danger' = 'primary'): string {
|
||||
return `<span class="badge badge-${type}">${text}</span>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 텍스트 내 줄바꿈을 구분자(/)로 변경하여 한 줄로 표시
|
||||
*/
|
||||
export function formatInline(value: any): string {
|
||||
return String(value || '').replace(/\n/g, ' / ').trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 날짜 문자열 포맷팅 (YYYY.MM.DD -> YYYY-MM-DD)
|
||||
*/
|
||||
export function normalizeDate(dateStr: string): string {
|
||||
if (!dateStr) return '';
|
||||
let str = String(dateStr).replace(/\./g, '-').trim();
|
||||
// YYYYMM 형식 처리 (6자리 숫자)
|
||||
if (/^\d{6}$/.test(str)) {
|
||||
return `${str.substring(0, 4)}-${str.substring(4, 6)}`;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 구매일로부터 현재까지의 경과 연수 계산 (소수점 첫째자리)
|
||||
*/
|
||||
export function calculateAssetAge(purchaseDate: string): number {
|
||||
const normalized = normalizeDate(purchaseDate);
|
||||
if (!normalized) return 0;
|
||||
|
||||
const purchase = new Date(normalized);
|
||||
if (isNaN(purchase.getTime())) return 0;
|
||||
|
||||
const diffMs = Date.now() - purchase.getTime();
|
||||
const age = diffMs / (1000 * 60 * 60 * 24 * 365.25);
|
||||
return Math.max(0, parseFloat(age.toFixed(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 고유 ID 생성 (7자리 랜덤 문자열)
|
||||
*/
|
||||
export function generateId(): string {
|
||||
return Math.random().toString(36).substring(2, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* 두 자산 객체 간의 변경 사항 감지
|
||||
*/
|
||||
export function getAssetChanges(oldAsset: any, newAsset: any, fields: {key: string, label: string}[]): string {
|
||||
const changes: string[] = [];
|
||||
fields.forEach(field => {
|
||||
const oldVal = String(oldAsset[field.key] || '').trim();
|
||||
const newVal = String(newAsset[field.key] || '').trim();
|
||||
if (oldVal !== newVal) {
|
||||
changes.push(`${field.label}: ${oldVal || '없음'} → ${newVal || '없음'}`);
|
||||
}
|
||||
});
|
||||
return changes.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* 자산 목록 정렬 (기본: 법인별 -> 자산번호 순)
|
||||
*/
|
||||
export function sortAssets<T>(list: T[]): T[] {
|
||||
return [...list].sort((a: any, b: any) => {
|
||||
// 1순위: 법인 (가나다순)
|
||||
const corpA = String(a.법인 || a.corp || '').trim();
|
||||
const corpB = String(b.법인 || b.corp || '').trim();
|
||||
if (corpA < corpB) return -1;
|
||||
if (corpA > corpB) return 1;
|
||||
|
||||
// 2순위: 자산번호/코드 (영문/숫자순)
|
||||
const codeA = String(a.자산코드 || a.자산번호 || a.id || '').trim();
|
||||
const codeB = String(b.자산코드 || b.자산번호 || b.id || '').trim();
|
||||
if (codeA < codeB) return -1;
|
||||
if (codeA > codeB) return 1;
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 동적 정렬 함수
|
||||
* @param list 정렬할 목록
|
||||
* @param key 정렬 기준 필드
|
||||
* @param direction 정렬 방향 ('asc' | 'desc')
|
||||
*/
|
||||
export function dynamicSort<T>(list: T[], key: string, direction: 'asc' | 'desc'): T[] {
|
||||
return [...list].sort((a: any, b: any) => {
|
||||
let valA = a[key];
|
||||
let valB = b[key];
|
||||
|
||||
// 숫자인 경우 처리
|
||||
if (typeof valA === 'number' && typeof valB === 'number') {
|
||||
return direction === 'asc' ? valA - valB : valB - valA;
|
||||
}
|
||||
|
||||
// 금액 필드 (숫자형 문자열 포함) 처리
|
||||
if (key === '금액' || key === 'price' || key === '수량' || key === 'qty') {
|
||||
const numA = typeof valA === 'number' ? valA : parseInt(String(valA || '0').replace(/[^0-9-]/g, ''), 10);
|
||||
const numB = typeof valB === 'number' ? valB : parseInt(String(valB || '0').replace(/[^0-9-]/g, ''), 10);
|
||||
return direction === 'asc' ? numA - numB : numB - numA;
|
||||
}
|
||||
|
||||
// 문자열 정렬 (기본)
|
||||
valA = String(valA || '').toLowerCase();
|
||||
valB = String(valB || '').toLowerCase();
|
||||
|
||||
if (valA < valB) return direction === 'asc' ? -1 : 1;
|
||||
if (valA > valB) return direction === 'asc' ? 1 : -1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 뷰용 액션 버튼 HTML 생성 (중복 제거를 위해 비워둠)
|
||||
*/
|
||||
export function getActionButtonsHTML(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 100점 만점 감점형 PC 성능 점수 계산 (CPU + RAM + GPU + 연식)
|
||||
*/
|
||||
export function calculatePcScoreDeductive(cpu: string, ram: string, gpu: string, purchaseDate: string): number {
|
||||
let score = 100;
|
||||
if (!cpu) cpu = '';
|
||||
if (!ram) ram = '';
|
||||
if (!gpu) gpu = '';
|
||||
|
||||
const cpuUpper = cpu.toUpperCase();
|
||||
const ramUpper = ram.toUpperCase();
|
||||
const gpuUpper = gpu.toUpperCase();
|
||||
|
||||
// 1. CPU 등급 감점 (최대 -30점)
|
||||
let cpuDeduction = 0;
|
||||
if (cpuUpper.includes('I9') || cpuUpper.includes('RYZEN 9') || cpuUpper.includes('RYZEN9')) {
|
||||
cpuDeduction = 0;
|
||||
} else if (cpuUpper.includes('I7') || cpuUpper.includes('RYZEN 7') || cpuUpper.includes('RYZEN7')) {
|
||||
cpuDeduction = 5;
|
||||
} else if (cpuUpper.includes('I5') || cpuUpper.includes('RYZEN 5') || cpuUpper.includes('RYZEN5')) {
|
||||
cpuDeduction = 15;
|
||||
} else if (cpuUpper.includes('I3') || cpuUpper.includes('RYZEN 3') || cpuUpper.includes('RYZEN3')) {
|
||||
cpuDeduction = 25;
|
||||
} else {
|
||||
cpuDeduction = 30;
|
||||
}
|
||||
score -= cpuDeduction;
|
||||
|
||||
// 2. CPU 세대 노후 감점 (최대 -15점)
|
||||
let genDeduction = 0;
|
||||
const intelMatch = cpuUpper.match(/I\d-?(\d+)/);
|
||||
let gen = 0;
|
||||
if (intelMatch && intelMatch[1]) {
|
||||
const numStr = intelMatch[1];
|
||||
if (numStr.length === 5) gen = parseInt(numStr.substring(0, 2), 10);
|
||||
else if (numStr.length === 4) gen = parseInt(numStr.substring(0, 1), 10);
|
||||
}
|
||||
|
||||
const amdMatch = cpuUpper.match(/RYZEN\s?\d\s?-?(\d+)/);
|
||||
let amdGen = 0;
|
||||
if (amdMatch && amdMatch[1] && !intelMatch) {
|
||||
const numStr = amdMatch[1];
|
||||
if (numStr.length === 4) amdGen = parseInt(numStr.substring(0, 1), 10);
|
||||
}
|
||||
|
||||
if (intelMatch) {
|
||||
if (gen >= 12) genDeduction = 0;
|
||||
else if (gen >= 10) genDeduction = 5;
|
||||
else if (gen >= 8) genDeduction = 10;
|
||||
else genDeduction = 15;
|
||||
} else if (amdMatch) {
|
||||
if (amdGen >= 5) genDeduction = 0;
|
||||
else if (amdGen >= 3) genDeduction = 5;
|
||||
else genDeduction = 10;
|
||||
} else {
|
||||
genDeduction = 15;
|
||||
}
|
||||
score -= genDeduction;
|
||||
|
||||
// 3. RAM 용량 감점 (최대 -25점)
|
||||
const ramMatch = ramUpper.match(/(\d+)\s*GB/);
|
||||
let ramDeduction = 25;
|
||||
if (ramMatch && ramMatch[1]) {
|
||||
const ramVal = parseInt(ramMatch[1], 10);
|
||||
if (ramVal >= 32) ramDeduction = 0;
|
||||
else if (ramVal >= 16) ramDeduction = 10;
|
||||
else if (ramVal >= 8) ramDeduction = 20;
|
||||
else ramDeduction = 25;
|
||||
}
|
||||
score -= ramDeduction;
|
||||
|
||||
// 4. GPU 성능 감점 (최대 -25점)
|
||||
let gpuDeduction = 25;
|
||||
if (!gpuUpper || gpuUpper === '-' || gpuUpper.trim() === '') {
|
||||
gpuDeduction = 25;
|
||||
} else if (
|
||||
gpuUpper.includes('RTX 4090') || gpuUpper.includes('RTX 4080') || gpuUpper.includes('RTX 4070') ||
|
||||
gpuUpper.includes('RTX 3090') || gpuUpper.includes('RTX 3080') ||
|
||||
gpuUpper.includes('RTX A5000') || gpuUpper.includes('RTX A6000') || gpuUpper.includes('RTX A4000')
|
||||
) {
|
||||
gpuDeduction = 0;
|
||||
} else if (
|
||||
gpuUpper.includes('RTX 3070') || gpuUpper.includes('RTX 3060') || gpuUpper.includes('RTX 2060') ||
|
||||
gpuUpper.includes('RTX A2000') || gpuUpper.includes('RTX A3000') || gpuUpper.includes('QUADRO')
|
||||
) {
|
||||
gpuDeduction = 5;
|
||||
} else if (
|
||||
gpuUpper.includes('GTX 1660') || gpuUpper.includes('GTX 1080') || gpuUpper.includes('GTX 1070') ||
|
||||
gpuUpper.includes('GTX 1060') || gpuUpper.includes('RX 6700') || gpuUpper.includes('RX 6600')
|
||||
) {
|
||||
gpuDeduction = 15;
|
||||
} else {
|
||||
gpuDeduction = 25;
|
||||
}
|
||||
score -= gpuDeduction;
|
||||
|
||||
// 5. 연식(노후도) 감점 (최대 -15점)
|
||||
let age = 0;
|
||||
if (purchaseDate && purchaseDate !== '-') {
|
||||
let normalized = purchaseDate.replace(/\./g, '-').trim();
|
||||
if (/^\d{6}$/.test(normalized)) {
|
||||
normalized = `${normalized.substring(0, 4)}-${normalized.substring(4, 6)}`;
|
||||
}
|
||||
const purchase = new Date(normalized);
|
||||
if (!isNaN(purchase.getTime())) {
|
||||
// 2026년 5월 31일 기준 경과연수 계산
|
||||
const mockToday = new Date('2026-05-31');
|
||||
const diffMs = mockToday.getTime() - purchase.getTime();
|
||||
age = diffMs / (1000 * 60 * 60 * 24 * 365.25);
|
||||
age = Math.max(0, parseFloat(age.toFixed(1)));
|
||||
}
|
||||
}
|
||||
|
||||
let ageDeduction = 0;
|
||||
if (age < 1) ageDeduction = 0;
|
||||
else if (age < 2) ageDeduction = 3;
|
||||
else if (age < 3) ageDeduction = 6;
|
||||
else if (age < 4) ageDeduction = 9;
|
||||
else if (age < 5) ageDeduction = 12;
|
||||
else ageDeduction = 15;
|
||||
|
||||
score -= ageDeduction;
|
||||
|
||||
return Math.max(10, score);
|
||||
}
|
||||
|
||||
/**
|
||||
* 성능 점수 기준 등급 뱃지 메타 정보 가져오기
|
||||
*/
|
||||
export function getPcGrade(score: number, isWin11Incompatible?: boolean): { name: string; class: string; color: string } {
|
||||
if (score >= 85) return { name: '최상급', class: 'b-purple', color: '#7C3AED' };
|
||||
if (score >= 70) return { name: '상급', class: 'b-primary', color: '#4F46E5' };
|
||||
if (score >= 40) return { name: '중급', class: 'b-green', color: '#10B981' };
|
||||
if (score >= 20 && !isWin11Incompatible) return { name: '보급', class: 'b-yellow', color: '#F59E0B' };
|
||||
return { name: '교체 대상', class: 'badge-danger', color: '#EF4444' };
|
||||
}
|
||||
|
||||
/**
|
||||
* Windows 11 업그레이드 지원 불가능한 하드웨어 조건인지 판별
|
||||
*/
|
||||
export function isWindows11Incompatible(cpu: string, ram: string): boolean {
|
||||
if (!cpu) return true;
|
||||
const cpuUpper = cpu.toUpperCase();
|
||||
|
||||
// 1. RAM 4GB 미만은 공식 미지원
|
||||
if (ram) {
|
||||
const ramMatch = ram.toUpperCase().match(/(\d+)\s*GB/);
|
||||
if (ramMatch && ramMatch[1]) {
|
||||
const ramVal = parseInt(ramMatch[1], 10);
|
||||
if (ramVal < 4) return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. CPU 세대 검사
|
||||
// Intel CPU 세대 판정
|
||||
const intelMatch = cpuUpper.match(/I\d-?(\d+)/);
|
||||
if (intelMatch && intelMatch[1]) {
|
||||
const numStr = intelMatch[1];
|
||||
let gen = 0;
|
||||
if (numStr.length === 5) gen = parseInt(numStr.substring(0, 2), 10);
|
||||
else if (numStr.length === 4) gen = parseInt(numStr.substring(0, 1), 10);
|
||||
else if (numStr.length === 3) gen = parseInt(numStr.substring(0, 1), 10); // 3자리수 구형 세대 (예: i5-750)
|
||||
|
||||
if (gen > 0 && gen < 8) return true; // 8세대 미만 불가
|
||||
return false;
|
||||
}
|
||||
|
||||
// AMD Ryzen CPU 세대 판정
|
||||
const amdMatch = cpuUpper.match(/RYZEN\s?\d\s?-?(\d+)/);
|
||||
if (amdMatch && amdMatch[1]) {
|
||||
const numStr = amdMatch[1];
|
||||
let amdGen = 0;
|
||||
if (numStr.length === 4) amdGen = parseInt(numStr.substring(0, 1), 10); // 1xxx, 2xxx 등
|
||||
|
||||
if (amdGen > 0 && amdGen < 2) return true; // Ryzen 1세대 이하는 불가
|
||||
return false;
|
||||
}
|
||||
|
||||
// Apple Silicon은 지원
|
||||
if (cpuUpper.includes('APPLE') || cpuUpper.includes('M1') || cpuUpper.includes('M2') || cpuUpper.includes('M3') || cpuUpper.includes('M4')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 그 외 확실한 구형 CPU 제품군
|
||||
const knownOldCpus = ['CORE2', 'CORE 2', 'PENTIUM', 'CELERON', 'ATHLON', 'PHENOM', 'XEON'];
|
||||
if (knownOldCpus.some(name => cpuUpper.includes(name))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 세대 매칭은 안되었으나 Intel Core i 시리즈 구조이면 구형(1세대 등)으로 간주
|
||||
if (cpuUpper.includes('I3') || cpuUpper.includes('I5') || cpuUpper.includes('I7') || cpuUpper.includes('I9')) {
|
||||
// i5-620M 처럼 옛날 구형 모바일 칩 등
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
import { PAGE_DESCRIPTIONS } from './schema';
|
||||
|
||||
export const API_BASE_URL = '';
|
||||
|
||||
/**
|
||||
* ITAM 공통 유틸리티 함수
|
||||
*/
|
||||
|
||||
/**
|
||||
* 페이지 헤더(타이틀 및 설명) 렌더링
|
||||
*/
|
||||
export function renderPageHeader(container: HTMLElement, pageId: string) {
|
||||
const config = PAGE_DESCRIPTIONS[pageId];
|
||||
if (!config) return;
|
||||
|
||||
const header = document.createElement('div');
|
||||
header.className = 'page-header';
|
||||
header.innerHTML = `
|
||||
<div class="page-title-group">
|
||||
<h2 class="page-title">${config.title}</h2>
|
||||
<p class="page-description">${config.description}</p>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(header);
|
||||
}
|
||||
|
||||
/**
|
||||
* 숫자에 천 단위 콤마 추가 (금액 표시용)
|
||||
*/
|
||||
export function formatPrice(value: string | number): string {
|
||||
if (value === undefined || value === null) return '';
|
||||
const num = String(value).replace(/[^0-9]/g, '');
|
||||
if (!num) return '';
|
||||
return num.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML 배지 생성 (정/부 담당자, 원격도구 등)
|
||||
*/
|
||||
export function createBadge(text: string, type: 'primary' | 'muted' | 'success' | 'danger' = 'primary'): string {
|
||||
return `<span class="badge badge-${type}">${text}</span>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 텍스트 내 줄바꿈을 구분자(/)로 변경하여 한 줄로 표시
|
||||
*/
|
||||
export function formatInline(value: any): string {
|
||||
return String(value || '').replace(/\n/g, ' / ').trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 날짜 문자열 포맷팅 (YYYY.MM.DD -> YYYY-MM-DD)
|
||||
*/
|
||||
export function normalizeDate(dateStr: string): string {
|
||||
if (!dateStr) return '';
|
||||
let str = String(dateStr).replace(/\./g, '-').trim();
|
||||
// YYYYMM 형식 처리 (6자리 숫자)
|
||||
if (/^\d{6}$/.test(str)) {
|
||||
return `${str.substring(0, 4)}-${str.substring(4, 6)}`;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 구매일로부터 현재까지의 경과 연수 계산 (소수점 첫째자리)
|
||||
*/
|
||||
export function calculateAssetAge(purchaseDate: string): number {
|
||||
const normalized = normalizeDate(purchaseDate);
|
||||
if (!normalized) return 0;
|
||||
|
||||
const purchase = new Date(normalized);
|
||||
if (isNaN(purchase.getTime())) return 0;
|
||||
|
||||
const diffMs = Date.now() - purchase.getTime();
|
||||
const age = diffMs / (1000 * 60 * 60 * 24 * 365.25);
|
||||
return Math.max(0, parseFloat(age.toFixed(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 고유 ID 생성 (7자리 랜덤 문자열)
|
||||
*/
|
||||
export function generateId(): string {
|
||||
return Math.random().toString(36).substring(2, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* 두 자산 객체 간의 변경 사항 감지
|
||||
*/
|
||||
export function getAssetChanges(oldAsset: any, newAsset: any, fields: {key: string, label: string}[]): string {
|
||||
const changes: string[] = [];
|
||||
fields.forEach(field => {
|
||||
const oldVal = String(oldAsset[field.key] || '').trim();
|
||||
const newVal = String(newAsset[field.key] || '').trim();
|
||||
if (oldVal !== newVal) {
|
||||
changes.push(`${field.label}: ${oldVal || '없음'} → ${newVal || '없음'}`);
|
||||
}
|
||||
});
|
||||
return changes.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* 자산 목록 정렬 (기본: 법인별 -> 자산번호 순)
|
||||
*/
|
||||
export function sortAssets<T>(list: T[]): T[] {
|
||||
return [...list].sort((a: any, b: any) => {
|
||||
// 1순위: 법인 (가나다순)
|
||||
const corpA = String(a.법인 || a.corp || '').trim();
|
||||
const corpB = String(b.법인 || b.corp || '').trim();
|
||||
if (corpA < corpB) return -1;
|
||||
if (corpA > corpB) return 1;
|
||||
|
||||
// 2순위: 자산번호/코드 (영문/숫자순)
|
||||
const codeA = String(a.자산코드 || a.자산번호 || a.id || '').trim();
|
||||
const codeB = String(b.자산코드 || b.자산번호 || b.id || '').trim();
|
||||
if (codeA < codeB) return -1;
|
||||
if (codeA > codeB) return 1;
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 동적 정렬 함수
|
||||
* @param list 정렬할 목록
|
||||
* @param key 정렬 기준 필드
|
||||
* @param direction 정렬 방향 ('asc' | 'desc')
|
||||
*/
|
||||
export function dynamicSort<T>(list: T[], key: string, direction: 'asc' | 'desc'): T[] {
|
||||
return [...list].sort((a: any, b: any) => {
|
||||
let valA = a[key];
|
||||
let valB = b[key];
|
||||
|
||||
// 숫자인 경우 처리
|
||||
if (typeof valA === 'number' && typeof valB === 'number') {
|
||||
return direction === 'asc' ? valA - valB : valB - valA;
|
||||
}
|
||||
|
||||
// 금액 필드 (숫자형 문자열 포함) 처리
|
||||
if (key === '금액' || key === 'price' || key === '수량' || key === 'qty') {
|
||||
const numA = typeof valA === 'number' ? valA : parseInt(String(valA || '0').replace(/[^0-9-]/g, ''), 10);
|
||||
const numB = typeof valB === 'number' ? valB : parseInt(String(valB || '0').replace(/[^0-9-]/g, ''), 10);
|
||||
return direction === 'asc' ? numA - numB : numB - numA;
|
||||
}
|
||||
|
||||
// 문자열 정렬 (기본)
|
||||
valA = String(valA || '').toLowerCase();
|
||||
valB = String(valB || '').toLowerCase();
|
||||
|
||||
if (valA < valB) return direction === 'asc' ? -1 : 1;
|
||||
if (valA > valB) return direction === 'asc' ? 1 : -1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 뷰용 액션 버튼 HTML 생성 (중복 제거를 위해 비워둠)
|
||||
*/
|
||||
export function getActionButtonsHTML(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 100점 만점 감점형 PC 성능 점수 계산 (CPU + RAM + GPU + 연식)
|
||||
*/
|
||||
export function calculatePcScoreDeductive(cpu: string, ram: string, gpu: string, purchaseDate: string): number {
|
||||
let score = 100;
|
||||
if (!cpu) cpu = '';
|
||||
if (!ram) ram = '';
|
||||
if (!gpu) gpu = '';
|
||||
|
||||
const cpuUpper = cpu.toUpperCase();
|
||||
const ramUpper = ram.toUpperCase();
|
||||
const gpuUpper = gpu.toUpperCase();
|
||||
|
||||
// 1. CPU 등급 감점 (최대 -30점)
|
||||
let cpuDeduction = 0;
|
||||
if (cpuUpper.includes('I9') || cpuUpper.includes('RYZEN 9') || cpuUpper.includes('RYZEN9')) {
|
||||
cpuDeduction = 0;
|
||||
} else if (cpuUpper.includes('I7') || cpuUpper.includes('RYZEN 7') || cpuUpper.includes('RYZEN7')) {
|
||||
cpuDeduction = 5;
|
||||
} else if (cpuUpper.includes('I5') || cpuUpper.includes('RYZEN 5') || cpuUpper.includes('RYZEN5')) {
|
||||
cpuDeduction = 15;
|
||||
} else if (cpuUpper.includes('I3') || cpuUpper.includes('RYZEN 3') || cpuUpper.includes('RYZEN3')) {
|
||||
cpuDeduction = 25;
|
||||
} else {
|
||||
cpuDeduction = 30;
|
||||
}
|
||||
score -= cpuDeduction;
|
||||
|
||||
// 2. CPU 세대 노후 감점 (최대 -15점)
|
||||
let genDeduction = 0;
|
||||
const intelMatch = cpuUpper.match(/I\d-?(\d+)/);
|
||||
let gen = 0;
|
||||
if (intelMatch && intelMatch[1]) {
|
||||
const numStr = intelMatch[1];
|
||||
if (numStr.length === 5) gen = parseInt(numStr.substring(0, 2), 10);
|
||||
else if (numStr.length === 4) gen = parseInt(numStr.substring(0, 1), 10);
|
||||
}
|
||||
|
||||
const amdMatch = cpuUpper.match(/RYZEN\s?\d\s?-?(\d+)/);
|
||||
let amdGen = 0;
|
||||
if (amdMatch && amdMatch[1] && !intelMatch) {
|
||||
const numStr = amdMatch[1];
|
||||
if (numStr.length === 4) amdGen = parseInt(numStr.substring(0, 1), 10);
|
||||
}
|
||||
|
||||
if (intelMatch) {
|
||||
if (gen >= 12) genDeduction = 0;
|
||||
else if (gen >= 10) genDeduction = 5;
|
||||
else if (gen >= 8) genDeduction = 10;
|
||||
else genDeduction = 15;
|
||||
} else if (amdMatch) {
|
||||
if (amdGen >= 5) genDeduction = 0;
|
||||
else if (amdGen >= 3) genDeduction = 5;
|
||||
else genDeduction = 10;
|
||||
} else {
|
||||
genDeduction = 15;
|
||||
}
|
||||
score -= genDeduction;
|
||||
|
||||
// 3. RAM 용량 감점 (최대 -25점)
|
||||
const ramMatch = ramUpper.match(/(\d+)\s*GB/);
|
||||
let ramDeduction = 25;
|
||||
if (ramMatch && ramMatch[1]) {
|
||||
const ramVal = parseInt(ramMatch[1], 10);
|
||||
if (ramVal >= 32) ramDeduction = 0;
|
||||
else if (ramVal >= 16) ramDeduction = 10;
|
||||
else if (ramVal >= 8) ramDeduction = 20;
|
||||
else ramDeduction = 25;
|
||||
}
|
||||
score -= ramDeduction;
|
||||
|
||||
// 4. GPU 성능 감점 (최대 -25점)
|
||||
let gpuDeduction = 25;
|
||||
if (!gpuUpper || gpuUpper === '-' || gpuUpper.trim() === '') {
|
||||
gpuDeduction = 25;
|
||||
} else if (
|
||||
gpuUpper.includes('RTX 4090') || gpuUpper.includes('RTX 4080') || gpuUpper.includes('RTX 4070') ||
|
||||
gpuUpper.includes('RTX 3090') || gpuUpper.includes('RTX 3080') ||
|
||||
gpuUpper.includes('RTX A5000') || gpuUpper.includes('RTX A6000') || gpuUpper.includes('RTX A4000')
|
||||
) {
|
||||
gpuDeduction = 0;
|
||||
} else if (
|
||||
gpuUpper.includes('RTX 3070') || gpuUpper.includes('RTX 3060') || gpuUpper.includes('RTX 2060') ||
|
||||
gpuUpper.includes('RTX A2000') || gpuUpper.includes('RTX A3000') || gpuUpper.includes('QUADRO')
|
||||
) {
|
||||
gpuDeduction = 5;
|
||||
} else if (
|
||||
gpuUpper.includes('GTX 1660') || gpuUpper.includes('GTX 1080') || gpuUpper.includes('GTX 1070') ||
|
||||
gpuUpper.includes('GTX 1060') || gpuUpper.includes('RX 6700') || gpuUpper.includes('RX 6600')
|
||||
) {
|
||||
gpuDeduction = 15;
|
||||
} else {
|
||||
gpuDeduction = 25;
|
||||
}
|
||||
score -= gpuDeduction;
|
||||
|
||||
// 5. 연식(노후도) 감점 (최대 -15점)
|
||||
let age = 0;
|
||||
if (purchaseDate && purchaseDate !== '-') {
|
||||
let normalized = purchaseDate.replace(/\./g, '-').trim();
|
||||
if (/^\d{6}$/.test(normalized)) {
|
||||
normalized = `${normalized.substring(0, 4)}-${normalized.substring(4, 6)}`;
|
||||
}
|
||||
const purchase = new Date(normalized);
|
||||
if (!isNaN(purchase.getTime())) {
|
||||
// 2026년 5월 31일 기준 경과연수 계산
|
||||
const mockToday = new Date('2026-05-31');
|
||||
const diffMs = mockToday.getTime() - purchase.getTime();
|
||||
age = diffMs / (1000 * 60 * 60 * 24 * 365.25);
|
||||
age = Math.max(0, parseFloat(age.toFixed(1)));
|
||||
}
|
||||
}
|
||||
|
||||
let ageDeduction = 0;
|
||||
if (age < 1) ageDeduction = 0;
|
||||
else if (age < 2) ageDeduction = 3;
|
||||
else if (age < 3) ageDeduction = 6;
|
||||
else if (age < 4) ageDeduction = 9;
|
||||
else if (age < 5) ageDeduction = 12;
|
||||
else ageDeduction = 15;
|
||||
|
||||
score -= ageDeduction;
|
||||
|
||||
return Math.max(10, score);
|
||||
}
|
||||
|
||||
/**
|
||||
* 성능 점수 기준 등급 뱃지 메타 정보 가져오기
|
||||
*/
|
||||
export function getPcGrade(score: number, isWin11Incompatible?: boolean): { name: string; class: string; color: string } {
|
||||
if (score >= 85) return { name: '최상급', class: 'b-purple', color: '#7C3AED' };
|
||||
if (score >= 70) return { name: '상급', class: 'b-primary', color: '#4F46E5' };
|
||||
if (score >= 40) return { name: '중급', class: 'b-green', color: '#10B981' };
|
||||
if (score >= 20 && !isWin11Incompatible) return { name: '보급', class: 'b-yellow', color: '#F59E0B' };
|
||||
return { name: '교체 대상', class: 'badge-danger', color: '#EF4444' };
|
||||
}
|
||||
|
||||
/**
|
||||
* Windows 11 업그레이드 지원 불가능한 하드웨어 조건인지 판별
|
||||
*/
|
||||
export function isWindows11Incompatible(cpu: string, ram: string): boolean {
|
||||
if (!cpu) return true;
|
||||
const cpuUpper = cpu.toUpperCase();
|
||||
|
||||
// 1. RAM 4GB 미만은 공식 미지원
|
||||
if (ram) {
|
||||
const ramMatch = ram.toUpperCase().match(/(\d+)\s*GB/);
|
||||
if (ramMatch && ramMatch[1]) {
|
||||
const ramVal = parseInt(ramMatch[1], 10);
|
||||
if (ramVal < 4) return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. CPU 세대 검사
|
||||
// Intel CPU 세대 판정
|
||||
const intelMatch = cpuUpper.match(/I\d-?(\d+)/);
|
||||
if (intelMatch && intelMatch[1]) {
|
||||
const numStr = intelMatch[1];
|
||||
let gen = 0;
|
||||
if (numStr.length === 5) gen = parseInt(numStr.substring(0, 2), 10);
|
||||
else if (numStr.length === 4) gen = parseInt(numStr.substring(0, 1), 10);
|
||||
else if (numStr.length === 3) gen = parseInt(numStr.substring(0, 1), 10); // 3자리수 구형 세대 (예: i5-750)
|
||||
|
||||
if (gen > 0 && gen < 8) return true; // 8세대 미만 불가
|
||||
return false;
|
||||
}
|
||||
|
||||
// AMD Ryzen CPU 세대 판정
|
||||
const amdMatch = cpuUpper.match(/RYZEN\s?\d\s?-?(\d+)/);
|
||||
if (amdMatch && amdMatch[1]) {
|
||||
const numStr = amdMatch[1];
|
||||
let amdGen = 0;
|
||||
if (numStr.length === 4) amdGen = parseInt(numStr.substring(0, 1), 10); // 1xxx, 2xxx 등
|
||||
|
||||
if (amdGen > 0 && amdGen < 2) return true; // Ryzen 1세대 이하는 불가
|
||||
return false;
|
||||
}
|
||||
|
||||
// Apple Silicon은 지원
|
||||
if (cpuUpper.includes('APPLE') || cpuUpper.includes('M1') || cpuUpper.includes('M2') || cpuUpper.includes('M3') || cpuUpper.includes('M4')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 그 외 확실한 구형 CPU 제품군
|
||||
const knownOldCpus = ['CORE2', 'CORE 2', 'PENTIUM', 'CELERON', 'ATHLON', 'PHENOM', 'XEON'];
|
||||
if (knownOldCpus.some(name => cpuUpper.includes(name))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 세대 매칭은 안되었으나 Intel Core i 시리즈 구조이면 구형(1세대 등)으로 간주
|
||||
if (cpuUpper.includes('I3') || cpuUpper.includes('I5') || cpuUpper.includes('I7') || cpuUpper.includes('I9')) {
|
||||
// i5-620M 처럼 옛날 구형 모바일 칩 등
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user