|
|
|
@@ -68,7 +68,8 @@
|
|
|
|
|
|
|
|
|
|
openBtn.addEventListener("click", function () {
|
|
|
|
|
var nameEl = document.getElementById("cf24-name-text");
|
|
|
|
|
modal.open((nameEl ? nameEl.textContent : "") + " (상품번호 " + no + ")");
|
|
|
|
|
state.productName = nameEl ? nameEl.textContent.trim() : "";
|
|
|
|
|
modal.open(state.productName + " (상품번호 " + no + ")");
|
|
|
|
|
myGen = modal.gen;
|
|
|
|
|
load();
|
|
|
|
|
});
|
|
|
|
@@ -233,6 +234,34 @@
|
|
|
|
|
return state.imageBase ? state.imageBase + (path.charAt(0) === "/" ? "" : "/") + path : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 이미지 주소 → 쇼핑몰 기준 경로("/web/product/…"). 도메인·CDN 주소(이중 주소 포함)는 뗀다.
|
|
|
|
|
function shopPath(url) {
|
|
|
|
|
url = String(url || "").trim();
|
|
|
|
|
var at = url.lastIndexOf("/web/");
|
|
|
|
|
if (at >= 0) return url.slice(at);
|
|
|
|
|
return url.indexOf("web/") === 0 ? "/" + url : url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 모바일 스와이프(product-swiper.js)에 붙여 넣을 품목코드 → 썸네일 경로 목록.
|
|
|
|
|
// 썸네일은 행에 **지금 보이는** 이미지(버튼 → 연결 → 품목 이미지, 깨진 후보는 건너뛴 결과)다.
|
|
|
|
|
// // 상품명
|
|
|
|
|
// "P00000CM000A": "/web/product/extra/202503/….jpg",
|
|
|
|
|
function swipeCode(tbody) {
|
|
|
|
|
var lines = ["// " + (state.productName || ("상품번호 " + no))];
|
|
|
|
|
var count = 0;
|
|
|
|
|
var missing = 0;
|
|
|
|
|
tbody.querySelectorAll("tr").forEach(function (tr) {
|
|
|
|
|
var code = tr.dataset.code;
|
|
|
|
|
if (!code) return; // 아직 품목코드 없는 행(새 행·생성 대기)
|
|
|
|
|
var img = tr.querySelector("img.cf24-opt-thumb");
|
|
|
|
|
var path = img ? shopPath(img.getAttribute("src")) : "";
|
|
|
|
|
if (!path) missing++;
|
|
|
|
|
lines.push(' "' + code + '": "' + path + '",');
|
|
|
|
|
count++;
|
|
|
|
|
});
|
|
|
|
|
return { text: lines.join("\n"), count: count, missing: missing };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 후보(버튼 이미지 → 연결 이미지 → 품목 image) 중 첫 번째를 보여주고, 깨지면 다음
|
|
|
|
|
// 후보로 넘어간다(cf24ThumbFallback). 전부 실패하면 "없음".
|
|
|
|
|
var THUMB_EMPTY = '<div class="cf24-opt-thumb-empty">없음</div>';
|
|
|
|
@@ -367,6 +396,7 @@
|
|
|
|
|
' <label class="cf24-side-field cf24-u-optname"><span>옵션명</span><input type="text" name="option_name" value="' + esc(group.option_name) + '" placeholder="예: 구성" /></label>' +
|
|
|
|
|
' <label class="cf24-side-field cf24-side-field-type"><span>표시방식</span>' + typeSelect(group.option_display_type || DEFAULT_TYPE, "option_display_type") + "</label>" +
|
|
|
|
|
' <span class="cf24-u-head-actions">' +
|
|
|
|
|
(isNew ? "" : ' <button type="button" class="erp-btn erp-btn-outline" id="cf24-u-swipe" title="품목코드와 썸네일 경로를 모바일 스와이프(product-swiper.js) 형식으로 복사합니다">모바일 스와이프 코드 복사</button>') +
|
|
|
|
|
' <button type="button" class="erp-btn erp-btn-outline" id="cf24-u-import">옵션값 불러오기</button>' +
|
|
|
|
|
' <button type="button" class="erp-btn erp-btn-outline" id="cf24-u-add">+ 행 추가</button>' +
|
|
|
|
|
" </span>" +
|
|
|
|
@@ -416,6 +446,18 @@
|
|
|
|
|
tr.querySelector('[name="option_text"]').focus();
|
|
|
|
|
});
|
|
|
|
|
body.querySelector("#cf24-u-import").addEventListener("click", function () { openImport(isNew, tbody, msg); });
|
|
|
|
|
var swipeBtn = body.querySelector("#cf24-u-swipe");
|
|
|
|
|
if (swipeBtn) swipeBtn.addEventListener("click", function () {
|
|
|
|
|
var out = swipeCode(tbody);
|
|
|
|
|
if (!out.count) { window.erpAlert("품목코드가 있는 행이 없습니다."); return; }
|
|
|
|
|
copyText(out.text, function () {
|
|
|
|
|
var old = swipeBtn.textContent;
|
|
|
|
|
swipeBtn.textContent = "복사됨";
|
|
|
|
|
setTimeout(function () { swipeBtn.textContent = old; }, 1200);
|
|
|
|
|
msg.textContent = "스와이프 코드 " + out.count + "개 품목 복사" +
|
|
|
|
|
(out.missing ? " — 썸네일 없는 품목 " + out.missing + "개는 경로가 비어 있습니다" : "");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
body.querySelector("#cf24-u-save").addEventListener("click", function () { saveUnified(isNew, tbody, msg); });
|
|
|
|
|
var del = body.querySelector("#cf24-opt-delete");
|
|
|
|
|
if (del) del.addEventListener("click", deleteOptions);
|
|
|
|
|