From e5b19f5ef097548b960a15a59be19b206bab2a60 Mon Sep 17 00:00:00 2001 From: ssw Date: Thu, 11 Jun 2026 16:08:16 +0800 Subject: [PATCH] auto(1dc9423ac708): session end @ 2026-06-11T16:08:15 (+1f) --- .../src/main/java/ssw/dacli/FormBuilder.java | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/ssw-dacli/src/main/java/ssw/dacli/FormBuilder.java b/ssw-dacli/src/main/java/ssw/dacli/FormBuilder.java index 772ce6c..4d7a9b4 100644 --- a/ssw-dacli/src/main/java/ssw/dacli/FormBuilder.java +++ b/ssw-dacli/src/main/java/ssw/dacli/FormBuilder.java @@ -27,6 +27,27 @@ public class FormBuilder { private static final ObjectMapper mapper = new ObjectMapper(); + /** + * 从 field map 中提取中文 label (v12.0 修复盲点 31: 浏览器层组件不显示名称)。 + * + * 读取优先级 (NEW → OLD → fallback): + * 1. fieldName — polish-convention.py 强制 NEW 约定 (与 create_form.py 一致) + * 2. label — form-fix 风格 OLD 约定 (向后兼容) + * 3. field — snake_case 英文名 (最后回退, 不应触发) + * + * v11 实战沉淀: formData.fields[].__config__.label / columnOptions.label / searchList.label + * / columnList.label / defaultColumnList.label 全部依赖此方法。 + * 之前 5 处代码各自写 `field.getOrDefault("label", "")` → 漏 fieldName → 浏览器空白。 + */ + static String extractLabel(Map field) { + Object fn = field.get("fieldName"); + if (fn != null && !String.valueOf(fn).isEmpty()) return String.valueOf(fn); + Object lb = field.get("label"); + if (lb != null && !String.valueOf(lb).isEmpty()) return String.valueOf(lb); + Object f = field.get("field"); + return f == null ? "" : String.valueOf(f); + } + // ======================== 公开 API:完整 payload 构建 ======================== /** @@ -205,7 +226,7 @@ public class FormBuilder { Map bf = createTableField( (String) field.getOrDefault("field", ""), - (String) field.getOrDefault("label", field.getOrDefault("field", "")), + extractLabel(field), dataType, dataLength, 0, allowNull, 0); tableFields.add(bf); } @@ -477,7 +498,7 @@ public class FormBuilder { subCfg.put("tipLabel", ""); subCfg.put("dragDisabled", false); subCfg.put("className", new ArrayList<>()); - subCfg.put("label", cf.getOrDefault("label", "")); + subCfg.put("label", extractLabel(cf)); subCfg.put("trigger", "blur"); subCfg.put("showLabel", true); subCfg.put("required", cf.getOrDefault("required", false)); @@ -595,7 +616,7 @@ public class FormBuilder { for (Map field : fields) { String jnpfKey = (String) field.getOrDefault("jnpfKey", "input"); String fieldVModel = (String) field.getOrDefault("field", ""); - String label = (String) field.getOrDefault("label", ""); + String label = extractLabel(field); Map col = new LinkedHashMap<>(); col.put("label", label); col.put("prop", fieldVModel); @@ -626,7 +647,7 @@ public class FormBuilder { for (Map field : fields) { Map col = new LinkedHashMap<>(); col.put("value", field.getOrDefault("field", "")); - col.put("label", field.getOrDefault("label", "")); + col.put("label", extractLabel(field)); col.put("width", 120); col.put("sort", options.size()); options.add(col); @@ -653,7 +674,7 @@ public class FormBuilder { for (Map field : fields) { String jnpfKey = (String) field.getOrDefault("jnpfKey", "input"); String fieldVModel = (String) field.getOrDefault("field", ""); - String label = (String) field.getOrDefault("label", ""); + String label = extractLabel(field); Map search = new LinkedHashMap<>(); search.put("field", fieldVModel); search.put("label", label); @@ -703,7 +724,7 @@ public class FormBuilder { for (Map field : fields) { String jnpfKey = (String) field.getOrDefault("jnpfKey", "input"); String fieldVModel = (String) field.getOrDefault("field", ""); - String label = (String) field.getOrDefault("label", ""); + String label = extractLabel(field); Map col = new LinkedHashMap<>(); col.put("prop", fieldVModel); col.put("label", label); @@ -770,7 +791,7 @@ public class FormBuilder { if (field.containsKey("field") && field.get("field") != null) { Map normalized = new LinkedHashMap<>(); normalized.put("field", field.get("field")); - normalized.put("label", field.getOrDefault("label", "")); + normalized.put("label", extractLabel(field)); normalized.put("type", field.getOrDefault("type", "input")); normalized.put("jnpfKey", field.getOrDefault("jnpfKey", mapTypeToJnpfKey((String) normalized.get("type")))); normalized.put("columnData", field.getOrDefault("columnData", "")); @@ -855,7 +876,7 @@ public class FormBuilder { public static Map buildFieldConfig(Map field, String tableName, int formId) { String jnpfKey = (String) field.getOrDefault("jnpfKey", "input"); String fieldVModel = (String) field.getOrDefault("field", ""); - String fieldName = (String) field.getOrDefault("label", fieldVModel); + String fieldName = extractLabel(field); Object requiredObj = field.getOrDefault("required", false); if ("datePicker".equals(jnpfKey) || "timePicker".equals(jnpfKey)) { requiredObj = false; // P0-7: 时间字段强制非必填 @@ -959,7 +980,7 @@ public class FormBuilder { for (Map field : fields) { String jnpfKey = (String) field.getOrDefault("jnpfKey", "input"); String fieldVModel = (String) field.getOrDefault("field", ""); - String fieldName = (String) field.getOrDefault("label", fieldVModel); + String fieldName = extractLabel(field); Object requiredObj = field.getOrDefault("required", false); // P0-7: 时间字段强制非必填,避免平台 swapDatetime NPE if ("datePicker".equals(jnpfKey) || "timePicker".equals(jnpfKey)) {