2 Commits

Author SHA1 Message Date
king 1096fd68ab Merge branch 'feat/cafe24-option-sale-price' 2026-11-10 00:59:45 +09:00
king 8bd62fbf6d feat(카페24): 옵션 팝업 판매 가격 열, 추가금액 자동 계산
- 추가금액과 진열 사이에 판매 가격 열 추가(판매가 + 추가금액)
- 판매 가격 입력 시 기본 정보 판매가와의 차액을 추가금액에 입력
- Enter/아래 화살표는 아래 행, 위 화살표는 위 행 판매 가격으로 이동

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 00:59:44 +09:00
3 changed files with 49 additions and 3 deletions
+1
View File
@@ -14,6 +14,7 @@
- 정보 패널(`routes_product_info.py`, `_side.html`)에서 상품명·판매가·공급가·소비자가, 대표이미지, 옵션(생성/이름·썸네일·표시방식 수정/삭제)·품목(자체코드·추가금액·진열·판매) 수정.
- 대표이미지는 `POST /admin/products/{no}/images` 에 base64 data URI + `image_upload_type=A`.
NNEditor 업로드 경로를 PUT `detail_image` 에 넣는 방식은 적용 안 됨.
- 옵션/품목 팝업 「판매 가격」 열: 기본 정보 판매가 + 추가금액을 보여주고, 입력하면 추가금액을 역산(`cafe24-options.js` `bindSalePrice`). 저장되는 값은 추가금액뿐. Enter·↓ 아래 행, ↑ 위 행으로 이동.
- 옵션/품목 팝업(단일 옵션 화면) 「모바일 스와이프 복사(코드)」: `// 상품명` + `"품목코드": "/web/…썸네일 경로",` 줄들을 클립보드로
(`cafe24-options.js` `swipeCode` — 행에 지금 보이는 썸네일 기준, 도메인/CDN 은 떼고 `/web/` 부터).
「모바일 스와이프 복사(이름)」은 키가 품목코드 대신 옵션값 이름(`swipeCode(tbody, true)`, 품목코드 있는 행만).
@@ -130,7 +130,7 @@
{% endblock %}
{% block scripts %}
<script src="/static/cafe24-options.js?v=20261106b"></script>
<script src="/static/cafe24-options.js?v=20261110a"></script>
<script>
(function () {
var pane = document.getElementById("cf24-editor-pane");
+47 -2
View File
@@ -309,6 +309,47 @@
function amountPlain(v) { return String(parseInt(String(v || "0").replace(/,/g, ""), 10) || 0); }
function norm(s) { return String(s || "").replace(/\s+/g, "").toLowerCase(); }
// 판매 가격 칸 = 기본 정보 판매가 + 추가금액. 화면 계산용이고 저장되는 값은 추가금액뿐이다.
function basePrice() {
var el = root.querySelector('#cf24-basic-form [name="price"]');
return parseInt(amountPlain(el && el.value), 10);
}
function salePrice(amount) { return String(basePrice() + parseInt(amountPlain(amount), 10)); }
function salePriceCell(amount) {
return '<td class="cf24-v-amount"><input type="text" class="cf24-sale-price" inputmode="numeric" value="' + salePrice(amount) + '" /></td>';
}
function bindSalePrice(tbody) {
// capture: 불러오기·입력 복원이 보내는 input 이벤트는 버블링하지 않는다.
tbody.addEventListener("input", function (e) {
var tr = e.target.closest("tr");
var sale = tr.querySelector(".cf24-sale-price");
var amount = tr.querySelector('[name="additional_amount"]');
if (e.target === sale) {
sale.value = sale.value.replace(/\D/g, "");
amount.value = sale.value ? String(parseInt(sale.value, 10) - basePrice()) : "0";
amount.dispatchEvent(new Event("input")); // 변경 표시
} else if (e.target === amount && document.activeElement !== sale) {
sale.value = salePrice(amount.value);
}
}, true);
tbody.addEventListener("focusout", function (e) {
if (!e.target.classList.contains("cf24-sale-price")) return;
e.target.value = salePrice(e.target.closest("tr").querySelector('[name="additional_amount"]').value);
});
tbody.addEventListener("keydown", function (e) {
if (!e.target.classList.contains("cf24-sale-price")) return;
var down = e.key === "Enter" || e.key === "ArrowDown";
if (!down && e.key !== "ArrowUp") return;
e.preventDefault();
var tr = e.target.closest("tr")[down ? "nextElementSibling" : "previousElementSibling"];
if (!tr) return;
var next = tr.querySelector(".cf24-sale-price");
next.focus();
next.select();
});
}
/* ═══════════════════════════════════════════════════════════
화면 분기
═══════════════════════════════════════════════════════════ */
@@ -380,6 +421,7 @@
: '<span class="cf24-muted">저장 시 부여</span>') + "</td>" +
'<td class="cf24-v-code"><input type="text" name="custom_variant_code" maxlength="40" value="' + esc(variant ? variant.custom_variant_code : "") + '" /></td>' +
'<td class="cf24-v-amount"><input type="text" name="additional_amount" inputmode="numeric" value="' + esc(amountPlain(variant ? variant.additional_amount : "0")) + '" /></td>' +
salePriceCell(variant ? variant.additional_amount : "0") +
'<td class="cf24-v-flag">' + toggleBtn("display", variant ? !!variant.display : true) + "</td>" +
'<td class="cf24-v-flag">' + toggleBtn("selling", variant ? !!variant.selling : true) + "</td>" +
'<td class="cf24-u-del">' + (awaiting ? "" : '<button type="button" class="cf24-u-remove" title="' + (isNewRow ? "행 삭제" : "품목 삭제 (카페24에 바로 반영)") + '">✕</button>') + "</td>" +
@@ -406,7 +448,7 @@
"</div>" +
'<div class="cf24-u-tablewrap"><table class="cf24-variants cf24-u-table"><thead><tr>' +
'<th class="cf24-u-drag"></th><th class="cf24-u-thumb">썸네일</th><th>옵션값 이름</th><th class="cf24-v-syscode">품목코드</th>' +
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th>' +
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-amount">판매 가격</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th>' +
"</tr></thead><tbody id=\"cf24-u-body\">";
rows.forEach(function (r, i) { html += rowHtml(r, canDrag, i); });
if (isNew) html += rowHtml({ index: null, value: null, variant: null }, true, null);
@@ -436,6 +478,7 @@
var tbody = body.querySelector("#cf24-u-body");
var msg = body.querySelector("#cf24-u-msg");
trackDirty(wrap);
bindSalePrice(tbody);
bindToggles(tbody);
bindCopy(tbody);
bindThumbUploads(tbody, msg);
@@ -964,7 +1007,7 @@
html += '<p class="cf24-muted">품목이 아직 조회되지 않았습니다. 잠시 뒤 창을 닫았다 다시 여세요.</p>';
} else {
html += '<div class="cf24-variants-wrap"><table class="cf24-variants"><thead><tr><th class="cf24-v-imgcol"></th><th>옵션</th><th class="cf24-v-syscode">품목코드</th>' +
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th></tr></thead><tbody>';
'<th class="cf24-v-code">자체 품목코드</th><th class="cf24-v-amount">추가금액</th><th class="cf24-v-amount">판매 가격</th><th class="cf24-v-flag">진열</th><th class="cf24-v-flag">판매</th><th class="cf24-u-del"></th></tr></thead><tbody>';
variants.forEach(function (v) {
var label = v.options.map(function (o) { return o.value; }).join(" / ") || v.variant_code;
html += '<tr class="cf24-v-item" data-code="' + esc(v.variant_code) + '">' +
@@ -973,6 +1016,7 @@
'<td class="cf24-v-syscode"><button type="button" class="cf24-v-copy" data-copy-text="' + esc(v.variant_code) + '">' + esc(v.variant_code) + "</button></td>" +
'<td class="cf24-v-code"><input type="text" name="custom_variant_code" maxlength="40" value="' + esc(v.custom_variant_code) + '" /></td>' +
'<td class="cf24-v-amount"><input type="text" name="additional_amount" inputmode="numeric" value="' + esc(amountPlain(v.additional_amount)) + '" /></td>' +
salePriceCell(v.additional_amount) +
'<td class="cf24-v-flag">' + toggleBtn("display", !!v.display) + "</td><td class=\"cf24-v-flag\">" + toggleBtn("selling", !!v.selling) + "</td>" +
'<td class="cf24-u-del"><button type="button" class="cf24-u-remove" data-code="' + esc(v.variant_code) + '" title="품목 삭제 (카페24에 바로 반영)">✕</button></td></tr>';
});
@@ -990,6 +1034,7 @@
var wrap = body.querySelector(".cf24-variants-wrap");
if (wrap) {
trackDirty(wrap);
bindSalePrice(wrap.querySelector("tbody"));
bindToggles(wrap);
bindCopy(wrap);
body.querySelector("#cf24-var-save").addEventListener("click", function () { saveMultiVariants(wrap); });