feat(project): 연간 목표 상·하반기 칸·반기 접기·이름 바로 수정·월 칸 병합·로아스 %
- 6월·12월 오른쪽에 상반기·하반기 칸 추가. 매출 목표·실적은 반기 합계, 달성률은 연간과 같은 규칙, 업무 영역 글 칸은 month 13·14 로 저장 - 반기 칸 머리 버튼으로 1~6월 / 7~12월 칸을 접었다 펴기(너비 애니메이션, localStorage pj_goal_fold). 표를 width:1px + table-layout:fixed 로 바꿔 펼칠 때도 애니메이션이 적용되게 함 - 업무 영역·줄 이름을 눌러 그 자리에서 수정(✎ 버튼 제거) - 월 칸 가로 병합(goal_cell_merges, 반기 안에서만): Shift+클릭 선택 후 병합 버튼, 우클릭 메뉴로 좌/우 병합·해제. 병합 시 글은 월 순서대로 첫 칸에 모음 - 로아스 목표·실적 칸 % 표기 - 마이그레이션 014 (goal_cells month CHECK 0~14, goal_cell_merges) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1840,6 +1840,11 @@ class ProjectStore:
|
||||
with self._pool.connection() as conn:
|
||||
return self._table_exists(conn, "goal_years")
|
||||
|
||||
def goals_halves_enabled(self) -> bool:
|
||||
"""상·하반기 글 칸·월 칸 병합(마이그레이션 014) 적용 여부."""
|
||||
with self._pool.connection() as conn:
|
||||
return self._table_exists(conn, "goal_cell_merges")
|
||||
|
||||
def list_goal_years(self) -> list[int]:
|
||||
"""목표를 만든 연도(최근 연도 먼저). 013 미적용이면 UndefinedTable."""
|
||||
with self._pool.connection() as conn:
|
||||
@@ -1913,7 +1918,9 @@ class ProjectStore:
|
||||
"""한 해 목표 표 전체. 연도가 없으면 None.
|
||||
|
||||
metrics = {"sales": {"target": {1: 12.0, ...}, "actual": {...}}, "roas": {...}}
|
||||
areas = [{id, name, color, rows: [{id, label, cells: {0: "연간 글", 1: "1월 글", ...}}]}]
|
||||
areas = [{id, name, color, rows: [{id, label, cells: {0: "연간 글", 1: "1월 글", 13: "상반기 글", ...},
|
||||
merges: {시작월: 칸 수}}]}]
|
||||
halves = 마이그레이션 014 적용 여부(상·하반기 글 칸·병합)
|
||||
"""
|
||||
with self._pool.connection() as conn:
|
||||
head = conn.execute(
|
||||
@@ -1940,6 +1947,13 @@ class ProjectStore:
|
||||
"WHERE a.year = %s",
|
||||
(year,),
|
||||
).fetchall()
|
||||
halves = self._table_exists(conn, "goal_cell_merges")
|
||||
merge_rows = conn.execute(
|
||||
"SELECT m.row_id, m.start_month, m.span FROM goal_cell_merges m "
|
||||
"JOIN goal_rows r ON r.id = m.row_id JOIN goal_areas a ON a.id = r.area_id "
|
||||
"WHERE a.year = %s",
|
||||
(year,),
|
||||
).fetchall() if halves else []
|
||||
metrics: dict[str, dict[str, dict[int, float]]] = {
|
||||
m: {k: {} for k in store.GOAL_KINDS} for m in store.GOAL_METRICS
|
||||
}
|
||||
@@ -1948,10 +1962,15 @@ class ProjectStore:
|
||||
cells: dict[int, dict[int, str]] = {}
|
||||
for c in cell_rows:
|
||||
cells.setdefault(int(c["row_id"]), {})[int(c["month"])] = c["body"]
|
||||
merges: dict[int, dict[int, int]] = {}
|
||||
for g in merge_rows:
|
||||
merges.setdefault(int(g["row_id"]), {})[int(g["start_month"])] = int(g["span"])
|
||||
rows_by_area: dict[int, list[dict[str, Any]]] = {}
|
||||
for r in row_rows:
|
||||
rid = int(r["id"])
|
||||
rows_by_area.setdefault(int(r["area_id"]), []).append(
|
||||
{"id": int(r["id"]), "label": r["label"], "cells": cells.get(int(r["id"]), {})}
|
||||
{"id": rid, "label": r["label"], "cells": cells.get(rid, {}),
|
||||
"merges": merges.get(rid, {})}
|
||||
)
|
||||
areas = [
|
||||
{"id": int(a["id"]), "name": a["name"], "color": a["color"],
|
||||
@@ -1959,7 +1978,7 @@ class ProjectStore:
|
||||
for a in area_rows
|
||||
]
|
||||
return {"year": int(head["year"]), "sales_unit": head["sales_unit"],
|
||||
"metrics": metrics, "areas": areas}
|
||||
"metrics": metrics, "areas": areas, "halves": halves}
|
||||
|
||||
def set_goal_metric(
|
||||
self, *, year: int, metric: str, kind: str, month: int, value: float | None, updated_by: str = ""
|
||||
@@ -2094,6 +2113,17 @@ class ProjectStore:
|
||||
with self._pool.connection() as conn:
|
||||
if not conn.execute("SELECT 1 FROM goal_rows WHERE id = %s", (row_id,)).fetchone():
|
||||
raise KeyError(row_id)
|
||||
if m != store.GOAL_YEAR:
|
||||
halves = self._table_exists(conn, "goal_cell_merges")
|
||||
if m > 12 and not halves:
|
||||
raise store.GoalMigration014Needed()
|
||||
# 병합된 칸의 가운데·끝 월(글은 병합 시작 월에만 둔다) — 다른 창에서 병합된 뒤의 늦은 저장
|
||||
if m <= 12 and halves and conn.execute(
|
||||
"SELECT 1 FROM goal_cell_merges WHERE row_id = %s "
|
||||
"AND start_month < %s AND start_month + span - 1 >= %s",
|
||||
(row_id, m, m),
|
||||
).fetchone():
|
||||
raise ValueError("병합된 칸입니다. 새로고침해 주세요.")
|
||||
if not text:
|
||||
conn.execute("DELETE FROM goal_cells WHERE row_id = %s AND month = %s", (row_id, m))
|
||||
else:
|
||||
@@ -2104,6 +2134,67 @@ class ProjectStore:
|
||||
(row_id, m, text, store.norm_str(updated_by, lower=True)),
|
||||
)
|
||||
|
||||
def merge_goal_cells(self, *, row_id: int, start: Any, end: Any, updated_by: str = "") -> tuple[int, int]:
|
||||
"""업무 영역 줄의 start~end 월 칸을 가로로 합친다 → (시작 월, 칸 수).
|
||||
|
||||
걸쳐 있는 기존 병합은 통째로 흡수한다(병합은 서로 겹치지 않고 반기 안이라 범위도 반기 안).
|
||||
글은 범위 안 칸들의 글을 월 순서대로 줄바꿈으로 이어 시작 월 칸에 두고, 나머지 칸 글은 지운다."""
|
||||
s, e = store.validate_goal_merge(start, end)
|
||||
who = store.norm_str(updated_by, lower=True)
|
||||
with self._pool.connection() as conn:
|
||||
with conn.transaction():
|
||||
if not self._table_exists(conn, "goal_cell_merges"):
|
||||
raise store.GoalMigration014Needed()
|
||||
if not conn.execute(
|
||||
"SELECT 1 FROM goal_rows WHERE id = %s FOR UPDATE", (row_id,)
|
||||
).fetchone():
|
||||
raise KeyError(row_id)
|
||||
for g in conn.execute(
|
||||
"SELECT start_month, span FROM goal_cell_merges WHERE row_id = %s", (row_id,)
|
||||
).fetchall():
|
||||
gs, ge = int(g["start_month"]), int(g["start_month"]) + int(g["span"]) - 1
|
||||
if gs <= e and ge >= s:
|
||||
s, e = min(s, gs), max(e, ge)
|
||||
bodies = [
|
||||
str(c["body"]).strip() for c in conn.execute(
|
||||
"SELECT body FROM goal_cells WHERE row_id = %s AND month BETWEEN %s AND %s "
|
||||
"ORDER BY month",
|
||||
(row_id, s, e),
|
||||
).fetchall()
|
||||
]
|
||||
text = store.validate_goal_text("\n".join(b for b in bodies if b))
|
||||
conn.execute(
|
||||
"DELETE FROM goal_cell_merges WHERE row_id = %s AND start_month BETWEEN %s AND %s",
|
||||
(row_id, s, e),
|
||||
)
|
||||
conn.execute(
|
||||
"DELETE FROM goal_cells WHERE row_id = %s AND month BETWEEN %s AND %s",
|
||||
(row_id, s, e),
|
||||
)
|
||||
if text:
|
||||
conn.execute(
|
||||
"INSERT INTO goal_cells (row_id, month, body, updated_by) VALUES (%s,%s,%s,%s)",
|
||||
(row_id, s, text, who),
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO goal_cell_merges (row_id, start_month, span, updated_by) "
|
||||
"VALUES (%s, %s, %s, %s)",
|
||||
(row_id, s, e - s + 1, who),
|
||||
)
|
||||
return s, e - s + 1
|
||||
|
||||
def unmerge_goal_cells(self, *, row_id: int, start: int) -> None:
|
||||
"""병합 해제 — 글은 시작 월 칸에 그대로 남는다."""
|
||||
with self._pool.connection() as conn:
|
||||
if not self._table_exists(conn, "goal_cell_merges"):
|
||||
raise store.GoalMigration014Needed()
|
||||
row = conn.execute(
|
||||
"DELETE FROM goal_cell_merges WHERE row_id = %s AND start_month = %s RETURNING row_id",
|
||||
(row_id, start),
|
||||
).fetchone()
|
||||
if row is None:
|
||||
raise KeyError(row_id)
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 직렬화
|
||||
# ════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -2514,6 +2514,7 @@ def inbox_page(request: Request) -> HTMLResponse:
|
||||
# 조회: project 권한자 전원 · 입력/구조 변경: 관리자(is_admin) 전용
|
||||
# ────────────────────────────────────────────────────────────
|
||||
_GOALS_MIGRATION_MSG = "연간 목표 기능이 아직 준비되지 않았습니다(DB 마이그레이션 013 필요)."
|
||||
_GOALS_014_MSG = "상·하반기 칸과 칸 병합은 DB 마이그레이션 014 가 필요합니다."
|
||||
|
||||
|
||||
def _fmt_goal_num(v: float | None) -> str:
|
||||
@@ -2525,10 +2526,37 @@ def _fmt_goal_num(v: float | None) -> str:
|
||||
return f"{v:,.2f}".rstrip("0").rstrip(".")
|
||||
|
||||
|
||||
def _goal_label(metric: str, v: float | None) -> str:
|
||||
"""지표 칸 표기 — 로아스는 % 단위(499 → "499%"). 입력칸도 이 표기로 보이고, 저장 때 % 는 떼고 읽는다."""
|
||||
s = _fmt_goal_num(v)
|
||||
return f"{s}%" if s and metric == "roas" else s
|
||||
|
||||
|
||||
def _goal_row_layout(merges: dict[int, int], this_month: int) -> list[dict[str, Any]]:
|
||||
"""업무 영역 한 줄의 칸 배치 — 연간 · 1~6월 · 상반기 · 7~12월 · 하반기 순서.
|
||||
|
||||
월 칸은 병합(시작 월 → 칸 수)을 반영해 {"m", "span", "h"(1|2), "now"}, 연간·반기 칸은 {"m": 0|13|14}.
|
||||
병합 정보가 반기를 넘거나 겹치면(있을 수 없지만) 그 병합은 무시한다."""
|
||||
out: list[dict[str, Any]] = [{"m": store.GOAL_YEAR, "kind": "year"}]
|
||||
for h, (lo, hi, half_m) in enumerate(((1, 6, store.GOAL_H1), (7, 12, store.GOAL_H2)), start=1):
|
||||
mo = lo
|
||||
while mo <= hi:
|
||||
span = int(merges.get(mo, 1) or 1)
|
||||
if span < 1 or mo + span - 1 > hi:
|
||||
span = 1
|
||||
out.append({"m": mo, "span": span, "h": h, "kind": "month",
|
||||
"now": mo <= this_month <= mo + span - 1})
|
||||
mo += span
|
||||
out.append({"m": half_m, "kind": "half", "h": h})
|
||||
return out
|
||||
|
||||
|
||||
def _goal_call(fn: Any, *args: Any, **kwargs: Any) -> Any:
|
||||
"""목표 DB 호출 공통 — 013 미적용 503, 없는 대상 404, 입력 오류 400."""
|
||||
try:
|
||||
return fn(*args, **kwargs)
|
||||
except store.GoalMigration014Needed:
|
||||
raise HTTPException(status_code=503, detail=_GOALS_014_MSG)
|
||||
except UndefinedTable:
|
||||
raise HTTPException(status_code=503, detail=_GOALS_MIGRATION_MSG)
|
||||
except KeyError:
|
||||
@@ -2562,11 +2590,15 @@ def goals_page(request: Request, year: int) -> HTMLResponse:
|
||||
admin = is_admin(user)
|
||||
enabled = st.goals_enabled()
|
||||
board = st.get_goal_board(year=year) if enabled else None
|
||||
if board:
|
||||
for m in board["metrics"].values():
|
||||
for kind in list(m):
|
||||
m[kind + "_label"] = {mo: _fmt_goal_num(v) for mo, v in m[kind].items()}
|
||||
today = today_kst()
|
||||
this_month = today.month if today.year == year else 0
|
||||
if board:
|
||||
for metric, m in board["metrics"].items():
|
||||
for kind in list(m):
|
||||
m[kind + "_label"] = {mo: _goal_label(metric, v) for mo, v in m[kind].items()}
|
||||
for area in board["areas"]:
|
||||
for row in area["rows"]:
|
||||
row["layout"] = _goal_row_layout(row.get("merges") or {}, this_month)
|
||||
return render_template(
|
||||
request,
|
||||
"project/goals.html",
|
||||
@@ -2588,7 +2620,9 @@ def goals_page(request: Request, year: int) -> HTMLResponse:
|
||||
"goal_year": year,
|
||||
"board": board,
|
||||
"months": list(range(1, 13)),
|
||||
"this_month": today.month if today.year == year else 0,
|
||||
"halves": [(1, list(range(1, 7)), store.GOAL_H1, "상반기"),
|
||||
(2, list(range(7, 13)), store.GOAL_H2, "하반기")],
|
||||
"this_month": this_month,
|
||||
"goal_area_colors": list(store.GOAL_AREA_COLORS),
|
||||
},
|
||||
)
|
||||
@@ -2631,7 +2665,7 @@ def api_set_goal_metric(request: Request, year: int, payload: dict[str, Any] = B
|
||||
kind=str(payload.get("kind") or ""), month=payload.get("month"),
|
||||
value=value, updated_by=user["email"],
|
||||
)
|
||||
return JSONResponse({"ok": True, "value": value, "label": _fmt_goal_num(value)})
|
||||
return JSONResponse({"ok": True, "value": value, "label": _goal_label(str(payload.get("metric") or ""), value)})
|
||||
|
||||
|
||||
@router.post("/api/goals/{year}/areas")
|
||||
@@ -2703,7 +2737,7 @@ def api_move_goal_row(request: Request, row_id: int, payload: dict[str, Any] = B
|
||||
def api_set_goal_cell(
|
||||
request: Request, row_id: int, month: int, payload: dict[str, Any] = Body(...)
|
||||
) -> JSONResponse:
|
||||
"""업무 영역 칸 글 — month 0 = 연간, 1~12 = 월. 빈 글 = 지움."""
|
||||
"""업무 영역 칸 글 — month 0 = 연간, 1~12 = 월, 13 = 상반기, 14 = 하반기(014). 빈 글 = 지움."""
|
||||
user = _require_admin(request)
|
||||
st = _db_or_503(request)
|
||||
_goal_call(
|
||||
@@ -2711,3 +2745,24 @@ def api_set_goal_cell(
|
||||
body=payload.get("body", ""), updated_by=user["email"],
|
||||
)
|
||||
return JSONResponse({"ok": True})
|
||||
|
||||
|
||||
@router.post("/api/goals/rows/{row_id}/merge")
|
||||
def api_merge_goal_cells(request: Request, row_id: int, payload: dict[str, Any] = Body(...)) -> JSONResponse:
|
||||
"""월 칸 가로 병합 {start, end}(반기 안, 2칸 이상) — 걸친 병합은 흡수, 글은 이어서 시작 월 칸에."""
|
||||
user = _require_admin(request)
|
||||
st = _db_or_503(request)
|
||||
start, span = _goal_call(
|
||||
st.merge_goal_cells, row_id=row_id, start=payload.get("start"), end=payload.get("end"),
|
||||
updated_by=user["email"],
|
||||
)
|
||||
return JSONResponse({"ok": True, "start": start, "span": span})
|
||||
|
||||
|
||||
@router.delete("/api/goals/rows/{row_id}/merge/{start}")
|
||||
def api_unmerge_goal_cells(request: Request, row_id: int, start: int) -> JSONResponse:
|
||||
"""병합 해제 — 글은 시작 월 칸에 남는다."""
|
||||
_require_admin(request)
|
||||
st = _db_or_503(request)
|
||||
_goal_call(st.unmerge_goal_cells, row_id=row_id, start=start)
|
||||
return JSONResponse({"ok": True})
|
||||
|
||||
@@ -356,7 +356,7 @@ def validate_time(t: Any) -> str | None:
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 연간 목표 (마이그레이션 013) — 사이드바 "목표" → 연도
|
||||
# ════════════════════════════════════════════════════════════
|
||||
GOAL_METRICS: tuple[str, ...] = ("sales", "roas") # 매출 · 로아스
|
||||
GOAL_METRICS: tuple[str, ...] = ("sales", "roas") # 매출 · 로아스(단위 %)
|
||||
GOAL_KINDS: tuple[str, ...] = ("target", "actual") # 목표 · 실적
|
||||
# 업무 영역 줄 배경색 — 스프레드시트처럼 연한 색 16가지(글자는 항상 진한 색, 8칸×2줄).
|
||||
# 처음 8색(상품·마케팅·컨텐츠·유통 기본색 포함)은 예전 목록 그대로 들어 있다.
|
||||
@@ -386,17 +386,46 @@ def validate_goal_year(y: Any) -> int:
|
||||
return v
|
||||
|
||||
|
||||
class GoalMigration014Needed(RuntimeError):
|
||||
"""상·하반기 글 칸·월 칸 병합은 마이그레이션 014(goal_cell_merges) 뒤에만 된다."""
|
||||
|
||||
|
||||
GOAL_YEAR = 0 # 업무 영역 글 칸 — 연간
|
||||
GOAL_H1 = 13 # 상반기(1~6월) — 마이그레이션 014
|
||||
GOAL_H2 = 14 # 하반기(7~12월)
|
||||
|
||||
|
||||
def goal_half_of(month: int) -> int:
|
||||
"""1~6월 → 1(상반기), 7~12월 → 2(하반기)."""
|
||||
return 1 if month <= 6 else 2
|
||||
|
||||
|
||||
def validate_goal_month(m: Any, *, allow_year: bool = False) -> int:
|
||||
"""1~12월. allow_year 이면 0(연간)도 허용."""
|
||||
"""1~12월. allow_year 이면 업무 영역 글 칸 — 0(연간)·13(상반기)·14(하반기)도 허용."""
|
||||
try:
|
||||
v = int(m)
|
||||
except (TypeError, ValueError):
|
||||
raise ValueError("월이 올바르지 않습니다.")
|
||||
if not ((0 if allow_year else 1) <= v <= 12):
|
||||
if not ((0 if allow_year else 1) <= v <= (GOAL_H2 if allow_year else 12)):
|
||||
raise ValueError("월이 올바르지 않습니다.")
|
||||
return v
|
||||
|
||||
|
||||
def validate_goal_merge(start: Any, end: Any) -> tuple[int, int]:
|
||||
"""월 칸 병합 범위(start~end 월, 2칸 이상) — 상반기·하반기를 넘지 않는다."""
|
||||
try:
|
||||
s, e = int(start), int(end)
|
||||
except (TypeError, ValueError):
|
||||
raise ValueError("병합할 월이 올바르지 않습니다.")
|
||||
if s > e:
|
||||
s, e = e, s
|
||||
if not (1 <= s and e <= 12) or s == e:
|
||||
raise ValueError("병합은 1~12월 안에서 2칸 이상 골라야 합니다.")
|
||||
if goal_half_of(s) != goal_half_of(e):
|
||||
raise ValueError("상반기(1~6월)와 하반기(7~12월)를 넘어 병합할 수 없습니다.")
|
||||
return s, e
|
||||
|
||||
|
||||
def validate_goal_value(v: Any) -> float | None:
|
||||
"""지표 숫자 — '1,234.5' 같은 쉼표·공백·% 는 떼고 읽는다. 빈값은 None(=지움)."""
|
||||
s = norm_str(v).replace(",", "").replace("%", "").replace(" ", "")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -51,8 +51,9 @@
|
||||
{% else %}
|
||||
{% set sm = board.metrics.sales %}
|
||||
{% set rm = board.metrics.roas %}
|
||||
{# 월 칸은 pj-goal-m + data-h(1 = 상반기 1~6월, 2 = 하반기 7~12월) — 반기 접기(initGoals)가 이걸로 숨긴다 #}
|
||||
{% macro num_cell(metric, kind, labels, mo) -%}
|
||||
<td class="pj-goal-numtd{% if mo == this_month %} is-now{% endif %}">
|
||||
<td class="pj-goal-numtd pj-goal-m{% if mo == this_month %} is-now{% endif %}" data-h="{{ 1 if mo <= 6 else 2 }}">
|
||||
{%- if is_admin -%}
|
||||
<input type="text" class="pj-goal-num" inputmode="decimal" autocomplete="off"
|
||||
data-metric="{{ metric }}" data-kind="{{ kind }}" data-month="{{ mo }}"
|
||||
@@ -63,88 +64,114 @@
|
||||
</td>
|
||||
{%- endmacro %}
|
||||
<table class="pj-goal-table" id="pj-goal-table" data-year="{{ goal_year }}"
|
||||
data-admin="{{ 'true' if is_admin else 'false' }}">
|
||||
data-admin="{{ 'true' if is_admin else 'false' }}"
|
||||
data-halves="{{ 'true' if board.halves else 'false' }}">
|
||||
<thead>
|
||||
<tr>
|
||||
{# 오른쪽 끝을 끌어 이름 칸 너비 조절 — 브라우저에 기억(localStorage pj_goal_col_w) #}
|
||||
<th class="pj-goal-c1"><span class="pj-goal-colresize" data-col="c1" title="끌어서 너비 조절"></span></th>
|
||||
<th class="pj-goal-c2"><span class="pj-goal-colresize" data-col="c2" title="끌어서 너비 조절"></span></th>
|
||||
<th class="pj-goal-year-col">연간</th>
|
||||
{% for mo in months %}<th class="{% if mo == this_month %}is-now{% endif %}">{{ mo }}월</th>{% endfor %}
|
||||
{% for h, hmonths, hm, hname in halves %}
|
||||
{% for mo in hmonths %}<th class="pj-goal-m{% if mo == this_month %} is-now{% endif %}" data-h="{{ h }}"><span class="pj-goal-mlabel">{{ mo }}월</span></th>{% endfor %}
|
||||
{# 반기 칸 — 버튼으로 그 반기의 월 칸을 접었다 편다(localStorage pj_goal_fold) #}
|
||||
<th class="pj-goal-half-col" data-h="{{ h }}">
|
||||
<button type="button" class="pj-goal-fold" data-h="{{ h }}" aria-expanded="true"
|
||||
data-label="{{ hmonths[0] }}~{{ hmonths[-1] }}월"
|
||||
title="{{ hmonths[0] }}~{{ hmonths[-1] }}월 접기"><span class="material-symbols-outlined">chevron_left</span></button>{{ hname }}
|
||||
</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
{# ── 숫자 지표 ── #}
|
||||
{# ── 숫자 지표 — 연간·반기 칸은 화면에서 계산(매출 합계·달성률), 로아스는 % 단위 ── #}
|
||||
<tbody class="pj-goal-kpi">
|
||||
<tr>
|
||||
<th class="pj-goal-c1" rowspan="3">매출</th>
|
||||
<th class="pj-goal-c2">목표</th>
|
||||
<td class="pj-goal-sum" data-metric="sales" data-kind="target"></td>
|
||||
{% for mo in months %}{{ num_cell("sales", "target", sm.target_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-year-col" data-metric="sales" data-kind="target" data-scope="0"></td>
|
||||
{% for h, hmonths, hm, hname in halves %}
|
||||
{% for mo in hmonths %}{{ num_cell("sales", "target", sm.target_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-half-col" data-metric="sales" data-kind="target" data-scope="{{ hm }}"></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="pj-goal-c2">실적</th>
|
||||
<td class="pj-goal-sum" data-metric="sales" data-kind="actual"></td>
|
||||
{% for mo in months %}{{ num_cell("sales", "actual", sm.actual_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-year-col" data-metric="sales" data-kind="actual" data-scope="0"></td>
|
||||
{% for h, hmonths, hm, hname in halves %}
|
||||
{% for mo in hmonths %}{{ num_cell("sales", "actual", sm.actual_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-half-col" data-metric="sales" data-kind="actual" data-scope="{{ hm }}"></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
<tr class="pj-goal-rate-row">
|
||||
<th class="pj-goal-c2">달성</th>
|
||||
<td class="pj-goal-rate" data-month="0"></td>
|
||||
{% for mo in months %}<td class="pj-goal-rate{% if mo == this_month %} is-now{% endif %}" data-month="{{ mo }}"></td>{% endfor %}
|
||||
<td class="pj-goal-rate pj-goal-year-col" data-month="0"></td>
|
||||
{% for h, hmonths, hm, hname in halves %}
|
||||
{% for mo in hmonths %}<td class="pj-goal-rate pj-goal-m{% if mo == this_month %} is-now{% endif %}" data-h="{{ h }}" data-month="{{ mo }}"></td>{% endfor %}
|
||||
<td class="pj-goal-rate pj-goal-half-col" data-month="{{ hm }}"></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="pj-goal-c1" rowspan="2">로아스</th>
|
||||
<th class="pj-goal-c2">목표</th>
|
||||
<td class="pj-goal-sum pj-goal-sum-na"></td>
|
||||
{% for mo in months %}{{ num_cell("roas", "target", rm.target_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-sum-na pj-goal-year-col"></td>
|
||||
{% for h, hmonths, hm, hname in halves %}
|
||||
{% for mo in hmonths %}{{ num_cell("roas", "target", rm.target_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-sum-na pj-goal-half-col"></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="pj-goal-c2">실적</th>
|
||||
<td class="pj-goal-sum pj-goal-sum-na"></td>
|
||||
{% for mo in months %}{{ num_cell("roas", "actual", rm.actual_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-sum-na pj-goal-year-col"></td>
|
||||
{% for h, hmonths, hm, hname in halves %}
|
||||
{% for mo in hmonths %}{{ num_cell("roas", "actual", rm.actual_label, mo) }}{% endfor %}
|
||||
<td class="pj-goal-sum pj-goal-sum-na pj-goal-half-col"></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
{# ── 업무 영역 — 영역마다 tbody 하나, 배경은 영역 색 ── #}
|
||||
{# ── 업무 영역 — 영역마다 tbody 하나, 배경은 영역 색. 이름은 눌러서 그 자리에서 수정(관리자) ── #}
|
||||
{% for area in board.areas %}
|
||||
<tbody class="pj-goal-area" data-area-id="{{ area.id }}" style="--goal-bg: {{ area.color or '#fff' }}">
|
||||
{% for row in area.rows %}
|
||||
<tr data-row-id="{{ row.id }}">
|
||||
{% if loop.first %}
|
||||
<th class="pj-goal-c1 pj-goal-area-name" rowspan="{{ area.rows | length }}">
|
||||
<span class="pj-goal-area-text">{{ area.name }}</span>
|
||||
<span class="pj-goal-area-text"{% if is_admin %} data-goal-edit="area" title="눌러서 이름 수정"{% endif %}>{{ area.name }}</span>
|
||||
{% if is_admin %}
|
||||
<span class="pj-goal-tools">
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="area-rename" data-name="{{ area.name }}" title="이름 바꾸기">✎</button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="area-color" data-color="{{ area.color }}" title="색 바꾸기"><span class="material-symbols-outlined">palette</span></button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="area-up" title="위로">↑</button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="area-down" title="아래로">↓</button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="row-add" title="줄 추가">+</button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="area-del" data-name="{{ area.name }}" title="영역 삭제">×</button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="area-del" title="영역 삭제">×</button>
|
||||
</span>
|
||||
{% endif %}
|
||||
</th>
|
||||
{% endif %}
|
||||
<th class="pj-goal-c2 pj-goal-row-label">
|
||||
<span class="pj-goal-row-text">{{ row.label }}</span>
|
||||
{% if is_admin %}
|
||||
<span class="pj-goal-row-text"{% if is_admin %} data-goal-edit="row" title="눌러서 줄 이름 수정"{% endif %}>{{ row.label }}</span>
|
||||
{% if is_admin and area.rows | length > 1 %}
|
||||
<span class="pj-goal-tools">
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="row-rename" data-label="{{ row.label }}" title="줄 이름 바꾸기">✎</button>
|
||||
{% if area.rows | length > 1 %}
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="row-up" title="위로">↑</button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="row-down" title="아래로">↓</button>
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="row-del" data-label="{{ row.label }}" title="줄 삭제">×</button>
|
||||
{% endif %}
|
||||
<button type="button" class="pj-icon-btn" data-goal-act="row-del" title="줄 삭제">×</button>
|
||||
</span>
|
||||
{% endif %}
|
||||
</th>
|
||||
{% for mo in [0] + months %}
|
||||
<td class="pj-goal-texttd{% if mo == 0 %} pj-goal-year-col{% endif %}{% if mo == this_month %} is-now{% endif %}">
|
||||
{%- if is_admin -%}
|
||||
<textarea class="pj-goal-text" rows="1" data-row="{{ row.id }}" data-month="{{ mo }}"
|
||||
placeholder="{{ '연간 목표' if mo == 0 else '' }}">{{ row.cells.get(mo, '') }}</textarea>
|
||||
{% for c in row.layout %}
|
||||
{% set editable = is_admin and (c.kind != 'half' or board.halves) %}
|
||||
{% if c.kind == 'month' %}
|
||||
<td class="pj-goal-texttd pj-goal-m{% if c.span > 1 %} is-merged{% endif %}{% if c.now %} is-now{% endif %}"
|
||||
data-h="{{ c.h }}" data-month="{{ c.m }}" data-span="{{ c.span }}"{% if c.span > 1 %} colspan="{{ c.span }}" style="--span: {{ c.span }}"{% endif %}>
|
||||
{% else %}
|
||||
<td class="pj-goal-texttd {{ 'pj-goal-year-col' if c.kind == 'year' else 'pj-goal-half-col' }}" data-month="{{ c.m }}">
|
||||
{% endif %}
|
||||
{%- if editable -%}
|
||||
<textarea class="pj-goal-text" rows="1" data-row="{{ row.id }}" data-month="{{ c.m }}"
|
||||
placeholder="{{ '연간 목표' if c.m == 0 else ('상반기 목표' if c.m == 13 else ('하반기 목표' if c.m == 14 else '')) }}">{{ row.cells.get(c.m, '') }}</textarea>
|
||||
{%- else -%}
|
||||
<div class="pj-goal-text-ro">{{ row.cells.get(mo, '') }}</div>
|
||||
<div class="pj-goal-text-ro">{{ row.cells.get(c.m, '') }}</div>
|
||||
{%- endif -%}
|
||||
</td>
|
||||
{% endfor %}
|
||||
@@ -156,7 +183,8 @@
|
||||
{% if is_admin %}
|
||||
<div class="pj-goal-foot">
|
||||
<button type="button" class="pj-btn" id="pj-goal-area-add">+ 업무 영역 추가</button>
|
||||
<span class="pj-goal-note">칸을 고치면 바로 저장됩니다. 숫자 칸을 비우면 지워집니다.</span>
|
||||
<span class="pj-goal-note">칸을 고치면 바로 저장됩니다. 숫자 칸을 비우면 지워집니다.
|
||||
{%- if board.halves %} 월 칸은 Shift+클릭으로 여러 칸을 고른 뒤 병합하거나, 우클릭 메뉴로 병합·해제합니다.{% endif %}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -169,5 +197,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
<script src="/static/project.js?v=20261001a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
|
||||
<link rel="stylesheet" href="/static/project-help.css?v=20260926v" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
@@ -89,10 +89,15 @@
|
||||
<li><b>내 작업</b> — 내가 담당자인 작업 모음. 숫자 배지는 아직 끝나지 않은 작업 수입니다. (<a href="#mytasks">15장</a>)</li>
|
||||
<li><b>휴지통</b> — 지운 작업을 3개월 보관합니다. 관리자에게만 보입니다. (<a href="#trash">19장</a>)</li>
|
||||
<li><b>목표</b> — 누르면 바로 아래에 연도가 펼쳐집니다. 연도를 누르면 오른쪽에 그해 전체 목표가 한 표로 나옵니다 —
|
||||
맨 위에 <b>매출</b>(목표·실적·달성률)과 <b>로아스</b>(목표·실적)를 달마다, 그 아래에 <b>업무 영역</b>(상품·마케팅·컨텐츠·유통 등)별로
|
||||
연간·월별 계획을 적습니다. 매출의 <b>연간</b> 칸은 월 합계, <b>달성</b>은 실적÷목표(100% 이상 초록)로 저절로 계산됩니다.
|
||||
맨 위에 <b>매출</b>(목표·실적·달성률)과 <b>로아스</b>(목표·실적, 단위 %)를 달마다, 그 아래에 <b>업무 영역</b>(상품·마케팅·컨텐츠·유통 등)별로
|
||||
연간·반기·월별 계획을 적습니다. 6월 오른쪽에 <b>상반기</b>, 12월 오른쪽에 <b>하반기</b> 칸이 있고, 매출의 <b>연간·반기</b> 칸은 월 합계,
|
||||
<b>달성</b>은 실적÷목표(100% 이상 초록)로 저절로 계산됩니다. 반기 칸 머리의 <b>‹</b> 버튼을 누르면 그 반기의 월 칸(1~6월 또는 7~12월)이
|
||||
접히고, 다시 누르면 펼쳐집니다(접힌 상태는 내 브라우저에 기억).
|
||||
<b>입력은 관리자만</b> 할 수 있고(칸을 고치면 바로 저장), 다른 직원은 보기만 합니다. 관리자는 <b>+ 연도 추가</b>로 새해 목표를
|
||||
만들고(이전 연도의 업무 영역 구성을 그대로 가져옴), 영역 이름 칸에 마우스를 올려 이름·색·순서·줄 추가·삭제를 합니다.</li>
|
||||
만들고(이전 연도의 업무 영역 구성을 그대로 가져옴), 영역·줄 이름은 <b>눌러서 그 자리에서 고치고</b>(Enter 저장, Esc 취소),
|
||||
이름 칸에 마우스를 올려 색·순서·줄 추가·삭제를 합니다. 업무 영역의 월 칸은 <b>병합</b>할 수 있습니다 — 한 칸을 누르고
|
||||
<b>Shift+클릭</b>으로 같은 줄의 다른 칸까지 고른 뒤 떠 있는 "병합" 버튼을 누르거나, 칸을 <b>우클릭</b>해 "오른쪽/왼쪽 칸과 병합"·"병합 해제".
|
||||
병합은 상반기·하반기 안에서만 되고, 칸들의 글은 월 순서대로 첫 칸에 모입니다.</li>
|
||||
<li><b>프로젝트</b> — 내가 멤버인 프로젝트 목록입니다. 누르면 그 프로젝트 화면으로 갑니다. 완료한 프로젝트는 아래 <b>완료 프로젝트</b>에 흐리게 모입니다.</li>
|
||||
<li><b>전체 멤버</b> — 관리자에게만 보입니다. 사람 아이콘을 누르면 그 사람이 맡은 모든 작업을 한눈에 봅니다.</li>
|
||||
</ul>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -104,5 +104,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
<script src="/static/project.js?v=20261001a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -100,5 +100,5 @@
|
||||
"today": {{ today | tojson }}
|
||||
}
|
||||
</script>
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
<script src="/static/project.js?v=20261001a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
|
||||
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<!-- 타임라인 vis-timeline — self-host -->
|
||||
@@ -496,5 +496,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
<script src="/static/project.js?v=20261001a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
<script src="/static/project.js?v=20261001a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
+55
-1
@@ -2006,8 +2006,10 @@ html.pj-ui-scale .pj-modal-chat { max-height: calc(92vh / var(--pj-z)); }
|
||||
|
||||
/* 가로·세로 스크롤은 이 칸 하나가 맡고, 머리 줄과 왼쪽 두 칸(구분·항목)은 붙어 있다 */
|
||||
.pj-goal-pane { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
||||
/* width: 1px — table-layout: fixed 는 표 너비가 auto 가 아닐 때만 먹는다. 표는 칸 너비 합만큼 늘어나고,
|
||||
칸 너비가 머리 칸 width 로만 정해져야 반기 접기 애니메이션이 양방향으로 부드럽다(auto 면 펼 때 한 번에 튄다). */
|
||||
.pj-goal-table {
|
||||
border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12.5px;
|
||||
width: 1px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12.5px;
|
||||
color: var(--pj-ink); background: #fff; border: 1px solid #dfe2e6; border-radius: 10px;
|
||||
}
|
||||
/* 칸 너비는 여백·테두리 포함(border-box) — 안 그러면 padding 만큼 넓어진다 */
|
||||
@@ -2093,6 +2095,58 @@ textarea.pj-goal-text::placeholder { color: rgba(0, 0, 0, .3); }
|
||||
.pj-goal-numtd.is-saved, .pj-goal-texttd.is-saved { animation: pj-goal-saved 1s ease-out; }
|
||||
@keyframes pj-goal-saved { from { box-shadow: inset 0 0 0 2px #34a853; } to { box-shadow: inset 0 0 0 2px transparent; } }
|
||||
|
||||
.pj-goal-table th.is-saved { animation: pj-goal-saved 1s ease-out; }
|
||||
|
||||
/* 상반기·하반기 칸 — 6월·12월 오른쪽. 앞 칸 오른쪽 테두리와 겹쳐 두 줄로 구분된다. */
|
||||
.pj-goal-table thead th.pj-goal-half-col {
|
||||
width: 90px; min-width: 90px; max-width: 90px; padding: 0 6px; background: #eef0f3;
|
||||
}
|
||||
.pj-goal-table .pj-goal-half-col { border-left: 1px solid #cfd3d8; }
|
||||
.pj-goal-kpi td.pj-goal-half-col { background: #f4f5f7; }
|
||||
.pj-goal-texttd.pj-goal-half-col { font-weight: 600; }
|
||||
.pj-goal-kpi td { white-space: nowrap; }
|
||||
/* 반기 접기 버튼(반기 칸 머리) — 펼침 = ‹(왼쪽 월 칸을 접는다), 접힘 = 뒤집혀 ›, 강조색 */
|
||||
.pj-goal-fold {
|
||||
display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
|
||||
margin: 0 2px 0 -2px; padding: 0; border: none; border-radius: 5px; background: transparent;
|
||||
color: var(--pj-ink-soft); cursor: pointer; vertical-align: -5px;
|
||||
}
|
||||
.pj-goal-fold:hover { background: #dfe2e7; color: var(--pj-ink); }
|
||||
.pj-goal-fold .material-symbols-outlined { font-size: 18px; transition: transform .32s ease; }
|
||||
.pj-goal-fold.is-folded { background: var(--pj-accent-tint); color: var(--pj-accent-dark); }
|
||||
.pj-goal-fold.is-folded .material-symbols-outlined { transform: rotate(180deg); }
|
||||
/* 접기 애니메이션 — 월 칸 너비를 0 으로(.is-shrunk) 줄인 뒤 숨김(.is-gone), 펼 땐 거꾸로(initGoals applyFold).
|
||||
줄어드는 동안 칸 안 글이 다시 줄바꿈돼 줄 높이가 출렁이지 않게 안쪽 내용은 원래 폭(85px × 칸 수)으로 고정해 잘라 낸다. */
|
||||
.pj-goal-table .pj-goal-m { overflow: hidden; }
|
||||
.pj-goal-table.is-folding .pj-goal-m {
|
||||
transition: width .32s ease, min-width .32s ease, max-width .32s ease,
|
||||
padding .32s ease, border-right-width .32s ease;
|
||||
}
|
||||
.pj-goal-table.is-folding td.pj-goal-m > * { width: calc(85px * var(--span, 1) - 1px); }
|
||||
.pj-goal-table thead th.pj-goal-m.is-shrunk,
|
||||
.pj-goal-table td.pj-goal-m.is-shrunk {
|
||||
width: 0; min-width: 0; max-width: 0; padding-left: 0 !important; padding-right: 0 !important; border-right-width: 0;
|
||||
}
|
||||
.pj-goal-table .pj-goal-m.is-gone { display: none; }
|
||||
|
||||
/* 영역·줄 이름 — 눌러서 그 자리에서 수정(관리자) */
|
||||
.pj-goal-table [data-goal-edit] { cursor: text; border-radius: 5px; padding: 1px 3px; margin: -1px -3px; }
|
||||
.pj-goal-table [data-goal-edit]:hover { background: rgba(255, 255, 255, .65); box-shadow: 0 0 0 1px rgba(0, 0, 0, .14); }
|
||||
.pj-goal-table [data-goal-edit].is-editing {
|
||||
background: #fff; box-shadow: 0 0 0 2px var(--pj-accent); outline: none; word-break: normal;
|
||||
}
|
||||
.pj-goal-row-text[data-goal-edit]:empty { min-height: 1.5em; }
|
||||
.pj-goal-row-text[data-goal-edit]:empty:hover::before { content: "줄 이름"; color: rgba(0, 0, 0, .3); font-weight: 500; }
|
||||
|
||||
/* 월 칸 병합 — Shift+클릭 선택 표시와 떠 있는 병합 버튼(body 에 붙음) */
|
||||
.pj-goal-table td.pj-goal-texttd.is-merge-sel {
|
||||
box-shadow: inset 0 0 0 2px var(--pj-accent);
|
||||
background-image: linear-gradient(rgba(123, 104, 238, .12), rgba(123, 104, 238, .12));
|
||||
}
|
||||
.pj-goal-mergebar { position: fixed; z-index: 1000; }
|
||||
.pj-goal-mergebar .pj-btn { display: inline-flex; align-items: center; gap: 4px; box-shadow: 0 6px 18px rgba(16, 24, 40, .2); }
|
||||
.pj-goal-mergebar .material-symbols-outlined { font-size: 18px; }
|
||||
|
||||
.pj-goal-foot { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; }
|
||||
|
||||
/* 영역 색 고르기 팝업(body 에 붙음) */
|
||||
|
||||
+281
-28
@@ -8025,27 +8025,104 @@
|
||||
td.textContent = (Math.round(r * 10) / 10).toLocaleString("ko-KR") + "%";
|
||||
td.classList.add(r >= 100 ? "is-good" : "is-low");
|
||||
}
|
||||
// 합계 칸 — 연간(0) · 상반기(13, 1~6월) · 하반기(14, 7~12월)
|
||||
const SUM_SCOPES = [[0, 1, 12], [13, 1, 6], [14, 7, 12]];
|
||||
function recompute() {
|
||||
const tg = values("sales", "target"), ac = values("sales", "actual");
|
||||
let sumT = null, sumA = null;
|
||||
for (let m = 1; m <= 12; m++) {
|
||||
if (tg[m] != null) sumT = (sumT || 0) + tg[m];
|
||||
if (ac[m] != null) sumA = (sumA || 0) + ac[m];
|
||||
const td = table.querySelector('.pj-goal-rate[data-month="' + m + '"]');
|
||||
if (td) setRate(td, ac[m], tg[m]);
|
||||
}
|
||||
const st = table.querySelector('.pj-goal-sum[data-metric="sales"][data-kind="target"]');
|
||||
const sa = table.querySelector('.pj-goal-sum[data-metric="sales"][data-kind="actual"]');
|
||||
if (st) st.textContent = sumT == null ? "" : fmtNum(sumT);
|
||||
if (sa) sa.textContent = sumA == null ? "" : fmtNum(sumA);
|
||||
// 연간 달성률은 실적이 들어온 달까지만 비교(남은 달 목표까지 넣으면 연중엔 항상 낮게 나온다).
|
||||
let tUpTo = 0;
|
||||
for (let m = 1; m <= 12; m++) if (ac[m] != null && tg[m] != null) tUpTo += tg[m];
|
||||
const y0 = table.querySelector('.pj-goal-rate[data-month="0"]');
|
||||
if (y0) setRate(y0, sumA, tUpTo);
|
||||
if (y0) y0.dataset.tip = tUpTo ? "실적이 있는 달의 목표 합계 대비" : "";
|
||||
SUM_SCOPES.forEach(function (sc) {
|
||||
let sumT = null, sumA = null, tUpTo = 0;
|
||||
for (let m = sc[1]; m <= sc[2]; m++) {
|
||||
if (tg[m] != null) sumT = (sumT || 0) + tg[m];
|
||||
if (ac[m] != null) sumA = (sumA || 0) + ac[m];
|
||||
// 달성률은 실적이 들어온 달까지만 비교(남은 달 목표까지 넣으면 기간 중엔 항상 낮게 나온다).
|
||||
if (ac[m] != null && tg[m] != null) tUpTo += tg[m];
|
||||
}
|
||||
const st = table.querySelector('.pj-goal-sum[data-metric="sales"][data-kind="target"][data-scope="' + sc[0] + '"]');
|
||||
const sa = table.querySelector('.pj-goal-sum[data-metric="sales"][data-kind="actual"][data-scope="' + sc[0] + '"]');
|
||||
if (st) st.textContent = sumT == null ? "" : fmtNum(sumT);
|
||||
if (sa) sa.textContent = sumA == null ? "" : fmtNum(sumA);
|
||||
const rt = table.querySelector('.pj-goal-rate[data-month="' + sc[0] + '"]');
|
||||
if (rt) {
|
||||
setRate(rt, sumA, tUpTo);
|
||||
rt.dataset.tip = tUpTo ? "실적이 있는 달의 목표 합계 대비" : "";
|
||||
}
|
||||
});
|
||||
}
|
||||
recompute();
|
||||
|
||||
// ── 상·하반기 접기 — 반기 칸 머리의 버튼이 그 반기 월 칸(.pj-goal-m[data-h])을 접었다 편다.
|
||||
// 칸 너비를 0 으로 줄이는 애니메이션(.is-shrunk, CSS transition) 뒤 display:none(.is-gone),
|
||||
// 펼 때는 거꾸로. 상태는 브라우저에 기억(localStorage pj_goal_fold). 보기만 하는 사람도 쓸 수 있다.
|
||||
const FOLD_KEY = "pj_goal_fold";
|
||||
const FOLD_MS = 320;
|
||||
const fold = { 1: false, 2: false };
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem(FOLD_KEY) || "null");
|
||||
if (saved) { fold[1] = !!saved[1]; fold[2] = !!saved[2]; }
|
||||
} catch (_) {}
|
||||
const foldTimers = {};
|
||||
function halfCells(h) { return table.querySelectorAll('.pj-goal-m[data-h="' + h + '"]'); }
|
||||
function syncFoldBtn(h) {
|
||||
const btn = table.querySelector('.pj-goal-fold[data-h="' + h + '"]');
|
||||
if (!btn) return;
|
||||
btn.classList.toggle("is-folded", fold[h]);
|
||||
btn.setAttribute("aria-expanded", fold[h] ? "false" : "true");
|
||||
btn.title = (btn.dataset.label || "") + (fold[h] ? " 펼치기" : " 접기");
|
||||
delete btn.dataset.tip; // 공용 말풍선이 옮겨 둔 예전 문구 대신 새 title 을 쓰게
|
||||
const th = btn.closest("th");
|
||||
if (th) th.classList.toggle("is-folded", fold[h]);
|
||||
}
|
||||
function applyFold(h, animate) {
|
||||
const cells = halfCells(h);
|
||||
const folded = fold[h];
|
||||
clearTimeout(foldTimers[h]);
|
||||
const reduce = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
syncFoldBtn(h);
|
||||
if (!animate || reduce) {
|
||||
cells.forEach(function (c) { c.classList.toggle("is-shrunk", folded); c.classList.toggle("is-gone", folded); });
|
||||
if (!folded) table.querySelectorAll('.pj-goal-m[data-h="' + h + '"] textarea.pj-goal-text').forEach(fit);
|
||||
return;
|
||||
}
|
||||
table.classList.add("is-folding");
|
||||
if (folded) {
|
||||
cells.forEach(function (c) { c.classList.add("is-shrunk"); });
|
||||
} else {
|
||||
cells.forEach(function (c) { c.classList.remove("is-gone"); });
|
||||
void table.offsetWidth; // 너비 0 인 채로 한 번 그린 뒤 원래 너비로 늘린다
|
||||
cells.forEach(function (c) { c.classList.remove("is-shrunk"); });
|
||||
}
|
||||
foldTimers[h] = setTimeout(function () {
|
||||
if (folded) cells.forEach(function (c) { c.classList.add("is-gone"); });
|
||||
else table.querySelectorAll('.pj-goal-m[data-h="' + h + '"] textarea.pj-goal-text').forEach(fit);
|
||||
if (!foldTimers[3 - h]) table.classList.remove("is-folding");
|
||||
delete foldTimers[h];
|
||||
}, FOLD_MS + 20);
|
||||
}
|
||||
table.querySelectorAll(".pj-goal-fold").forEach(function (btn) {
|
||||
btn.addEventListener("click", function (e) {
|
||||
e.stopPropagation();
|
||||
const h = btn.dataset.h;
|
||||
fold[h] = !fold[h];
|
||||
try { localStorage.setItem(FOLD_KEY, JSON.stringify(fold)); } catch (_) {}
|
||||
clearMergeSel();
|
||||
applyFold(h, true);
|
||||
});
|
||||
});
|
||||
// 글 칸 높이 맞추기 — 접혀 안 보이는 칸은 건너뛴다(높이 0 으로 재져 펼쳤을 때 글이 잘림). 펼칠 때 다시 잰다.
|
||||
function fit(ta) {
|
||||
if (!ta.offsetParent) return;
|
||||
ta.style.height = "auto";
|
||||
ta.style.height = ta.scrollHeight + "px";
|
||||
}
|
||||
applyFold(1, false);
|
||||
applyFold(2, false);
|
||||
|
||||
// 병합 선택(Shift+클릭) — 관리자 전용, 아래에서 채운다. 접기 버튼이 먼저 부르므로 여기 둔다.
|
||||
let clearMergeSel = function () {};
|
||||
if (!isAdmin) return;
|
||||
|
||||
// ── 숫자 칸 ──
|
||||
@@ -8080,7 +8157,6 @@
|
||||
}
|
||||
|
||||
// ── 글 칸 ──
|
||||
function fit(ta) { ta.style.height = "auto"; ta.style.height = ta.scrollHeight + "px"; }
|
||||
const pending = new Map(); // textarea → 타이머
|
||||
function cellUrl(ta) { return "/project/api/goals/rows/" + ta.dataset.row + "/cells/" + ta.dataset.month; }
|
||||
async function saveText(ta) {
|
||||
@@ -8199,7 +8275,13 @@
|
||||
setTimeout(function () { document.addEventListener("mousedown", onColorDocDown, true); }, 0);
|
||||
}
|
||||
|
||||
// ── 영역·줄 도구(✎ 색 ↑ ↓ + ×) — 이벤트 위임 ──
|
||||
// ── 영역·줄 도구(색 ↑ ↓ + ×) — 이벤트 위임. 이름 바꾸기는 이름을 눌러 그 자리에서(아래 startNameEdit) ──
|
||||
function textOf(node, sel) {
|
||||
const t = node && node.querySelector(sel);
|
||||
return t ? t.textContent.trim() : "";
|
||||
}
|
||||
// 저장 안 된 글이 있으면 먼저 저장(구조 변경·병합 전에 — 병합은 서버가 DB 의 글을 모은다)
|
||||
function flushTexts() { return Promise.all(Array.from(pending.keys()).map(saveText)); }
|
||||
table.addEventListener("click", async function (e) {
|
||||
const b = e.target.closest("[data-goal-act]");
|
||||
if (!b) return;
|
||||
@@ -8209,17 +8291,14 @@
|
||||
const areaId = tbody && tbody.dataset.areaId;
|
||||
const rowId = tr && tr.dataset.rowId;
|
||||
try {
|
||||
if (act === "area-rename") {
|
||||
const v = await prompt("업무 영역 이름", b.dataset.name || "");
|
||||
if (v == null || !String(v).trim() || v === b.dataset.name) return;
|
||||
await api("PUT", "/project/api/goals/areas/" + areaId, { name: String(v).trim() });
|
||||
} else if (act === "area-color") {
|
||||
if (act === "area-color") {
|
||||
openColorPop(b, areaId, b.dataset.color, tbody);
|
||||
return;
|
||||
} else if (act === "area-up" || act === "area-down") {
|
||||
await api("POST", "/project/api/goals/areas/" + areaId + "/move", { direction: act === "area-up" ? -1 : 1 });
|
||||
} else if (act === "area-del") {
|
||||
const ok = await confirm("'" + (b.dataset.name || "") + "' 업무 영역을 삭제할까요?\n안의 줄과 글도 모두 삭제됩니다.",
|
||||
const name = textOf(tbody, ".pj-goal-area-text");
|
||||
const ok = await confirm("'" + name + "' 업무 영역을 삭제할까요?\n안의 줄과 글도 모두 삭제됩니다.",
|
||||
{ okText: "삭제", cancelText: "취소" });
|
||||
if (!ok) return;
|
||||
await api("DELETE", "/project/api/goals/areas/" + areaId);
|
||||
@@ -8227,23 +8306,197 @@
|
||||
const v = await prompt("새 줄 이름 (예: 쿠팡 — 비워 둬도 됩니다)", "");
|
||||
if (v == null) return;
|
||||
await api("POST", "/project/api/goals/areas/" + areaId + "/rows", { label: String(v).trim() });
|
||||
} else if (act === "row-rename") {
|
||||
const v = await prompt("줄 이름", b.dataset.label || "");
|
||||
if (v == null || v === b.dataset.label) return;
|
||||
await api("PUT", "/project/api/goals/rows/" + rowId, { label: String(v).trim() });
|
||||
} else if (act === "row-up" || act === "row-down") {
|
||||
await api("POST", "/project/api/goals/rows/" + rowId + "/move", { direction: act === "row-up" ? -1 : 1 });
|
||||
} else if (act === "row-del") {
|
||||
const label = b.dataset.label ? "'" + b.dataset.label + "' 줄" : "이 줄";
|
||||
const lb = textOf(tr, ".pj-goal-row-text");
|
||||
const label = lb ? "'" + lb + "' 줄" : "이 줄";
|
||||
const ok = await confirm(label + "을 삭제할까요? 그 줄의 글도 모두 삭제됩니다.", { okText: "삭제", cancelText: "취소" });
|
||||
if (!ok) return;
|
||||
await api("DELETE", "/project/api/goals/rows/" + rowId);
|
||||
} else return;
|
||||
// 저장 안 된 글이 있으면 먼저 저장하고 새로고침
|
||||
await Promise.all(Array.from(pending.keys()).map(saveText));
|
||||
await flushTexts();
|
||||
reloadKeepScroll();
|
||||
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
|
||||
});
|
||||
|
||||
// ── 영역·줄 이름 — 눌러서 그 자리에서 수정(Enter·칸 떠남 = 저장, Esc = 취소). 서식 없이 글자만. ──
|
||||
function startNameEdit(span) {
|
||||
if (span.isContentEditable) return;
|
||||
const kind = span.dataset.goalEdit;
|
||||
const orig = span.textContent;
|
||||
span.contentEditable = "true";
|
||||
span.classList.add("is-editing");
|
||||
span.focus();
|
||||
const r = document.createRange();
|
||||
r.selectNodeContents(span);
|
||||
const sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(r);
|
||||
let done = false;
|
||||
async function finish(save) {
|
||||
if (done) return;
|
||||
done = true;
|
||||
span.contentEditable = "false";
|
||||
span.classList.remove("is-editing");
|
||||
span.removeEventListener("keydown", onKey);
|
||||
span.removeEventListener("blur", onBlur);
|
||||
const v = span.textContent.replace(/\s+/g, " ").trim();
|
||||
if (!save || v === orig.trim()) { span.textContent = orig; return; }
|
||||
if (kind === "area" && !v) {
|
||||
span.textContent = orig;
|
||||
showToast("업무 영역 이름을 입력하세요.", "error");
|
||||
return;
|
||||
}
|
||||
span.textContent = v;
|
||||
try {
|
||||
if (kind === "area") {
|
||||
await api("PUT", "/project/api/goals/areas/" + span.closest(".pj-goal-area").dataset.areaId, { name: v });
|
||||
} else {
|
||||
await api("PUT", "/project/api/goals/rows/" + span.closest("tr").dataset.rowId, { label: v });
|
||||
}
|
||||
flashSaved(span.closest("th"));
|
||||
} catch (err) {
|
||||
span.textContent = orig;
|
||||
showToast("이름 변경 실패: " + err.message, "error");
|
||||
}
|
||||
}
|
||||
function onKey(e) {
|
||||
if (isImeEnter(e)) return;
|
||||
if (e.key === "Enter") { e.preventDefault(); span.blur(); }
|
||||
else if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); finish(false); span.blur(); }
|
||||
}
|
||||
function onBlur() { finish(true); }
|
||||
span.addEventListener("keydown", onKey);
|
||||
span.addEventListener("blur", onBlur);
|
||||
}
|
||||
table.addEventListener("click", function (e) {
|
||||
const span = e.target.closest("[data-goal-edit]");
|
||||
if (span) startNameEdit(span);
|
||||
});
|
||||
table.addEventListener("paste", function (e) {
|
||||
const span = e.target.closest && e.target.closest("[data-goal-edit].is-editing");
|
||||
if (!span) return;
|
||||
e.preventDefault();
|
||||
const text = ((e.clipboardData || window.clipboardData).getData("text/plain") || "").replace(/\s+/g, " ");
|
||||
document.execCommand("insertText", false, text);
|
||||
});
|
||||
|
||||
// ── 월 칸 병합(마이그레이션 014) — 한 줄의 같은 반기 안에서만.
|
||||
// · Shift+클릭: 마지막으로 누른 월 칸부터 그 칸까지 고른 뒤 떠 있는 "N~M월 병합" 버튼
|
||||
// · 우클릭: 선택한 칸 병합 / 오른쪽·왼쪽 칸과 병합 / 병합 해제
|
||||
// 글은 서버가 월 순서대로 줄바꿈으로 이어 첫 칸에 모은다. 해제하면 글은 첫 칸에 남는다.
|
||||
if (table.dataset.halves === "true") {
|
||||
let anchor = null; // 마지막으로 누른 월 칸
|
||||
let mergeSel = null; // {row, h, start, end}
|
||||
let mergeBar = null;
|
||||
const monthTd = function (node) {
|
||||
const td = node && node.closest && node.closest("td.pj-goal-texttd.pj-goal-m");
|
||||
return td && table.contains(td) ? td : null;
|
||||
};
|
||||
const cellInfo = function (td) {
|
||||
const m = parseInt(td.dataset.month, 10);
|
||||
const span = parseInt(td.dataset.span || "1", 10);
|
||||
return { row: td.closest("tr").dataset.rowId, h: td.dataset.h, start: m, end: m + span - 1, span: span };
|
||||
};
|
||||
clearMergeSel = function () {
|
||||
mergeSel = null;
|
||||
table.querySelectorAll("td.is-merge-sel").forEach(function (td) { td.classList.remove("is-merge-sel"); });
|
||||
if (mergeBar) { mergeBar.remove(); mergeBar = null; }
|
||||
};
|
||||
const mergeCells = async function (rowId, start, end) {
|
||||
try {
|
||||
await flushTexts();
|
||||
await api("POST", "/project/api/goals/rows/" + rowId + "/merge", { start: start, end: end });
|
||||
reloadKeepScroll();
|
||||
} catch (err) { showToast("병합 실패: " + err.message, "error"); }
|
||||
};
|
||||
const unmergeCell = async function (rowId, start) {
|
||||
try {
|
||||
await flushTexts();
|
||||
await api("DELETE", "/project/api/goals/rows/" + rowId + "/merge/" + start);
|
||||
reloadKeepScroll();
|
||||
} catch (err) { showToast("병합 해제 실패: " + err.message, "error"); }
|
||||
};
|
||||
const showMergeSel = function (rowId, h, start, end) {
|
||||
clearMergeSel();
|
||||
mergeSel = { row: rowId, h: h, start: start, end: end };
|
||||
let last = null;
|
||||
table.querySelectorAll('tr[data-row-id="' + rowId + '"] > td.pj-goal-texttd.pj-goal-m[data-h="' + h + '"]')
|
||||
.forEach(function (td) {
|
||||
const c = cellInfo(td);
|
||||
if (c.start >= start && c.end <= end) { td.classList.add("is-merge-sel"); last = td; }
|
||||
});
|
||||
// 떠 있는 병합 버튼 — body 에 붙인다(화면 배율 밖)
|
||||
mergeBar = document.createElement("div");
|
||||
mergeBar.className = "pj-goal-mergebar";
|
||||
const btn = document.createElement("button");
|
||||
btn.type = "button";
|
||||
btn.className = "pj-btn pj-btn-primary";
|
||||
btn.innerHTML = '<span class="material-symbols-outlined">cell_merge</span>';
|
||||
btn.appendChild(document.createTextNode(start + "~" + end + "월 병합"));
|
||||
btn.addEventListener("click", function () {
|
||||
const s = mergeSel;
|
||||
clearMergeSel();
|
||||
if (s) mergeCells(s.row, s.start, s.end);
|
||||
});
|
||||
mergeBar.appendChild(btn);
|
||||
document.body.appendChild(mergeBar);
|
||||
const r = last.getBoundingClientRect();
|
||||
const vw = document.documentElement.clientWidth, vh = document.documentElement.clientHeight;
|
||||
mergeBar.style.left = Math.max(8, Math.min(r.right - mergeBar.offsetWidth, vw - mergeBar.offsetWidth - 8)) + "px";
|
||||
mergeBar.style.top = Math.max(8, Math.min(r.bottom + 6, vh - mergeBar.offsetHeight - 8)) + "px";
|
||||
};
|
||||
table.addEventListener("mousedown", function (e) {
|
||||
if (e.button !== 0) return;
|
||||
const td = monthTd(e.target);
|
||||
if (!td) return;
|
||||
const c = cellInfo(td);
|
||||
if (e.shiftKey && anchor && anchor.row === c.row && anchor.h === c.h && anchor.start !== c.start) {
|
||||
e.preventDefault(); // 글 선택·포커스 이동 없이 범위만 고른다
|
||||
showMergeSel(c.row, c.h, Math.min(anchor.start, c.start), Math.max(anchor.end, c.end));
|
||||
return;
|
||||
}
|
||||
anchor = c;
|
||||
clearMergeSel();
|
||||
});
|
||||
// 다른 곳을 누르거나 Esc·스크롤이면 선택 해제
|
||||
document.addEventListener("mousedown", function (e) {
|
||||
if (!mergeSel || (mergeBar && mergeBar.contains(e.target)) || monthTd(e.target)) return;
|
||||
clearMergeSel();
|
||||
}, true);
|
||||
document.addEventListener("keydown", function (e) { if (e.key === "Escape" && mergeSel) clearMergeSel(); });
|
||||
pane.addEventListener("scroll", function () { if (mergeSel) clearMergeSel(); });
|
||||
table.addEventListener("contextmenu", function (e) {
|
||||
const td = monthTd(e.target);
|
||||
if (!td) return;
|
||||
e.preventDefault();
|
||||
const c = cellInfo(td);
|
||||
const isMonth = function (x) { return x && x.classList.contains("pj-goal-m") && x.dataset.h === c.h; };
|
||||
const items = [];
|
||||
const s = mergeSel;
|
||||
if (s && s.row === c.row && c.start >= s.start && c.end <= s.end) {
|
||||
items.push({ label: "선택한 칸 병합 (" + s.start + "~" + s.end + "월)",
|
||||
onClick: function () { clearMergeSel(); mergeCells(s.row, s.start, s.end); } });
|
||||
}
|
||||
const next = td.nextElementSibling, prev = td.previousElementSibling;
|
||||
if (isMonth(next)) {
|
||||
const n = cellInfo(next);
|
||||
items.push({ label: "오른쪽 칸과 병합 (" + c.start + "~" + n.end + "월)",
|
||||
onClick: function () { mergeCells(c.row, c.start, n.end); } });
|
||||
}
|
||||
if (isMonth(prev)) {
|
||||
const p = cellInfo(prev);
|
||||
items.push({ label: "왼쪽 칸과 병합 (" + p.start + "~" + c.end + "월)",
|
||||
onClick: function () { mergeCells(c.row, p.start, c.end); } });
|
||||
}
|
||||
if (c.span > 1) {
|
||||
if (items.length) items.push(null);
|
||||
items.push({ label: "병합 해제", onClick: function () { unmergeCell(c.row, c.start); } });
|
||||
}
|
||||
if (items.length) showContextMenu(e.clientX, e.clientY, items);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ── 휴지통(관리자 전용 화면) — [복구] 누르면 원래 id 그대로 되살리고 줄을 지운다.
|
||||
|
||||
@@ -293,6 +293,8 @@ docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_012_comment_replies_reactions.sql
|
||||
docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_013_goals.sql
|
||||
docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_014_goal_halves_merges.sql
|
||||
|
||||
# 4) 재배포 (git pull 후 반드시 --build)
|
||||
cd /opt/www/main && docker compose up -d --build web
|
||||
@@ -509,6 +511,37 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
|
||||
영역 색은 팝업(body 에 붙임)에서 바로 바뀜. 목표 테이블은 live-version 트리거에 넣지 않았다(입력 중 새로고침 방지).
|
||||
- 추후: 매출 실적을 실적 모듈(`performance_db`)에서 월별로 자동으로 채우기.
|
||||
|
||||
### 6-9-1. 상·하반기 칸 · 반기 접기 · 이름 바로 수정 · 월 칸 병합 · 로아스 % (마이그레이션 014)
|
||||
|
||||
- **열 순서** — 연간 · 1~6월 · **상반기** · 7~12월 · **하반기**. 템플릿 컨텍스트 `halves`
|
||||
(`(반기, 월 목록, 글 칸 번호 13|14, 이름)`), 월 칸은 `pj-goal-m` + `data-h="1|2"`, 반기 칸은 `pj-goal-half-col`.
|
||||
- 숫자 지표: 매출 목표·실적의 반기 칸 = 그 반기 월 합계(`data-scope="13|14"`, 연간은 `0`), 달성률은 연간과 같은 규칙
|
||||
(실적이 있는 달의 목표 합계 대비, `SUM_SCOPES`). 로아스 반기·연간 칸은 계산하지 않는다(회색).
|
||||
- 업무 영역 글: `goal_cells.month` **13 = 상반기, 14 = 하반기**(014 가 CHECK 를 0~14 로 넓힘). 014 미적용이면 반기 글 칸은
|
||||
보기 전용 빈 칸이고, 저장 API 는 503 "마이그레이션 014 필요"(`store.GoalMigration014Needed`).
|
||||
- **반기 접기** — 반기 칸 머리의 버튼(`.pj-goal-fold`, 펼침 ‹ / 접힘 뒤집힌 › + 강조색)이 그 반기 월 칸을 접었다 편다.
|
||||
보기 전용 사용자도 쓸 수 있고 상태는 브라우저별 localStorage `pj_goal_fold`(`{"1":bool,"2":bool}`).
|
||||
애니메이션(`applyFold`): 접기 = `.is-shrunk`(칸 width·padding·테두리 → 0, `.is-folding` 동안만 transition .32s) 뒤
|
||||
`.is-gone`(display:none), 펴기 = 거꾸로. 줄어드는 동안 칸 안 내용은 원래 폭(`85px × --span`)으로 고정해 잘라 내서 줄 높이가
|
||||
출렁이지 않는다. **표는 `width: 1px` + `table-layout: fixed`** — fixed 는 표 너비가 auto 가 아닐 때만 먹는다(auto 면 칸 너비가
|
||||
내용을 따라가 펼칠 때 애니메이션 없이 한 번에 튄다). 표는 칸 너비 합만큼 늘어난다. 접힌 칸의 글 칸 높이는 잴 수 없어(`fit` 이
|
||||
`offsetParent` 없으면 건너뜀) 펼친 뒤 다시 잰다. `prefers-reduced-motion` 이면 애니메이션 없이.
|
||||
- **영역·줄 이름 바로 수정**(관리자) — 이름(`[data-goal-edit="area|row"]`)을 누르면 contenteditable(`startNameEdit`) —
|
||||
Enter·칸 떠남 = 저장, Esc = 취소, 붙여넣기는 글자만. 영역 이름 빈 값은 되돌림(서버도 400), 줄 이름은 빈 값 허용(빈 줄 이름은
|
||||
마우스를 올리면 "줄 이름" 자리 표시). 예전 ✎(prompt) 버튼은 없앴고 도구 막대는 색·↑·↓·+·× 만.
|
||||
- **월 칸 병합**(관리자, 014) — `goal_cell_merges(row_id, start_month, span)` — 한 줄 안에서 가로로만, **같은 반기 안에서만**
|
||||
(DB CHECK + `store.validate_goal_merge`), 2칸 이상. 화면은 `router._goal_row_layout` 이 줄마다 칸 배치(병합이면 `colspan`)를 만든다.
|
||||
- 고르기: 월 칸을 누른 뒤 **Shift+클릭**(같은 줄·같은 반기) → 칸 테두리 강조 + 떠 있는 "N~M월 병합" 버튼(`.pj-goal-mergebar`,
|
||||
body 에 붙음). 다른 곳 누름·Esc·스크롤 = 선택 해제.
|
||||
- 우클릭 메뉴: 선택한 칸 병합 / 오른쪽 칸과 병합 / 왼쪽 칸과 병합 / 병합 해제(병합된 칸). 월 칸에서는 브라우저 기본 우클릭 메뉴 대신 뜬다.
|
||||
- `POST /api/goals/rows/{row_id}/merge {start, end}` → `db.merge_goal_cells`: 걸친 기존 병합은 통째로 흡수, 범위 안 칸들의 글을
|
||||
월 순서대로 줄바꿈으로 이어 **시작 월 칸**에 두고 나머지 칸 글은 지운다(한 트랜잭션, 줄 FOR UPDATE). 화면은 먼저 저장 안 된 글을
|
||||
저장(`flushTexts`)한 뒤 부르고 새로고침. `DELETE /api/goals/rows/{row_id}/merge/{start}` = 해제(글은 시작 월 칸에 남음).
|
||||
- 병합된 칸의 가운데·끝 월로 늦게 온 글 저장은 400("병합된 칸입니다") — 다른 창에서 병합된 뒤의 저장이 숨은 칸에 쌓이지 않게.
|
||||
- 새 연도 만들기(구조 복사)는 병합을 복사하지 않는다(줄 이름만).
|
||||
- **로아스 단위 %** — 로아스 목표·실적 칸은 `499%` 처럼 보인다(`router._goal_label`, 저장 응답 `label` 도 같음). 입력은 `499`·`499%`
|
||||
둘 다 되고 저장 값은 숫자(`validate_goal_value` 가 `%` 를 뗀다).
|
||||
|
||||
## 6-10. 권한·저장 안전장치 (2026-09-30 점검 반영, 새 마이그레이션·환경변수 없음)
|
||||
|
||||
**권한 공통 기준 — `access.py`** (라우터·마감 알림이 같은 규칙)
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
-- =====================================================================
|
||||
-- project_db 마이그레이션 014 — 연간 목표: 상·하반기 칸 · 월 칸 병합
|
||||
-- =====================================================================
|
||||
-- 멱등(idempotent). DROP TABLE/TRUNCATE 없음 — goal_cells 의 month CHECK 제약만 넓혀 다시 건다.
|
||||
--
|
||||
-- goal_cells.month 0 = 연간, 1~12 = 월, 13 = 상반기, 14 = 하반기
|
||||
-- goal_cell_merges 업무 영역 줄의 월 칸 가로 병합. start_month 부터 span 칸(2칸 이상).
|
||||
-- 상반기(1~6)·하반기(7~12)를 넘지 않는다(사이에 상반기 칸이 있고, 반기를 접을 수 있어서).
|
||||
-- 글은 start_month 칸(goal_cells)에 둔다.
|
||||
--
|
||||
-- 미적용이어도 목표 화면은 동작한다 — 상·하반기 글 칸과 병합만 "마이그레이션 014 필요".
|
||||
--
|
||||
-- 적용 (1회, 여러 번 돌려도 안전):
|
||||
-- docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
-- < scripts/sql/project_db_014_goal_halves_merges.sql
|
||||
-- =====================================================================
|
||||
|
||||
\set ON_ERROR_STOP on
|
||||
\connect project_db
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE goal_cells DROP CONSTRAINT IF EXISTS goal_cells_month_check;
|
||||
ALTER TABLE goal_cells ADD CONSTRAINT goal_cells_month_check CHECK (month BETWEEN 0 AND 14);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS goal_cell_merges (
|
||||
row_id BIGINT NOT NULL REFERENCES goal_rows(id) ON DELETE CASCADE,
|
||||
start_month SMALLINT NOT NULL,
|
||||
span SMALLINT NOT NULL,
|
||||
updated_by TEXT NOT NULL DEFAULT '',
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (row_id, start_month),
|
||||
CONSTRAINT goal_cell_merges_range CHECK (
|
||||
span >= 2 AND start_month >= 1 AND start_month + span - 1 <= 12
|
||||
AND (start_month <= 6) = (start_month + span - 1 <= 6)
|
||||
)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE goal_cell_merges IS '연간 목표 — 업무 영역 줄의 월 칸 가로 병합(반기 안에서만)';
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON goal_cell_merges TO project_app;
|
||||
|
||||
COMMIT;
|
||||
|
||||
SELECT 'project_db 014 goal halves/merges ready' AS status;
|
||||
@@ -456,6 +456,75 @@ def test_store_date_range_unit():
|
||||
raise AssertionError(args)
|
||||
|
||||
|
||||
def test_store_goal_merge_unit():
|
||||
from app.modules.project import store
|
||||
assert store.validate_goal_merge(3, 1) == (1, 3)
|
||||
assert store.validate_goal_merge(7, 12) == (7, 12)
|
||||
assert store.validate_goal_month(13, allow_year=True) == 13
|
||||
for args in ((6, 7), (3, 3), (0, 2), (11, 13)):
|
||||
try:
|
||||
store.validate_goal_merge(*args)
|
||||
except ValueError:
|
||||
continue
|
||||
raise AssertionError(args)
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 연간 목표 — 상·하반기 글 칸 · 월 칸 병합(마이그레이션 014) · 로아스 % 표기
|
||||
# ════════════════════════════════════════════════════════════
|
||||
def test_goal_halves_and_merges():
|
||||
year = 2060 + int(RUN, 16) % 40
|
||||
ST.delete_goal_year(year=year) if year in ST.list_goal_years() else None
|
||||
assert req("POST", "/project/api/goals/years", ADMIN, json={"year": year}).status_code == 201
|
||||
try:
|
||||
board = ST.get_goal_board(year=year)
|
||||
assert board["halves"] is True, "마이그레이션 014 적용 필요"
|
||||
rid = board["areas"][0]["rows"][0]["id"]
|
||||
cell = lambda m, body, who=ADMIN: req( # noqa: E731
|
||||
"PUT", f"/project/api/goals/rows/{rid}/cells/{m}", who, json={"body": body})
|
||||
# 상·하반기 글 칸(13·14), 범위 밖(15)은 400, 비관리자는 403
|
||||
assert cell(13, "상반기 글").status_code == 200 and cell(14, "하반기 글").status_code == 200
|
||||
assert cell(15, "x").status_code == 400
|
||||
assert cell(13, "y", BOB).status_code == 403
|
||||
for m, body in ((2, "이월"), (3, "삼월"), (5, "오월")):
|
||||
assert cell(m, body).status_code == 200
|
||||
merge = lambda s, e: req( # noqa: E731
|
||||
"POST", f"/project/api/goals/rows/{rid}/merge", ADMIN, json={"start": s, "end": e})
|
||||
# 반기를 넘는 병합·한 칸 병합은 400
|
||||
assert merge(5, 8).status_code == 400 and merge(4, 4).status_code == 400
|
||||
r = merge(2, 3)
|
||||
assert r.status_code == 200 and r.json() == {"ok": True, "start": 2, "span": 2}, r.text
|
||||
cells = ST.get_goal_board(year=year)["areas"][0]["rows"][0]["cells"]
|
||||
assert cells[2] == "이월\n삼월" and 3 not in cells
|
||||
# 병합된 칸의 가운데 월에 늦게 온 저장은 거절(글은 시작 월에만)
|
||||
assert cell(3, "늦은 저장").status_code == 400
|
||||
# 걸친 병합은 흡수: 3~5 → 2~5, 글은 월 순서대로 이어진다
|
||||
r = merge(3, 5)
|
||||
assert r.json() == {"ok": True, "start": 2, "span": 4}, r.text
|
||||
row = ST.get_goal_board(year=year)["areas"][0]["rows"][0]
|
||||
assert row["merges"] == {2: 4} and row["cells"][2] == "이월\n삼월\n오월" and 5 not in row["cells"]
|
||||
assert row["cells"][13] == "상반기 글" and row["cells"][14] == "하반기 글"
|
||||
# 해제 — 글은 시작 월에 남음, 없는 병합 해제는 404
|
||||
assert req("DELETE", f"/project/api/goals/rows/{rid}/merge/2", ADMIN).status_code == 200
|
||||
assert req("DELETE", f"/project/api/goals/rows/{rid}/merge/2", ADMIN).status_code == 404
|
||||
row = ST.get_goal_board(year=year)["areas"][0]["rows"][0]
|
||||
assert row["merges"] == {} and row["cells"][2] == "이월\n삼월\n오월"
|
||||
# 로아스 % 표기(입력에 % 가 있어도 숫자로 저장)
|
||||
r = req("PUT", f"/project/api/goals/{year}/metrics", ADMIN,
|
||||
json={"metric": "roas", "kind": "target", "month": 1, "value": "499%"})
|
||||
assert r.status_code == 200 and r.json()["label"] == "499%" and r.json()["value"] == 499
|
||||
r = req("PUT", f"/project/api/goals/{year}/metrics", ADMIN,
|
||||
json={"metric": "sales", "kind": "target", "month": 1, "value": "1,200"})
|
||||
assert r.json()["label"] == "1,200"
|
||||
# 영역·줄 이름(그 자리 수정이 쓰는 API) — 영역 이름은 빈 값 400, 줄 이름은 빈 값 허용
|
||||
aid = ST.get_goal_board(year=year)["areas"][0]["id"]
|
||||
assert req("PUT", f"/project/api/goals/areas/{aid}", ADMIN, json={"name": ""}).status_code == 400
|
||||
assert req("PUT", f"/project/api/goals/areas/{aid}", ADMIN, json={"name": "상품2"}).status_code == 200
|
||||
assert req("PUT", f"/project/api/goals/rows/{rid}", ADMIN, json={"label": ""}).status_code == 200
|
||||
finally:
|
||||
ST.delete_goal_year(year=year)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if not ENABLED:
|
||||
print("SKIP: PROJECT_TEST_DB_URL(localhost) not set")
|
||||
|
||||
Reference in New Issue
Block a user