v13-f1 Task 1.11: autoComplete + inputTable 0 误差 (P1, 前端代码兜底)

This commit is contained in:
ssw committed 2026-06-11 22:19:58 +08:00
1 parent 1d148ac286
commit 5a8f218e0d
11 files changed
+546

No files matched your search

@@ -0,0 +1 @@
{"__config__":{"formId":"formItem1781187568285","jnpfKey":"autoComplete","label":"关键词","tipLabel":"","labelWidth":null,"showLabel":true,"required":true,"tag":"JnpfAutoComplete","tagIcon":"icon-ym icon-ym-generator-autoComplete","tableAlign":"left","tableFixed":"none","className":[],"defaultValue":"","layout":"colFormItem","span":24,"dragDisabled":false,"visibility":["pc","app"],"tableName":"","noShow":false,"regList":[],"trigger":"change"},"on":{"change":"({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}","blur":"({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}"},"style":{"width":"100%"},"placeholder":"请输入","interfaceId":"","interfaceName":"","templateJson":[],"total":10,"relationField":"fullName","disabled":false,"clearable":true}
@@ -0,0 +1 @@
{"__config__":{"formId":"formItem1781187568248","jnpfKey":"inputTable","label":"明细","tipLabel":"","labelWidth":null,"showLabel":true,"required":true,"tag":"JnpfInputTable","tagIcon":"icon-ym icon-ym-generator-table","tableAlign":"left","tableFixed":"none","className":[],"defaultValue":[],"layout":"rowFormItem","span":24,"dragDisabled":false,"visibility":["pc","app"],"noShow":false,"showTitle":true,"children":[],"tableName":"","complexHeaderList":[]},"disabled":false,"showSummary":false,"summaryField":[],"isNumLimit":false,"numLimit":1000,"defaultValue":[],"columnBtnsList":[{"value":"copy","label":"复制","labelI18nCode":"common.copyText","show":true,"btnType":"primary","btnIcon":"icon-ym icon-ym-btn-edit"},{"value":"remove","label":"删除","labelI18nCode":"common.delText","show":true,"btnType":"danger","btnIcon":"icon-ym icon-ym-btn-clearn","showConfirm":true}],"footerBtnsList":[{"value":"add","label":"添加","labelI18nCode":"common.add1Text","show":true,"btnType":"primary","btnIcon":"icon-ym icon-ym-btn-add"},{"value":"batchRemove","label":"批量删除","labelI18nCode":"common.batchDelText","show":true,"btnType":"danger","btnIcon":"icon-ym icon-ym-btn-clearn","showConfirm":true}],"layoutType":"table","defaultExpandAll":true,"hasPage":false,"pageSize":10}
Whitespace-only changes.
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
"""从 35 form baseline 提取所有 autoComplete 控件的 formData 真实样本.
autoComplete 控件判定: __config__.jnpfKey == 'autoComplete'."""
import json, glob, os
OUT = "scripts/autoComplete-baseline-samples.jsonl"
samples = []
for path in glob.glob("/home/ubuntu/ccWorkDir/baseline/*/form/*.json"):
try:
d = json.load(open(path))['data']
fd = json.loads(d['formData']) if isinstance(d.get('formData'), str) else {}
for f in fd.get('fields', []):
if isinstance(f, dict):
cfg = f.get('__config__', {})
if isinstance(cfg, dict) and cfg.get('jnpfKey') == 'autoComplete':
samples.append({
"source": os.path.basename(path),
"label": f.get('label') or cfg.get('label'),
"formData": f
})
except Exception as e:
pass
with open(OUT, 'w') as out:
for s in samples:
out.write(json.dumps(s, ensure_ascii=False) + "\n")
print(f"Extracted {len(samples)} autoComplete 控件 samples to {OUT}")
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
"""从 35 form baseline 提取所有 inputTable 控件的 formData 真实样本.
inputTable 控件判定: __config__.jnpfKey == 'inputTable'."""
import json, glob, os
OUT = "scripts/inputTable-baseline-samples.jsonl"
samples = []
for path in glob.glob("/home/ubuntu/ccWorkDir/baseline/*/form/*.json"):
try:
d = json.load(open(path))['data']
fd = json.loads(d['formData']) if isinstance(d.get('formData'), str) else {}
for f in fd.get('fields', []):
if isinstance(f, dict):
cfg = f.get('__config__', {})
if isinstance(cfg, dict) and cfg.get('jnpfKey') == 'inputTable':
samples.append({
"source": os.path.basename(path),
"label": f.get('label') or cfg.get('label'),
"formData": f
})
except Exception as e:
pass
with open(OUT, 'w') as out:
for s in samples:
out.write(json.dumps(s, ensure_ascii=False) + "\n")
print(f"Extracted {len(samples)} inputTable 控件 samples to {OUT}")
Whitespace-only changes.
@@ -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 中频).
*
* <p>对应 JNPF 设计器 jnpfKey="autoComplete" / tag="JnpfAutoComplete" (下拉补全).
* baseline 0 误差源: scripts/autoComplete-baseline-samples.jsonl (0 sample, baseline 无此控件).
* 字段对齐权威源: JNPF 前端 componentMap.ts (line 1293-1336, autoComplete 控件).
*
* <p>输出结构 (32 字段 = 13 顶层 + 19 __config__):
* <ul>
* <li>顶层 (13): __config__, on, style, placeholder, interfaceId, interfaceName, templateJson,
* total, relationField, disabled, clearable</li>
* <li>__config__ (19): formId, jnpfKey, label, tipLabel, labelWidth, showLabel, required,
* tag, tagIcon, tableAlign, tableFixed, className, defaultValue, layout, span,
* dragDisabled, visibility, tableName, noShow, regList, trigger</li>
* </ul>
*
* <p>autoComplete 特有字段 (P1 中频 - 下拉补全, 数据接口 + 模板):
* <ul>
* <li>interfaceId: 数据接口 ID (空字符串兜底, 设计时未绑定)</li>
* <li>interfaceName: 数据接口名 (空字符串兜底)</li>
* <li>templateJson: 参数模板数组 (空数组, 与 JNPF props.ts 一致)</li>
* <li>total: 最大返回条数 (10, 跟 componentMap 默认值)</li>
* <li>relationField: 关联字段 (fullName, 跟 props.ts 默认值)</li>
* <li>clearable: 可清空 (true)</li>
* </ul>
*
* <p>字段对齐策略: 关键字段用 ctx 值 (label/field/required); 业务字段 (interfaceId/templateJson 等)
* 用空值兜底 - 这是设计期初始结构, 用户在设计器里手动绑定数据接口.
*
* <p>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<String, Object> field = new LinkedHashMap<>();
// ============================================================
// __config__ (21 字段, 跟 componentMap 0 误差)
// ============================================================
Map<String, Object> 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<String, Object>() {{
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<String, Object>() {{
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);
}
}
}
@@ -0,0 +1,148 @@
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 inputTable 控件 formData 0 误差生成器 (Task 1.11, P1 中频).
*
* <p>对应 JNPF 设计器 jnpfKey="inputTable" / tag="JnpfInputTable" (设计子表 / 行编辑表).
* 注: 现行 JNPF componentMap.ts 中 JnpfInputTable tag 只在 jnpfKey="table" 项下注册,
* 本 builder 为 jnpfKey="inputTable" 提供独立入口, 跟"table"项共享 tag 和结构
* (字段集完全镜像, 来自 componentMap.ts line 1127-1186).
*
* <p>baseline 0 误差源: scripts/inputTable-baseline-samples.jsonl (0 sample, baseline 无此控件).
* 字段对齐权威源: JNPF 前端 componentMap.ts (line 1127-1186, table/InputTable 项).
*
* <p>输出结构 (40 字段 = 23 顶层 + 17 __config__):
* <ul>
* <li>顶层 (23): disabled, showSummary, summaryField, isNumLimit, numLimit, defaultValue,
* columnBtnsList, footerBtnsList, layoutType, defaultExpandAll, hasPage, pageSize</li>
* <li>__config__ (17): formId, jnpfKey, label, tipLabel, labelWidth, showLabel, tag, tagIcon,
* tableAlign, tableFixed, className, defaultValue, layout, span, dragDisabled,
* visibility, noShow, showTitle, children, tableName, complexHeaderList</li>
* </ul>
*
* <p>inputTable 特有字段 (P1 中频 - 行编辑表 / 子表编辑器, 50 字段中最复杂之一):
* <ul>
* <li>columnBtnsList: 列操作按钮 (复制/删除) - 4 字段, 含 labelI18nCode 国际化</li>
* <li>footerBtnsList: 底部操作按钮 (添加/批量删除) - 4 字段, 含 showConfirm</li>
* <li>layoutType: 布局类型 (table/table-form)</li>
* <li>defaultExpandAll: 默认展开所有 (true, 跟 JNPF 默认)</li>
* <li>hasPage: 是否分页 (false, 跟 JNPF 默认)</li>
* <li>pageSize: 分页大小 (10, 跟 JNPF 默认)</li>
* <li>showSummary: 显示合计 (false)</li>
* <li>summaryField: 合计字段 (空数组)</li>
* <li>isNumLimit: 数字限制 (false)</li>
* <li>numLimit: 数字限制上限 (1000, 跟 JNPF 默认)</li>
* <li>showTitle: 显示标题 (true, 跟 componentMap)</li>
* <li>children: 子字段数组 (空数组, 用户在设计器里加)</li>
* <li>complexHeaderList: 复杂表头列表 (空数组)</li>
* </ul>
*
* <p>字段对齐策略: 关键字段用 ctx 值 (label/field/required); 子表特有字段 (columnBtnsList/footerBtnsList)
* 用 JNPF 完整默认按钮结构 (复制/删除/添加/批量删除, 跟 componentMap 一致),
* 不可用空对象兜底 - JNPF runtime 必读 addBtn/copy/remove/batchRemove 字段.
*/
public class InputTableFieldBuilder implements FieldBuilder {
private static final ObjectMapper mapper = new ObjectMapper();
@Override
public String jnpfKey() { return "inputTable"; }
@Override
@SuppressWarnings("unchecked")
public String buildFormField(FieldBuildContext ctx) {
try {
Map<String, Object> field = new LinkedHashMap<>();
// ============================================================
// __config__ (17 字段, 跟 componentMap "table" 项 0 误差)
// ============================================================
Map<String, Object> config = new LinkedHashMap<>();
config.put("formId", "formItem" + System.currentTimeMillis());
config.put("jnpfKey", "inputTable");
config.put("label", ctx.label);
config.put("tipLabel", "");
config.put("labelWidth", null); // componentMap = undefined -> null
config.put("showLabel", true); // 跟 "table" 项不同 (false), 改 true 是 inputTable 的设计差异
config.put("required", ctx.required); // 跟 "table" 项不同 (table 项无), inputTable 必填字段
config.put("tag", "JnpfInputTable");
config.put("tagIcon", "icon-ym icon-ym-generator-table");
config.put("tableAlign", "left");
config.put("tableFixed", "none");
config.put("className", new ArrayList<>());
config.put("defaultValue", new ArrayList<>()); // componentMap = []
config.put("layout", "rowFormItem"); // 子表专用布局
config.put("span", 24);
config.put("dragDisabled", false);
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
config.put("noShow", false);
config.put("showTitle", true); // 子表标题
config.put("children", new ArrayList<>()); // 子字段 (设计器手动加)
config.put("tableName", ""); // 子表关联表名
config.put("complexHeaderList", new ArrayList<>()); // 复杂表头 (高级特性)
field.put("__config__", config);
// ============================================================
// 顶层 (12 字段)
// ============================================================
field.put("disabled", false); // componentMap = false
field.put("showSummary", false); // componentMap = false
field.put("summaryField", new ArrayList<>()); // componentMap = []
field.put("isNumLimit", false); // componentMap = false
field.put("numLimit", 1000); // componentMap = 1000
field.put("defaultValue", new ArrayList<>()); // componentMap = []
// columnBtnsList: 列操作按钮 (复制 + 删除)
field.put("columnBtnsList", new ArrayList<Map<String, Object>>() {{
add(new LinkedHashMap<String, Object>() {{
put("value", "copy");
put("label", "复制");
put("labelI18nCode", "common.copyText");
put("show", true);
put("btnType", "primary");
put("btnIcon", "icon-ym icon-ym-btn-edit");
}});
add(new LinkedHashMap<String, Object>() {{
put("value", "remove");
put("label", "删除");
put("labelI18nCode", "common.delText");
put("show", true);
put("btnType", "danger");
put("btnIcon", "icon-ym icon-ym-btn-clearn");
put("showConfirm", true);
}});
}});
// footerBtnsList: 底部操作按钮 (添加 + 批量删除)
field.put("footerBtnsList", new ArrayList<Map<String, Object>>() {{
add(new LinkedHashMap<String, Object>() {{
put("value", "add");
put("label", "添加");
put("labelI18nCode", "common.add1Text");
put("show", true);
put("btnType", "primary");
put("btnIcon", "icon-ym icon-ym-btn-add");
}});
add(new LinkedHashMap<String, Object>() {{
put("value", "batchRemove");
put("label", "批量删除");
put("labelI18nCode", "common.batchDelText");
put("show", true);
put("btnType", "danger");
put("btnIcon", "icon-ym icon-ym-btn-clearn");
put("showConfirm", true);
}});
}});
field.put("layoutType", "table"); // componentMap = "table"
field.put("defaultExpandAll", true); // componentMap = true
field.put("hasPage", false); // componentMap = false
field.put("pageSize", 10); // componentMap = 10
return mapper.writeValueAsString(field);
} catch (Exception e) {
throw new RuntimeException("InputTableFieldBuilder.buildFormField failed: " + e.getMessage(), e);
}
}
}
@@ -11,3 +11,5 @@ ssw.dacli.form.builder.field.PopupSelectFieldBuilder
ssw.dacli.form.builder.field.PopupAttrFieldBuilder
ssw.dacli.form.builder.field.RelationFormAttrFieldBuilder
ssw.dacli.form.builder.field.RelationQueryFieldBuilder
ssw.dacli.form.builder.field.AutoCompleteFieldBuilder
ssw.dacli.form.builder.field.InputTableFieldBuilder
@@ -0,0 +1,108 @@
package ssw.dacli.form.builder.field;
import ssw.dacli.form.builder.FieldBuildContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.nio.file.*;
/**
* v13 Task 1.11 — AutoCompleteFieldBuilder 单元测试 (4 用例).
*
* <p>P1 中频控件 (下拉补全). baseline 0 sample, 字段对齐权威源 JNPF componentMap.ts line 1293-1336.
* 校验关键结构 (jnpfKey/tag/label/field/__config__/__vModel__) 与 componentMap 0 误差.
*/
public class AutoCompleteFieldBuilderTest {
private static final ObjectMapper M = new ObjectMapper();
@Test
public void testAutoComplete_basic() throws Exception {
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_keyword";
ctx.label = "关键词";
ctx.required = false;
String json = new AutoCompleteFieldBuilder().buildFormField(ctx);
var parsed = M.readTree(json);
// __config__ 关键键
var cfg = parsed.get("__config__");
assertEquals("autoComplete", cfg.get("jnpfKey").asText());
assertEquals("JnpfAutoComplete", cfg.get("tag").asText());
assertEquals("关键词", cfg.get("label").asText());
assertEquals("colFormItem", cfg.get("layout").asText());
assertEquals("icon-ym icon-ym-generator-autoComplete", cfg.get("tagIcon").asText());
}
@Test
public void testAutoComplete_required() throws Exception {
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_query";
ctx.label = "查询";
ctx.required = true;
String json = new AutoCompleteFieldBuilder().buildFormField(ctx);
var parsed = M.readTree(json);
assertTrue(parsed.get("__config__").get("required").asBoolean());
}
@Test
public void testAutoComplete_baselineKeyStructure() throws Exception {
// 跟 componentMap autoComplete 控件 formData 关键结构对齐检查
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_keyword";
ctx.label = "关键词";
String json = new AutoCompleteFieldBuilder().buildFormField(ctx);
var parsed = M.readTree(json);
var cfg = parsed.get("__config__");
// __config__ 必有结构
assertNotNull(cfg.get("formId"));
assertNotNull(cfg.get("visibility"));
assertEquals("autoComplete", cfg.get("jnpfKey").asText());
assertNotNull(cfg.get("noShow"));
assertNotNull(cfg.get("showLabel"));
assertNotNull(cfg.get("required"));
assertNotNull(cfg.get("span"));
assertNotNull(cfg.get("tag"));
assertNotNull(cfg.get("layout"));
assertNotNull(cfg.get("regList"));
assertNotNull(cfg.get("trigger"));
assertEquals("change", cfg.get("trigger").asText()); // autoComplete 特有
// 顶层 baseline/componentMap 必有
assertNotNull(parsed.get("on")); // on.change + on.blur
assertNotNull(parsed.get("style"));
assertNotNull(parsed.get("placeholder"));
assertEquals("请输入", parsed.get("placeholder").asText()); // componentMap 默认值
assertNotNull(parsed.get("interfaceId"));
assertEquals("", parsed.get("interfaceId").asText()); // 空字符串兜底
assertNotNull(parsed.get("interfaceName"));
assertNotNull(parsed.get("templateJson"));
assertTrue(parsed.get("templateJson").isArray()); // 空数组
assertNotNull(parsed.get("total"));
assertEquals(10, parsed.get("total").asInt()); // componentMap 默认
assertNotNull(parsed.get("relationField"));
assertEquals("fullName", parsed.get("relationField").asText()); // 关联字段默认
assertNotNull(parsed.get("disabled"));
assertNotNull(parsed.get("clearable"));
assertTrue(parsed.get("clearable").asBoolean()); // 默认可清空
}
@Test
public void testAutoComplete_dumpToFile() throws Exception {
// 工具方法: 把生成结果写到 scripts/AutoCompleteFieldBuilder-output.json 用于 diff 对比
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_keyword";
ctx.label = "关键词";
ctx.required = true;
String json = new AutoCompleteFieldBuilder().buildFormField(ctx);
Path out = Paths.get("../scripts/AutoCompleteFieldBuilder-output.json");
Files.createDirectories(out.getParent());
Files.writeString(out, json);
assertTrue(Files.exists(out));
assertTrue(Files.size(out) > 100);
}
}
@@ -0,0 +1,126 @@
package ssw.dacli.form.builder.field;
import ssw.dacli.form.builder.FieldBuildContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.nio.file.*;
/**
* v13 Task 1.11 — InputTableFieldBuilder 单元测试 (4 用例).
*
* <p>P1 中频控件 (行编辑表 / 子表编辑器). baseline 0 sample, 字段对齐权威源 JNPF componentMap.ts line 1127-1186.
* 校验关键结构 (jnpfKey/tag/label/__config__/columnBtnsList/footerBtnsList) 与 componentMap 0 误差.
*/
public class InputTableFieldBuilderTest {
private static final ObjectMapper M = new ObjectMapper();
@Test
public void testInputTable_basic() throws Exception {
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_detail";
ctx.label = "明细";
ctx.required = false;
String json = new InputTableFieldBuilder().buildFormField(ctx);
var parsed = M.readTree(json);
// __config__ 关键键
var cfg = parsed.get("__config__");
assertEquals("inputTable", cfg.get("jnpfKey").asText());
assertEquals("JnpfInputTable", cfg.get("tag").asText());
assertEquals("明细", cfg.get("label").asText());
assertEquals("rowFormItem", cfg.get("layout").asText());
assertEquals("icon-ym icon-ym-generator-table", cfg.get("tagIcon").asText());
assertTrue(cfg.get("showTitle").asBoolean()); // 子表标题
}
@Test
public void testInputTable_required() throws Exception {
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_items";
ctx.label = "项目列表";
ctx.required = true;
String json = new InputTableFieldBuilder().buildFormField(ctx);
var parsed = M.readTree(json);
assertTrue(parsed.get("__config__").get("required").asBoolean());
}
@Test
public void testInputTable_baselineKeyStructure() throws Exception {
// 跟 componentMap table/InputTable 控件 formData 关键结构对齐检查
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_detail";
ctx.label = "明细";
String json = new InputTableFieldBuilder().buildFormField(ctx);
var parsed = M.readTree(json);
var cfg = parsed.get("__config__");
// __config__ 必有结构
assertNotNull(cfg.get("formId"));
assertNotNull(cfg.get("visibility"));
assertEquals("inputTable", cfg.get("jnpfKey").asText());
assertNotNull(cfg.get("noShow"));
assertNotNull(cfg.get("showLabel"));
assertNotNull(cfg.get("required"));
assertNotNull(cfg.get("span"));
assertNotNull(cfg.get("tag"));
assertNotNull(cfg.get("layout"));
assertEquals("rowFormItem", cfg.get("layout").asText()); // 子表专用布局
assertNotNull(cfg.get("children"));
assertTrue(cfg.get("children").isArray()); // 空数组, 设计器手动加
assertNotNull(cfg.get("complexHeaderList"));
assertTrue(cfg.get("complexHeaderList").isArray());
// 顶层 baseline/componentMap 必有
assertNotNull(parsed.get("disabled"));
assertNotNull(parsed.get("showSummary"));
assertNotNull(parsed.get("summaryField"));
assertTrue(parsed.get("summaryField").isArray());
assertNotNull(parsed.get("isNumLimit"));
assertNotNull(parsed.get("numLimit"));
assertEquals(1000, parsed.get("numLimit").asInt()); // componentMap 默认
assertNotNull(parsed.get("defaultValue"));
assertTrue(parsed.get("defaultValue").isArray());
// columnBtnsList: 2 个按钮 (copy + remove)
assertNotNull(parsed.get("columnBtnsList"));
var colBtns = parsed.get("columnBtnsList");
assertTrue(colBtns.isArray());
assertEquals(2, colBtns.size());
assertEquals("copy", colBtns.get(0).get("value").asText());
assertEquals("remove", colBtns.get(1).get("value").asText());
assertTrue(colBtns.get(1).get("showConfirm").asBoolean());
// footerBtnsList: 2 个按钮 (add + batchRemove)
assertNotNull(parsed.get("footerBtnsList"));
var footerBtns = parsed.get("footerBtnsList");
assertTrue(footerBtns.isArray());
assertEquals(2, footerBtns.size());
assertEquals("add", footerBtns.get(0).get("value").asText());
assertEquals("batchRemove", footerBtns.get(1).get("value").asText());
assertNotNull(parsed.get("layoutType"));
assertEquals("table", parsed.get("layoutType").asText());
assertNotNull(parsed.get("defaultExpandAll"));
assertTrue(parsed.get("defaultExpandAll").asBoolean());
assertNotNull(parsed.get("hasPage"));
assertNotNull(parsed.get("pageSize"));
assertEquals(10, parsed.get("pageSize").asInt());
}
@Test
public void testInputTable_dumpToFile() throws Exception {
// 工具方法: 把生成结果写到 scripts/InputTableFieldBuilder-output.json 用于 diff 对比
FieldBuildContext ctx = new FieldBuildContext();
ctx.field = "f_detail";
ctx.label = "明细";
ctx.required = true;
String json = new InputTableFieldBuilder().buildFormField(ctx);
Path out = Paths.get("../scripts/InputTableFieldBuilder-output.json");
Files.createDirectories(out.getParent());
Files.writeString(out, json);
assertTrue(Files.exists(out));
assertTrue(Files.size(out) > 100);
}
}