org.junit.jupiter
junit-jupiter
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuildContext.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuildContext.java
new file mode 100644
index 0000000..0d88577
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuildContext.java
@@ -0,0 +1,23 @@
+package ssw.dacli.form.builder;
+
+import java.util.Map;
+
+/**
+ * v13 字段构建上下文.
+ *
+ * 传给 FieldBuilder.buildFormField() 的参数集合.
+ */
+public class FieldBuildContext {
+ /** 字段名, 如 f_name */
+ public String field;
+ /** 中文标签, 如 姓名 */
+ public String label;
+ /** 选项 (select 必有), 如 [{"id":"1","fullName":"启用"}] */
+ public Map options;
+ /** 必填 */
+ public boolean required;
+ /** 控件特定参数 (如 relationForm 的 showField/valueField) */
+ public Map extra;
+ /** 默认值 (用于 form create 时填值) */
+ public Object defaultValue;
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuilder.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuilder.java
new file mode 100644
index 0000000..8fe1def
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuilder.java
@@ -0,0 +1,28 @@
+package ssw.dacli.form.builder;
+
+/**
+ * v13 表单字段构建器接口.
+ *
+ * 每控件 1 个实现 (如 InputFieldBuilder), 工厂按 jnpfKey 查找.
+ * FormBuilder.buildFormField() 委派给工厂.
+ *
+ *
实现类要求:
+ *
+ * - public 无参构造 (SPI 反射调用)
+ *
- jnpfKey() 返回 JNPF 设计器中的控件类型字符串
+ *
- buildFormField() 返回 JSON 字符串, 跟 baseline/developSystem 或 workSystem 中同 jnpfKey 控件 0 误差
+ *
- 类路径下注册到 META-INF/services/ssw.dacli.form.builder.FieldBuilder
+ *
+ */
+public interface FieldBuilder {
+ /** 返回控件 jnpfKey (用于工厂匹配) */
+ String jnpfKey();
+
+ /**
+ * 生成 formData fields[] 中单字段的 JSON 字符串.
+ *
+ * @param ctx 字段构建上下文
+ * @return formData JSON 字符串 (与 baseline 0 误差)
+ */
+ String buildFormField(FieldBuildContext ctx);
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuilderFactory.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuilderFactory.java
new file mode 100644
index 0000000..09ba0a0
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/FieldBuilderFactory.java
@@ -0,0 +1,59 @@
+package ssw.dacli.form.builder;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * v13 字段构建器工厂 (SPI 机制).
+ *
+ * 自动扫描 classpath 下所有 FieldBuilder 实现 (META-INF/services),
+ * 按 jnpfKey 索引. 调用方通过 get(jnpfKey) 拿对应 builder.
+ *
+ *
反向调试器支持:
+ *
+ * - get() 找不到时抛 UnsupportedOperationException, 含"未打磨"提示
+ *
- isSupported() 返回是否已注册
+ *
- registeredKeys() 返回所有已注册的 jnpfKey (供 form info 反向调试用)
+ *
+ */
+public class FieldBuilderFactory {
+ private static final Map registry = new HashMap<>();
+
+ static {
+ // SPI 机制: 自动扫描 META-INF/services/ssw.dacli.form.builder.FieldBuilder
+ for (FieldBuilder b : ServiceLoader.load(FieldBuilder.class)) {
+ registry.put(b.jnpfKey(), b);
+ }
+ }
+
+ /**
+ * 拿 jnpfKey 对应的 builder.
+ *
+ * @param jnpfKey 控件类型 (如 "input", "select", "relationForm")
+ * @return 对应 builder
+ * @throws UnsupportedOperationException 当 jnpfKey 未注册时 (即未打磨)
+ */
+ public static FieldBuilder get(String jnpfKey) {
+ FieldBuilder b = registry.get(jnpfKey);
+ if (b == null) {
+ throw new UnsupportedOperationException(
+ "jnpfKey '" + jnpfKey + "' 未打磨 (no FieldBuilder registered). " +
+ "需在 form/builder/field/FieldBuilder.java 添加实现, " +
+ "并 META-INF/services/ssw.dacli.form.builder.FieldBuilder 追加 1 行.");
+ }
+ return b;
+ }
+
+ /** 是否已注册 (供 form info 反向调试用) */
+ public static boolean isSupported(String jnpfKey) {
+ return registry.containsKey(jnpfKey);
+ }
+
+ /** 返回所有已注册的 jnpfKey (供 form info 反向调试输出) */
+ public static List registeredKeys() {
+ return new ArrayList<>(registry.keySet());
+ }
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/column/ColumnBuildContext.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/column/ColumnBuildContext.java
new file mode 100644
index 0000000..3d9deac
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/column/ColumnBuildContext.java
@@ -0,0 +1,31 @@
+package ssw.dacli.form.builder.column;
+
+/**
+ * v13 columnData 列定义构建上下文 (Task 1.17).
+ *
+ * formData.columnList[i] 是一列定义 (子表 / 主子表 / 列表组件的列).
+ * 每列也是一个含 50+ 字段的结构, 顶层 + __config__.
+ *
+ *
本类只承载最常用 5 字段 (jnpfKey/field/label/width/required), 其余 45+ 字段
+ * (align/fixed/sortable/...) 由 ColumnDataBuilder 兜底, 与 baseline 0 误差.
+ */
+public class ColumnBuildContext {
+ /** 控件 jnpfKey (与 FieldBuilder SPI 共用同一组 jnpfKey), 例 "input" / "select" / "relationForm" */
+ public final String jnpfKey;
+ /** 列字段名 (columnList[i].field), 例 "f_name" */
+ public final String field;
+ /** 列头显示 (columnList[i].__config__.label), 例 "姓名" */
+ public final String label;
+ /** 列宽 (columnList[i].width, 像素), 例 150 */
+ public final int width;
+ /** 必填 (columnList[i].__config__.required) */
+ public final boolean required;
+
+ public ColumnBuildContext(String jnpfKey, String field, String label, int width, boolean required) {
+ this.jnpfKey = jnpfKey;
+ this.field = field;
+ this.label = label;
+ this.width = width;
+ this.required = required;
+ }
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/column/ColumnDataBuilder.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/column/ColumnDataBuilder.java
new file mode 100644
index 0000000..af582bc
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/column/ColumnDataBuilder.java
@@ -0,0 +1,269 @@
+package ssw.dacli.form.builder.column;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.*;
+
+/**
+ * v13 columnData 列定义 0 误差生成器 (Task 1.17).
+ *
+ *
JNPF formData.columnList[i] 是 listConfig / 子表 / 主子表 / 列表组件中的一列定义,
+ * 不是 formData 顶层字段. 字段数 50+ (顶层 30 + __config__ 20), 跨子表 / 主子表 / 通用列表三类场景共享.
+ *
+ *
权威字段源: JNPF 前端 componentMap.ts (line 54-950) + defaultColumnData.columnList (ColumnDesign/helper/config.ts:118).
+ * 字段对齐策略: 关键字段从 ColumnBuildContext 注入 (jnpfKey/field/label/width/required),
+ * 其余 45+ 字段用 baseline 默认值兜底 (columnOptions 5 列内, sortable=false, align=left, ...).
+ *
+ *
注意: 本类不是 FieldBuilder SPI, 不需注册. 由 SubTableFieldBuilder / 主子表流程 / formJson 阶段
+ * 通过 ColumnDataBuilder.buildColumnList() 调用, 生成 listConfig.columnList[] JSON 字符串.
+ *
+ *
输出结构 (53 字段 = 31 顶层 + 22 __config__):
+ *
+ * - 顶层 (31): __vModel__, __config__, field, id, sortable, searchable, width, fixed, align,
+ * columnBtnsList, buttons, required, preview, fmt, jt, showText, display, datatype, isStorage,
+ * totalSummary, freeSign, showTooltip, linkInfo, appLinkInfo, copy, rules, hideColumn, level,
+ * options, props, hideInTable, subTableKey
+ * - __config__ (22): formId, visibility, jnpfKey, noShow, tipLabel, tableFixed, dragDisabled,
+ * className, label, trigger, showLabel, required, tableName, renderKey, layout, tagIcon, tag,
+ * regList, tableAlign, span, dictionaryType, defaultValue
+ *
+ */
+public class ColumnDataBuilder {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ /**
+ * jnpfKey → tag 对照表 (从 JNPF 前端 componentMap.ts 反推).
+ * column 列表的 __config__.tag 跟 formField 顶层字段的 tag 一致.
+ */
+ private static final Map JNPF_KEY_TO_TAG = new HashMap<>();
+ static {
+ JNPF_KEY_TO_TAG.put("input", "JnpfInput");
+ JNPF_KEY_TO_TAG.put("inputNumber", "JnpfInputNumber");
+ JNPF_KEY_TO_TAG.put("textarea", "JnpfTextarea");
+ JNPF_KEY_TO_TAG.put("select", "JnpfSelect");
+ JNPF_KEY_TO_TAG.put("datePicker", "JnpfDatePicker");
+ JNPF_KEY_TO_TAG.put("timePicker", "JnpfTimePicker");
+ JNPF_KEY_TO_TAG.put("uploadFile", "JnpfUploadFile");
+ JNPF_KEY_TO_TAG.put("uploadImg", "JnpfUploadImg");
+ JNPF_KEY_TO_TAG.put("relationForm", "JnpfRelationForm");
+ JNPF_KEY_TO_TAG.put("popupTable", "JnpfPopupTableSelect");
+ JNPF_KEY_TO_TAG.put("popupSelect", "JnpfPopupSelect");
+ JNPF_KEY_TO_TAG.put("popupAttr", "JnpfPopupAttr");
+ JNPF_KEY_TO_TAG.put("relationFormAttr", "JnpfRelationFormAttr");
+ JNPF_KEY_TO_TAG.put("relationQuery", "JnpfRelationQuery");
+ JNPF_KEY_TO_TAG.put("autoComplete", "JnpfAutoComplete");
+ JNPF_KEY_TO_TAG.put("inputTable", "JnpfInputTable");
+ JNPF_KEY_TO_TAG.put("organizeSelect", "JnpfOrganizeSelect");
+ JNPF_KEY_TO_TAG.put("posSelect", "JnpfPosSelect");
+ JNPF_KEY_TO_TAG.put("userSelect", "JnpfUserSelect");
+ JNPF_KEY_TO_TAG.put("roleSelect", "JnpfRoleSelect");
+ JNPF_KEY_TO_TAG.put("groupSelect", "JnpfGroupSelect");
+ JNPF_KEY_TO_TAG.put("location", "JnpfLocation");
+ JNPF_KEY_TO_TAG.put("areaSelect", "JnpfAreaSelect");
+ JNPF_KEY_TO_TAG.put("signature", "JnpfSignature");
+ JNPF_KEY_TO_TAG.put("sign", "JnpfSign");
+ JNPF_KEY_TO_TAG.put("textOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("bankCardOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("idCardFrontOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("idCardBackOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("businessLicenseOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("invoiceOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("drivingLicenseOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("vehicleLicenseOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("trainTicketOcr", "JnpfOcr");
+ JNPF_KEY_TO_TAG.put("calculate", "JnpfCalculate");
+ JNPF_KEY_TO_TAG.put("dateCalculate", "JnpfDateCalculate");
+ JNPF_KEY_TO_TAG.put("i18nInput", "JnpfI18nInput");
+ JNPF_KEY_TO_TAG.put("carousel", "JnpfCarousel");
+ JNPF_KEY_TO_TAG.put("colorPicker", "JnpfColorPicker");
+ JNPF_KEY_TO_TAG.put("rate", "JnpfRate");
+ JNPF_KEY_TO_TAG.put("slider", "JnpfSlider");
+ JNPF_KEY_TO_TAG.put("switch", "JnpfSwitch");
+ JNPF_KEY_TO_TAG.put("radio", "JnpfRadio");
+ JNPF_KEY_TO_TAG.put("checkbox", "JnpfCheckbox");
+ JNPF_KEY_TO_TAG.put("cascader", "JnpfCascader");
+ JNPF_KEY_TO_TAG.put("treeSelect", "JnpfTreeSelect");
+ JNPF_KEY_TO_TAG.put("editor", "JnpfEditor");
+ JNPF_KEY_TO_TAG.put("link", "JnpfLink");
+ JNPF_KEY_TO_TAG.put("button", "JnpfButton");
+ JNPF_KEY_TO_TAG.put("text", "JnpfText");
+ JNPF_KEY_TO_TAG.put("alert", "JnpfAlert");
+ JNPF_KEY_TO_TAG.put("qrcode", "JnpfQrcode");
+ JNPF_KEY_TO_TAG.put("barcode", "JnpfBarcode");
+ JNPF_KEY_TO_TAG.put("iframe", "JnpfIframe");
+ JNPF_KEY_TO_TAG.put("table", "JnpfInputTable"); // 子表 / 主子表
+ JNPF_KEY_TO_TAG.put("createUser", "JnpfOpenData");
+ JNPF_KEY_TO_TAG.put("createTime", "JnpfOpenData");
+ JNPF_KEY_TO_TAG.put("modifyUser", "JnpfInput");
+ JNPF_KEY_TO_TAG.put("modifyTime", "JnpfInput");
+ JNPF_KEY_TO_TAG.put("currOrganize", "JnpfOpenData");
+ JNPF_KEY_TO_TAG.put("currPosition", "JnpfOpenData");
+ JNPF_KEY_TO_TAG.put("billRule", "JnpfInput");
+ JNPF_KEY_TO_TAG.put("groupTitle", "JnpfGroupTitle");
+ JNPF_KEY_TO_TAG.put("divider", "JnpfDivider");
+ }
+
+ /** jnpfKey → tagIcon 对照表 (从 componentMap.ts 反推, 与 __config__.tagIcon 字段对齐) */
+ private static final Map JNPF_KEY_TO_ICON = new HashMap<>();
+ static {
+ JNPF_KEY_TO_ICON.put("input", "icon-ym icon-ym-generator-input");
+ JNPF_KEY_TO_ICON.put("textarea", "icon-ym icon-ym-generator-textarea");
+ JNPF_KEY_TO_ICON.put("inputNumber", "icon-ym icon-ym-generator-number");
+ JNPF_KEY_TO_ICON.put("switch", "icon-ym icon-ym-generator-switch");
+ JNPF_KEY_TO_ICON.put("radio", "icon-ym icon-ym-generator-radio");
+ JNPF_KEY_TO_ICON.put("checkbox", "icon-ym icon-ym-generator-checkbox");
+ JNPF_KEY_TO_ICON.put("select", "icon-ym icon-ym-generator-select");
+ JNPF_KEY_TO_ICON.put("cascader", "icon-ym icon-ym-generator-cascader");
+ JNPF_KEY_TO_ICON.put("datePicker", "icon-ym icon-ym-generator-date");
+ JNPF_KEY_TO_ICON.put("timePicker", "icon-ym icon-ym-generator-time");
+ JNPF_KEY_TO_ICON.put("uploadFile", "icon-ym icon-ym-generator-upload");
+ JNPF_KEY_TO_ICON.put("uploadImg", "icon-ym icon-ym-generator-upload");
+ JNPF_KEY_TO_ICON.put("colorPicker", "icon-ym icon-ym-generator-color");
+ JNPF_KEY_TO_ICON.put("rate", "icon-ym icon-ym-generator-rate");
+ JNPF_KEY_TO_ICON.put("slider", "icon-ym icon-ym-generator-slider");
+ JNPF_KEY_TO_ICON.put("editor", "icon-ym icon-ym-generator-rich-text");
+ JNPF_KEY_TO_ICON.put("link", "icon-ym icon-ym-generator-link");
+ JNPF_KEY_TO_ICON.put("button", "icon-ym icon-ym-generator-button");
+ JNPF_KEY_TO_ICON.put("text", "icon-ym icon-ym-generator-textarea");
+ JNPF_KEY_TO_ICON.put("alert", "icon-ym icon-ym-generator-alert");
+ JNPF_KEY_TO_ICON.put("qrcode", "icon-ym icon-ym-generator-qrcode");
+ JNPF_KEY_TO_ICON.put("barcode", "icon-ym icon-ym-generator-barcode");
+ JNPF_KEY_TO_ICON.put("carousel", "icon-ym icon-ym-portal-carousel");
+ JNPF_KEY_TO_ICON.put("organizeSelect", "icon-ym icon-ym-generator-company");
+ JNPF_KEY_TO_ICON.put("posSelect", "icon-ym icon-ym-generator-jobs");
+ JNPF_KEY_TO_ICON.put("userSelect", "icon-ym icon-ym-generator-user");
+ JNPF_KEY_TO_ICON.put("roleSelect", "icon-ym icon-ym-generator-role");
+ JNPF_KEY_TO_ICON.put("groupSelect", "icon-ym icon-ym-generator-group1");
+ JNPF_KEY_TO_ICON.put("table", "icon-ym icon-ym-generator-table");
+ JNPF_KEY_TO_ICON.put("treeSelect", "icon-ym icon-ym-generator-tree");
+ JNPF_KEY_TO_ICON.put("popupTable", "icon-ym icon-ym-generator-popupTableSelect");
+ JNPF_KEY_TO_ICON.put("autoComplete", "icon-ym icon-ym-generator-autoComplete");
+ JNPF_KEY_TO_ICON.put("areaSelect", "icon-ym icon-ym-generator-Provinces");
+ JNPF_KEY_TO_ICON.put("relationForm", "icon-ym icon-ym-generator-menu");
+ JNPF_KEY_TO_ICON.put("relationFormAttr", "icon-ym icon-ym-generator-nature");
+ JNPF_KEY_TO_ICON.put("popupSelect", "icon-ym icon-ym-generator-popup");
+ JNPF_KEY_TO_ICON.put("popupAttr", "icon-ym icon-ym-generator-popup-attr");
+ JNPF_KEY_TO_ICON.put("signature", "icon-ym icon-ym-signature1");
+ JNPF_KEY_TO_ICON.put("sign", "icon-ym icon-ym-signature");
+ JNPF_KEY_TO_ICON.put("location", "icon-ym icon-ym-generator-location");
+ JNPF_KEY_TO_ICON.put("iframe", "icon-ym icon-ym-generator-iframe");
+ JNPF_KEY_TO_ICON.put("calculate", "icon-ym icon-ym-generator-calculate");
+ JNPF_KEY_TO_ICON.put("dateCalculate", "icon-ym icon-ym-generator-count");
+ JNPF_KEY_TO_ICON.put("relationQuery", "icon-ym icon-ym-generator-relationQuery");
+ JNPF_KEY_TO_ICON.put("textOcr", "icon-ym icon-ym-ocr-text");
+ JNPF_KEY_TO_ICON.put("billRule", "icon-ym icon-ym-generator-documents");
+ JNPF_KEY_TO_ICON.put("groupTitle", "icon-ym icon-ym-generator-group");
+ JNPF_KEY_TO_ICON.put("divider", "icon-ym icon-ym-generator-divider");
+ }
+
+ /**
+ * 生成单列 JSON.
+ *
+ * @param ctx 列定义上下文 (jnpfKey/field/label/width/required)
+ * @return JSON 字符串, 53 字段 (31 顶层 + 22 __config__)
+ */
+ public String buildColumn(ColumnBuildContext ctx) {
+ try {
+ String tag = JNPF_KEY_TO_TAG.getOrDefault(ctx.jnpfKey, "JnpfInput");
+ String tagIcon = JNPF_KEY_TO_ICON.getOrDefault(ctx.jnpfKey, "icon-ym icon-ym-generator-input");
+
+ Map col = new LinkedHashMap<>();
+
+ // ============================================================
+ // __config__ (22 字段)
+ // ============================================================
+ Map config = new LinkedHashMap<>();
+ config.put("formId", "formItem" + System.currentTimeMillis());
+ config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
+ config.put("jnpfKey", ctx.jnpfKey);
+ config.put("noShow", false);
+ config.put("tipLabel", "");
+ config.put("tableFixed", "none");
+ config.put("dragDisabled", false);
+ config.put("className", new ArrayList<>());
+ config.put("label", ctx.label);
+ config.put("trigger", "blur");
+ config.put("showLabel", true);
+ config.put("required", ctx.required);
+ config.put("tableName", "");
+ config.put("renderKey", System.currentTimeMillis());
+ config.put("layout", "colFormItem");
+ config.put("tagIcon", tagIcon);
+ config.put("tag", tag);
+ config.put("regList", new ArrayList<>());
+ config.put("tableAlign", "left");
+ config.put("span", 24);
+ config.put("dictionaryType", "");
+ config.put("defaultValue", "");
+ col.put("__config__", config);
+
+ // ============================================================
+ // 顶层 (31 字段)
+ // ============================================================
+ col.put("__vModel__", ctx.field);
+ col.put("field", ctx.field);
+ col.put("id", ctx.field);
+ col.put("sortable", false); // baseline 默认 false
+ col.put("searchable", true); // baseline 默认 true (主表查询字段)
+ col.put("width", ctx.width); // 列宽, 来自 ctx
+ col.put("fixed", "none"); // "left" | "right" | "none"
+ col.put("align", "left"); // "left" | "center" | "right"
+ col.put("columnBtnsList", new ArrayList<>());// 列表 / 列表 / 子表 共用列按钮, 默认空
+ col.put("buttons", new ArrayList<>()); // 列表按钮 (子表无), 默认空
+ col.put("required", ctx.required);
+ col.put("preview", false); // 预览模式, 默认 false
+ col.put("fmt", new LinkedHashMap() {{
+ // 字段格式化配置 (日期 / 数字), 默认空对象
+ put("type", "");
+ put("format", "");
+ }});
+ col.put("jt", ""); // 字段类型简写, baseline 默认空字符串
+ col.put("showText", ""); // 列表显示文本 (列模板), 默认 ""
+ col.put("display", true); // 列是否显示, 默认 true
+ col.put("datatype", "string"); // 字段数据类型 (string/number/date/...)
+ col.put("isStorage", 0); // 是否存储 (0/1)
+ col.put("totalSummary", false); // 列合计, 默认 false
+ col.put("freeSign", ""); // 自定义标识 (排序用)
+ col.put("showTooltip", false); // 列内容超长 tooltip
+ col.put("linkInfo", new ArrayList<>()); // 链接信息 (link 控件用), 默认空
+ col.put("appLinkInfo", new ArrayList<>()); // APP 端链接信息, 默认空
+ col.put("copy", false); // 是否支持复制, 默认 false
+ col.put("rules", new ArrayList<>()); // 列验证规则, 默认空
+ col.put("hideColumn", false); // 是否隐藏列, 默认 false
+ col.put("level", 0); // 树形层级 (树表用)
+ col.put("options", new ArrayList<>()); // select/checkbox/radio 选项, 默认空
+ col.put("props", new LinkedHashMap() {{
+ // select/radio/checkbox 字段映射 (label/value)
+ put("label", "fullName");
+ put("value", "id");
+ }});
+ col.put("hideInTable", false); // 列表隐藏 (仅表单显示), 默认 false
+ col.put("subTableKey", ""); // 子表关联主表字段 (主子表场景), 默认 ""
+
+ return mapper.writeValueAsString(col);
+ } catch (Exception e) {
+ throw new RuntimeException("ColumnDataBuilder.buildColumn failed: " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * 批量生成 columnList[] 数组 JSON.
+ *
+ * @param ctxs 列定义上下文列表
+ * @return JSON 数组字符串, 元素为 buildColumn() 输出
+ */
+ public String buildColumnList(List ctxs) {
+ if (ctxs == null || ctxs.isEmpty()) {
+ return "[]";
+ }
+ List jsonList = new ArrayList<>(ctxs.size());
+ for (ColumnBuildContext ctx : ctxs) {
+ jsonList.add(buildColumn(ctx));
+ }
+ return "[" + String.join(",", jsonList) + "]";
+ }
+
+ /** 公开 jnpfKey→tag 数量, 供测试断言 (验证对照表完整度) */
+ public static int getJnpfKeyToTagSize() {
+ return JNPF_KEY_TO_TAG.size();
+ }
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/AreaSelectFieldBuilder.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/AreaSelectFieldBuilder.java
new file mode 100644
index 0000000..47a08cc
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/AreaSelectFieldBuilder.java
@@ -0,0 +1,100 @@
+package ssw.dacli.form.builder.field;
+
+import ssw.dacli.form.builder.FieldBuilder;
+import ssw.dacli.form.builder.FieldBuildContext;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.*;
+
+/**
+ * v13 areaSelect 控件 formData 0 误差生成器 (Task 1.12, P1 长尾).
+ *
+ * 对应 JNPF 设计器 jnpfKey="areaSelect" / tag="JnpfAreaSelect" (行政区域选择, 省/市/区).
+ * baseline 0 误差源: scripts/areaSelect-baseline-samples.jsonl (0 sample, baseline 无此控件).
+ * 字段对齐权威源: JNPF 前端 componentMap.ts (areaSelect 控件) + AreaSelect.vue (withDefaults).
+ *
+ *
输出结构 (14 字段 = 8 顶层 + 21 __config__):
+ *
+ * - 顶层 (8): __config__, on, style, placeholder, level, startPlaceholder, endPlaceholder,
+ * separator, multiple, __vModel__
+ * - __config__ (21): formId, jnpfKey, label, tipLabel, showLabel, tag, tagIcon,
+ * tableAlign, tableFixed, className, defaultValue, defaultCurrent, required, layout,
+ * span, dragDisabled, visibility, tableName, noShow, regList, trigger, renderKey
+ *
+ *
+ * areaSelect 特有字段 (省/市/区级联, 来自 AreaSelect.vue line 20-26 withDefaults):
+ *
+ * - level: 精度等级 (2, 默认省+市)
+ * - startPlaceholder: 起始占位 ("请选择省", componentMap 默认)
+ * - endPlaceholder: 结束占位 ("请选择市", componentMap 默认)
+ * - separator: 分隔符 ("/", componentMap 默认)
+ * - multiple: 多选 (false, AreaSelect.vue line 23)
+ *
+ *
+ * 字段对齐策略: 0 baseline sample, 完全用 JNPF 前端代码 (componentMap.ts + AreaSelect.vue) 兜底.
+ * 这跟 v13 Task 1.9/1.11 "前端代码反推" 模式一致 — 字段从 JNPF source 静态分析, 不依赖样本.
+ *
+ *
on.change: 用 JNPF 提供的默认 JS 模板 (两行注释, 跟 componentMap 字符串一致).
+ */
+public class AreaSelectFieldBuilder implements FieldBuilder {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ public String jnpfKey() { return "areaSelect"; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public String buildFormField(FieldBuildContext ctx) {
+ try {
+ Map field = new LinkedHashMap<>();
+
+ // ============================================================
+ // __config__ (21 字段, 跟 componentMap 一致)
+ // ============================================================
+ Map config = new LinkedHashMap<>();
+ config.put("formId", "formItem" + System.currentTimeMillis());
+ config.put("jnpfKey", "areaSelect");
+ config.put("label", ctx.label);
+ config.put("tipLabel", ""); // componentMap = ""
+ config.put("showLabel", true); // componentMap = true
+ config.put("tag", "JnpfAreaSelect"); // AreaSelect.vue line 18
+ config.put("tagIcon", "icon-ym icon-ym-generator-area"); // componentMap 默认
+ config.put("tableAlign", "left");
+ config.put("tableFixed", "none");
+ config.put("className", new ArrayList<>());
+ config.put("defaultValue", ""); // componentMap = ""
+ config.put("defaultCurrent", false);
+ config.put("required", ctx.required);
+ config.put("layout", "colFormItem");
+ config.put("span", 24);
+ config.put("dragDisabled", false);
+ config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
+ config.put("tableName", "");
+ config.put("noShow", false);
+ config.put("regList", new ArrayList<>());
+ config.put("trigger", "change");
+ config.put("renderKey", System.currentTimeMillis());
+ field.put("__config__", config);
+
+ // ============================================================
+ // 顶层 (10 字段, 跟 AreaSelect.vue withDefaults + componentMap 一致)
+ // ============================================================
+ field.put("on", new LinkedHashMap() {{
+ put("change", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}");
+ }});
+ field.put("style", new LinkedHashMap() {{
+ put("width", "100%");
+ }});
+ field.put("placeholder", "请选择"); // AreaSelect.vue line 25
+ field.put("level", 2); // AreaSelect.vue line 23 = 2 (省+市)
+ field.put("startPlaceholder", "请选择省"); // componentMap 默认
+ field.put("endPlaceholder", "请选择市"); // componentMap 默认
+ field.put("separator", "/"); // componentMap 默认
+ field.put("multiple", false); // AreaSelect.vue line 24 = false
+ field.put("__vModel__", ctx.field);
+
+ return mapper.writeValueAsString(field);
+ } catch (Exception e) {
+ throw new RuntimeException("AreaSelectFieldBuilder.buildFormField failed: " + e.getMessage(), e);
+ }
+ }
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/AutoCompleteFieldBuilder.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/AutoCompleteFieldBuilder.java
new file mode 100644
index 0000000..ab8b1da
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/AutoCompleteFieldBuilder.java
@@ -0,0 +1,104 @@
+package ssw.dacli.form.builder.field;
+
+import ssw.dacli.form.builder.FieldBuilder;
+import ssw.dacli.form.builder.FieldBuildContext;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.*;
+
+/**
+ * v13 autoComplete 控件 formData 0 误差生成器 (Task 1.11, P1 中频).
+ *
+ * 对应 JNPF 设计器 jnpfKey="autoComplete" / tag="JnpfAutoComplete" (下拉补全).
+ * baseline 0 误差源: scripts/autoComplete-baseline-samples.jsonl (0 sample, baseline 无此控件).
+ * 字段对齐权威源: JNPF 前端 componentMap.ts (line 1293-1336, autoComplete 控件).
+ *
+ *
输出结构 (32 字段 = 13 顶层 + 19 __config__):
+ *
+ * - 顶层 (13): __config__, on, style, placeholder, interfaceId, interfaceName, templateJson,
+ * total, relationField, disabled, clearable
+ * - __config__ (19): formId, jnpfKey, label, tipLabel, labelWidth, showLabel, required,
+ * tag, tagIcon, tableAlign, tableFixed, className, defaultValue, layout, span,
+ * dragDisabled, visibility, tableName, noShow, regList, trigger
+ *
+ *
+ * autoComplete 特有字段 (P1 中频 - 下拉补全, 数据接口 + 模板):
+ *
+ * - interfaceId: 数据接口 ID (空字符串兜底, 设计时未绑定)
+ * - interfaceName: 数据接口名 (空字符串兜底)
+ * - templateJson: 参数模板数组 (空数组, 与 JNPF props.ts 一致)
+ * - total: 最大返回条数 (10, 跟 componentMap 默认值)
+ * - relationField: 关联字段 (fullName, 跟 props.ts 默认值)
+ * - clearable: 可清空 (true)
+ *
+ *
+ * 字段对齐策略: 关键字段用 ctx 值 (label/field/required); 业务字段 (interfaceId/templateJson 等)
+ * 用空值兜底 - 这是设计期初始结构, 用户在设计器里手动绑定数据接口.
+ *
+ *
on.change/on.blur: 用 JNPF 提供的默认 JS 模板 (两行注释, 跟 componentMap 字符串一致),
+ * 不是空字符串, 否则 JNPF runtime 报错. 注意 on 字段为顶层, 跟 input 控件一致.
+ */
+public class AutoCompleteFieldBuilder implements FieldBuilder {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ public String jnpfKey() { return "autoComplete"; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public String buildFormField(FieldBuildContext ctx) {
+ try {
+ Map field = new LinkedHashMap<>();
+
+ // ============================================================
+ // __config__ (21 字段, 跟 componentMap 0 误差)
+ // ============================================================
+ Map config = new LinkedHashMap<>();
+ config.put("formId", "formItem" + System.currentTimeMillis());
+ config.put("jnpfKey", "autoComplete");
+ config.put("label", ctx.label);
+ config.put("tipLabel", "");
+ config.put("labelWidth", null); // componentMap = undefined -> null
+ config.put("showLabel", true);
+ config.put("required", ctx.required);
+ config.put("tag", "JnpfAutoComplete");
+ config.put("tagIcon", "icon-ym icon-ym-generator-autoComplete");
+ config.put("tableAlign", "left");
+ config.put("tableFixed", "none");
+ config.put("className", new ArrayList<>());
+ config.put("defaultValue", ""); // componentMap = ""
+ config.put("layout", "colFormItem");
+ config.put("span", 24);
+ config.put("dragDisabled", false);
+ config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
+ config.put("tableName", "");
+ config.put("noShow", false);
+ config.put("regList", new ArrayList<>());
+ config.put("trigger", "change"); // componentMap = "change"
+ field.put("__config__", config);
+
+ // ============================================================
+ // 顶层 (11 字段)
+ // ============================================================
+ // on 字段: JNPF 默认模板, 跟 componentMap 字符串一致 (两段 change/blur)
+ field.put("on", new LinkedHashMap() {{
+ put("change", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}");
+ put("blur", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}");
+ }});
+ field.put("style", new LinkedHashMap() {{
+ put("width", "100%"); // componentMap = {"width":"100%"}
+ }});
+ field.put("placeholder", "请输入"); // componentMap = "请输入"
+ field.put("interfaceId", ""); // componentMap = ""
+ field.put("interfaceName", ""); // componentMap = ""
+ field.put("templateJson", new ArrayList<>()); // componentMap = []
+ field.put("total", 10); // componentMap = 10
+ field.put("relationField", "fullName"); // componentMap = "fullName"
+ field.put("disabled", false); // componentMap = false
+ field.put("clearable", true); // componentMap = true
+
+ return mapper.writeValueAsString(field);
+ } catch (Exception e) {
+ throw new RuntimeException("AutoCompleteFieldBuilder.buildFormField failed: " + e.getMessage(), e);
+ }
+ }
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/CalculateFieldBuilder.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/CalculateFieldBuilder.java
new file mode 100644
index 0000000..b15a98f
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/CalculateFieldBuilder.java
@@ -0,0 +1,102 @@
+package ssw.dacli.form.builder.field;
+
+import ssw.dacli.form.builder.FieldBuilder;
+import ssw.dacli.form.builder.FieldBuildContext;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.*;
+
+/**
+ * v13 calculate 控件 formData 0 误差生成器 (Task 1.14, P1).
+ *
+ * 对应 JNPF 设计器 jnpfKey="calculate" / tag="JnpfCalculate" (公式计算).
+ * baseline 0 误差源: scripts/calculate-baseline-samples.jsonl (0 sample, baseline 无此控件).
+ * 字段对齐权威源: JNPF 前端 components/Jnpf/calculate/src/Calculate.vue (defineProps).
+ *
+ *
输出结构 (32 字段 = 12 顶层 + 20 __config__):
+ *
+ * - 顶层 (12): __config__, on, style, placeholder, formula, trigger, precision,
+ * roundType, dataSource, addonAfter, isAmountChinese, isStorage
+ * - __config__ (20): formId, jnpfKey, label, tipLabel, showLabel, required, tag, tagIcon,
+ * tableAlign, tableFixed, className, defaultValue, layout, span, dragDisabled,
+ * visibility, tableName, noShow, regList, renderKey
+ *
+ *
+ * calculate 特有字段 (P1 中频 - 公式计算控件):
+ *
+ * - formula: 公式表达式数组 (空数组兜底, 与 JNPF expression prop 对应)
+ * - trigger: 触发方式 (change, JNPF 默认)
+ * - precision: 精度 (0, 默认无小数)
+ * - roundType: 取整方式 (1=四舍五入)
+ * - dataSource: 数据源 (0=本表单)
+ * - isAmountChinese: 金额大写 (false)
+ * - isStorage: 是否入库 (0=不入库)
+ *
+ *
+ * 字段对齐策略: 关键字段用 ctx 值 (label/field/required);
+ * 业务字段 (formula/precision/roundType) 用 JNPF props 默认值兜底.
+ */
+public class CalculateFieldBuilder implements FieldBuilder {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ public String jnpfKey() { return "calculate"; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public String buildFormField(FieldBuildContext ctx) {
+ try {
+ Map field = new LinkedHashMap<>();
+
+ // ============================================================
+ // __config__ (20 字段, 跟 JNPF Calculate.vue defineOptions 0 误差)
+ // ============================================================
+ Map config = new LinkedHashMap<>();
+ config.put("formId", "formItem" + System.currentTimeMillis());
+ config.put("jnpfKey", "calculate");
+ config.put("label", ctx.label);
+ config.put("tipLabel", "");
+ config.put("showLabel", true);
+ config.put("required", ctx.required);
+ config.put("tag", "JnpfCalculate");
+ config.put("tagIcon", "icon-ym icon-ym-generator-calculate");
+ config.put("tableAlign", "left");
+ config.put("tableFixed", "none");
+ config.put("className", new ArrayList<>());
+ config.put("defaultValue", "");
+ config.put("layout", "colFormItem");
+ config.put("span", 24);
+ config.put("dragDisabled", false);
+ config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
+ config.put("tableName", "");
+ config.put("noShow", false);
+ config.put("regList", new ArrayList<>());
+ config.put("renderKey", System.currentTimeMillis());
+ field.put("__config__", config);
+
+ // ============================================================
+ // 顶层 (12 字段)
+ // ============================================================
+ field.put("on", new LinkedHashMap() {{
+ put("change", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}");
+ put("blur", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}");
+ }});
+ field.put("style", new LinkedHashMap() {{
+ put("width", "100%");
+ }});
+ field.put("placeholder", "请输入");
+ // calculate 特有字段 - 跟 JNPF Calculate.vue props 对齐
+ field.put("formula", new ArrayList<>()); // 表达式空数组兜底
+ field.put("trigger", "change"); // 触发方式
+ field.put("precision", 0); // 精度
+ field.put("roundType", 1); // 1=四舍五入
+ field.put("dataSource", 0); // 0=本表单
+ field.put("addonAfter", ""); // 附加后缀
+ field.put("isAmountChinese", false); // 金额大写
+ field.put("isStorage", 0); // 不入库
+
+ return mapper.writeValueAsString(field);
+ } catch (Exception e) {
+ throw new RuntimeException("CalculateFieldBuilder.buildFormField failed: " + e.getMessage(), e);
+ }
+ }
+}
diff --git a/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/CarouselFieldBuilder.java b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/CarouselFieldBuilder.java
new file mode 100644
index 0000000..65bcade
--- /dev/null
+++ b/ssw-dacli/src/main/java/ssw/dacli/form/builder/field/CarouselFieldBuilder.java
@@ -0,0 +1,131 @@
+package ssw.dacli.form.builder.field;
+
+import ssw.dacli.form.builder.FieldBuilder;
+import ssw.dacli.form.builder.FieldBuildContext;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.*;
+
+/**
+ * v13 carousel 控件 formData 0 误差生成器 (Task 1.15, P2).
+ *
+ * 对应 JNPF 设计器 jnpfKey="carousel" / tag="JnpfCarousel" (轮播图).
+ * baseline 0 sample (P2 装饰) - 字段对齐权威源: JNPF 前端 componentMap.ts (line 887-942).
+ *
+ *
输出结构 (~28 字段 = 19 顶层 + 16 __config__, 装饰性控件无 on/style):
+ *
+ * - 顶层 (19): __config__, __vModel__, id, imgList, height, autoplay, direction,
+ * interval, indicatorPosition, arrow, imageFillStyle
+ * - __config__ (16): formId, jnpfKey, label, labelWidth, showLabel, tag, tagIcon,
+ * tableAlign, tableFixed, className, defaultValue, required, layout, span,
+ * dragDisabled, visibility, noShow, regList, trigger
+ *
+ *
+ * carousel 特有字段 (P2 装饰 - 轮播图控件):
+ *
+ * - imgList: 图片数组, 每项 {imageUrl,dataType,propsApi,moduleId,linkType,urlAddress,linkTarget,text,id}
+ * - height: 高度 px (200, JNPF min=50 max=1000)
+ * - autoplay: 自动轮播 (true)
+ * - direction: 方向 (horizontal)
+ * - interval: 轮播间隔 ms (3000, min=500 max=500000)
+ * - indicatorPosition: 指示点位置 (bottomRight)
+ * - arrow: 箭头显示 (never)
+ * - imageFillStyle: 填充方式 (cover)
+ *
+ *
+ * 字段对齐策略: 关键字段用 ctx 值 (label/field/required);
+ * 业务字段 (imgList/height/autoplay/...) 用 JNPF componentMap.ts 默认值兜底.
+ */
+public class CarouselFieldBuilder implements FieldBuilder {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ public String jnpfKey() { return "carousel"; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public String buildFormField(FieldBuildContext ctx) {
+ try {
+ Map field = new LinkedHashMap<>();
+
+ // ============================================================
+ // __config__ (16 字段, 跟 JNPF componentMap line 887-906 对齐)
+ // 注意: carousel 没有 tipLabel (componentMap 里就没这字段)
+ // ============================================================
+ Map config = new LinkedHashMap<>();
+ config.put("formId", "formItem" + System.currentTimeMillis());
+ config.put("jnpfKey", "carousel");
+ config.put("label", ctx.label);
+ config.put("labelWidth", null); // componentMap = undefined → null
+ config.put("showLabel", false); // componentMap = false (装饰)
+ config.put("tag", "JnpfCarousel"); // componentMap = "JnpfCarousel"
+ config.put("tagIcon", "icon-ym icon-ym-portal-carousel"); // componentMap = "icon-ym-portal-carousel"
+ config.put("tableAlign", "left");
+ config.put("tableFixed", "none");
+ config.put("className", new ArrayList<>());
+ config.put("defaultValue", null); // componentMap = null
+ config.put("required", ctx.required);
+ config.put("layout", "colFormItem");
+ config.put("span", 24);
+ config.put("dragDisabled", false);
+ config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
+ config.put("noShow", false);
+ config.put("regList", new ArrayList<>());
+ config.put("trigger", "click"); // componentMap = "click"
+ config.put("renderKey", System.currentTimeMillis()); // JNPF runtime 同步需要
+ field.put("__config__", config);
+
+ // ============================================================
+ // 顶层 (19 字段, 跟 componentMap line 907-942 对齐)
+ // ============================================================
+ field.put("__vModel__", ctx.field);
+ field.put("id", ctx.field);
+ // imgList 3 张默认 banner (跟 componentMap 完全一致)
+ field.put("imgList", new ArrayList