20260205 업데이트(컨텐츠 페이지 연결)

This commit is contained in:
2026-02-05 10:06:09 +09:00
parent 5d52f6d37a
commit 6dcc2eb796
208 changed files with 8143 additions and 1524 deletions

View File

@@ -1,4 +1,4 @@
import { w2grid, w2ui, w2popup, w2alert } from 'https://cdn.jsdelivr.net/gh/vitmalina/w2ui@master/dist/w2ui.es6.min.js'
import { w2grid, w2ui, w2popup, w2alert} from 'https://cdn.jsdelivr.net/gh/vitmalina/w2ui@master/dist/w2ui.es6.min.js'
// 파일이 실제 존재하는지 확인 필수! 존재하지 않으면 아래 코드가 모두 멈춥니다.
import { bindProductPopupEvents } from '/kngil/js/adm_common.js'
@@ -49,6 +49,18 @@ export function openuseHistoryPopup(memberId = '',isSuperAdmin='') {
placeholder="부서명 입력">
</div>
<div style="display: flex; align-items: center; gap: 5px;"> <span style="font-weight: bold; color: #333; white-space: nowrap;">구입일</span>
<input type="date" id="searchFbuydt"
style="width: 130px; padding: 4px; border: 1px solid #ccc; border-radius: 4px;">
<span style="color: #666;">~</span>
<input type="date" id="searchTbuydt"
style="width: 130px; padding: 4px; border: 1px solid #ccc; border-radius: 4px;">
</div>
<button id="btnSearchHistory"
style="padding: 6px 20px; background: #1565c0; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; margin-left: auto;">
검색
@@ -61,27 +73,33 @@ export function openuseHistoryPopup(memberId = '',isSuperAdmin='') {
`,
onOpen(event) {
event.onComplete = () => {
const searchBtn = document.getElementById('btnSearchHistory');
const searchInput = document.getElementById('searchMemberId');
const inputUnm = document.getElementById('searchUserNm');
const inputDnm = document.getElementById('searchDeptNm');
// 조회 버튼 클릭 시 동작
if (searchBtn) {
searchBtn.onclick = () => {
loadUseHistoryData(searchInput.value,inputUnm,inputDnm);
};
}
const searchBtn = document.getElementById('btnSearchHistory');
const inputs = {
mid: document.getElementById('searchMemberId'),
unm: document.getElementById('searchUserNm'),
dnm: document.getElementById('searchDeptNm'),
fdt: document.getElementById('searchFbuydt'),
tdt: document.getElementById('searchTbuydt')
};
// 엔터키 지원
if (searchInput,inputUnm,inputDnm) {
searchInput.onkeydown = (e) => {
if (e.key === 'Enter') searchBtn.click();
};
}
// 1. 날짜 필드 캘린더 연결 (W2UI 스타일)
if (inputs.fdt) inputs.fdt.type = 'date';
if (inputs.tdt) inputs.tdt.type = 'date';
createUseHistoryGrid(memberId);
loadUseHistoryData(memberId);
// 2. 조회 버튼 클릭
if (searchBtn) {
searchBtn.onclick = () => loadUseHistoryData();
}
// 3. 모든 입력창 엔터키 지원
Object.values(inputs).forEach(el => {
if (el) el.onkeydown = (e) => { if (e.key === 'Enter') searchBtn.click(); };
});
// 4. 초기 그리드 생성 및 데이터 로드
createUseHistoryGrid(memberId);
loadUseHistoryData();
}
}
});
@@ -96,21 +114,25 @@ function createUseHistoryGrid(memberId) {
footer: true,
lineNumbers: true // 행 번호를 표시하면 디버깅이 편합니다.
},
columns: [
// field 이름이 PHP에서 내려주는 JSON 키값과 정확히 일치해야 함!
{ field: 'member_id', text: '회원ID', size: '100px',style: 'text-align: center', attr: 'align=center',hidden: true }, // name 아님!
{ field: 'use_dt', text: '사용자', size: '100px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
{ field: 'user_id', text: '사용자ID', size: '100px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
{ field: 'sq_no', text: '순번', size: '100px',style: 'text-align: center', attr: 'align=center' ,hidden: true}, // name 아님!
{ field: 'user_nm', text: '성명', size: '100px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
{ field: 'dept_nm', text: '부서', size: '100px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
{ field: 'posit_nm', text: '직위', size: '100px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
{ field: 'use_yn', text: '사용여부', size: '80px', attr: 'align=center' ,sortable: true}, // name 아님!
{ field: 'use_area', text: '사용면적', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
{ field: 'ser_bc', text: '서비스구분', size: '150px', attr: 'align=center' ,sortable: true}, // name 아님!
]
columns: [
{ field: 'use_dt', text: '사용일자', size: '100px',
style: 'text-align: center', attr: 'align=center', sortable: true },
{ field: 'user_id', text: '사용자ID', size: '100px',
style: 'text-align: center', attr: 'align=center', sortable: true },
{ field: 'user_nm', text: '성명', size: '100px',
style: 'text-align: center', attr: 'align=center', sortable: true },
{ field: 'dept_nm', text: '부서', size: '120px',
tyle: 'text-align: center', attr: 'align=center', sortable: true },
{ field: 'posit_nm', text: '직위', size: '100px',
style: 'text-align: center', attr: 'align=center', sortable: true },
{ field: 'use_yn', text: '사용여부', size: '80px',
style: 'text-align: center', attr: 'align=center', sortable: true },
// 사용면적: 제목은 가운데(style), 숫자는 오른쪽(attr)이 데이터 가독성에 좋습니다.
{ field: 'use_area', text: '사용면적', size: '100px', render: 'number:0',
style: 'text-align: center', attr: 'align=right', sortable: true },
{ field: 'ser_bc', text: '서비스구분', size: '200px',
style: 'text-align: center', attr: 'align=center', sortable: true },
]
});
}
@@ -119,10 +141,11 @@ async function loadUseHistoryData(memberId = ''){
const grid = w2ui.UseHistoryGrid;
if (!grid) return;
// DOM에서 현재 입력된 값을 실시간으로 읽어옴
const sMid = document.getElementById('searchMemberId')?.value || '';
const sUnm = document.getElementById('searchUserNm')?.value || '';
const sDnm = document.getElementById('searchDeptNm')?.value || '';
const sfdt = document.getElementById('searchFbuydt')?.value || '';
const stdt = document.getElementById('searchTbuydt')?.value || '';
grid.lock('조회 중...', true);
@@ -130,6 +153,8 @@ async function loadUseHistoryData(memberId = ''){
searchParams.append('member_id', sMid);
searchParams.append('user_nm', sUnm);
searchParams.append('dept_nm', sDnm);
searchParams.append('fuse_dt', sfdt);
searchParams.append('tuse_dt', stdt);
const response = await fetch('/kngil/bbs/adm_use_history.php', {
method: 'POST',
@@ -146,8 +171,33 @@ async function loadUseHistoryData(memberId = ''){
}
grid.clear();
grid.add(data);
// --- 합계 계산 로직 시작 ---
if (data.length > 0) {
// 일반 데이터 추가
grid.add(data);
// 합계 변수 초기화
let totalArea = 0;
data.forEach(item => {
// 숫자가 아닌 값이 올 경우를 대비해 Number() 처리
totalArea += Number(item.use_area || 0);
});
// Summary 행 생성
grid.summary = [{
recid: 'summary',
w2ui: { summary: true, style: 'background-color: #f0f0f0; font-weight: bold;' },
use_dt: '합 계', // 합계 문구를 노출할 위치 (보통 첫 번째나 두 번째 컬럼)
use_area: totalArea // 계산된 합계값
}];
} else {
grid.summary = []; // 데이터가 없으면 합계행 비우기
}
// --- 합계 계산 로직 끝 ---
grid.unlock();
grid.refresh(); // 변경된 summary 정보를 화면에 반영
} catch (e) {
console.error(e);
@@ -155,4 +205,3 @@ async function loadUseHistoryData(memberId = ''){
w2alert('사용이력 조회 실패: ' + e.message);
}
}
////////////////////////////////////////////////////////////////////////