Refine major department options

This commit is contained in:
Codex
2026-05-27 13:32:49 +08:00
parent b5f41c3dda
commit 2863b34d47
3 changed files with 65 additions and 3 deletions

View File

@@ -705,8 +705,12 @@ function renderField(record, name, label, type, options, alerted = false, source
const sourceClass = source === "ai" ? " is-ai-modified" : source === "manual" ? " is-manual-modified" : "";
let control = "";
if (type === "select") {
const normalizedValue = String(value ?? "");
const normalizedOptions = (options || []).map((option) => String(option));
const optionItems = ["", ...normalizedOptions];
if (normalizedValue && !normalizedOptions.includes(normalizedValue)) optionItems.push(normalizedValue);
control = `<select data-field="${name}" data-type="${type}">
${(options || []).map((option) => `<option value="${escapeHtml(option)}" ${option === value ? "selected" : ""}>${escapeHtml(option)}</option>`).join("")}
${optionItems.map((option) => `<option value="${escapeHtml(option)}" ${option === normalizedValue ? "selected" : ""}>${escapeHtml(option || "请选择")}</option>`).join("")}
</select>`;
} else if (type === "json") {
control = renderJsonEditor(name, value, sourceMap);