feat(inout): 오른쪽 발주·입고 달력·상품 그룹·색상·담당자 아이콘
- 모든 화면 2열, 오른쪽 300x320 달력(프로젝트 달력 모양) — 날짜별 발주·입고, 누르면 목록 - 옵션 → 상품 정보: 그룹(은 함유량·색상 한 번만), 상품별 그룹·색상(마이그레이션 006) - 발주 메일 품목 표에서 색상 있는 품목 줄 배경을 그 색으로(발주 당시 색상 사본) - 옵션 → 담당자 = 아이콘 + 이름, 아래 이메일 - 006 확인을 연결 열기 전에 해 동시 발주에서 연결 풀이 바닥나지 않게 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+161
-6
@@ -332,6 +332,9 @@
|
||||
e.preventDefault();
|
||||
const sub = e.submitter;
|
||||
if (sub && sub.dataset.confirm && !(await confirmMsg(sub.dataset.confirm))) return;
|
||||
// 그룹 저장은 옵션을 다시 그린다 — 저장 안 한 상품 정보 변경이 사라지기 전에 묻는다
|
||||
if (form.classList.contains("io-group-form") && dirtyRows().length &&
|
||||
!(await confirmMsg("저장 안 한 상품 정보 변경이 있습니다. 버리고 그룹을 저장할까요?"))) return;
|
||||
const action = sub && sub.getAttribute("formaction") ? sub.getAttribute("formaction") : form.getAttribute("action");
|
||||
const buttons = Array.from(dlg.querySelectorAll("button[type=submit]"));
|
||||
buttons.forEach(function (b) { b.disabled = true; });
|
||||
@@ -351,10 +354,43 @@
|
||||
}
|
||||
});
|
||||
// ── 상품 정보 탭(004) — 단가·무게·은 함유량, 바뀐 줄만 [변경 저장], 불러오기·지우기·되살리기 ──
|
||||
// 006: 그룹(select)·색상(select) — 그룹 상품은 은 함유량·색상을 그룹 값으로 보여 준다(자기 값 칸은 숨김, 저장은 그대로).
|
||||
function isChanged(el) {
|
||||
if (el.tagName === "SELECT") {
|
||||
const d = Array.from(el.options).find(function (o) { return o.defaultSelected; }) || el.options[0];
|
||||
return el.value !== (d ? d.value : "");
|
||||
}
|
||||
return el.value.trim() !== el.defaultValue.trim();
|
||||
}
|
||||
function rowChanged(tr) { return Array.from(tr.querySelectorAll("[data-key]")).some(isChanged); }
|
||||
function dirtyRows() {
|
||||
return Array.from(body.querySelectorAll(".io-prod-table tbody tr")).filter(function (tr) {
|
||||
return Array.from(tr.querySelectorAll("input[data-key]")).some(function (i) { return i.value.trim() !== i.defaultValue.trim(); });
|
||||
});
|
||||
return Array.from(body.querySelectorAll(".io-prod-table tbody tr")).filter(rowChanged);
|
||||
}
|
||||
function paintSwatch(sel) {
|
||||
const sw = sel.parentNode && sel.parentNode.querySelector(".io-swatch");
|
||||
const opt = sel.options[sel.selectedIndex];
|
||||
const hex = opt ? opt.dataset.hex : "";
|
||||
if (!sw) return;
|
||||
sw.style.background = hex || "#fff";
|
||||
sw.classList.toggle("is-none", !hex);
|
||||
}
|
||||
// 그룹을 바꾸면 그 줄의 그룹 값(은 함유량·색상)을 고른 그룹 것으로 다시 보여 준다
|
||||
function paintGroup(tr) {
|
||||
const sel = tr.querySelector(".io-group-select");
|
||||
if (!sel) return;
|
||||
const opt = sel.options[sel.selectedIndex];
|
||||
const grouped = !!sel.value;
|
||||
tr.classList.toggle("is-grouped", grouped);
|
||||
const vals = tr.querySelectorAll(".io-group-val");
|
||||
if (vals[0]) vals[0].textContent = (opt && opt.dataset.silver) || "-";
|
||||
if (vals[1]) {
|
||||
const key = (opt && opt.dataset.color) || "none";
|
||||
const csel = tr.querySelector(".io-color-select");
|
||||
const copt = csel && Array.from(csel.options).find(function (o) { return o.value === key; });
|
||||
const sw = vals[1].querySelector(".io-swatch"), nm = vals[1].querySelector(".io-color-name");
|
||||
if (sw) { sw.style.background = (copt && copt.dataset.hex) || "#fff"; sw.classList.toggle("is-none", !(copt && copt.dataset.hex)); }
|
||||
if (nm) nm.textContent = copt ? copt.textContent : "";
|
||||
}
|
||||
}
|
||||
function paintDirty() {
|
||||
const n = dirtyRows().length;
|
||||
@@ -391,12 +427,17 @@
|
||||
if (cnt) cnt.textContent = q ? shown + "개 찾음" : cnt.dataset.base;
|
||||
return;
|
||||
}
|
||||
if (inp.classList && inp.classList.contains("io-color-select")) paintSwatch(inp); // 그룹 표·상품 표 공통
|
||||
if (!inp.dataset || !inp.dataset.key) return;
|
||||
const tr = inp.closest("tr");
|
||||
const w = dec(tr.querySelector('[data-key="weight_g"]').value), pct = dec(tr.querySelector('[data-key="silver_pct"]').value);
|
||||
if (inp.dataset.key === "group_id") paintGroup(tr);
|
||||
const gsel = tr.querySelector(".io-group-select");
|
||||
const gopt = gsel && gsel.value ? gsel.options[gsel.selectedIndex] : null;
|
||||
const w = dec(tr.querySelector('[data-key="weight_g"]').value);
|
||||
const pct = gopt ? dec(gopt.dataset.silver) : dec(tr.querySelector('[data-key="silver_pct"]').value);
|
||||
const ag = tr.querySelector(".io-ag");
|
||||
if (ag) ag.textContent = w !== null && pct !== null ? (Math.round(w * pct / 100 * 10000) / 10000).toLocaleString("ko-KR", { maximumFractionDigits: 4 }) : "-";
|
||||
tr.classList.toggle("is-dirty", Array.from(tr.querySelectorAll("input[data-key]")).some(function (i) { return i.value.trim() !== i.defaultValue.trim(); }));
|
||||
tr.classList.toggle("is-dirty", rowChanged(tr));
|
||||
paintDirty();
|
||||
});
|
||||
body.addEventListener("click", async function (e) {
|
||||
@@ -409,7 +450,9 @@
|
||||
} else if (t.closest("#io-prod-save")) {
|
||||
const rows = dirtyRows().map(function (tr) {
|
||||
const v = function (k) { return tr.querySelector('[data-key="' + k + '"]').value.trim(); };
|
||||
return { code: tr.dataset.code, unit_price: v("unit_price"), weight_g: v("weight_g"), silver_pct: v("silver_pct") };
|
||||
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
|
||||
return row;
|
||||
});
|
||||
if (rows.length) await act("/inout/settings/products/save", { rows: rows });
|
||||
} else if (t.dataset && t.dataset.exclude) {
|
||||
@@ -696,4 +739,116 @@
|
||||
});
|
||||
return { open: open };
|
||||
}
|
||||
|
||||
// ── 오른쪽 달력(2026-10-21) — 입출고 모든 화면. 프로젝트 달력과 같은 모양(일요일 시작·오늘 검은 동그라미·토 파랑·일/공휴일 빨강),
|
||||
// 날짜 칸 = 발주(파랑)·입고(초록) 건수, 누르면 그날 목록 팝업(발주서로 이동). 달 이동은 새로고침 없이 GET /inout/api/calendar.
|
||||
const calEl = document.getElementById("io-cal");
|
||||
if (calEl) initCalendar(calEl);
|
||||
|
||||
function initCalendar(cal) {
|
||||
const daysEl = cal.querySelector(".io-cal-days"), titleEl = cal.querySelector(".io-cal-title");
|
||||
let month = cal.dataset.month, data = null, pop = null, seq = 0;
|
||||
const pad = function (n) { return String(n).padStart(2, "0"); };
|
||||
const isoOf = function (d) { return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate()); };
|
||||
const escH = function (v) { const d = document.createElement("div"); d.textContent = v == null ? "" : String(v); return d.innerHTML; };
|
||||
const WD = "일월화수목금토";
|
||||
function shift(ym, step) {
|
||||
const p = ym.split("-").map(Number);
|
||||
const d = new Date(p[0], p[1] - 1 + step, 1);
|
||||
return d.getFullYear() + "-" + pad(d.getMonth() + 1);
|
||||
}
|
||||
function closePop() { if (pop) { pop.remove(); pop = null; } }
|
||||
async function load() {
|
||||
closePop();
|
||||
const p = month.split("-").map(Number);
|
||||
titleEl.textContent = p[0] + "년 " + p[1] + "월";
|
||||
const mine = ++seq; // 빠르게 넘기면 늦게 온 앞 달 응답이 덮지 않게
|
||||
cal.classList.add("is-loading");
|
||||
try {
|
||||
const res = await fetch("/inout/api/calendar?month=" + encodeURIComponent(month));
|
||||
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||
const got = await res.json();
|
||||
if (mine !== seq) return;
|
||||
data = got;
|
||||
render();
|
||||
} catch (_) {
|
||||
if (mine !== seq) return;
|
||||
data = null;
|
||||
daysEl.innerHTML = '<p class="io-cal-err">달력을 불러오지 못했습니다.</p>';
|
||||
} finally {
|
||||
if (mine === seq) cal.classList.remove("is-loading");
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
const start = new Date(data.start + "T00:00:00");
|
||||
let html = "";
|
||||
for (let i = 0; i < 42; i++) {
|
||||
const d = new Date(start.getFullYear(), start.getMonth(), start.getDate() + i);
|
||||
const iso = isoOf(d), wd = d.getDay();
|
||||
const ev = data.days[iso] || { orders: [], receipts: [] };
|
||||
const hol = data.holidays[iso] || "";
|
||||
const cls = ["io-cal-day"];
|
||||
if (iso.slice(0, 7) !== data.month) cls.push("is-out");
|
||||
if (iso === data.today) cls.push("is-today");
|
||||
if (wd === 0 || hol) cls.push("is-sun"); else if (wd === 6) cls.push("is-sat");
|
||||
if (ev.orders.length || ev.receipts.length) cls.push("has-ev");
|
||||
const tip = [iso.replace(/-/g, ".") + "(" + WD[wd] + ")" + (hol ? " " + hol : "")];
|
||||
if (ev.orders.length) tip.push("발주 " + ev.orders.length + "건");
|
||||
if (ev.receipts.length) tip.push("입고 " + ev.receipts.length + "건");
|
||||
html += '<button type="button" class="' + cls.join(" ") + '" data-date="' + iso + '" title="' + escH(tip.join(" · ")) + '">' +
|
||||
'<span class="io-cal-num">' + d.getDate() + "</span>" +
|
||||
'<span class="io-cal-marks">' +
|
||||
(ev.orders.length ? '<i class="io-cal-m is-order">' + ev.orders.length + "</i>" : "") +
|
||||
(ev.receipts.length ? '<i class="io-cal-m is-receipt">' + ev.receipts.length + "</i>" : "") +
|
||||
"</span></button>";
|
||||
}
|
||||
daysEl.innerHTML = html;
|
||||
}
|
||||
// 그날 목록 — body 에 붙이는 작은 팝업(달력 칸 아래, 화면 밖이면 위로)
|
||||
function openDay(btn) {
|
||||
closePop();
|
||||
const iso = btn.dataset.date;
|
||||
const ev = (data && data.days[iso]) || { orders: [], receipts: [] };
|
||||
if (!ev.orders.length && !ev.receipts.length) return;
|
||||
const d = new Date(iso + "T00:00:00"), hol = (data.holidays || {})[iso];
|
||||
const item = function (href, kind, label, main, sub) {
|
||||
return '<a class="io-calpop-item" href="' + href + '"><i class="io-cal-m ' + kind + '">' + label + "</i>" +
|
||||
'<span class="io-calpop-main">' + main + '</span><span class="io-calpop-sub">' + sub + "</span></a>";
|
||||
};
|
||||
let html = '<div class="io-calpop-head">' + iso.replace(/-/g, ".") + "(" + WD[d.getDay()] + ")" + (hol ? ' <span class="is-hol">' + escH(hol) + "</span>" : "") + "</div>";
|
||||
ev.orders.forEach(function (o) {
|
||||
html += item("/inout/orders/" + o.id, "is-order", "발주", escH(o.order_no) + " · " + escH(o.factory),
|
||||
escH(o.item) + " · " + Number(o.qty).toLocaleString("ko-KR") + "개");
|
||||
});
|
||||
ev.receipts.forEach(function (r) {
|
||||
html += item("/inout/orders/" + r.order_id, "is-receipt", "입고", escH(r.order_no) + " · " + escH(r.factory),
|
||||
Number(r.qty).toLocaleString("ko-KR") + "개 입고");
|
||||
});
|
||||
pop = document.createElement("div");
|
||||
pop.className = "io-calpop";
|
||||
pop.setAttribute("role", "dialog");
|
||||
pop.setAttribute("aria-label", iso + " 발주·입고");
|
||||
pop.innerHTML = html;
|
||||
document.body.appendChild(pop);
|
||||
const r = btn.getBoundingClientRect(), w = pop.offsetWidth, h = pop.offsetHeight;
|
||||
let left = Math.min(Math.max(8, r.left + r.width / 2 - w / 2), window.innerWidth - w - 8);
|
||||
let top = r.bottom + 6;
|
||||
if (top + h > window.innerHeight - 8) top = Math.max(8, r.top - h - 6);
|
||||
pop.style.left = left + window.scrollX + "px";
|
||||
pop.style.top = top + window.scrollY + "px";
|
||||
}
|
||||
cal.addEventListener("click", function (e) {
|
||||
const nav = e.target.closest(".io-cal-nav");
|
||||
if (nav) { month = shift(month, Number(nav.dataset.step)); load(); return; }
|
||||
if (e.target.closest(".io-cal-today")) { month = (data && data.today ? data.today : cal.dataset.month).slice(0, 7); load(); return; }
|
||||
const day = e.target.closest(".io-cal-day");
|
||||
if (day) { if (pop && pop.dataset.date === day.dataset.date) closePop(); else { openDay(day); if (pop) pop.dataset.date = day.dataset.date; } }
|
||||
});
|
||||
document.addEventListener("mousedown", function (e) {
|
||||
if (pop && !pop.contains(e.target) && !e.target.closest(".io-cal-day")) closePop();
|
||||
});
|
||||
document.addEventListener("keydown", function (e) { if (e.key === "Escape") closePop(); });
|
||||
window.addEventListener("resize", closePop);
|
||||
load();
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user