feat(project): month-bounded meeting weeks, weekly sales targets, sticky header
- Weeks stay inside the month: week 1 starts on the 1st (through the next Sunday if the 1st is a weekend); a trailing Mon/Tue joins the last week. "Last week" is the previous period. - Prev-week review columns: 전주 업무 | 결과(text, new result_note) | 전주 목표 | 결과(amount). - Header now shows month target, cumulative weekly target, month-to-date sales and gap (amount + %), with decisions/notes beside it; the area stays fixed while scrolling. - Goals board: the monthly sales target is entered per week; the sum becomes the month target. - Migration 020: result_note, goal_week_targets, drop Monday-only check, move absorbed Monday meetings to the new week start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+119
-14
@@ -9023,16 +9023,103 @@
|
||||
function fitAll() { table.querySelectorAll(".pj-goal-text").forEach(fit); }
|
||||
QUARTERS.forEach(function (q) { applyFold(q, false); });
|
||||
|
||||
// 병합 선택(Shift+클릭) — 관리자 전용, 아래에서 채운다. 접기 버튼이 먼저 부르므로 여기 둔다.
|
||||
let clearMergeSel = function () {};
|
||||
if (!isAdmin) return;
|
||||
|
||||
function flashSaved(node) {
|
||||
node.classList.remove("is-saved");
|
||||
void node.offsetWidth;
|
||||
node.classList.add("is-saved");
|
||||
}
|
||||
|
||||
// ── 주차별 매출 목표(020) — 매출 목표 칸을 누르면 그 달 주차 입력 창(body 에 붙음). 저장하면 주차 합계가 월 목표.
|
||||
// 관리자는 입력·저장, 보기만 하는 사람은 주차별 값 보기. 주차는 서버(store.month_weeks)가 정한다.
|
||||
const WEEKS = window.PJ_GOAL_WEEKS || null;
|
||||
let weekPop = null;
|
||||
function closeWeekPop() {
|
||||
if (!weekPop) return;
|
||||
weekPop.remove();
|
||||
weekPop = null;
|
||||
document.removeEventListener("mousedown", onWeekDoc, true);
|
||||
document.removeEventListener("keydown", onWeekKey, true);
|
||||
}
|
||||
function onWeekDoc(e) { if (weekPop && !weekPop.contains(e.target)) closeWeekPop(); }
|
||||
function onWeekKey(e) { if (e.key === "Escape") closeWeekPop(); }
|
||||
function openWeekPop(cell) {
|
||||
closeWeekPop();
|
||||
const mo = cell.dataset.month, list = (WEEKS && WEEKS[mo]) || [];
|
||||
const unit = window.PJ_GOAL_UNIT || "";
|
||||
const edit = isAdmin && cell.tagName === "INPUT";
|
||||
weekPop = document.createElement("div");
|
||||
weekPop.className = "pj-goal-wkpop";
|
||||
weekPop.innerHTML = '<div class="pj-goal-wkpop-head">' + mo + "월 주차별 매출 목표" +
|
||||
(unit ? " <small>(" + escapeHtml(unit) + ")</small>" : "") + "</div>" +
|
||||
list.map(function (w) {
|
||||
return '<label class="pj-goal-wkpop-row"><span>' + w.n + "주차 <em>" + escapeHtml(w.label) + "</em></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>' +
|
||||
(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");
|
||||
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);
|
||||
}
|
||||
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 });
|
||||
list.forEach(function (w) { if (res.weeks && w.start in res.weeks) w.value = res.weeks[w.start]; });
|
||||
cell.value = res.label || "";
|
||||
recompute();
|
||||
flashSaved(cell.parentElement);
|
||||
closeWeekPop();
|
||||
} catch (err) {
|
||||
btn.disabled = false;
|
||||
showToast("저장 실패: " + err.message, "error");
|
||||
}
|
||||
}
|
||||
weekPop.addEventListener("click", function (e) {
|
||||
const b = e.target.closest("[data-act]");
|
||||
if (!b) return;
|
||||
if (b.dataset.act === "save") save(b); else closeWeekPop();
|
||||
});
|
||||
weekPop.addEventListener("keydown", function (e) {
|
||||
if (edit && e.key === "Enter" && !isImeEnter(e) && e.target.tagName === "INPUT") {
|
||||
e.preventDefault();
|
||||
save(weekPop.querySelector('[data-act="save"]'));
|
||||
}
|
||||
});
|
||||
setTimeout(function () {
|
||||
document.addEventListener("mousedown", onWeekDoc, true);
|
||||
document.addEventListener("keydown", onWeekKey, true);
|
||||
}, 0);
|
||||
if (edit && inputs.length) { inputs[0].focus(); inputs[0].select(); }
|
||||
}
|
||||
if (WEEKS) {
|
||||
table.addEventListener("click", function (e) {
|
||||
const c = e.target.closest(".pj-goal-num[data-weekly]");
|
||||
if (c) openWeekPop(c);
|
||||
});
|
||||
table.addEventListener("keydown", function (e) {
|
||||
const c = e.target.closest(".pj-goal-num[data-weekly]");
|
||||
if (c && (e.key === "Enter" || e.key === " ") && !isImeEnter(e)) { e.preventDefault(); openWeekPop(c); }
|
||||
});
|
||||
}
|
||||
|
||||
// 병합 선택(Shift+클릭) — 관리자 전용, 아래에서 채운다. 접기 버튼이 먼저 부르므로 여기 둔다.
|
||||
let clearMergeSel = function () {};
|
||||
if (!isAdmin) return;
|
||||
|
||||
// ── 숫자 칸 — Enter·칸 떠남에 저장(createFieldSaver: 같은 칸 요청 차례대로, 늦은 응답이 새 입력을 덮지 않음).
|
||||
// 서버 표기(쉼표)는 요청 뒤 입력이 그대로일 때만 칸에 넣는다. 실패해도 입력값은 그대로(빨간 테두리), Esc = 저장된 값으로.
|
||||
const numSaver = createFieldSaver({
|
||||
@@ -9054,7 +9141,7 @@
|
||||
},
|
||||
onFail: function (inp, err) { markSaveFailed(inp.parentElement, err); },
|
||||
});
|
||||
table.querySelectorAll("input.pj-goal-num").forEach(function (inp) {
|
||||
table.querySelectorAll("input.pj-goal-num:not([data-weekly])").forEach(function (inp) {
|
||||
numSaver.track(inp, inp.value);
|
||||
inp.addEventListener("focus", function () { inp.select(); });
|
||||
inp.addEventListener("input", recompute);
|
||||
@@ -9984,7 +10071,7 @@
|
||||
// · 글(주요 업무·메모): 0.8초 멈춤·칸 떠남·페이지 떠남에 저장. 금액·참석자: 칸 떠남·Enter 에 저장.
|
||||
// · 지난주 결과 금액은 지난 회의록의 같은 줄(tr data-prev)에 저장한다.
|
||||
// · 줄 추가·순서·삭제·구역 추가는 저장 뒤 새로고침(스크롤 위치 되살림). 메뉴는 body 에 붙는다.
|
||||
// ── 회의록 표 — 이번주(2칸) ↔ 지난주 리뷰(3칸) 순서 바꾸기. 줄마다 is-this / is-prev 칸 묶음을 통째로 옮긴다
|
||||
// ── 회의록 표 — 이번주(2칸) ↔ 지난주 리뷰(4칸) 순서 바꾸기. 줄마다 is-this / is-prev 칸 묶음을 통째로 옮긴다
|
||||
// (colgroup·머리 두 줄·구역 줄 모두). 보는 사람마다 브라우저에 기억 — localStorage pj_meet_order:{로그인 이메일} = "prev"(지난주 먼저).
|
||||
// 다시 그리기(repaintMeeting)는 칸을 선택자로 찾으므로 순서와 무관.
|
||||
function initMeetOrder() {
|
||||
@@ -10026,10 +10113,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ── 회의록 위쪽 고정 영역(숫자 4칸 | 결정 사항·메모) — 스크롤해도 위에 붙고, 표 머리 줄은 그 아래에 붙는다.
|
||||
// 높이가 바뀌면(메모 줄 수·창 너비) --pj-meet-top-h 를 다시 잰다. 배율(.pj-ui-scale) 안이라 offsetHeight(배율 전 값)로.
|
||||
function initMeetTop(pane) {
|
||||
const top = el("pj-meet-top");
|
||||
if (!top) return;
|
||||
const apply = function () { pane.style.setProperty("--pj-meet-top-h", top.offsetHeight + "px"); };
|
||||
apply();
|
||||
if (window.ResizeObserver) new ResizeObserver(apply).observe(top);
|
||||
else window.addEventListener("resize", apply);
|
||||
}
|
||||
|
||||
function initGoalMeeting() {
|
||||
const pane = el("pj-meet-pane");
|
||||
if (!pane) return;
|
||||
initMeetOrder();
|
||||
initMeetTop(pane);
|
||||
const week = pane.dataset.week, year = pane.dataset.year;
|
||||
const isAdmin = pane.dataset.admin === "true";
|
||||
const SCROLL_KEY = "pj_meet_scroll";
|
||||
@@ -10076,7 +10175,7 @@
|
||||
const meetingUrl = "/project/api/goals/meetings/" + week;
|
||||
function itemUrl(id) { return "/project/api/goals/meeting-items/" + id; }
|
||||
|
||||
// ── 금액 칸(금주 목표 · 줄 정량 목표 · 지난주 결과) — Enter·칸 떠남에 저장(createFieldSaver: 같은 칸 요청 차례대로).
|
||||
// ── 금액 칸(줄 정량 목표 · 지난주 결과 금액) — Enter·칸 떠남에 저장(createFieldSaver: 같은 칸 요청 차례대로).
|
||||
// 서버 확정값(원 정수)을 쉼표 표기로 칸에 넣는 건 요청 뒤 입력이 그대로일 때만 — 그 사이 다시 입력한 초안은 덮지 않는다.
|
||||
// 실패해도 입력값은 그대로(빨간 테두리), Esc = 저장된 값으로.
|
||||
// 금주 목표 저장 뒤 머리 숫자는 페이지 새로고침 없이 숫자 칸만 다시 그린다(meetRepaint — 다른 칸의 저장 안 된 글 보존).
|
||||
@@ -10223,7 +10322,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ── 글 칸(이번주 할 일·메모) — 0.8초 멈춤·칸 떠남에 저장(createFieldSaver).
|
||||
// ── 글 칸(주요 업무 · 지난주 결과 글 · 메모) — 0.8초 멈춤·칸 떠남에 저장(createFieldSaver).
|
||||
// 지난주 결과 글(.pj-meet-rnote, data-field=result_note)은 지난 주차 줄(tr data-prev)에 저장한다.
|
||||
// 보낸 값만 저장됨으로 기록하고, 같은 칸 요청은 차례대로(진행 중에 새로 쓴 글은 뒤이어 저장). 실패해도 글은 그대로 두고
|
||||
// 다음 입력·칸 떠남·줄 작업 전에 다시 보낸다. 초안은 localStorage(pj_draft:meet:…)에도 — 페이지가 닫혀도 다음에 되살린다.
|
||||
const notes = el("pj-meet-notes");
|
||||
@@ -10231,11 +10331,16 @@
|
||||
read: function (ta) { return ta.value; },
|
||||
write: function (ta, v) { ta.value = v; fit(ta); },
|
||||
send: function (ta, v, o) {
|
||||
return ta === notes ? api("PUT", meetingUrl, { notes: v }, o)
|
||||
: api("PUT", itemUrl(ta.closest("tr").dataset.item), { content: v }, o);
|
||||
if (ta === notes) return api("PUT", meetingUrl, { notes: v }, o);
|
||||
const tr = ta.closest("tr");
|
||||
if (ta.dataset.field === "result_note") return api("PUT", itemUrl(tr.dataset.prev), { result_note: v }, o);
|
||||
return api("PUT", itemUrl(tr.dataset.item), { content: v }, o);
|
||||
},
|
||||
draftKey: function (ta) {
|
||||
return ta === notes ? "meet:notes:" + week : "meet:item:" + ta.closest("tr").dataset.item + ":content";
|
||||
if (ta === notes) return "meet:notes:" + week;
|
||||
const tr = ta.closest("tr");
|
||||
return ta.dataset.field === "result_note" ? "meet:item:" + tr.dataset.prev + ":result_note"
|
||||
: "meet:item:" + tr.dataset.item + ":content";
|
||||
},
|
||||
onSaved: function (ta) { const n = ta.closest("td") || ta; clearSaveFailed(n); flashSaved(n); },
|
||||
onClear: function (ta) { clearSaveFailed(ta.closest("td") || ta); },
|
||||
@@ -10259,7 +10364,7 @@
|
||||
ta.addEventListener("blur", function () { textSaver.flush(ta).catch(function () {}); });
|
||||
}
|
||||
if (notes) bindText(notes);
|
||||
if (table) table.querySelectorAll(".pj-meet-text").forEach(bindText);
|
||||
if (table) table.querySelectorAll(".pj-meet-text, .pj-meet-rnote").forEach(bindText);
|
||||
if (cellGrid) cellGrid.bindSaver({ flush: flushAll, save: function (ta) { return textSaver.flush(ta); },
|
||||
replace: function (ta, value) { ta.value = value; textSaver.acceptSaved(ta, ta.value); },
|
||||
rowMenu: rowMenu, addRow: function (section, ref, place) { run(function () { return addRow(section, ref, place); }); },
|
||||
@@ -10267,7 +10372,7 @@
|
||||
if (table && window.PJGoalText) window.PJGoalText.init(table, el("pj-goal-format"));
|
||||
if (restored) showToast("저장되지 않았던 글 " + restored + "칸을 되살려 다시 저장합니다.");
|
||||
else if (conflict) showToast("다른 곳에서 바뀐 칸 " + conflict + "개는 예전 초안을 되살리지 않았습니다.");
|
||||
window.addEventListener("resize", function () { document.querySelectorAll(".pj-meet-text, #pj-meet-notes").forEach(fit); });
|
||||
window.addEventListener("resize", function () { document.querySelectorAll(".pj-meet-text, .pj-meet-rnote, #pj-meet-notes").forEach(fit); });
|
||||
// 페이지 떠남 — 글은 keepalive 로 한 번 더 보내고(보장 아님, 초안 백업이 남음), 실패·진행 중·금액 미저장이면 이탈 경고
|
||||
window.addEventListener("beforeunload", function (e) {
|
||||
textSaver.onBeforeUnload(e);
|
||||
@@ -10279,7 +10384,7 @@
|
||||
table.addEventListener("click", function (e) {
|
||||
if (e.button !== 0 || e.defaultPrevented || e.target.closest("textarea, input, select, button, a, [contenteditable], [data-meet-edit], .pj-meet-colresize, .pj-goal-move-edge")) return;
|
||||
const td = e.target.closest("td");
|
||||
const f = td && td.querySelector(".pj-meet-text, input.pj-meet-amount");
|
||||
const f = td && td.querySelector(".pj-meet-text, .pj-meet-rnote, input.pj-meet-amount");
|
||||
if (!f || f === document.activeElement) return;
|
||||
f.focus();
|
||||
if (f.tagName === "TEXTAREA") { const n = f.value.length; f.setSelectionRange(n, n); }
|
||||
|
||||
Reference in New Issue
Block a user