20260205 업데이트(컨텐츠 페이지 연결)
This commit is contained in:
@@ -16,13 +16,8 @@ export function openPurchaseHistoryPopup(memberId = '',isSuperAdmin='') {
|
||||
height: 600,
|
||||
modal: true,
|
||||
body:
|
||||
/*
|
||||
`
|
||||
<div style="padding:8px">
|
||||
<div id="purchaseHistoryGrid" style="height:520px;"></div>
|
||||
</div>
|
||||
*/
|
||||
`
|
||||
|
||||
`
|
||||
<div id="popupMainContainer" style="display: flex; flex-direction: column; height: 100%; padding: 10px; gap: 10px; box-sizing: border-box;">
|
||||
|
||||
<div id="searchFormArea" style="display: flex; align-items: center; gap: 10px; padding: 15px; background: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">
|
||||
@@ -31,7 +26,19 @@ export function openPurchaseHistoryPopup(memberId = '',isSuperAdmin='') {
|
||||
${!isSuperAdmin ? 'disabled' : ''}
|
||||
style="width: 150px; padding: 6px; border: 1px solid #ccc; border-radius: 4px;"
|
||||
placeholder="아이디 입력">
|
||||
|
||||
|
||||
<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;">
|
||||
검색
|
||||
@@ -45,21 +52,25 @@ export function openPurchaseHistoryPopup(memberId = '',isSuperAdmin='') {
|
||||
onOpen(event) {
|
||||
event.onComplete = () => {
|
||||
const searchBtn = document.getElementById('btnSearchHistory');
|
||||
const searchInput = document.getElementById('searchMemberId');
|
||||
const inputs = {
|
||||
mid: document.getElementById('searchMemberId'),
|
||||
fdt: document.getElementById('searchFbuydt'),
|
||||
tdt: document.getElementById('searchTbuydt')
|
||||
};
|
||||
|
||||
// 조회 버튼 클릭 시 동작
|
||||
// 1. 날짜 필드 캘린더 연결 (W2UI 스타일)
|
||||
if (inputs.fdt) inputs.fdt.type = 'date';
|
||||
if (inputs.tdt) inputs.tdt.type = 'date';
|
||||
|
||||
// 2. 조회 버튼 클릭
|
||||
if (searchBtn) {
|
||||
searchBtn.onclick = () => {
|
||||
loadPurchaseHistoryData(searchInput.value);
|
||||
};
|
||||
searchBtn.onclick = () => loadPurchaseHistoryData();
|
||||
}
|
||||
|
||||
// 엔터키 지원
|
||||
if (searchInput) {
|
||||
searchInput.onkeydown = (e) => {
|
||||
if (e.key === 'Enter') searchBtn.click();
|
||||
};
|
||||
}
|
||||
// 3. 모든 입력창 엔터키 지원
|
||||
Object.values(inputs).forEach(el => {
|
||||
if (el) el.onkeydown = (e) => { if (e.key === 'Enter') searchBtn.click(); };
|
||||
});
|
||||
|
||||
createPurchaseHistoryGrid(memberId);
|
||||
loadPurchaseHistoryData(memberId);
|
||||
@@ -78,44 +89,49 @@ function createPurchaseHistoryGrid(memberId) {
|
||||
lineNumbers: true // 행 번호를 표시하면 디버깅이 편합니다.
|
||||
},
|
||||
columns: [
|
||||
// field 이름이 PHP에서 내려주는 JSON 키값과 정확히 일치해야 함!
|
||||
{ field: 'member_id', text: '회원ID', size: '80px',style: 'text-align: center', attr: 'align=center',sortable: true }, // name 아님!
|
||||
{ field: 'sq_no', text: '순번', size: '50px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'user_nm', text: '구매자', size: '80px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'co_nm', text: '회사명', size: '100px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'bs_no', text: '사업자번호', size: '100px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'buy_dt', text: '구입일자', size: '80px',style: 'text-align: center', attr: 'align=center',sortable: true }, // name 아님!
|
||||
{ field: 'itm_nm', text: '상품명', size: '80px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'area', text: '상품면적', size: '80px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'itm_qty', text: '수량', size: '80px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'itm_area', text: '면적', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'add_area', text: '추가면적', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'sum_area', text: '합계면적', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'itm_amt', text: '단가', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'dis_rt', text: '할인율', size: '80px', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'buy_amt', text: '공급금액', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'vat_amt', text: '부가세', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'sum_amt', text: '합계', size: '100px',render: 'number:0' , attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'end_dt', text: '종료일', size: '80px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'ok_yn', text: '승인여부', size: '80px',style: 'text-align: center', attr: 'align=center' ,sortable: true}, // name 아님!
|
||||
{ field: 'rmks', text: '비고', size: '150px',style: 'text-align: center', attr: 'align=center' ,sortable: true} // name 아님!
|
||||
{ field: 'member_id', text: '회원ID', size: '80px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'sq_no', text: '순번', size: '50px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'user_nm', text: '구매자', size: '80px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'co_nm', text: '회사명', size: '100px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'bs_no', text: '사업자번호', size: '100px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'buy_dt', text: '구입일자', size: '80px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'itm_nm', text: '상품명', size: '80px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
|
||||
// --- 숫자/면적 데이터: 제목(center), 데이터(right) ---
|
||||
{ field: 'area', text: '상품면적', size: '80px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'itm_qty', text: '수량', size: '80px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'itm_area', text: '면적', size: '100px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'add_area', text: '추가면적', size: '100px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'sum_area', text: '합계면적', size: '100px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'itm_amt', text: '단가', size: '100px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'dis_rt', text: '할인율', size: '80px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'buy_amt', text: '공급금액', size: '100px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'vat_amt', text: '부가세', size: '100px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
{ field: 'sum_amt', text: '합계', size: '100px', render: 'number:0', style: 'text-align: center', attr: 'align=right', sortable: true },
|
||||
// --------------------------------------------------
|
||||
|
||||
{ field: 'end_dt', text: '종료일', size: '80px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'ok_yn', text: '승인여부', size: '80px', style: 'text-align: center', attr: 'align=center', sortable: true },
|
||||
{ field: 'rmks', text: '비고', size: '150px', style: 'text-align: center', attr: 'align=left', sortable: true }
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async function loadPurchaseHistoryData(memberId) {
|
||||
async function loadPurchaseHistoryData() {
|
||||
try {
|
||||
const grid = w2ui.purchaseHistoryGrid;
|
||||
if (!grid) return;
|
||||
|
||||
const sMid = document.getElementById('searchMemberId')?.value || '';
|
||||
const sfdt = document.getElementById('searchFbuydt')?.value || '';
|
||||
const stdt = document.getElementById('searchTbuydt')?.value || '';
|
||||
|
||||
grid.lock('조회 중...', true);
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('member_id', memberId);
|
||||
searchParams.append('member_nm', '');
|
||||
searchParams.append('fbuy_dt', '');
|
||||
searchParams.append('tbuy_dt', '');
|
||||
searchParams.append('member_id', sMid);
|
||||
searchParams.append('fbuy_dt', sfdt);
|
||||
searchParams.append('tbuy_dt', stdt);
|
||||
|
||||
const response = await fetch('/kngil/bbs/adm_purch_popup.php', {
|
||||
method: 'POST',
|
||||
@@ -123,22 +139,45 @@ async function loadPurchaseHistoryData(memberId) {
|
||||
body: searchParams
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error(`서버 응답 오류: ${response.status}`);
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
grid.clear();
|
||||
|
||||
if (data && data.length > 0) {
|
||||
// 1. 일반 데이터 추가
|
||||
grid.add(data);
|
||||
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error('응답 데이터 형식 오류');
|
||||
// 2. 합계(Summary) 계산
|
||||
let totals = {
|
||||
recid: 'summary',
|
||||
w2ui: { summary: true, style: 'background-color: #efefef; font-weight: bold;' },
|
||||
user_nm: '합계', // 합계 문구를 표시할 컬럼
|
||||
area: 0, itm_area: 0, add_area: 0, sum_area: 0,
|
||||
itm_amt: 0, buy_amt: 0, vat_amt: 0, sum_amt: 0
|
||||
};
|
||||
|
||||
data.forEach(row => {
|
||||
totals.area += Number(row.area || 0);
|
||||
totals.itm_area += Number(row.itm_area || 0);
|
||||
totals.add_area += Number(row.add_area || 0);
|
||||
totals.sum_area += Number(row.sum_area || 0);
|
||||
totals.itm_amt += Number(row.itm_amt || 0);
|
||||
totals.buy_amt += Number(row.buy_amt || 0);
|
||||
totals.vat_amt += Number(row.vat_amt || 0);
|
||||
totals.sum_amt += Number(row.sum_amt || 0);
|
||||
});
|
||||
|
||||
// 3. 그리드 하단에 합계 행 주입
|
||||
grid.summary = [totals];
|
||||
}
|
||||
|
||||
grid.clear();
|
||||
grid.add(data);
|
||||
grid.unlock();
|
||||
grid.refresh(); // 변경사항 반영
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
if (w2ui.purchaseHistoryGrid) w2ui.purchaseHistoryGrid.unlock();
|
||||
w2alert('구매이력 조회 실패: ' + e.message);
|
||||
w2alert('조회 실패: ' + e.message);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user