update
This commit is contained in:
@ -207,9 +207,56 @@
|
||||
if (focusMain) setExpanded(focusMain, true);
|
||||
}
|
||||
|
||||
// ── 编辑页:实时翻译建议 + 季节码预览 ──────────────────────────────
|
||||
// 与后端 pkg/season.Derive 同规则;仅用于只读预览,服务端保存时仍按同规则重算 season_code。
|
||||
function deriveSeasonCode(year, collectionType, season) {
|
||||
if (!year) return '';
|
||||
var y = String(year).slice(-2);
|
||||
var prefix = 'SS';
|
||||
switch (collectionType) {
|
||||
case 'resort': prefix = 'RES'; break;
|
||||
case 'pre_fall': prefix = 'PF'; break;
|
||||
case 'couture': case 'menswear': prefix = 'FW'; break;
|
||||
default:
|
||||
if (season === 'fall' || season === 'winter') prefix = 'FW';
|
||||
else prefix = 'SS';
|
||||
}
|
||||
return prefix + y;
|
||||
}
|
||||
|
||||
function initEditForm() {
|
||||
var en = document.getElementById('rw-title-en') || document.getElementById('snap-title-en');
|
||||
if (!en) return;
|
||||
var cn = document.getElementById('rw-title-cn') || document.getElementById('snap-title-cn');
|
||||
|
||||
// 英文标题失焦且中文为空时,拉建议回填(不覆盖手填)。
|
||||
en.addEventListener('blur', function () {
|
||||
if (cn && cn.value.trim() === '') {
|
||||
fetch('/admin/api/suggest-title-cn?title_en=' + encodeURIComponent(en.value))
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (d) { if (d && d.title_cn) cn.value = d.title_cn; })
|
||||
.catch(function () {});
|
||||
}
|
||||
});
|
||||
|
||||
// 走秀:年份/季节/系列变动即时算季节码(只读预览;服务端保存时仍按同规则重算)。
|
||||
var year = document.getElementById('rw-year');
|
||||
var season = document.getElementById('rw-season');
|
||||
var collection = document.getElementById('rw-collection');
|
||||
var code = document.getElementById('rw-season-code');
|
||||
function refreshCode() {
|
||||
if (!year || !code) return;
|
||||
code.value = deriveSeasonCode(year.value, collection ? collection.value : '', season ? season.value : '');
|
||||
}
|
||||
if (year) year.addEventListener('input', refreshCode);
|
||||
if (season) season.addEventListener('input', refreshCode);
|
||||
if (collection) collection.addEventListener('input', refreshCode);
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
initZoom();
|
||||
if (document.getElementById('sel-all') || document.getElementById('batchbar')) initArticleList();
|
||||
if (document.getElementById('batch')) initArticleDetail();
|
||||
initEditForm();
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user