feat(performance): 광고비 파일 여러 개 업로드(같은 날짜는 최신 파일) + 끝나면 창 닫기

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 17:32:01 +09:00
parent 15a5eddf20
commit e3bc9d518d
9 changed files with 150 additions and 25 deletions
+11 -8
View File
@@ -329,7 +329,8 @@
return '<option value="' + esc(c.code) + '">' + esc(c.name) + "</option>";
}).join("") + "</select>" +
'<p class="perf-muted perf-ad-help" style="margin:0 0 10px"></p>' +
'<input type="file" class="erp-input perf-upload-file" accept=".csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" aria-label="광고 보고서 파일" />' +
'<input type="file" multiple class="erp-input perf-upload-file" accept=".csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" aria-label="광고 보고서 파일(여러 개 가능)" />' +
'<p class="perf-muted" style="margin:6px 0 0">파일을 여러 개 고를 수 있습니다. 같은 날짜가 여러 파일에 있으면 파일 날짜(수정 시각)가 최신인 파일 값을 씁니다.</p>' +
'<div class="perf-upload-result"></div>';
const sel = m.body.querySelector(".perf-ad-channel");
const help = m.body.querySelector(".perf-ad-help");
@@ -347,12 +348,15 @@
m.foot.appendChild(go);
cancel.addEventListener("click", m.close);
go.addEventListener("click", async function () {
const f = fileInput.files && fileInput.files[0];
if (!f) { out.innerHTML = '<p class="perf-notice is-warn">파일을 고르세요.</p>'; return; }
const picked = Array.prototype.slice.call(fileInput.files || []);
if (!picked.length) { out.innerHTML = '<p class="perf-notice is-warn">파일을 고르세요.</p>'; return; }
go.disabled = true;
out.innerHTML = '<p class="perf-muted">올리는 중…</p>';
out.innerHTML = '<p class="perf-muted">올리는 중… (' + picked.length + "개 파일)</p>";
const fd = new FormData();
fd.append("file", f);
picked.forEach(function (f) {
fd.append("files", f);
fd.append("modified", String(f.lastModified || 0)); // 같은 날짜는 파일 날짜가 최신인 파일 값
});
let res, body = null;
try {
res = await fetch("/performance/api/ad-spend/upload?channel=" + encodeURIComponent(sel.value),
@@ -372,9 +376,8 @@
return;
}
saved = body.saved > 0;
out.innerHTML = '<p class="perf-notice is-ok">' + esc(body.name) + " " + fmt(body.saved) + "일 반영 (" +
esc(body.from === body.to ? body.from : body.from + " ~ " + body.to) + ") · 합계 " + fmt(body.total) + "원</p>" +
'<p class="perf-muted" style="margin:6px 0 0">창을 닫으면 표·합계·그래프가 다시 계산됩니다.</p>';
if (saved) { m.close(); return; } // 업로드가 끝나면 창을 닫고 표·합계·그래프를 다시 그린다(onClose 새로고침)
out.innerHTML = '<p class="perf-notice is-ok">반영할 날짜가 없습니다.</p>';
fileInput.value = "";
});
});