feat(입출고): 미라클 봉투·미라클백 상품을 표로 분리하고 파렛트 입력 추가

이름에 "미라클 봉투"·"미라클백"이 들어간 상품은 옵션 → 상품 정보에서
별도 표로 나누고 박스당 수량·1파렛트당 박스 수량을 입력한다.
새 발주서 합계 줄에 봉투·백 박스·파렛트를 통·뚜껑과 따로 표시한다.
마이그레이션 008 필요, 미적용이면 모두 일반 상품으로 동작한다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 15:17:47 +09:00
parent d0e3e3622b
commit b6c8173899
15 changed files with 231 additions and 27 deletions
+2
View File
@@ -275,6 +275,7 @@
.io-prod-search { width: 220px; }
.io-prod-scroll { max-height: min(440px, calc(100vh - 340px)); overflow-y: auto; border: 1px solid var(--color-subtle-ash); border-radius: 8px; }
.io-prod-table thead th { position: sticky; top: 0; z-index: 1; background: #fafbfc; }
.io-prod-part-title { padding: 10px 12px 6px; font-size: 13.2px; font-weight: 700; }
.io-prod-table col.w-code { width: 128px; }
.io-prod-table col.w-num { width: 120px; }
.io-prod-table col.w-ag { width: 92px; }
@@ -462,6 +463,7 @@
.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[hidden] { display: none; }
.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; }
+32 -7
View File
@@ -56,6 +56,7 @@
// 힌트 = 통·뚜껑 입수의 최소공배수(둘 다 박스가 꽉 차는 수량 단위)와 지금 수량에 가까운 그 배수(누르면 수량 칸에 넣음).
const palletBoxes = parseInt(form.dataset.palletBoxes || "0", 10);
const pallet = document.getElementById("io-pallet");
const bagPallet = document.getElementById("io-pallet-bag");
const gcd = function (a, b) { while (b) { const t = a % b; a = b; b = t; } return a; };
const lcm = function (a, b) { return a / gcd(a, b) * b; };
function boxCell(tr, n, has) {
@@ -64,13 +65,14 @@
const out = { body: 0, lid: 0, unset: has && !body };
if (!cell) return out;
if (!has) { cell.innerHTML = "-"; return out; }
if (!body) { cell.innerHTML = '<span class="erp-muted" title="옵션 → 상품 정보에서 통 수량(박스)을 넣으면 계산합니다">박스 입수 미설정</span>'; return out; }
const bag = tr.dataset.bag === "1"; // 봉투·백 — 통·뚜껑 구분 없음
if (!body) { cell.innerHTML = '<span class="erp-muted" title="옵션 → 상품 정보에서 ' + (bag ? "박스당 수량" : "통 수량(박스)") + '을 넣으면 계산합니다">박스 입수 미설정</span>'; return out; }
out.body = n ? Math.ceil(n / body) : 0;
out.lid = n && lid ? Math.ceil(n / lid) : 0;
const unit = lid ? lcm(body, lid) : body; // 통·뚜껑이 모두 꽉 차는 수량 단위
let html = '<div class="io-box-main">통 <b>' + fmt(out.body) + "</b>박스" +
(lid ? ' · 뚜껑 <b>' + fmt(out.lid) + "</b>박스" : ' · <span class="erp-muted">뚜껑 없음</span>') + "</div>";
const per = "통 " + fmt(body) + "개/박스" + (lid ? " · 뚜껑 " + fmt(lid) + "개/박스" : "");
let html = '<div class="io-box-main">' + (bag ? "" : "통 ") + "<b>" + fmt(out.body) + "</b>박스" +
(bag ? "" : lid ? ' · 뚜껑 <b>' + fmt(out.lid) + "</b>박스" : ' · <span class="erp-muted">뚜껑 없음</span>') + "</div>";
const per = (bag ? "" : "통 ") + fmt(body) + "개/박스" + (lid ? " · 뚜껑 " + fmt(lid) + "개/박스" : "");
let hint;
if (n && n % unit === 0) {
hint = '<span class="io-box-ok">✓ ' + (lid ? "통·뚜껑 박스가 모두 꽉 찹니다" : "박스가 꽉 찹니다") + "</span>";
@@ -129,6 +131,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;
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);
@@ -139,7 +142,15 @@
if (cell) cell.textContent = has && price !== null && n ? (Math.round(price * n * 100) / 100).toLocaleString("ko-KR") : "-";
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++;
if (has && tr.dataset.bag === "1") {
const cap = parseInt(tr.dataset.palletBox || "0", 10) || 0;
bagLines++;
bagBoxes += bx.body;
if (cap) bagShare += bx.body / cap; // 1파렛트 박스 수가 다른 봉투·백은 차지하는 비율로 더함
if (bx.unset || !cap) bagUnset++;
} else {
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);
@@ -153,6 +164,13 @@
pallet.querySelector('[data-k="vis"]').innerHTML = palletVis(all);
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 + "종 제외" : ""));
}
totalQty.textContent = fmt(q);
totalLines.textContent = fmt(k);
if (totalAmount) totalAmount.textContent = (Math.round(amount * 100) / 100).toLocaleString("ko-KR");
@@ -284,7 +302,10 @@
const row = input.closest("tr");
if (row) { // 단가(상품 정보) — 금액 계산용, 박스 입수(007) — 박스·파렛트 계산용
row.dataset.price = it.price === null || it.price === undefined ? "" : String(it.price);
if ("bodyBox" in row.dataset) { row.dataset.bodyBox = it.body_per_box || ""; row.dataset.lidBox = it.lid_per_box || ""; }
if ("bodyBox" in row.dataset) {
row.dataset.bodyBox = it.body_per_box || ""; row.dataset.lidBox = it.lid_per_box || "";
row.dataset.bag = it.is_bag ? "1" : ""; row.dataset.palletBox = it.boxes_per_pallet || "";
}
const pc = row.querySelector(".io-price");
if (pc) pc.textContent = it.unit_price || "-";
}
@@ -531,6 +552,9 @@
tr.hidden = !hit;
if (hit) shown++;
});
body.querySelectorAll(".io-prod-part").forEach(function (part) { // 찾은 줄이 없는 표는 제목째 숨김
part.hidden = !part.querySelector("tbody tr:not([hidden])");
});
const cnt = body.querySelector("#io-prod-count");
if (cnt) cnt.dataset.base = cnt.dataset.base || cnt.textContent;
if (cnt) cnt.textContent = q ? shown + "개 찾음" : cnt.dataset.base;
@@ -561,7 +585,8 @@
const v = function (k) { return tr.querySelector('[data-key="' + k + '"]').value.trim(); };
const row = { code: tr.dataset.code, unit_price: v("unit_price"), weight_g: v("weight_g"), silver_pct: v("silver_pct") };
if (tr.querySelector('[data-key="group_id"]')) { row.group_id = v("group_id"); row.color = v("color"); } // 006
if (tr.querySelector('[data-key="body_per_box"]')) { row.body_per_box = v("body_per_box"); row.lid_per_box = v("lid_per_box"); } // 007
if (tr.querySelector('[data-key="boxes_per_pallet"]')) { row.body_per_box = v("body_per_box"); row.boxes_per_pallet = v("boxes_per_pallet"); } // 008 봉투·백
else if (tr.querySelector('[data-key="body_per_box"]')) { row.body_per_box = v("body_per_box"); row.lid_per_box = v("lid_per_box"); } // 007
return row;
});
if (rows.length) await act("/inout/settings/products/save", { rows: rows });