feat(performance): per-shop manual sales input, column order, bold centered table headers (migration 002)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 17:26:57 +09:00
parent dd1bc310dc
commit 454b3cc700
16 changed files with 690 additions and 34 deletions
+15 -2
View File
@@ -102,11 +102,12 @@ a.perf-seg.is-active, a.perf-seg.is-active:link, a.perf-seg.is-active:visited {
.perf-table-wrap { overflow-x: auto; }
.perf-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.perf-table th, .perf-table td { padding: 6px 8px; border-bottom: 1px solid #efefef; white-space: nowrap; }
/* 열 제목 — 가운데·굵게·검정(2026-10-12) */
.perf-table thead th {
font-size: 12px; font-weight: 500; color: var(--color-midtone-gray); text-align: right;
font-size: 12px; font-weight: 700; color: #000; text-align: center;
background: var(--perf-soft); border-bottom: 1px solid var(--perf-line); position: sticky; top: 0;
}
.perf-table thead th.perf-th-label { text-align: left; }
.perf-table thead th.perf-th-label { text-align: center; }
.perf-td-label { text-align: left; font-weight: 500; }
.perf-num { text-align: right; }
.perf-zero { color: #c9c9c9; }
@@ -128,6 +129,18 @@ td.is-link:hover { background: #eef2ff; text-decoration: underline; }
/* 표시 기준 전환 — 한 칸에 3값, data-metric 으로 하나만 보인다 */
.perf .v { display: none; }
/* 수동 입력 칸 — 설정에서 켠 쇼핑몰의 날짜 칸. 파란 숫자 = 수동 입력값, 입력 중엔 숫자 대신 입력칸 */
.perf-manual-mark { font-size: 11px; color: #1a56db; font-weight: 400; }
.perf-main td.is-manual-cell { cursor: text; position: relative; }
.perf-main td.is-manual-cell:hover { background: #eef3ff; box-shadow: inset 0 0 0 1px #c7d6fb; }
.perf-main td.is-manual-cell:focus { outline: 2px solid #1a56db; outline-offset: -2px; }
.perf-main td.is-manual .v-gross { color: #1a56db; font-weight: 600; }
.perf-main td.is-stale .v-commission, .perf-main td.is-stale .v-net { opacity: .4; }
.perf-main td.is-editing { padding: 2px 4px; }
.perf .perf-main td.is-editing .v { display: none; }
.perf-manual-input { width: 100%; min-width: 90px; box-sizing: border-box; padding: 3px 6px; border: 1px solid #1a56db; border-radius: 4px;
font: inherit; text-align: right; background: #fff; outline: none; }
.perf-manual-help { margin: 8px 2px 0; font-size: 12px; }
.perf[data-metric="gross"] .v-gross,
.perf[data-metric="commission"] .v-commission,
.perf[data-metric="net"] .v-net { display: inline; }
+83
View File
@@ -333,6 +333,89 @@
if (!td) return;
openEvents(td.dataset.code, td.dataset.from, td.dataset.to);
});
// ── 수동 입력(설정에서 켠 쇼핑몰) — 날짜 칸을 눌러 총매출 입력. Enter 저장 후 아래 칸 · Shift+Enter 위 칸 · Esc 취소.
// 비우고 저장하면 그날은 다시 API 값. 저장은 칸마다 차례로, 입력을 마치면(다른 칸으로 안 넘어가면) 새로고침해
// 합계·수수료·그래프를 서버 계산으로 다시 그린다.
let manualDirty = false;
let manualChain = Promise.resolve();
function manualCells(code) {
return Array.prototype.slice.call(root.querySelectorAll('td.is-manual-cell[data-manual-code="' + code + '"]'));
}
function digitsOf(td) { return td.dataset.manualValue || ""; }
function finishManual() {
setTimeout(function () {
if (root.querySelector(".perf-manual-input")) return; // 다른 칸으로 넘어감
manualChain.then(function () { if (manualDirty) location.reload(); });
}, 120);
}
function saveManual(td, text) {
const raw = String(text || "").replace(/[,\s원]/g, "");
const was = digitsOf(td);
if (raw !== "" && !/^-?\d+$/.test(raw)) return Promise.reject(new Error("숫자(원)만 입력하세요."));
if (raw === was) return Promise.resolve(false); // 바뀐 것 없음(빈 칸 그대로 포함)
const job = manualChain.then(function () {
return api("PUT", "/performance/api/manual-sales/" + encodeURIComponent(td.dataset.manualCode) + "/" +
encodeURIComponent(td.dataset.date), { amount: raw === "" ? null : Number(raw) });
}).then(function (res) {
const manual = res.manual == null ? "" : String(res.manual);
td.dataset.manualValue = manual;
td.classList.toggle("is-manual", manual !== "");
td.title = manual !== "" ? "수동 입력값 — 눌러 고치기(비우고 저장하면 API 값)" : "눌러 총매출 직접 입력";
const g = td.querySelector(".v-gross");
if (g) g.innerHTML = won(res.amount);
td.classList.add("is-stale"); // 수수료·차감 매출은 새로고침 때 다시 계산
manualDirty = true;
return true;
});
manualChain = job.catch(function () {});
return job;
}
function editManual(td) {
if (td.querySelector(".perf-manual-input")) return;
const input = el("input", { type: "text", inputmode: "numeric", class: "perf-manual-input",
"aria-label": ((data.names || {})[td.dataset.manualCode] || "") + " " + td.dataset.date + " 총매출" });
input.value = digitsOf(td);
const g = td.querySelector(".v-gross");
input.placeholder = digitsOf(td) ? "" : (g ? g.textContent.trim().replace(/[–-]/, "") : "") || "총매출";
td.classList.add("is-editing");
td.appendChild(input);
input.focus();
input.select();
let done = false;
function close() {
if (done) return;
done = true;
input.remove();
td.classList.remove("is-editing");
}
function commit(step) {
if (done) return;
const val = input.value;
close();
const cells = manualCells(td.dataset.manualCode);
const next = step ? cells[cells.indexOf(td) + step] : null;
if (next) editManual(next);
saveManual(td, val).catch(function (err) {
alertMsg("저장 실패(" + td.dataset.date + "): " + err.message);
}).then(finishManual);
}
input.addEventListener("keydown", function (e) {
if (e.isComposing) return;
if (e.key === "Enter" || e.key === "Tab") { e.preventDefault(); commit(e.shiftKey ? -1 : 1); }
else if (e.key === "ArrowDown" || e.key === "ArrowUp") { e.preventDefault(); commit(e.key === "ArrowUp" ? -1 : 1); }
else if (e.key === "Escape") { e.preventDefault(); close(); td.focus(); finishManual(); }
});
input.addEventListener("blur", function () { commit(0); });
}
root.addEventListener("click", function (e) {
const td = e.target.closest("td.is-manual-cell");
if (td && !e.target.closest(".perf-manual-input")) editManual(td);
});
root.addEventListener("keydown", function (e) {
const td = e.target.closest && e.target.closest("td.is-manual-cell");
if (td && e.target === td && (e.key === "Enter" || e.key === "F2")) { e.preventDefault(); editManual(td); }
});
async function openEvents(code, from, to) {
const name = (data.names || {})[code] || code;
const title = name + " · " + (from === to ? from : from + " ~ " + to) + " 주문 내역";