feat(project): manual monthly sales target with weekly diff

Week target popup now has its own "month total" input at the top; the
monthly target is saved as entered instead of being the sum of weeks.
Bottom shows week sum and diff (month target - week sum), colored
for remaining / over / even. Requests without `month` (stale cached JS)
still fall back to the week sum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 09:20:07 +09:00
parent 9eea1a073a
commit 701f43a1f8
8 changed files with 61 additions and 25 deletions
+8
View File
@@ -2853,6 +2853,14 @@ input.pj-meet-amount::placeholder { color: rgba(0, 0, 0, .28); }
.pj-goal-wkpop-row input[readonly] { background: #f7f8f9; }
.pj-goal-wkpop-sum { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--pj-border); }
.pj-goal-wkpop-sum b { font-variant-numeric: tabular-nums; }
/* 월 전체 목표(직접 입력) — 주차 줄과 구분선 */
.pj-goal-wkpop-month { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--pj-border); font-weight: 700; }
/* 차이 = 월 목표 − 주차 합계 — 남음(+) 주황, 넘음(−) 빨강, 딱 맞음 초록 */
.pj-goal-wkpop-diff { margin-top: 4px; padding-top: 0; border-top: 0; }
.pj-goal-wkpop-diff small { font-size: 11px; color: var(--pj-ink-soft); }
.pj-goal-wkpop-diff b.is-left { color: #c2410c; }
.pj-goal-wkpop-diff b.is-over { color: #dc2626; }
.pj-goal-wkpop-diff b.is-even { color: #16a34a; }
.pj-goal-wkpop-acts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
/* 나를 태그·작업 배정 알림 — 화면 가운데 아래 큰 팝업(body 에 붙음), 닫기 전까지 깜박인다(2026-10-07) */
+23 -8
View File
@@ -9231,8 +9231,9 @@
node.classList.add("is-saved");
}
// ── 주차별 매출 목표(020) — 매출 목표 칸을 누르면 그 달 주차 입력 창(body 에 붙음). 저장하면 주차 합계가 월 목표.
// 관리자는 입력·저장, 보기만 하는 사람은 주차별 값 보기. 주차는 서버(store.month_weeks)가 정한다.
// ── 주차별 매출 목표(020) — 매출 목표 칸을 누르면 그 달 입력 창(body 에 붙음). 월 목표는 맨 위에 직접 입력,
// 아래에 주차별 목표, 맨 아래 주차 합계와 차이(월 목표 − 주차 합계). 주차 합계가 월 목표가 되지 않는다.
// 관리자는 입력·저장, 보기만 하는 사람은 값 보기. 주차는 서버(store.month_weeks)가 정한다.
const WEEKS = window.PJ_GOAL_WEEKS || null;
let weekPop = null;
function closeWeekPop() {
@@ -9253,34 +9254,48 @@
weekPop.className = "pj-goal-wkpop";
weekPop.innerHTML = '<div class="pj-goal-wkpop-head">' + mo + "월 주차별 매출 목표" +
(unit ? " <small>(" + escapeHtml(unit) + ")</small>" : "") + "</div>" +
'<label class="pj-goal-wkpop-row pj-goal-wkpop-month"><span>' + mo + "월 전체 목표</span>" +
'<input type="text" inputmode="decimal" autocomplete="off" data-month-total="1" value="' +
escapeHtml((cell.tagName === "INPUT" ? cell.value : cell.textContent).trim()) + '"' +
(edit ? "" : " readonly") + "></label>" +
list.map(function (w) {
return '<label class="pj-goal-wkpop-row"><span>' + w.n + "주차 <em>" + escapeHtml(w.label) + "</em>" +
(w.days ? ' <i class="pj-goal-wkpop-days">' + w.days + "일</i>" : "") + "</span>" +
'<input type="text" inputmode="decimal" autocomplete="off" data-start="' + w.start + '" value="' +
escapeHtml(w.value || "") + '"' + (edit ? "" : " readonly") + "></label>";
}).join("") +
'<div class="pj-goal-wkpop-sum"><span>합계 = 월 목표</span><b></b></div>' +
'<div class="pj-goal-wkpop-sum"><span>주차 합계</span><b data-sum="weeks"></b></div>' +
'<div class="pj-goal-wkpop-sum pj-goal-wkpop-diff"><span>차이 <small>(월 목표 − 주차 합계)</small></span><b data-sum="diff"></b></div>' +
(edit ? '<div class="pj-goal-wkpop-acts"><button type="button" class="pj-btn pj-btn-sm" data-act="cancel">취소</button>' +
'<button type="button" class="pj-btn pj-btn-sm pj-btn-primary" data-act="save">저장</button></div>' : "");
document.body.appendChild(weekPop);
const r = cell.getBoundingClientRect(), vw = document.documentElement.clientWidth, vh = document.documentElement.clientHeight;
weekPop.style.left = Math.max(8, Math.min(r.left, vw - weekPop.offsetWidth - 8)) + "px";
weekPop.style.top = (r.bottom + 6 + weekPop.offsetHeight > vh ? Math.max(8, r.top - weekPop.offsetHeight - 6) : r.bottom + 6) + "px";
const inputs = Array.from(weekPop.querySelectorAll("input"));
const sumEl = weekPop.querySelector(".pj-goal-wkpop-sum b");
const monthInput = weekPop.querySelector("input[data-month-total]");
const inputs = Array.from(weekPop.querySelectorAll("input[data-start]"));
const sumEl = weekPop.querySelector('[data-sum="weeks"]'), diffEl = weekPop.querySelector('[data-sum="diff"]');
function paintSum() {
let t = null;
inputs.forEach(function (i) { const n = numOf(i); if (n != null) t = (t || 0) + n; });
sumEl.textContent = t == null ? "—" : fmtNum(t);
const total = numOf(monthInput);
const d = total == null ? null : total - (t || 0);
// 차이 + = 주차에 아직 못 나눈 금액, − = 주차 합계가 월 목표를 넘음, 0 = 딱 맞음
diffEl.textContent = d == null ? "—" : (d > 0 ? "+" : "") + fmtNum(d);
diffEl.classList.toggle("is-over", d != null && d < 0);
diffEl.classList.toggle("is-left", d != null && d > 0);
diffEl.classList.toggle("is-even", d != null && Math.abs(d) < 0.005);
}
inputs.forEach(function (i) { i.addEventListener("input", paintSum); });
[monthInput].concat(inputs).forEach(function (i) { i.addEventListener("input", paintSum); });
paintSum();
async function save(btn) {
const weeks = {};
inputs.forEach(function (i) { weeks[i.dataset.start] = i.value; });
btn.disabled = true;
try {
const res = await api("PUT", "/project/api/goals/" + year + "/week-targets/" + mo, { weeks: weeks });
const res = await api("PUT", "/project/api/goals/" + year + "/week-targets/" + mo,
{ month: monthInput.value, weeks: weeks });
list.forEach(function (w) { if (res.weeks && w.start in res.weeks) w.value = res.weeks[w.start]; });
cell.value = res.label || "";
recompute();
@@ -9306,7 +9321,7 @@
document.addEventListener("mousedown", onWeekDoc, true);
document.addEventListener("keydown", onWeekKey, true);
}, 0);
if (edit && inputs.length) { inputs[0].focus(); inputs[0].select(); }
if (edit) { monthInput.focus(); monthInput.select(); }
}
if (WEEKS) {
table.addEventListener("click", function (e) {