feat(입출고): 봉투·백 합계 줄에 파렛트 그림 표시

새 발주서 합계 줄의 봉투·백도 통처럼 파렛트 그림으로 보여 주고,
"통·뚜껑과 따로 셈" 글자를 뺀다. 1파렛트 박스 수가 다른 상품이 섞이면
가장 큰 값으로 환산해 잔량은 %만 표시하고, 그림은 60칸까지만 그린다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 15:34:54 +09:00
parent 307a0c31b1
commit 57745e114e
7 changed files with 34 additions and 21 deletions
+23 -12
View File
@@ -107,22 +107,25 @@
'<rect class="io-pal-base" x="1" y="' + (H + 3) + '" width="5" height="3"/><rect class="io-pal-base" x="' + (W / 2 - 2.5) + '" y="' + (H + 3) + '" width="5" height="3"/>' +
'<rect class="io-pal-base" x="' + (W - 6) + '" y="' + (H + 3) + '" width="5" height="3"/></svg>';
}
function palletVis(all) {
// cap = 1파렛트 박스 수. mixed = 1파렛트 박스 수가 다른 봉투·백이 섞임 — all 은 cap 기준 환산값이라 잔량은 %만 보여 준다.
function palletVis(all, cap, mixed) {
if (!all) return "";
const full = Math.floor(all / palletBoxes), rem = all % palletBoxes, MAX = 10;
const full = Math.floor(all / cap), rem = all % cap, MAX = 10;
const cells = Math.min(cap, 60); // cap 은 입력값 — 아주 커도 그림 칸 수는 60칸까지(비율로 칠함)
let html = "";
if (full) {
let icons = "";
for (let i = 0; i < Math.min(full, MAX); i++) icons += palletSvg(palletBoxes, palletBoxes);
for (let i = 0; i < Math.min(full, MAX); i++) icons += palletSvg(cells, cells);
html += '<span class="io-pal-group" title="꽉 찬 파렛트 ' + full + '개">' + icons +
(full > MAX ? '<span class="io-pal-more">+' + (full - MAX) + "</span>" : "") +
'<span class="io-pal-cap">꽉 찬 파렛트 <b>' + fmt(full) + "</b></span></span>";
}
if (rem) {
const pct = Math.round(rem / palletBoxes * 100);
html += '<span class="io-pal-group is-rem" title="잔량 파렛트 ' + rem + "/" + palletBoxes + '박스">' + palletSvg(rem, palletBoxes) +
'<span class="io-pal-cap">잔량 <b>' + rem + "</b>박스 · <b>" + pct + "%</b><br>" +
'<span class="io-pal-need">' + (palletBoxes - rem) + "박스 더 실으면 한 파렛트</span></span></span>";
const pct = Math.round(rem / cap * 100);
const drawn = Math.min(cells - 1, Math.max(1, Math.round(rem / cap * cells)));
html += '<span class="io-pal-group is-rem" title="잔량 파렛트 ' + (mixed ? pct + "%" : rem + "/" + cap + "박스") + '">' + palletSvg(drawn, cells) +
'<span class="io-pal-cap">잔량 ' + (mixed ? "<b>" + pct + "%</b></span></span>" : "<b>" + rem + "</b>박스 · <b>" + pct + "%</b><br>" +
'<span class="io-pal-need">' + (cap - rem) + "박스 더 실으면 한 파렛트</span></span></span>");
} else {
html += '<span class="io-pal-ok">✓ 모든 파렛트가 꽉 찹니다</span>';
}
@@ -131,7 +134,7 @@
function renumber() {
let q = 0, k = 0, amount = 0, missing = 0;
let bodyBoxes = 0, lidBoxes = 0, unset = 0;
let bagLines = 0, bagBoxes = 0, bagShare = 0, bagUnset = 0;
let bagLines = 0, bagBoxes = 0, bagCapped = 0, bagShare = 0, bagCap = 0, bagMixed = false, bagUnset = 0;
body.querySelectorAll(".io-line").forEach(function (tr, i) {
tr.querySelector(".io-col-no").textContent = String(i + 1);
const n = num(tr.querySelector(".io-qty").value);
@@ -146,7 +149,12 @@
const cap = parseInt(tr.dataset.palletBox || "0", 10) || 0;
bagLines++;
bagBoxes += bx.body;
if (cap) bagShare += bx.body / cap; // 1파렛트 박스 수가 다른 봉투·백은 차지하는 비율로 더함
if (cap) { // 1파렛트 박스 수가 다른 봉투·백은 차지하는 비율로 더함
bagCapped += bx.body;
bagShare += bx.body / cap;
if (bagCap && cap !== bagCap) bagMixed = true;
bagCap = Math.max(bagCap, cap);
}
if (bx.unset || !cap) bagUnset++;
} else {
bodyBoxes += bx.body; lidBoxes += bx.lid; if (bx.unset) unset++;
@@ -161,15 +169,18 @@
const all = bodyBoxes + lidBoxes, pallets = Math.ceil(all / palletBoxes);
const set = function (key, v) { pallet.querySelector('[data-k="' + key + '"]').textContent = v; };
set("body", fmt(bodyBoxes)); set("lid", fmt(lidBoxes)); set("boxes", fmt(all)); set("pallets", fmt(pallets));
pallet.querySelector('[data-k="vis"]').innerHTML = palletVis(all);
pallet.querySelector('[data-k="vis"]').innerHTML = palletVis(all, palletBoxes);
set("note", "1파렛트 = " + palletBoxes + "박스" + (unset ? " · 박스 입수 미설정 " + unset + "종 제외" : ""));
}
if (bagPallet) {
bagPallet.hidden = !bagLines;
const setBag = function (key, v) { bagPallet.querySelector('[data-k="' + key + '"]').textContent = v; };
setBag("boxes", fmt(bagBoxes));
setBag("pallets", fmt(Math.ceil(Math.round(bagShare * 1e6) / 1e6))); // 소수 오차로 한 파렛트 더 나오지 않게
setBag("note", "통·뚜껑과 따로 셈" + (bagUnset ? " · 박스당 수량·1파렛트당 박스 수량 미설정 " + bagUnset + "종 제외" : ""));
// 섞이면 가장 큰 1파렛트 박스 수로 환산(소수 오차로 한 파렛트 더 나오지 않게 반올림 후 올림)
const bagAll = bagMixed ? Math.ceil(Math.round(bagShare * bagCap * 1e6) / 1e6) : bagCapped;
setBag("pallets", fmt(bagCap ? Math.ceil(bagAll / bagCap) : 0));
bagPallet.querySelector('[data-k="vis"]').innerHTML = palletVis(bagAll, bagCap, bagMixed);
setBag("note", bagUnset ? "박스당 수량·1파렛트당 박스 수량 미설정 " + bagUnset + "종 제외" : "");
}
totalQty.textContent = fmt(q);
totalLines.textContent = fmt(k);