feat(라이브커머스): 달력 보기와 호스트 비용 계산 추가
2시간 칸 × 날짜 달력(카드 머리 = Tiktok Handle, SALES·COM·Fee), 끌어 옮기기· 맞바꾸기, Jump to Date, 날짜별 합계·광고비·ROAS 를 넣는다. 호스트 비용 = 시간 × RM 25 + 판매금액 10%, 표 보기에도 표시한다. 끝 시간을 필수로 바꾸고 광고비 표는 마이그레이션 002 로 추가한다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,61 @@
|
||||
.lv-table td.lv-r { text-align: left; }
|
||||
}
|
||||
|
||||
.lv-views { display: inline-flex; gap: 4px; margin-left: 10px; }
|
||||
|
||||
/* ── 달력 보기 ── */
|
||||
.lv-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
|
||||
.lv-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #fff; }
|
||||
.lv-kpi span { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--color-midtone-gray, #666); }
|
||||
.lv-kpi b { font-size: 18px; font-variant-numeric: tabular-nums; }
|
||||
.lv-jump { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 12px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #fff; }
|
||||
.lv-jump-label { margin-right: 4px; font-size: 13px; font-weight: 600; color: #4b5563; }
|
||||
.lv-jump-day { min-width: 28px; height: 28px; padding: 0 4px; border: 1px solid transparent; border-radius: 6px; background: #f1f3f6; color: #1f2937; font-size: 13px; font-weight: 600; cursor: pointer; }
|
||||
.lv-jump-day:hover { background: #e2e6ec; }
|
||||
.lv-jump-day.is-weekend { background: #fff6dc; border-color: #f3e2ae; color: #8a4b08; }
|
||||
.lv-jump-day.is-today { outline: 2px solid #111; outline-offset: -2px; }
|
||||
.lv-tip { margin: 0; padding: 8px 12px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #f6f8fb; font-size: 13px; color: #374151; }
|
||||
|
||||
.lv-cal-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; }
|
||||
.lv-cal { border-collapse: separate; border-spacing: 0; min-width: max-content; }
|
||||
.lv-cal th, .lv-cal td { border-right: 1px solid #e3e6eb; border-bottom: 1px solid #e3e6eb; }
|
||||
.lv-cal thead th { position: sticky; top: 0; z-index: 2; width: 182px; min-width: 182px; padding: 8px 6px; background: #e4e8ee; text-align: center; font-weight: 700; }
|
||||
.lv-cal thead th.is-weekend { background: #f5efd3; color: #7a5c00; }
|
||||
.lv-cal thead th.is-today { box-shadow: inset 0 -3px 0 #111; }
|
||||
.lv-cal-weekday { font-size: 13px; letter-spacing: .03em; }
|
||||
.lv-cal-count { display: inline-block; min-width: 18px; padding: 0 4px; margin-left: 2px; border: 1px solid #cfd4dc; border-radius: 4px; background: #fff; color: #374151; font-size: 11px; font-weight: 600; }
|
||||
.lv-cal-date { margin-top: 2px; font-size: 11px; font-weight: 600; color: #6b7280; }
|
||||
.lv-cal .lv-cal-time { position: sticky; left: 0; z-index: 1; width: 132px; min-width: 132px; padding: 8px; background: #f6f7f9; text-align: center; font-size: 13px; font-weight: 700; white-space: nowrap; }
|
||||
.lv-cal thead .lv-cal-time { z-index: 3; background: #d9dee6; }
|
||||
.lv-cal .lv-cal-time small { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 600; color: #6b7280; }
|
||||
.lv-cell { min-height: 100px; padding: 4px; vertical-align: top; background: #fff; }
|
||||
.lv-cell.is-weekend { background: #fffdf3; }
|
||||
.lv-cell.is-drop { background: #e8f1ff; box-shadow: inset 0 0 0 2px #3b82f6; }
|
||||
.lv-cell-add { display: block; width: 100%; min-height: 88px; border: 1px dashed #d8dce3; border-radius: 6px; background: transparent; color: #b0b6c0; font-size: 16px; cursor: pointer; }
|
||||
.lv-cell-add:hover, .lv-cell-add:focus-visible { border-color: #6b7280; color: #374151; }
|
||||
.lv-card { margin-bottom: 4px; border: 1.5px solid #1f2937; border-radius: 6px; background: #fff; overflow: hidden; }
|
||||
.lv-card-head { display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-bottom: 1px solid #1f2937; cursor: grab; }
|
||||
.lv-card-head:active { cursor: grabbing; }
|
||||
.lv-card-grip { font-size: 12px; color: #374151; }
|
||||
.lv-card-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; font-size: 13px; font-weight: 800; letter-spacing: .03em; color: #111; }
|
||||
.lv-card-edit { padding: 0 2px; border: 0; background: none; color: #374151; font-size: 13px; cursor: pointer; }
|
||||
.lv-card-nums { display: grid; grid-template-columns: 1fr 1fr; }
|
||||
.lv-card-nums div { display: flex; flex-direction: column; text-align: center; }
|
||||
.lv-card-nums div + div { border-left: 1px solid #e3e6eb; }
|
||||
.lv-card-nums span { padding: 2px 0; background: #f6f7f9; font-size: 10px; font-weight: 600; color: #4b5563; }
|
||||
.lv-card-nums b { padding: 3px 0; font-size: 14px; font-variant-numeric: tabular-nums; }
|
||||
.lv-card-foot { display: flex; justify-content: space-between; gap: 4px; padding: 2px 6px; border-top: 1px solid #e3e6eb; background: #f6f7f9; font-size: 10.5px; font-weight: 600; color: #4b5563; }
|
||||
.lv-card-foot b { color: #8a2c0d; }
|
||||
.lv-card-foot a { color: #1d4f91; }
|
||||
.lv-cal tfoot th, .lv-cal tfoot td { position: sticky; bottom: 0; z-index: 2; padding: 8px; background: #101a33; color: #fff; border-color: #2a3550; }
|
||||
.lv-cal tfoot .lv-cal-time { z-index: 3; background: #101a33; font-size: 12px; }
|
||||
.lv-total { display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: 11px; font-weight: 600; }
|
||||
.lv-total div { display: flex; justify-content: space-between; gap: 6px; }
|
||||
.lv-total dt { color: #aab3c5; }
|
||||
.lv-total dd { margin: 0; font-variant-numeric: tabular-nums; color: #fbbf72; white-space: nowrap; }
|
||||
.lv-total dd.is-sales { color: #6ee7a8; }
|
||||
.lv-total-edit { padding: 0 2px; border: 0; background: none; color: #cbd5e1; font-size: 11px; cursor: pointer; }
|
||||
|
||||
.lv-dlg { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 12px; }
|
||||
.lv-dlg::backdrop { background: rgba(0, 0, 0, .35); }
|
||||
.lv-dlg form { display: flex; flex-direction: column; gap: 12px; padding: 20px 22px; }
|
||||
|
||||
+85
-8
@@ -1,6 +1,13 @@
|
||||
/* 라이브 커머스(2026-11-04) — 스케줄표·호스트 설정 공용: 추가·고치기 창, 저장·지우기(fetch → JSON {ok, message}, 틀려도 입력한 값이 창에 남음). */
|
||||
/* 라이브 커머스(2026-11-04) — 스케줄표·달력·호스트 설정 공용: 추가·고치기 창, 저장·지우기(fetch → JSON {ok, message}, 틀려도 입력한 값이 창에 남음).
|
||||
달력: Jump to Date, 카드 끌어 옮기기·맞바꾸기, 날짜별 광고비. 다시 그린 뒤에도 보던 가로 위치 유지. */
|
||||
(function () {
|
||||
"use strict";
|
||||
const calWrap = document.getElementById("lv-cal-wrap");
|
||||
const CAL_POS = "lv_cal_left";
|
||||
function reload() {
|
||||
if (calWrap) { try { sessionStorage.setItem(CAL_POS, String(calWrap.scrollLeft)); } catch (_) {} }
|
||||
location.reload();
|
||||
}
|
||||
const dlg = document.getElementById("lv-dlg");
|
||||
const form = document.getElementById("lv-form");
|
||||
if (!dlg || !form) return;
|
||||
@@ -60,16 +67,17 @@
|
||||
function open(row) {
|
||||
form.reset();
|
||||
say("");
|
||||
title.textContent = row ? title.dataset.edit : title.dataset.add;
|
||||
const editing = !!(row && row.id);
|
||||
title.textContent = editing ? title.dataset.edit : title.dataset.add;
|
||||
form.elements.id.value = "";
|
||||
Array.from(form.elements).forEach(function (el) {
|
||||
if (!row || !el.name || !(el.name in row)) return;
|
||||
if (el.type === "checkbox") el.checked = !!row[el.name];
|
||||
else if (el.type !== "file") el.value = row[el.name];
|
||||
});
|
||||
if (!row) form.elements.id.value = "";
|
||||
showHosts(row && row.host_id);
|
||||
if (row && hostSelect) hostSelect.value = String(row.host_id); // 위에서 보이게 한 뒤 다시 고름
|
||||
showSaved(row && row.images);
|
||||
showHosts(editing && row.host_id);
|
||||
if (editing && hostSelect) hostSelect.value = String(row.host_id); // 위에서 보이게 한 뒤 다시 고름
|
||||
showSaved(editing && row.images);
|
||||
dlg.showModal();
|
||||
}
|
||||
|
||||
@@ -82,11 +90,13 @@
|
||||
document.addEventListener("click", async function (e) {
|
||||
const edit = e.target.closest("[data-edit]");
|
||||
if (edit && edit.tagName === "BUTTON") { open(JSON.parse(edit.dataset.edit)); return; }
|
||||
const fresh = e.target.closest("button[data-new]");
|
||||
if (fresh) { open(JSON.parse(fresh.dataset.new)); return; }
|
||||
const btn = e.target.closest("button[data-post]");
|
||||
if (!btn) return;
|
||||
if (!(await window.erpConfirm(btn.dataset.confirm))) return;
|
||||
const r = await post(btn.dataset.post);
|
||||
if (r.ok) { location.reload(); return; }
|
||||
if (r.ok) { reload(); return; }
|
||||
if (dlg.open) say(r.message); else window.erpAlert(r.message);
|
||||
});
|
||||
|
||||
@@ -98,8 +108,75 @@
|
||||
save.disabled = true;
|
||||
say("");
|
||||
const r = await post(form.getAttribute("action"), body);
|
||||
if (r.ok) { location.reload(); return; }
|
||||
if (r.ok) { reload(); return; }
|
||||
save.disabled = false;
|
||||
say(r.message);
|
||||
});
|
||||
|
||||
if (!calWrap) return;
|
||||
|
||||
// ── 달력: 날짜로 가기(TIME 열이 고정이라 그 폭만큼 띄움) ──
|
||||
function jumpTo(iso) {
|
||||
const col = calWrap.querySelector('thead th[data-day="' + iso + '"]');
|
||||
const time = calWrap.querySelector("thead .lv-cal-time");
|
||||
if (col && time) calWrap.scrollLeft += col.getBoundingClientRect().left - time.getBoundingClientRect().right;
|
||||
}
|
||||
document.addEventListener("click", function (e) {
|
||||
const b = e.target.closest("[data-jump]");
|
||||
if (b) jumpTo(b.dataset.jump);
|
||||
});
|
||||
let left = null;
|
||||
try { left = sessionStorage.getItem(CAL_POS); sessionStorage.removeItem(CAL_POS); } catch (_) {}
|
||||
if (left !== null) calWrap.scrollLeft = Number(left);
|
||||
else {
|
||||
const today = calWrap.querySelector("thead th[data-today]");
|
||||
if (today) jumpTo(today.dataset.day);
|
||||
}
|
||||
|
||||
// ── 달력: 날짜별 광고비 ──
|
||||
document.addEventListener("click", async function (e) {
|
||||
const b = e.target.closest("button[data-spend]");
|
||||
if (!b) return;
|
||||
const value = await window.erpPrompt(b.dataset.spend + " AD SPEND (RM) — 비우면 지웁니다", b.dataset.value || "");
|
||||
if (value === null || value === undefined) return;
|
||||
const body = new FormData();
|
||||
body.set("day", b.dataset.spend);
|
||||
body.set("amount", value);
|
||||
const r = await post("/live/ad-spend", body);
|
||||
if (r.ok) reload(); else window.erpAlert(r.message);
|
||||
});
|
||||
|
||||
// ── 달력: 카드 머리를 끌어 빈 칸으로 옮기기, 다른 카드 위에 놓아 맞바꾸기 ──
|
||||
let dragging = null;
|
||||
calWrap.addEventListener("dragstart", function (e) {
|
||||
const head = e.target.closest && e.target.closest(".lv-card-head");
|
||||
if (!head) return;
|
||||
dragging = head.closest("[data-card]").dataset.card;
|
||||
e.dataTransfer.effectAllowed = "move";
|
||||
e.dataTransfer.setData("text/plain", dragging);
|
||||
});
|
||||
calWrap.addEventListener("dragend", function () {
|
||||
dragging = null;
|
||||
calWrap.querySelectorAll(".is-drop").forEach(function (c) { c.classList.remove("is-drop"); });
|
||||
});
|
||||
calWrap.addEventListener("dragover", function (e) {
|
||||
const cell = dragging && e.target.closest("[data-drop]");
|
||||
if (!cell) return;
|
||||
e.preventDefault();
|
||||
calWrap.querySelectorAll(".is-drop").forEach(function (c) { if (c !== cell) c.classList.remove("is-drop"); });
|
||||
cell.classList.add("is-drop");
|
||||
});
|
||||
calWrap.addEventListener("drop", async function (e) {
|
||||
const cell = dragging && e.target.closest("[data-drop]");
|
||||
if (!cell) return;
|
||||
e.preventDefault();
|
||||
const id = dragging;
|
||||
const onto = e.target.closest("[data-card]");
|
||||
if (onto && onto.dataset.card === id) return;
|
||||
const body = new FormData();
|
||||
if (onto) body.set("swap_with", onto.dataset.card);
|
||||
else { body.set("broadcast_date", cell.dataset.day); body.set("start_time", cell.dataset.start); }
|
||||
const r = await post("/live/broadcasts/" + id + "/move", body);
|
||||
if (r.ok) reload(); else window.erpAlert(r.message);
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user