feat(inout): 발주 수량 공배수 ◀ ▶·파렛트 그림·품목 표 제목 행 서식

- 품목 표 제목 행 가운데·굵게·110%
- 수량 칸 오른쪽 ◀ ▶ 로 통·뚜껑 입수 공배수만큼 줄이기·늘리기
- 합계 줄에 꽉 찬 파렛트 그림과 잔량 파렛트(실린 박스만 색칠, %, 몇 박스 더)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 15:38:50 +09:00
parent 48c0c96f1f
commit 8652064415
8 changed files with 104 additions and 15 deletions
+26 -2
View File
@@ -435,13 +435,37 @@
.io-dlg-pane[data-pane="groups"] .io-group-table { margin-top: 12px; }
/* ── 새 발주서: 통·뚜껑 박스·파렛트(2026-10-21, 007) — 화면 계산만 ── */
.io-lines .io-col-box { min-width: 190px; white-space: normal !important; font-size: 12.5px; }
.io-lines .io-col-box { min-width: 210px; white-space: normal !important; }
.io-lines td.io-col-box { font-size: 12.5px; }
.io-box-main b { font-variant-numeric: tabular-nums; }
.io-box-hint { margin-top: 2px; font-size: 11.5px; color: var(--color-midtone-gray, #666); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.io-box-ok { color: #1e7a34; font-weight: 600; }
.io-box-ok { color: #1e7a34; font-weight: 600; white-space: nowrap; }
.io-box-pick { border: 1px solid #cfe0fb; background: #f0f6ff; color: #1d4f91; border-radius: 6px; padding: 0 6px; height: 20px; font-size: 11.5px; cursor: pointer; }
.io-box-pick:hover { background: #dce9ff; }
.io-pallet { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; font-size: 13px; }
.io-pallet b { font-variant-numeric: tabular-nums; }
.io-pallet-main { font-size: 14px; font-weight: 600; }
.io-pallet-main b { font-size: 16px; color: #1d4f91; }
/* ── 새 발주서(2026-10-21): 품목 표 제목 행 가운데·굵게·110%, 수량 ◀ ▶(공배수만큼), 파렛트 그림 ── */
.io-lines thead th, .io-table.io-lines th.io-col-money { text-align: center; font-size: calc(var(--text-caption, 12px) * 1.1); font-weight: 700; color: var(--color-rich-black, #1d1d1f); }
.io-lines .io-col-qty { width: 196px; }
.io-qty-wrap { display: flex; align-items: center; gap: 4px; }
.io-qty-wrap .io-qty { flex: 1 1 auto; min-width: 0; }
.io-steps { display: inline-flex; gap: 2px; flex: none; }
.io-step { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 30px; padding: 0; border: 1px solid var(--color-subtle-ash, #e5e5e5);
border-radius: 8px; background: #fff; color: #1d4f91; cursor: pointer; }
.io-step:hover:not(:disabled) { background: #f0f6ff; border-color: #cfe0fb; }
.io-step:disabled { color: #c3c7cc; cursor: not-allowed; }
.io-pallet-vis { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.io-pal-group { display: inline-flex; align-items: flex-end; gap: 4px; }
.io-pal-group.is-rem { padding-left: 12px; border-left: 1px dashed #d5d9de; }
.io-pal-svg { display: block; flex: none; }
.io-pal-svg .is-on { fill: #c98a4b; stroke: #9c6631; stroke-width: .6; }
.io-pal-svg .is-off { fill: #fff; stroke: #c9cdd2; stroke-width: .6; stroke-dasharray: 1.2 1; }
.io-pal-svg .io-pal-base { fill: #8a6a48; }
.io-pal-more { font-size: 12px; font-weight: 700; color: #6b4a2b; align-self: center; }
.io-pal-cap { font-size: 12px; color: #4b5563; line-height: 1.35; align-self: center; margin-left: 2px; white-space: nowrap; }
.io-pal-cap b { color: #1d1d1f; font-variant-numeric: tabular-nums; }
.io-pal-need { color: #b45309; font-weight: 600; }
.io-pal-ok { color: #1e7a34; font-weight: 600; font-size: 12.5px; }
+61 -3
View File
@@ -84,6 +84,48 @@
cell.innerHTML = html + '<div class="io-box-hint" title="' + per + '">' + hint + "</div>";
return out;
}
// 줄의 수량 단위 — 통·뚜껑 입수의 최소공배수(뚜껑 없으면 통 입수). 제품을 안 골랐거나 입수가 없으면 0.
function unitOf(tr) {
if (!tr.querySelector('input[name="item_code"]').value) return 0;
const body = parseInt(tr.dataset.bodyBox || "0", 10) || 0, lid = parseInt(tr.dataset.lidBox || "0", 10) || 0;
return body ? (lid ? lcm(body, lid) : body) : 0;
}
// 파렛트 그림(SVG) — 6열 × 행(파렛트 박스 수 ÷ 6) 박스를 받침대 위에, 실린 박스는 아래 줄 왼쪽부터 색칠
function palletSvg(filled, total) {
const cols = 6, rows = Math.ceil(total / cols), w = 8, h = 7;
let boxes = "";
for (let i = 0; i < total; i++) {
const r = rows - 1 - Math.floor(i / cols), c = i % cols;
boxes += '<rect x="' + (c * w + 0.5) + '" y="' + (r * h + 0.5) + '" width="' + (w - 1.5) + '" height="' + (h - 1.5) +
'" rx="1" class="' + (i < filled ? "is-on" : "is-off") + '"/>';
}
const W = cols * w, H = rows * h;
return '<svg class="io-pal-svg" viewBox="0 0 ' + W + " " + (H + 6) + '" width="' + W + '" height="' + (H + 6) + '" aria-hidden="true">' + boxes +
'<rect class="io-pal-base" x="0" y="' + (H + 0.5) + '" width="' + W + '" height="2.5"/>' +
'<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) {
if (!all) return "";
const full = Math.floor(all / palletBoxes), rem = all % palletBoxes, MAX = 10;
let html = "";
if (full) {
let icons = "";
for (let i = 0; i < Math.min(full, MAX); i++) icons += palletSvg(palletBoxes, palletBoxes);
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>";
} else {
html += '<span class="io-pal-ok">✓ 모든 파렛트가 꽉 찹니다</span>';
}
return html;
}
function renumber() {
let q = 0, k = 0, amount = 0, missing = 0;
let bodyBoxes = 0, lidBoxes = 0, unset = 0;
@@ -98,13 +140,18 @@
if (has) { k++; q += n; if (price === null) missing++; else amount += price * n; }
const bx = boxCell(tr, n, has);
bodyBoxes += bx.body; lidBoxes += bx.lid; if (bx.unset) unset++;
const unit = unitOf(tr); // ◀ ▶ = 공배수만큼(입수가 없으면 누를 수 없음)
tr.querySelectorAll(".io-step").forEach(function (b) {
b.disabled = !unit || (b.dataset.step === "-1" && !n);
b.title = unit ? "공배수 " + fmt(unit) + "개씩 " + (b.dataset.step === "1" ? "늘리기" : "줄이기") : "제품을 고르고 박스 입수(옵션 → 상품 정보)가 있어야 쓸 수 있습니다";
});
});
if (pallet && palletBoxes > 0) {
const all = bodyBoxes + lidBoxes, pallets = Math.ceil(all / palletBoxes), last = all % palletBoxes;
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));
set("note", "1파렛트 = " + palletBoxes + "박스" + (all && last ? " · 마지막 파렛트 " + last + "박스(" + (palletBoxes - last) + "박스 더 실을 수 있음)" : "") +
(unset ? " · 박스 입수 미설정 " + unset + "종 제외" : ""));
pallet.querySelector('[data-k="vis"]').innerHTML = palletVis(all);
set("note", "1파렛트 = " + palletBoxes + "박스" + (unset ? " · 박스 입수 미설정 " + unset + "종 제외" : ""));
}
totalQty.textContent = fmt(q);
totalLines.textContent = fmt(k);
@@ -132,6 +179,17 @@
});
body.addEventListener("input", renumber); // 수량을 바꾸거나 제품 글을 고치면(고른 것 풀림) 다시 셈
body.addEventListener("io-chosen", renumber); // 검색 목록에서 제품을 고르면
body.addEventListener("click", function (e) { // ◀ ▶ = 공배수만큼 줄이기·늘리기(배수가 아니면 가까운 배수로 맞춤)
const step = e.target.closest(".io-step");
if (!step || step.disabled) return;
const tr = step.closest(".io-line"), unit = unitOf(tr), qty = tr.querySelector(".io-qty");
if (!unit) return;
const n = num(qty.value);
let next = step.dataset.step === "1" ? (Math.floor(n / unit) + 1) * unit : (n % unit ? Math.floor(n / unit) * unit : n - unit);
if (next < 0) next = 0;
qty.value = next ? next.toLocaleString("ko-KR") : "";
renumber();
});
body.addEventListener("click", function (e) { // 공배수 힌트 숫자 = 그 수량으로
const pick = e.target.closest(".io-box-pick");
if (!pick) return;