feat(dispatch): 수퍼 관리자 전용 기간별 발송 수량 엑셀 다운로드
- GET /dispatch/period-export?date_from=&date_to= (서버 측 is_super_admin 검사, 최대 366일) - 시트 「날짜별」(날짜/아이템코드/상품이름/수량) + 「아이템별 요약」(아이템×날짜 피벗, 합계) - seller_sku _N 배수 반영, 콤보는 발송된 그대로(분해 안 함), 상품명은 itemcode_db 우선 - 배치 목록 오른쪽에 기간 선택 카드(수퍼 관리자에게만 표시) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -114,7 +114,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="erp-card dsp-calwrap">
|
||||
<div class="dsp-calwrap" style="display:flex;flex-direction:column;gap:16px;">
|
||||
<div class="erp-card" style="margin:0;">
|
||||
<div class="cpg-card-head"><h3 style="margin:0;" data-ko="사방넷 출고 다운로드" data-en="Sabangnet Outbound Download">사방넷 출고 다운로드</h3></div>
|
||||
<p class="erp-muted" style="margin:4px 0 10px;font-size:13px;"
|
||||
data-ko="날짜를 클릭하면 그날 출고를 낱개로 분해한 사방넷 출고 엑셀을 받습니다. 사방넷에 올리면 출고로 잡혀 재고가 차감됩니다."
|
||||
@@ -143,6 +144,24 @@
|
||||
<div id="dsp-cal-deduct-note" class="erp-muted" style="font-size:12px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if is_super %}
|
||||
<div class="erp-card" style="margin:0;">
|
||||
<div class="cpg-card-head"><h3 style="margin:0;" data-ko="기간별 발송 수량" data-en="Shipped Qty by Period">기간별 발송 수량</h3></div>
|
||||
<p class="erp-muted" style="margin:4px 0 10px;font-size:13px;"
|
||||
data-ko="기간 안 날짜별·아이템별 발송 수량을 엑셀로 받습니다. (수퍼 관리자 전용)"
|
||||
data-en="Download shipped quantities per date and item for the period. (Super admin only)">기간 안 날짜별·아이템별 발송 수량을 엑셀로 받습니다. (수퍼 관리자 전용)</p>
|
||||
<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap;">
|
||||
<input type="date" id="dsp-pe-from" class="erp-input" style="flex:1 1 120px;min-width:0;padding:7px 8px;border:1px solid #cbd5e1;border-radius:8px;" />
|
||||
<span class="erp-muted">~</span>
|
||||
<input type="date" id="dsp-pe-to" class="erp-input" style="flex:1 1 120px;min-width:0;padding:7px 8px;border:1px solid #cbd5e1;border-radius:8px;" />
|
||||
</div>
|
||||
<button type="button" id="dsp-pe-dl" class="erp-btn erp-btn-primary" style="margin-top:10px;width:100%;"
|
||||
data-ko="📊 기간별 발송 수량 엑셀 다운로드" data-en="📊 Download Shipped Qty Excel">📊 기간별 발송 수량 엑셀 다운로드</button>
|
||||
<div id="dsp-pe-note" class="erp-muted" style="font-size:12px;margin-top:6px;"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -264,6 +283,53 @@
|
||||
render();
|
||||
})();
|
||||
|
||||
// ── 기간별 발송 수량 엑셀(수퍼 관리자) ──
|
||||
(function () {
|
||||
var btn = document.getElementById('dsp-pe-dl');
|
||||
if (!btn) return;
|
||||
var fromEl = document.getElementById('dsp-pe-from');
|
||||
var toEl = document.getElementById('dsp-pe-to');
|
||||
var note = document.getElementById('dsp-pe-note');
|
||||
function pad(n) { return (n < 10 ? '0' : '') + n; }
|
||||
function iso(d) { return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()); }
|
||||
function en() { return (window.dspLang && window.dspLang() === 'en'); }
|
||||
// 기본: 이번 달 1일 ~ 오늘
|
||||
var now = new Date();
|
||||
fromEl.value = iso(new Date(now.getFullYear(), now.getMonth(), 1));
|
||||
toEl.value = iso(now);
|
||||
|
||||
btn.onclick = function () {
|
||||
var f = fromEl.value, t = toEl.value;
|
||||
if (!f || !t) { alert(en() ? 'Pick both dates.' : '시작일과 종료일을 고르세요.'); return; }
|
||||
btn.disabled = true;
|
||||
note.textContent = en() ? 'Preparing…' : '만드는 중…';
|
||||
var url = '/dispatch/period-export?date_from=' + encodeURIComponent(f) + '&date_to=' + encodeURIComponent(t);
|
||||
fetch(url)
|
||||
.then(function (r) {
|
||||
if (!r.ok) {
|
||||
return r.json().catch(function () { return {}; }).then(function (j) {
|
||||
throw new Error((j && j.detail) || ('HTTP ' + r.status));
|
||||
});
|
||||
}
|
||||
var cd = r.headers.get('Content-Disposition') || '';
|
||||
var m = cd.match(/filename\*=UTF-8''([^;]+)/);
|
||||
var name = m ? decodeURIComponent(m[1]) : ('shipped_' + f + '_' + t + '.xlsx');
|
||||
return r.blob().then(function (b) {
|
||||
var a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(b);
|
||||
a.download = name;
|
||||
document.body.appendChild(a); a.click(); a.remove();
|
||||
setTimeout(function () { URL.revokeObjectURL(a.href); }, 1000);
|
||||
note.textContent = '';
|
||||
});
|
||||
})
|
||||
.catch(function (e) {
|
||||
note.textContent = (e && e.message) || (en() ? 'Failed' : '실패');
|
||||
})
|
||||
.then(function () { btn.disabled = false; });
|
||||
};
|
||||
})();
|
||||
|
||||
// ── 받는 사람 찾기(이름/주문/패키지/송장 번호 부분 일치) ──
|
||||
(function () {
|
||||
var wrap = document.getElementById('dsp-search');
|
||||
|
||||
Reference in New Issue
Block a user