地点库增加是否有图片列,修复批量导入图片时新增类型无法复用

This commit is contained in:
tamakyi
2026-09-18 18:00:28 +08:00
parent ad2531c113
commit dbc5f173ef
4 changed files with 52 additions and 4 deletions
+39
View File
@@ -244,6 +244,35 @@
}).catch(function (e) { alert('创建活动失败:' + e); });
}
// 自定义类别填好之后,把它挂到**所有**类别下拉上(含隐藏的选项源),当前这行改成直接选中它。
// 一次导入几十张同类型的照片时,第 2 张起就能从下拉里直接选到,不必再输入一遍同样的话 ——
// 类别是自由文本(存的就是 poi_category 原串),所以选项的 value 就是那串文字本身。
function categoryExists(sel, label) {
return [].some.call(sel.options, function (o) { return o.value === label; });
}
function addCategoryOption(label) {
var src = document.getElementById('category-options');
var sels = [].slice.call(document.querySelectorAll('select[name^="category_"]'));
if (src) sels.unshift(src);
sels.forEach(function (s) {
if (categoryExists(s, label)) return;
var opt = document.createElement('option');
opt.value = label;
opt.textContent = label;
// 插在「自定义…」前面,别让新类别落到那个特殊项之后
var tail = s.querySelector('option[value="__custom__"]');
if (tail) s.insertBefore(opt, tail); else s.appendChild(opt);
});
}
function promoteCategory(sel, input, wrap) {
if (sel.value !== '__custom__') return;
var label = (input.value || '').trim();
if (!label) return;
addCategoryOption(label);
sel.value = label;
wrap.style.display = 'none';
}
function setVal(name, v) {
var el = rowsBox.querySelector('input[name="' + name + '"], select[name="' + name + '"]');
if (el && v) el.value = v;
@@ -368,6 +397,15 @@
catSel.addEventListener('change', function () {
catCustomWrap.style.display = catSel.value === '__custom__' ? '' : 'none';
});
// 填完自定义类别(失焦或回车)就把它变成所有行都能直接选的一项
catCustom.addEventListener('change', function () {
promoteCategory(catSel, catCustom, catCustomWrap);
});
catCustom.addEventListener('keydown', function (e) {
if (e.key !== 'Enter') return;
e.preventDefault();
promoteCategory(catSel, catCustom, catCustomWrap);
});
td2.appendChild(groupCap('地点属性'));
row1.appendChild(fieldLabel('类别', catSel, 'flex:0 1 160px'));
row1.appendChild(catCustomWrap);
@@ -401,6 +439,7 @@
actNewBox.appendChild(actNewInput);
actNewBox.appendChild(actNewBtn);
var actNewWrap = fieldLabel('新建活动', actNewBox, 'flex:0 1 190px');
actNewWrap.classList.add('act-new');
actNewWrap.style.display = 'none';
actSel.addEventListener('change', function () {
var on = actSel.value === '__new__';