feat: migrate ServerPC data to asset_pc, enhance filters with location, and standardize page headers
- 서버PC 자산을 asset_pc 테이블로 통합 마이그레이션 및 스키마 확장 (위치, IP 정보 복구 완료) - 하드웨어 자산 페이지의 구매법인 필터를 자산위치 필터로 교체 및 동적 데이터 바인딩 적용 - 모든 자산 리스트 페이지 상단에 설명(Description) 필드 추가 및 헤더 표준화 - 상세 모달 내 삭제 버튼 기능 구현 및 서버PC 용도 필드 노출 오류 수정 - 현 사용조직 필터 리스트가 비어있던 DOM 셀렉터 버그 수정
This commit is contained in:
@@ -1,38 +1,23 @@
|
||||
import { state } from '../../core/state';
|
||||
import { openSwModal } from '../../components/Modal/SWModal';
|
||||
import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema';
|
||||
import { dynamicSort, getActionButtonsHTML } from '../../core/utils';
|
||||
import { dynamicSort, formatInline, getActionButtonsHTML, renderPageHeader } from '../../core/utils';
|
||||
import { setupTableSorting, SortState } from '../../core/tableHandler';
|
||||
import { createIcons, Cloud, CreditCard, DollarSign, RefreshCcw, Download, Upload, FileSpreadsheet, Plus } from 'lucide';
|
||||
import { renderFilterBar, applyCommonFilters } from '../../core/filterHandler';
|
||||
import { createIcons, Cloud, CreditCard, DollarSign, RefreshCcw, Plus } from 'lucide';
|
||||
|
||||
/**
|
||||
* 클라우드(운영 서비스) 자산 목록 뷰
|
||||
* 라인 정렬 보정 및 헤더 통일
|
||||
*/
|
||||
export function renderCloudList(container: HTMLElement) {
|
||||
const getFullList = () => state.masterData.cloud || [];
|
||||
renderPageHeader(container, '클라우드');
|
||||
|
||||
const fullList = state.masterData.cloud || [];
|
||||
let sortState: SortState = { key: '', direction: 'asc' };
|
||||
let currentFilters = { keyword: '', corp: '', dept: '', field: '' };
|
||||
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'search-bar';
|
||||
filterBar.innerHTML = `
|
||||
<div class="search-item flex-1">
|
||||
<label>통합 검색 (${ASSET_SCHEMA.PRODUCT_NAME.ui}/${ASSET_SCHEMA.CURRENT_DEPT.ui}/${ASSET_SCHEMA.EMAIL_ACCOUNT.ui})</label>
|
||||
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<label>${ASSET_SCHEMA.PURCHASE_METHOD.ui}</label>
|
||||
<select id="filter-payment">
|
||||
<option value="">전체 결제수단</option>
|
||||
<option value="법인카드">법인카드</option>
|
||||
<option value="인보이스">인보이스 (월별송금)</option>
|
||||
</select>
|
||||
</div>
|
||||
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
|
||||
<i data-lucide="refresh-ccw"></i> ${UI_TEXT.ACTION.RESET_FILTER}
|
||||
</button>
|
||||
${getActionButtonsHTML()}
|
||||
`;
|
||||
container.appendChild(filterBar);
|
||||
|
||||
const tableWrapper = document.createElement('div');
|
||||
@@ -41,12 +26,11 @@ export function renderCloudList(container: HTMLElement) {
|
||||
table.innerHTML = `
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center" style="width:50px;">No.</th>
|
||||
<th data-sort="${ASSET_SCHEMA.PRODUCT_NAME.key}">${ASSET_SCHEMA.PRODUCT_NAME.ui}</th>
|
||||
<th data-sort="${ASSET_SCHEMA.ASSET_PURPOSE.key}">${ASSET_SCHEMA.ASSET_PURPOSE.ui}</th>
|
||||
<th data-sort="${ASSET_SCHEMA.PURCHASE_VENDOR.key}">${ASSET_SCHEMA.PURCHASE_VENDOR.ui}</th>
|
||||
<th class="text-center" data-sort="${ASSET_SCHEMA.PURCHASE_AMOUNT.key}">${ASSET_SCHEMA.PURCHASE_AMOUNT.ui}</th>
|
||||
<th style="width: 30%;">${ASSET_SCHEMA.MEMO.ui}</th>
|
||||
<th class="col-memo" data-sort="${ASSET_SCHEMA.MEMO.key}">${ASSET_SCHEMA.MEMO.ui}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="cloud-tbody"></tbody>
|
||||
@@ -57,20 +41,7 @@ export function renderCloudList(container: HTMLElement) {
|
||||
const tbody = table.querySelector('tbody')!;
|
||||
|
||||
const updateTable = () => {
|
||||
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
|
||||
const paymentSelect = document.getElementById('filter-payment') as HTMLSelectElement;
|
||||
|
||||
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
|
||||
const payment = paymentSelect ? paymentSelect.value : '';
|
||||
|
||||
let filtered = getFullList().filter(asset => {
|
||||
const kwMatch = !keyword ||
|
||||
(asset[ASSET_SCHEMA.PRODUCT_NAME.key] || '').toLowerCase().includes(keyword) ||
|
||||
(asset[ASSET_SCHEMA.ASSET_PURPOSE.key] || '').toLowerCase().includes(keyword) ||
|
||||
(asset[ASSET_SCHEMA.PURCHASE_VENDOR.key] || '').toLowerCase().includes(keyword);
|
||||
const payMatch = !payment || asset[ASSET_SCHEMA.PURCHASE_METHOD.key] === payment;
|
||||
return kwMatch && payMatch;
|
||||
});
|
||||
let filtered = applyCommonFilters(fullList, currentFilters, ['PRODUCT_NAME', 'ASSET_PURPOSE', 'PURCHASE_VENDOR']);
|
||||
|
||||
if (sortState.key) {
|
||||
filtered = dynamicSort(filtered, sortState.key, sortState.direction);
|
||||
@@ -78,7 +49,7 @@ export function renderCloudList(container: HTMLElement) {
|
||||
|
||||
tbody.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="6" class="text-center" style="padding: 3rem; color: var(--text-muted);">${UI_TEXT.MESSAGES.NO_DATA}</td></tr>`;
|
||||
tbody.innerHTML = `<tr><td colspan="5" class="text-center" style="padding: 3rem; color: var(--text-muted);">${UI_TEXT.MESSAGES.NO_DATA}</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,12 +58,11 @@ export function renderCloudList(container: HTMLElement) {
|
||||
tr.style.cursor = 'pointer';
|
||||
|
||||
tr.innerHTML = `
|
||||
<td class="text-center">${idx+1}</td>
|
||||
<td>${asset[ASSET_SCHEMA.PRODUCT_NAME.key]||''}</td>
|
||||
<td>${asset[ASSET_SCHEMA.ASSET_PURPOSE.key]||''}</td>
|
||||
<td>${asset[ASSET_SCHEMA.PURCHASE_VENDOR.key]||''}</td>
|
||||
<td class="text-right" style="font-weight:600;">₩ ${asset[ASSET_SCHEMA.PURCHASE_AMOUNT.key] ? Number(String(asset[ASSET_SCHEMA.PURCHASE_AMOUNT.key]).replace(/,/g, '')).toLocaleString() : '0'}</td>
|
||||
<td>${formatInline(asset[ASSET_SCHEMA.MEMO.key]||'')}</td>
|
||||
<td class="col-memo">${formatInline(asset[ASSET_SCHEMA.MEMO.key]||'')}</td>
|
||||
`;
|
||||
|
||||
tr.addEventListener('click', () => openSwModal(asset, 'view'));
|
||||
@@ -104,16 +74,31 @@ export function renderCloudList(container: HTMLElement) {
|
||||
updateTable();
|
||||
});
|
||||
|
||||
createIcons({ icons: { Cloud, CreditCard, DollarSign, RefreshCcw, Download, Upload, FileSpreadsheet, Plus } });
|
||||
createIcons({ icons: { Cloud, CreditCard, DollarSign, RefreshCcw, Plus } });
|
||||
};
|
||||
|
||||
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
|
||||
document.getElementById('filter-payment')?.addEventListener('change', updateTable);
|
||||
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
|
||||
if (document.getElementById('filter-keyword')) (document.getElementById('filter-keyword') as HTMLInputElement).value = '';
|
||||
if (document.getElementById('filter-payment')) (document.getElementById('filter-payment') as HTMLSelectElement).value = '';
|
||||
updateTable();
|
||||
renderFilterBar(filterBar, {
|
||||
keywordLabel: `통합 검색 (${ASSET_SCHEMA.PRODUCT_NAME.ui}/${ASSET_SCHEMA.PURCHASE_VENDOR.ui})`,
|
||||
showCorp: true,
|
||||
showDept: true,
|
||||
onFilterChange: (filters) => {
|
||||
currentFilters = filters;
|
||||
updateTable();
|
||||
}
|
||||
});
|
||||
|
||||
// Populate Dept Options
|
||||
const deptSelect = container.querySelector('#filter-dept') as HTMLSelectElement;
|
||||
if (deptSelect) {
|
||||
const orgUnits = Array.from(new Set(fullList.map(a => a[ASSET_SCHEMA.CURRENT_DEPT.key]))).filter(Boolean).sort();
|
||||
orgUnits.forEach(dept => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(dept);
|
||||
opt.textContent = String(dept);
|
||||
deptSelect.appendChild(opt);
|
||||
});
|
||||
}
|
||||
|
||||
updateTable();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user