diff --git a/scripts/CalculateFieldBuilder-output.json b/scripts/CalculateFieldBuilder-output.json new file mode 100644 index 0000000..e943781 --- /dev/null +++ b/scripts/CalculateFieldBuilder-output.json @@ -0,0 +1 @@ +{"__config__":{"formId":"formItem1781188614580","jnpfKey":"calculate","label":"合计","tipLabel":"","showLabel":true,"required":true,"tag":"JnpfCalculate","tagIcon":"icon-ym icon-ym-generator-calculate","tableAlign":"left","tableFixed":"none","className":[],"defaultValue":"","layout":"colFormItem","span":24,"dragDisabled":false,"visibility":["pc","app"],"tableName":"","noShow":false,"regList":[],"renderKey":1781188614580},"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":"请输入","formula":[],"trigger":"change","precision":0,"roundType":1,"dataSource":0,"addonAfter":"","isAmountChinese":false,"isStorage":0} \ No newline at end of file diff --git a/scripts/DateCalculateFieldBuilder-output.json b/scripts/DateCalculateFieldBuilder-output.json new file mode 100644 index 0000000..1736524 --- /dev/null +++ b/scripts/DateCalculateFieldBuilder-output.json @@ -0,0 +1 @@ +{"__config__":{"formId":"formItem1781188614414","jnpfKey":"dateCalculate","label":"截止日期","tipLabel":"","showLabel":true,"required":true,"tag":"JnpfDateCalculate","tagIcon":"icon-ym icon-ym-generator-date-calculate","tableAlign":"left","tableFixed":"none","className":[],"layout":"colFormItem","span":24,"dragDisabled":false,"visibility":["pc","app"],"tableName":"","noShow":false,"regList":[],"renderKey":1781188614414},"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":"请输入","format":"yyyy-MM-dd","defaultValue":"","startTime":"","endTime":"","formula":[],"isStorage":0} \ No newline at end of file diff --git a/scripts/I18nInputFieldBuilder-output.json b/scripts/I18nInputFieldBuilder-output.json new file mode 100644 index 0000000..397e09a --- /dev/null +++ b/scripts/I18nInputFieldBuilder-output.json @@ -0,0 +1 @@ +{"__config__":{"formId":"formItem1781188614477","jnpfKey":"i18nInput","label":"多语言标题","tipLabel":"","showLabel":true,"required":true,"tag":"JnpfI18nInput","tagIcon":"icon-ym icon-ym-generator-i18nInput","tableAlign":"left","tableFixed":"none","className":[],"defaultValue":"","layout":"colFormItem","span":24,"dragDisabled":false,"visibility":["pc","app"],"tableName":"","noShow":false,"regList":[],"renderKey":1781188614477},"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":"请输入","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","i18n":"","maxlength":null} \ No newline at end of file diff --git a/scripts/calculate-baseline-samples.jsonl b/scripts/calculate-baseline-samples.jsonl new file mode 100644 index 0000000..e69de29 diff --git a/scripts/dateCalculate-baseline-samples.jsonl b/scripts/dateCalculate-baseline-samples.jsonl new file mode 100644 index 0000000..e69de29 diff --git a/scripts/extract-calculate-baseline.py b/scripts/extract-calculate-baseline.py new file mode 100644 index 0000000..734a105 --- /dev/null +++ b/scripts/extract-calculate-baseline.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +"""从 35 form baseline 提取所有 calculate 控件的 formData 真实样本. +calculate 控件判定: __config__.jnpfKey == 'calculate'.""" +import json, glob, os + +OUT = "scripts/calculate-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') == 'calculate': + 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)} calculate 控件 samples to {OUT}") diff --git a/scripts/extract-dateCalculate-baseline.py b/scripts/extract-dateCalculate-baseline.py new file mode 100644 index 0000000..82ff462 --- /dev/null +++ b/scripts/extract-dateCalculate-baseline.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +"""从 35 form baseline 提取所有 dateCalculate 控件的 formData 真实样本. +dateCalculate 控件判定: __config__.jnpfKey == 'dateCalculate'.""" +import json, glob, os + +OUT = "scripts/dateCalculate-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') == 'dateCalculate': + 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)} dateCalculate 控件 samples to {OUT}") diff --git a/scripts/extract-i18nInput-baseline.py b/scripts/extract-i18nInput-baseline.py new file mode 100644 index 0000000..da4d7c4 --- /dev/null +++ b/scripts/extract-i18nInput-baseline.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +"""从 35 form baseline 提取所有 i18nInput 控件的 formData 真实样本. +i18nInput 控件判定: __config__.jnpfKey == 'i18nInput'.""" +import json, glob, os + +OUT = "scripts/i18nInput-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') == 'i18nInput': + 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)} i18nInput 控件 samples to {OUT}") diff --git a/scripts/i18nInput-baseline-samples.jsonl b/scripts/i18nInput-baseline-samples.jsonl new file mode 100644 index 0000000..e69de29 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__): + *
calculate 特有字段 (P1 中频 - 公式计算控件): + *
字段对齐策略: 关键字段用 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 对应 JNPF 设计器 jnpfKey="dateCalculate" / tag="JnpfDateCalculate" (日期计算).
+ * baseline 0 误差源: scripts/dateCalculate-baseline-samples.jsonl (0 sample, baseline 无此控件).
+ * 字段对齐权威源: JNPF 前端 components/Jnpf/dateCalculate/src/DateCalculate.vue (defineProps).
+ *
+ * 输出结构 (29 字段 = 10 顶层 + 19 __config__):
+ * dateCalculate 特有字段 (P1 中频 - 日期计算控件):
+ * 字段对齐策略: 关键字段用 ctx 值 (label/field/required);
+ * 业务字段 (format/formula/isStorage) 用 JNPF props 默认值兜底.
+ */
+public class DateCalculateFieldBuilder implements FieldBuilder {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ public String jnpfKey() { return "dateCalculate"; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public String buildFormField(FieldBuildContext ctx) {
+ try {
+ Map 对应 JNPF 设计器 jnpfKey="i18nInput" / tag="JnpfI18nInput" (多语言输入框).
+ * baseline 0 误差源: scripts/i18nInput-baseline-samples.jsonl (0 sample, baseline 无此控件).
+ * 字段对齐权威源: JNPF 前端 components/Jnpf/i18nInput/src/props.ts (i18nInputProps).
+ *
+ * 输出结构 (29 字段 = 10 顶层 + 19 __config__):
+ * i18nInput 特有字段 (P1 中频 - 多语言输入框控件):
+ * 字段对齐策略: 关键字段用 ctx 值 (label/field/required);
+ * 业务字段 (i18n/prefixIcon/suffixIcon) 用 JNPF props.ts 默认值兜底.
+ */
+public class I18nInputFieldBuilder implements FieldBuilder {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ public String jnpfKey() { return "i18nInput"; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public String buildFormField(FieldBuildContext ctx) {
+ try {
+ Map P1 中频控件 (公式计算). baseline 0 sample, 字段对齐权威源 JNPF Calculate.vue defineProps.
+ * 校验关键结构 (jnpfKey/tag/label/field/__config__/__vModel__) 与 JNPF 0 误差.
+ */
+public class CalculateFieldBuilderTest {
+
+ private static final ObjectMapper M = new ObjectMapper();
+
+ @Test
+ public void testCalculate_basic() throws Exception {
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_total";
+ ctx.label = "合计";
+ ctx.required = false;
+
+ String json = new CalculateFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+
+ var cfg = parsed.get("__config__");
+ assertEquals("calculate", cfg.get("jnpfKey").asText());
+ assertEquals("JnpfCalculate", cfg.get("tag").asText());
+ assertEquals("合计", cfg.get("label").asText());
+ assertEquals("colFormItem", cfg.get("layout").asText());
+ assertEquals("icon-ym icon-ym-generator-calculate", cfg.get("tagIcon").asText());
+ }
+
+ @Test
+ public void testCalculate_required() throws Exception {
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_amount";
+ ctx.label = "金额";
+ ctx.required = true;
+
+ String json = new CalculateFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+ assertTrue(parsed.get("__config__").get("required").asBoolean());
+ }
+
+ @Test
+ public void testCalculate_baselineKeyStructure() throws Exception {
+ // 跟 JNPF Calculate.vue defineProps 关键结构对齐检查
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_total";
+ ctx.label = "合计";
+
+ String json = new CalculateFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+ var cfg = parsed.get("__config__");
+
+ // __config__ 必有结构
+ assertNotNull(cfg.get("formId"));
+ assertNotNull(cfg.get("visibility"));
+ assertEquals("calculate", 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("renderKey"));
+
+ // 顶层 calculate 特有
+ assertNotNull(parsed.get("on"));
+ assertNotNull(parsed.get("style"));
+ assertNotNull(parsed.get("placeholder"));
+ assertEquals("请输入", parsed.get("placeholder").asText());
+ assertNotNull(parsed.get("formula"));
+ assertTrue(parsed.get("formula").isArray()); // 表达式空数组
+ assertNotNull(parsed.get("trigger"));
+ assertEquals("change", parsed.get("trigger").asText());
+ assertNotNull(parsed.get("precision"));
+ assertEquals(0, parsed.get("precision").asInt());
+ assertNotNull(parsed.get("roundType"));
+ assertEquals(1, parsed.get("roundType").asInt());
+ assertNotNull(parsed.get("dataSource"));
+ assertEquals(0, parsed.get("dataSource").asInt());
+ assertNotNull(parsed.get("isAmountChinese"));
+ assertFalse(parsed.get("isAmountChinese").asBoolean());
+ assertNotNull(parsed.get("isStorage"));
+ assertEquals(0, parsed.get("isStorage").asInt());
+ }
+
+ @Test
+ public void testCalculate_dumpToFile() throws Exception {
+ // 工具方法: 把生成结果写到 scripts/CalculateFieldBuilder-output.json 用于 diff 对比
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_total";
+ ctx.label = "合计";
+ ctx.required = true;
+ String json = new CalculateFieldBuilder().buildFormField(ctx);
+ Path out = Paths.get("../scripts/CalculateFieldBuilder-output.json");
+ Files.createDirectories(out.getParent());
+ Files.writeString(out, json);
+ assertTrue(Files.exists(out));
+ assertTrue(Files.size(out) > 100);
+ }
+}
diff --git a/ssw-dacli/src/test/java/ssw/dacli/form/builder/field/DateCalculateFieldBuilderTest.java b/ssw-dacli/src/test/java/ssw/dacli/form/builder/field/DateCalculateFieldBuilderTest.java
new file mode 100644
index 0000000..c3366e0
--- /dev/null
+++ b/ssw-dacli/src/test/java/ssw/dacli/form/builder/field/DateCalculateFieldBuilderTest.java
@@ -0,0 +1,106 @@
+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.14 — DateCalculateFieldBuilder 单元测试 (4 用例).
+ *
+ * P1 中频控件 (日期计算). baseline 0 sample, 字段对齐权威源 JNPF DateCalculate.vue defineProps.
+ * 校验关键结构 (jnpfKey/tag/label/field/__config__/__vModel__) 与 JNPF 0 误差.
+ */
+public class DateCalculateFieldBuilderTest {
+
+ private static final ObjectMapper M = new ObjectMapper();
+
+ @Test
+ public void testDateCalculate_basic() throws Exception {
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_deadline";
+ ctx.label = "截止日期";
+ ctx.required = false;
+
+ String json = new DateCalculateFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+
+ var cfg = parsed.get("__config__");
+ assertEquals("dateCalculate", cfg.get("jnpfKey").asText());
+ assertEquals("JnpfDateCalculate", cfg.get("tag").asText());
+ assertEquals("截止日期", cfg.get("label").asText());
+ assertEquals("colFormItem", cfg.get("layout").asText());
+ assertEquals("icon-ym icon-ym-generator-date-calculate", cfg.get("tagIcon").asText());
+ }
+
+ @Test
+ public void testDateCalculate_required() throws Exception {
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_due";
+ ctx.label = "到期日";
+ ctx.required = true;
+
+ String json = new DateCalculateFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+ assertTrue(parsed.get("__config__").get("required").asBoolean());
+ }
+
+ @Test
+ public void testDateCalculate_baselineKeyStructure() throws Exception {
+ // 跟 JNPF DateCalculate.vue defineProps 关键结构对齐检查
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_deadline";
+ ctx.label = "截止日期";
+
+ String json = new DateCalculateFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+ var cfg = parsed.get("__config__");
+
+ // __config__ 必有结构
+ assertNotNull(cfg.get("formId"));
+ assertNotNull(cfg.get("visibility"));
+ assertEquals("dateCalculate", 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("renderKey"));
+
+ // 顶层 dateCalculate 特有
+ assertNotNull(parsed.get("on"));
+ assertNotNull(parsed.get("style"));
+ assertNotNull(parsed.get("placeholder"));
+ assertEquals("请输入", parsed.get("placeholder").asText());
+ assertNotNull(parsed.get("format"));
+ assertEquals("yyyy-MM-dd", parsed.get("format").asText());
+ assertNotNull(parsed.get("defaultValue"));
+ assertEquals("", parsed.get("defaultValue").asText());
+ assertNotNull(parsed.get("startTime"));
+ assertEquals("", parsed.get("startTime").asText());
+ assertNotNull(parsed.get("endTime"));
+ assertEquals("", parsed.get("endTime").asText());
+ assertNotNull(parsed.get("formula"));
+ assertTrue(parsed.get("formula").isArray()); // 表达式空数组
+ assertNotNull(parsed.get("isStorage"));
+ assertEquals(0, parsed.get("isStorage").asInt());
+ }
+
+ @Test
+ public void testDateCalculate_dumpToFile() throws Exception {
+ // 工具方法: 把生成结果写到 scripts/DateCalculateFieldBuilder-output.json 用于 diff 对比
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_deadline";
+ ctx.label = "截止日期";
+ ctx.required = true;
+ String json = new DateCalculateFieldBuilder().buildFormField(ctx);
+ Path out = Paths.get("../scripts/DateCalculateFieldBuilder-output.json");
+ Files.createDirectories(out.getParent());
+ Files.writeString(out, json);
+ assertTrue(Files.exists(out));
+ assertTrue(Files.size(out) > 100);
+ }
+}
diff --git a/ssw-dacli/src/test/java/ssw/dacli/form/builder/field/I18nInputFieldBuilderTest.java b/ssw-dacli/src/test/java/ssw/dacli/form/builder/field/I18nInputFieldBuilderTest.java
new file mode 100644
index 0000000..fc43886
--- /dev/null
+++ b/ssw-dacli/src/test/java/ssw/dacli/form/builder/field/I18nInputFieldBuilderTest.java
@@ -0,0 +1,106 @@
+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.14 — I18nInputFieldBuilder 单元测试 (4 用例).
+ *
+ * P1 中频控件 (多语言输入框). baseline 0 sample, 字段对齐权威源 JNPF i18nInputProps (props.ts).
+ * 校验关键结构 (jnpfKey/tag/label/field/__config__/__vModel__) 与 JNPF 0 误差.
+ */
+public class I18nInputFieldBuilderTest {
+
+ private static final ObjectMapper M = new ObjectMapper();
+
+ @Test
+ public void testI18nInput_basic() throws Exception {
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_title_i18n";
+ ctx.label = "多语言标题";
+ ctx.required = false;
+
+ String json = new I18nInputFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+
+ var cfg = parsed.get("__config__");
+ assertEquals("i18nInput", cfg.get("jnpfKey").asText());
+ assertEquals("JnpfI18nInput", cfg.get("tag").asText());
+ assertEquals("多语言标题", cfg.get("label").asText());
+ assertEquals("colFormItem", cfg.get("layout").asText());
+ assertEquals("icon-ym icon-ym-generator-i18nInput", cfg.get("tagIcon").asText());
+ }
+
+ @Test
+ public void testI18nInput_required() throws Exception {
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_desc_i18n";
+ ctx.label = "多语言描述";
+ ctx.required = true;
+
+ String json = new I18nInputFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+ assertTrue(parsed.get("__config__").get("required").asBoolean());
+ }
+
+ @Test
+ public void testI18nInput_baselineKeyStructure() throws Exception {
+ // 跟 JNPF i18nInputProps 关键结构对齐检查
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_title_i18n";
+ ctx.label = "多语言标题";
+
+ String json = new I18nInputFieldBuilder().buildFormField(ctx);
+ var parsed = M.readTree(json);
+ var cfg = parsed.get("__config__");
+
+ // __config__ 必有结构
+ assertNotNull(cfg.get("formId"));
+ assertNotNull(cfg.get("visibility"));
+ assertEquals("i18nInput", 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("renderKey"));
+
+ // 顶层 i18nInput 特有 - 跟 i18nInputProps 对齐
+ assertNotNull(parsed.get("on"));
+ assertNotNull(parsed.get("style"));
+ assertNotNull(parsed.get("placeholder"));
+ assertEquals("请输入", parsed.get("placeholder").asText());
+ assertNotNull(parsed.get("prefixIcon"));
+ assertEquals("", parsed.get("prefixIcon").asText());
+ assertNotNull(parsed.get("suffixIcon"));
+ assertEquals("", parsed.get("suffixIcon").asText());
+ assertNotNull(parsed.get("i18n"));
+ assertEquals("", parsed.get("i18n").asText()); // 空字符串兜底
+ assertNotNull(parsed.get("addonBefore"));
+ assertEquals("", parsed.get("addonBefore").asText());
+ assertNotNull(parsed.get("addonAfter"));
+ assertEquals("", parsed.get("addonAfter").asText());
+ assertNotNull(parsed.get("maxlength"));
+ assertTrue(parsed.get("maxlength").isNull()); // null 不限
+ }
+
+ @Test
+ public void testI18nInput_dumpToFile() throws Exception {
+ // 工具方法: 把生成结果写到 scripts/I18nInputFieldBuilder-output.json 用于 diff 对比
+ FieldBuildContext ctx = new FieldBuildContext();
+ ctx.field = "f_title_i18n";
+ ctx.label = "多语言标题";
+ ctx.required = true;
+ String json = new I18nInputFieldBuilder().buildFormField(ctx);
+ Path out = Paths.get("../scripts/I18nInputFieldBuilder-output.json");
+ Files.createDirectories(out.getParent());
+ Files.writeString(out, json);
+ assertTrue(Files.exists(out));
+ assertTrue(Files.size(out) > 100);
+ }
+}
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *