feat(rx-usage): 주문 모달 개선 - 버튼 3분할 + 총액 표시
- 🧪 테스트 / 🛒 장바구니만 / 🚀 즉시주문 버튼 분리 - cart_only 파라미터로 장바구니만 담기 기능 지원 - 주문 확인 모달에 총액 표시 추가 - 모달 너비 확장 (600px/650px)
This commit is contained in:
parent
a672c7a2a0
commit
442815b65e
@ -1224,7 +1224,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 선택된 도매상 전체 일괄 처리
|
// 선택된 도매상 전체 일괄 처리
|
||||||
async function executeAllWholesalers(dryRun = false) {
|
async function executeAllWholesalers(dryRun = false, cartOnly = false) {
|
||||||
const wsIds = Object.keys(pendingWholesalerItems);
|
const wsIds = Object.keys(pendingWholesalerItems);
|
||||||
|
|
||||||
// 체크된 도매상만 필터
|
// 체크된 도매상만 필터
|
||||||
@ -1240,10 +1240,20 @@
|
|||||||
|
|
||||||
// 버튼 비활성화
|
// 버튼 비활성화
|
||||||
const btnTest = document.getElementById('btnMultiTest');
|
const btnTest = document.getElementById('btnMultiTest');
|
||||||
|
const btnCart = document.getElementById('btnMultiCart');
|
||||||
const btnReal = document.getElementById('btnMultiReal');
|
const btnReal = document.getElementById('btnMultiReal');
|
||||||
btnTest.disabled = true;
|
btnTest.disabled = true;
|
||||||
|
btnCart.disabled = true;
|
||||||
btnReal.disabled = true;
|
btnReal.disabled = true;
|
||||||
btnReal.textContent = '처리 중...';
|
|
||||||
|
// 진행 상태 표시
|
||||||
|
if (dryRun) {
|
||||||
|
btnTest.textContent = '처리 중...';
|
||||||
|
} else if (cartOnly) {
|
||||||
|
btnCart.textContent = '처리 중...';
|
||||||
|
} else {
|
||||||
|
btnReal.textContent = '처리 중...';
|
||||||
|
}
|
||||||
|
|
||||||
const allResults = [];
|
const allResults = [];
|
||||||
let totalSuccess = 0;
|
let totalSuccess = 0;
|
||||||
@ -1272,7 +1282,7 @@
|
|||||||
})),
|
})),
|
||||||
reference_period: `${document.getElementById('startDate').value}~${document.getElementById('endDate').value}`,
|
reference_period: `${document.getElementById('startDate').value}~${document.getElementById('endDate').value}`,
|
||||||
dry_run: dryRun,
|
dry_run: dryRun,
|
||||||
cart_only: false // 장바구니 + 주문 확정까지
|
cart_only: cartOnly // true=장바구니만, false=즉시주문
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch('/api/order/quick-submit', {
|
const response = await fetch('/api/order/quick-submit', {
|
||||||
@ -1311,12 +1321,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeMultiWholesalerModal();
|
closeMultiWholesalerModal();
|
||||||
showMultiOrderResultModal(allResults, totalSuccess, totalFailed, dryRun);
|
showMultiOrderResultModal(allResults, totalSuccess, totalFailed, dryRun, cartOnly);
|
||||||
|
|
||||||
// 버튼 복원
|
// 버튼 복원
|
||||||
btnTest.disabled = false;
|
btnTest.disabled = false;
|
||||||
|
btnCart.disabled = false;
|
||||||
btnReal.disabled = false;
|
btnReal.disabled = false;
|
||||||
btnReal.textContent = '📤 전체 주문 전송';
|
btnTest.textContent = '🧪 테스트';
|
||||||
|
btnCart.textContent = '🛒 장바구니만';
|
||||||
|
btnReal.textContent = '🚀 전체 즉시주문';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 특정 품목만 클립보드 복사
|
// 특정 품목만 클립보드 복사
|
||||||
@ -1329,7 +1342,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 다중 도매상 결과 모달
|
// 다중 도매상 결과 모달
|
||||||
function showMultiOrderResultModal(results, totalSuccess, totalFailed, isDryRun) {
|
function showMultiOrderResultModal(results, totalSuccess, totalFailed, isDryRun, isCartOnly = false) {
|
||||||
const modal = document.getElementById('orderResultModal');
|
const modal = document.getElementById('orderResultModal');
|
||||||
const content = document.getElementById('orderResultContent');
|
const content = document.getElementById('orderResultContent');
|
||||||
const header = modal.querySelector('.order-modal-header h3');
|
const header = modal.querySelector('.order-modal-header h3');
|
||||||
@ -1339,7 +1352,7 @@
|
|||||||
header.innerHTML = '📋 전체 주문 결과';
|
header.innerHTML = '📋 전체 주문 결과';
|
||||||
|
|
||||||
const statusEmoji = totalFailed === 0 ? '✅' : totalSuccess === 0 ? '❌' : '⚠️';
|
const statusEmoji = totalFailed === 0 ? '✅' : totalSuccess === 0 ? '❌' : '⚠️';
|
||||||
const modeText = isDryRun ? '[테스트]' : '';
|
const modeText = isDryRun ? '[테스트]' : isCartOnly ? '[장바구니]' : '';
|
||||||
|
|
||||||
let html = `
|
let html = `
|
||||||
<div class="result-header ${totalFailed === 0 ? 'success' : 'partial'}">
|
<div class="result-header ${totalFailed === 0 ? 'success' : 'partial'}">
|
||||||
@ -1419,17 +1432,28 @@
|
|||||||
headerDiv.style.background = ws.gradient;
|
headerDiv.style.background = ws.gradient;
|
||||||
|
|
||||||
let html = '';
|
let html = '';
|
||||||
|
let totalAmount = 0;
|
||||||
|
|
||||||
items.forEach((item, idx) => {
|
items.forEach((item, idx) => {
|
||||||
|
// 예상 금액 계산 (단가 × 수량)
|
||||||
|
const unitPrice = item.unit_price || item.price || 0;
|
||||||
|
const itemAmount = unitPrice * item.qty;
|
||||||
|
totalAmount += itemAmount;
|
||||||
|
|
||||||
html += `
|
html += `
|
||||||
<tr>
|
<tr>
|
||||||
<td>${escapeHtml(item.product_name)}</td>
|
<td>${escapeHtml(item.product_name)}</td>
|
||||||
<td class="mono">${item.specification || '-'}</td>
|
<td class="mono">${item.specification || '-'}</td>
|
||||||
<td class="mono">${item.qty}</td>
|
<td class="mono" style="text-align:center;">${item.qty}</td>
|
||||||
|
<td class="mono" style="text-align:right;">${itemAmount > 0 ? itemAmount.toLocaleString() + '원' : '-'}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
tbody.innerHTML = html;
|
tbody.innerHTML = html;
|
||||||
document.getElementById('orderConfirmCount').textContent = items.length;
|
document.getElementById('orderConfirmCount').textContent = items.length;
|
||||||
|
document.getElementById('orderConfirmTotal').innerHTML = totalAmount > 0
|
||||||
|
? `₩${totalAmount.toLocaleString()}`
|
||||||
|
: '<span style="font-size:12px;color:var(--text-muted);">금액 미정</span>';
|
||||||
modal.classList.add('show');
|
modal.classList.add('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1508,7 +1532,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function executeOrder(dryRun = true) {
|
async function executeOrder(dryRun = true, cartOnly = false) {
|
||||||
const wholesaler = currentOrderWholesaler || 'geoyoung';
|
const wholesaler = currentOrderWholesaler || 'geoyoung';
|
||||||
|
|
||||||
// 해당 도매상 품목 필터
|
// 해당 도매상 품목 필터
|
||||||
@ -1522,11 +1546,20 @@
|
|||||||
|
|
||||||
// 버튼 비활성화
|
// 버튼 비활성화
|
||||||
const btnTest = document.getElementById('btnOrderTest');
|
const btnTest = document.getElementById('btnOrderTest');
|
||||||
|
const btnCart = document.getElementById('btnOrderCart');
|
||||||
const btnReal = document.getElementById('btnOrderReal');
|
const btnReal = document.getElementById('btnOrderReal');
|
||||||
btnTest.disabled = true;
|
btnTest.disabled = true;
|
||||||
|
btnCart.disabled = true;
|
||||||
btnReal.disabled = true;
|
btnReal.disabled = true;
|
||||||
btnTest.textContent = dryRun ? '처리 중...' : '🧪 테스트';
|
|
||||||
btnReal.textContent = !dryRun ? '처리 중...' : '🛒 장바구니 담기';
|
// 진행 상태 표시
|
||||||
|
if (dryRun) {
|
||||||
|
btnTest.textContent = '처리 중...';
|
||||||
|
} else if (cartOnly) {
|
||||||
|
btnCart.textContent = '처리 중...';
|
||||||
|
} else {
|
||||||
|
btnReal.textContent = '처리 중...';
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
@ -1544,7 +1577,7 @@
|
|||||||
})),
|
})),
|
||||||
reference_period: `${document.getElementById('startDate').value}~${document.getElementById('endDate').value}`,
|
reference_period: `${document.getElementById('startDate').value}~${document.getElementById('endDate').value}`,
|
||||||
dry_run: dryRun,
|
dry_run: dryRun,
|
||||||
cart_only: false // 장바구니 + 주문 확정까지
|
cart_only: cartOnly // true=장바구니만, false=즉시주문
|
||||||
};
|
};
|
||||||
|
|
||||||
// 타임아웃 설정
|
// 타임아웃 설정
|
||||||
@ -1576,9 +1609,11 @@
|
|||||||
showToast(`❌ 오류: ${err.message}`, 'error');
|
showToast(`❌ 오류: ${err.message}`, 'error');
|
||||||
} finally {
|
} finally {
|
||||||
btnTest.disabled = false;
|
btnTest.disabled = false;
|
||||||
|
btnCart.disabled = false;
|
||||||
btnReal.disabled = false;
|
btnReal.disabled = false;
|
||||||
btnTest.textContent = '🧪 테스트';
|
btnTest.textContent = '🧪 테스트';
|
||||||
btnReal.textContent = '📤 주문 전송';
|
btnCart.textContent = '🛒 장바구니만';
|
||||||
|
btnReal.textContent = '🚀 즉시주문';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2536,26 +2571,32 @@
|
|||||||
|
|
||||||
<!-- 주문 확인 모달 -->
|
<!-- 주문 확인 모달 -->
|
||||||
<div class="order-modal" id="orderConfirmModal">
|
<div class="order-modal" id="orderConfirmModal">
|
||||||
<div class="order-modal-content">
|
<div class="order-modal-content" style="max-width:600px;">
|
||||||
<div class="order-modal-header">
|
<div class="order-modal-header">
|
||||||
<h3 id="orderConfirmTitle">🏭 지오영 주문 확인</h3>
|
<h3 id="orderConfirmTitle">🏭 지오영 주문 확인</h3>
|
||||||
<button class="order-close" onclick="closeOrderConfirmModal()">✕</button>
|
<button class="order-close" onclick="closeOrderConfirmModal()">✕</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="order-modal-body">
|
<div class="order-modal-body">
|
||||||
<p style="margin-bottom:12px;color:var(--text-secondary);">
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
|
||||||
<span id="orderConfirmCount">0</span>개 품목을 <span id="orderConfirmWholesaler">지오영</span> 장바구니에 담습니다.
|
<p style="color:var(--text-secondary);margin:0;">
|
||||||
</p>
|
<span id="orderConfirmCount">0</span>개 품목을 <span id="orderConfirmWholesaler">지오영</span> 장바구니에 담습니다.
|
||||||
|
</p>
|
||||||
|
<div id="orderConfirmTotal" style="font-size:18px;font-weight:700;color:var(--accent-cyan);font-family:'JetBrains Mono',monospace;">
|
||||||
|
₩0
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<p style="margin-bottom:12px;font-size:12px;color:var(--accent-amber);">
|
<p style="margin-bottom:12px;font-size:12px;color:var(--accent-amber);">
|
||||||
⚠️ 장바구니 담기만 진행됩니다. 도매상 사이트에서 최종 확정이 필요합니다.
|
⚠️ 장바구니 담기만 진행됩니다. 도매상 사이트에서 최종 확정이 필요합니다.
|
||||||
</p>
|
</p>
|
||||||
<table class="order-confirm-table">
|
<table class="order-confirm-table">
|
||||||
<thead><tr><th>품목명</th><th>규격</th><th>수량</th></tr></thead>
|
<thead><tr><th>품목명</th><th>규격</th><th>수량</th><th style="text-align:right;">예상금액</th></tr></thead>
|
||||||
<tbody id="orderConfirmBody"></tbody>
|
<tbody id="orderConfirmBody"></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="order-modal-footer">
|
<div class="order-modal-footer" style="gap:8px;">
|
||||||
<button class="btn-order-test" id="btnOrderTest" onclick="executeOrder(true)">🧪 테스트</button>
|
<button class="btn-order-test" id="btnOrderTest" onclick="executeOrder(true, false)">🧪 테스트</button>
|
||||||
<button class="btn-order-real" id="btnOrderReal" onclick="executeOrder(false)">📤 주문 전송</button>
|
<button class="btn-order-cart" id="btnOrderCart" onclick="executeOrder(false, true)" style="background:linear-gradient(135deg, #0891b2, #06b6d4);">🛒 장바구니만</button>
|
||||||
|
<button class="btn-order-real" id="btnOrderReal" onclick="executeOrder(false, false)">🚀 즉시주문</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -2577,16 +2618,17 @@
|
|||||||
|
|
||||||
<!-- 다중 도매상 선택 모달 -->
|
<!-- 다중 도매상 선택 모달 -->
|
||||||
<div class="order-modal" id="multiWholesalerModal">
|
<div class="order-modal" id="multiWholesalerModal">
|
||||||
<div class="order-modal-content" style="max-width:550px;">
|
<div class="order-modal-content" style="max-width:650px;">
|
||||||
<div class="order-modal-header" style="background:linear-gradient(135deg, #059669, #10b981);">
|
<div class="order-modal-header" style="background:linear-gradient(135deg, #059669, #10b981);">
|
||||||
<h3>🛒 전체 도매상 주문</h3>
|
<h3>🛒 전체 도매상 주문</h3>
|
||||||
<button class="order-close" onclick="closeMultiWholesalerModal()">✕</button>
|
<button class="order-close" onclick="closeMultiWholesalerModal()">✕</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="order-modal-body" id="multiWholesalerBody">
|
<div class="order-modal-body" id="multiWholesalerBody">
|
||||||
</div>
|
</div>
|
||||||
<div class="order-modal-footer">
|
<div class="order-modal-footer" style="gap:8px;">
|
||||||
<button class="btn-order-test" id="btnMultiTest" onclick="executeAllWholesalers(true)">🧪 테스트</button>
|
<button class="btn-order-test" id="btnMultiTest" onclick="executeAllWholesalers(true, false)">🧪 테스트</button>
|
||||||
<button class="btn-order-real" id="btnMultiReal" onclick="executeAllWholesalers(false)">📤 전체 주문 전송</button>
|
<button class="btn-order-cart" id="btnMultiCart" onclick="executeAllWholesalers(false, true)" style="background:linear-gradient(135deg, #0891b2, #06b6d4);">🛒 장바구니만</button>
|
||||||
|
<button class="btn-order-real" id="btnMultiReal" onclick="executeAllWholesalers(false, false)">🚀 전체 즉시주문</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user