v13.23 P0 7 盲点 merge: select+userSelect+groupTitle+radio+divider+tableGrid+cascader 完整字段集 (替代 v13 简化版, 28 新 tests, 164/164 PASS)
This commit is contained in:
commit
3c5edbdea4
22 files changed
+1498
No files matched your search
@@ -0,0 +1 @@
|
||||
{"__config__":{"formId":"formItem1781223119899","visibility":["pc","app"],"jnpfKey":"cascader","noShow":false,"tipLabel":"","tableFixed":"none","dragDisabled":false,"className":[],"label":"地区","trigger":"change","showLabel":true,"required":true,"tableName":"","renderKey":1781223119899,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-cascader","tag":"JnpfCascader","regList":[],"tableAlign":"left","span":24,"defaultValue":[],"dataType":"static","dictionaryType":"","propsUrl":"","propsName":"","useCache":true,"templateJson":[]},"__vModel__":"f_region","field":"f_region","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%"},"options":[{"id":"1","fullName":"选项1","children":[{"id":"2","fullName":"选项1-1"}]}],"props":{"value":"id","label":"fullName","children":"children"},"placeholder":"请选择","disabled":false,"clearable":true,"filterable":false,"multiple":false,"id":"f_region","fullName":"地区","fullNameI18nCode":[""],"dropdownClassName":"","maxTagCount":null}
|
||||
@@ -0,0 +1 @@
|
||||
{"__config__":{"formId":"formItem1781223119790","visibility":["pc","app"],"jnpfKey":"divider","noShow":false,"label":"","showLabel":false,"className":[],"required":false,"layout":"colFormItem","span":24,"dragDisabled":false,"tagIcon":"icon-ym icon-ym-generator-divider","tag":"JnpfDivider","defaultValue":null},"__vModel__":"f_divider","content":"我是分割线","contentPosition":"center"}
|
||||
@@ -0,0 +1 @@
|
||||
{"__config__":{"formId":"formItem1781223119786","visibility":["pc","app"],"jnpfKey":"groupTitle","noShow":false,"label":"","showLabel":false,"className":[],"required":false,"layout":"colFormItem","span":24,"dragDisabled":false,"tagIcon":"icon-ym icon-ym-generator-group","tag":"JnpfGroupTitle","defaultValue":null},"__vModel__":"f_title","helpMessage":"","content":"基本信息","contentPosition":"left"}
|
||||
@@ -0,0 +1 @@
|
||||
{"__config__":{"formId":"formItem1781223119683","visibility":["pc","app"],"jnpfKey":"radio","noShow":false,"tipLabel":"","tableFixed":"none","dragDisabled":false,"className":[],"label":"性别","trigger":"change","showLabel":true,"required":true,"tableName":"","renderKey":1781223119683,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-radio","tag":"JnpfRadio","regList":[],"tableAlign":"left","span":24,"defaultValue":null,"dataType":"static","dictionaryType":"","propsUrl":"","propsName":"","useCache":true,"templateJson":[]},"__vModel__":"f_gender","field":"f_gender","on":{"change":"({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n\n}"},"style":{"width":"100%"},"options":[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],"props":{"label":"fullName","value":"id"},"direction":"horizontal","optionType":"default","buttonStyle":"solid","size":"default","disabled":false,"id":"f_gender","fullName":"性别","fullNameI18nCode":[""],"dropdownClassName":"","maxTagCount":null}
|
||||
@@ -0,0 +1 @@
|
||||
{"__config__":{"formId":"formItem1781223119853","visibility":["pc","app"],"jnpfKey":"select","noShow":false,"tipLabel":"","tableFixed":"none","dragDisabled":false,"className":[],"label":"状态","trigger":"change","showLabel":true,"required":true,"tableName":"","renderKey":1781223119853,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-select","tag":"JnpfSelect","regList":[],"tableAlign":"left","span":24,"dictionaryType":"","defaultValue":"","dataType":"static","propsUrl":"","propsName":"","useCache":true,"templateJson":[]},"__vModel__":"f_status","field":"f_status","on":{"change":"({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n\n}"},"style":{"width":"100%"},"options":[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],"props":{"label":"fullName","value":"id"},"placeholder":"请选择","clearable":true,"disabled":false,"filterable":false,"multiple":false,"id":"f_status","fullName":"状态","fullNameI18nCode":[""],"dropdownClassName":"","maxTagCount":null,"allowCreate":false,"defaultActiveFirstOption":true}
|
||||
@@ -0,0 +1 @@
|
||||
{"__config__":{"formId":"formItem1781223119773","visibility":["pc","app"],"jnpfKey":"tableGrid","noShow":false,"label":"","showLabel":false,"className":[],"required":false,"layout":"rowFormItem","span":24,"dragDisabled":false,"tagIcon":"icon-ym icon-ym-generator-tableGrid","tag":"Table","defaultValue":[],"borderType":"solid","borderColor":"#E2E0E0","borderWidth":1,"children":[{"title":"tr","__config__":{"jnpfKey":"tableGridTr","children":[{"title":"td","__config__":{"jnpfKey":"tableGridTd","merged":false,"colspan":1,"rowspan":1,"children":[],"backgroundColor":""}}]}}]},"__vModel__":"f_grid"}
|
||||
@@ -0,0 +1 @@
|
||||
{"__config__":{"formId":"formItem1781223119826","visibility":["pc","app"],"jnpfKey":"userSelect","noShow":false,"tipLabel":"","tableFixed":"none","dragDisabled":false,"className":[],"label":"用户","trigger":"change","showLabel":true,"required":true,"tableName":"","renderKey":1781223119826,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-user","tag":"JnpfUserSelect","regList":[],"tableAlign":"left","span":24,"defaultValue":null,"defaultCurrent":false},"__vModel__":"f_user","field":"f_user","on":{"change":"({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n\n}"},"style":{"width":"100%"},"placeholder":"请选择","selectType":"all","ableIds":[],"ableRelationIds":[],"relationField":"","multiple":false,"clearable":true,"disabled":false,"id":"f_user","fullName":"用户"}
|
||||
@@ -0,0 +1,126 @@
|
||||
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.23 cascader 控件 formData 0 误差生成器 (Task 1.22 P0).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="cascader" / tag="JnpfCascader" (级联选择).
|
||||
* baseline 源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:377 (cascader 完整 schema).
|
||||
*
|
||||
* <p>输出结构 (44 字段 = 18 顶层 + 26 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (18): __config__, __vModel__, field, on, style, options, props, placeholder, clearable,
|
||||
* disabled, filterable, multiple, id, fullName, fullNameI18nCode, dropdownClassName, maxTagCount</li>
|
||||
* <li>__config__ (26): formId, visibility, jnpfKey, noShow, tipLabel, tableFixed, dragDisabled,
|
||||
* className, label, trigger, showLabel, required, tableName, renderKey, layout, tagIcon, tag,
|
||||
* regList, tableAlign, span, defaultValue, dataType, dictionaryType, propsUrl, propsName,
|
||||
* useCache, templateJson</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>特殊性: cascader 是 dyOptionsList (config.ts:2, 动态 options), props 含 children 多级.
|
||||
* 跟 select 区别: 1) defaultValue 是 []; 2) on 有 change + blur 双事件; 3) options 含 children.
|
||||
*/
|
||||
public class CascaderFieldBuilder implements FieldBuilder {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String jnpfKey() { return "cascader"; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildFormField(FieldBuildContext ctx) {
|
||||
try {
|
||||
Map<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (跟 componentMap.ts cascader 0 误差对齐)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("jnpfKey", "cascader");
|
||||
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", "change");
|
||||
config.put("showLabel", true);
|
||||
config.put("required", ctx.required);
|
||||
config.put("tableName", "");
|
||||
config.put("renderKey", System.currentTimeMillis());
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-cascader");
|
||||
config.put("tag", "JnpfCascader");
|
||||
config.put("regList", new ArrayList<>());
|
||||
config.put("tableAlign", "left");
|
||||
config.put("span", 24);
|
||||
// cascader defaultValue 是 [] (componentMap.ts:389)
|
||||
config.put("defaultValue", ctx.defaultValue != null ? ctx.defaultValue : new ArrayList<>());
|
||||
// 字典数据源 (componentMap.ts:399-404)
|
||||
config.put("dataType", "static");
|
||||
config.put("dictionaryType", "");
|
||||
config.put("propsUrl", "");
|
||||
config.put("propsName", "");
|
||||
config.put("useCache", true);
|
||||
config.put("templateJson", new ArrayList<>());
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (跟 componentMap.ts cascader 0 误差对齐)
|
||||
// ============================================================
|
||||
field.put("__vModel__", ctx.field);
|
||||
field.put("field", ctx.field);
|
||||
// on 含 change + blur 双事件 (componentMap.ts:406-409)
|
||||
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%");
|
||||
}});
|
||||
// options (含 children 多级, componentMap.ts:411-422)
|
||||
if (ctx.options != null) {
|
||||
field.put("options", ctx.options);
|
||||
} else {
|
||||
field.put("options", new ArrayList<Object>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("id", "1");
|
||||
put("fullName", "选项1");
|
||||
put("children", new ArrayList<Object>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("id", "2");
|
||||
put("fullName", "选项1-1");
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
}
|
||||
// props (value/label/children 字段映射, componentMap.ts:423-427)
|
||||
field.put("props", new LinkedHashMap<String, Object>() {{
|
||||
put("value", "id");
|
||||
put("label", "fullName");
|
||||
put("children", "children");
|
||||
}});
|
||||
field.put("placeholder", "请选择");
|
||||
field.put("disabled", false);
|
||||
field.put("clearable", true);
|
||||
field.put("filterable", false);
|
||||
field.put("multiple", false);
|
||||
field.put("id", ctx.field);
|
||||
field.put("fullName", ctx.label);
|
||||
field.put("fullNameI18nCode", new ArrayList<>(Arrays.asList("")));
|
||||
field.put("dropdownClassName", "");
|
||||
field.put("maxTagCount", null);
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("CascaderFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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.23 divider 控件 formData 0 误差生成器 (Task 1.22 P0).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="divider" / tag="JnpfDivider" (分割线).
|
||||
* baseline 源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:1931 (divider 完整 schema).
|
||||
*
|
||||
* <p>输出结构 (16 字段 = 4 顶层 + 12 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (4): __config__, __vModel__, content, contentPosition</li>
|
||||
* <li>__config__ (12): formId, visibility, jnpfKey, noShow, label, showLabel, className, required,
|
||||
* layout, span, dragDisabled, tagIcon, tag, defaultValue</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>注意: divider 是 vModelIgnoreList (config.ts:4), 但保留 __vModel__ 兼容.
|
||||
* contentPosition: left/center/right (RDivider.vue:5-9).
|
||||
*/
|
||||
public class DividerFieldBuilder implements FieldBuilder {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String jnpfKey() { return "divider"; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildFormField(FieldBuildContext ctx) {
|
||||
try {
|
||||
Map<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (跟 componentMap.ts divider 0 误差对齐)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("jnpfKey", "divider");
|
||||
config.put("noShow", false);
|
||||
config.put("label", "");
|
||||
// divider 是 showLabel=false (componentMap.ts:1936)
|
||||
config.put("showLabel", false);
|
||||
config.put("className", new ArrayList<>());
|
||||
config.put("required", false);
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("span", 24);
|
||||
config.put("dragDisabled", false);
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-divider");
|
||||
config.put("tag", "JnpfDivider");
|
||||
config.put("defaultValue", null);
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (跟 RDivider.vue + componentMap.ts:1948-1949 0 误差对齐)
|
||||
// ============================================================
|
||||
field.put("__vModel__", ctx.field);
|
||||
// content: 展示文本 (RDivider.vue:13, componentMap.ts:1948 = "我是分割线")
|
||||
field.put("content", "我是分割线");
|
||||
// contentPosition: 文本位置 (RDivider.vue:16, componentMap.ts:1949 = "center")
|
||||
field.put("contentPosition", "center");
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("DividerFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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.23 groupTitle 控件 formData 0 误差生成器 (Task 1.22 P0).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="groupTitle" / tag="JnpfGroupTitle" (分组标题).
|
||||
* baseline 源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:1910 (groupTitle 完整 schema).
|
||||
* 布局控件, 出现 8 次.
|
||||
*
|
||||
* <p>输出结构 (18 字段 = 5 顶层 + 13 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (5): __config__, __vModel__, helpMessage, content, contentPosition</li>
|
||||
* <li>__config__ (13): formId, visibility, jnpfKey, noShow, label, showLabel, className, required,
|
||||
* layout, span, dragDisabled, tagIcon, tag, defaultValue</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>注意: groupTitle 是 vModelIgnoreList (config.ts:4), 不输出 __vModel__/field 双键, 但 JNPF 仍接受.
|
||||
* 简化做法: 保留 __vModel__ 兼容, contentPosition 跟 RGroupTitle.vue 0 误差 (left/center/right).
|
||||
*/
|
||||
public class GroupTitleFieldBuilder implements FieldBuilder {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String jnpfKey() { return "groupTitle"; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildFormField(FieldBuildContext ctx) {
|
||||
try {
|
||||
Map<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (跟 componentMap.ts groupTitle 0 误差对齐)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("jnpfKey", "groupTitle");
|
||||
config.put("noShow", false);
|
||||
// groupTitle 是 showLabel=false (componentMap.ts:1915)
|
||||
config.put("label", "");
|
||||
config.put("showLabel", false);
|
||||
config.put("className", new ArrayList<>());
|
||||
config.put("required", false);
|
||||
// 布局控件 layout="colFormItem" (componentMap.ts:1921) - 但 span=24 横跨整行
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("span", 24);
|
||||
config.put("dragDisabled", false);
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-group");
|
||||
config.put("tag", "JnpfGroupTitle");
|
||||
config.put("defaultValue", null);
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (跟 RGroupTitle.vue + componentMap.ts:1927-1929 0 误差对齐)
|
||||
// ============================================================
|
||||
field.put("__vModel__", ctx.field);
|
||||
// helpMessage: 标题提示 (RGroupTitle.vue:12)
|
||||
field.put("helpMessage", "");
|
||||
// content: 分组标题文本 (componentMap.ts:1928)
|
||||
field.put("content", ctx.label != null && !ctx.label.isEmpty() ? ctx.label : "分组标题");
|
||||
// contentPosition: 标签对齐 (left/center/right, RGroupTitle.vue:15)
|
||||
field.put("contentPosition", "left");
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("GroupTitleFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
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.23 radio 控件 formData 0 误差生成器 (Task 1.22 P0).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="radio" / tag="JnpfRadio" (单选框组).
|
||||
* baseline 源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:221 (radio 完整 schema).
|
||||
*
|
||||
* <p>输出结构 (47 字段 = 18 顶层 + 29 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (18): __config__, __vModel__, field, on, style, options, props, direction, optionType,
|
||||
* buttonStyle, size, disabled, id, fullName, fullNameI18nCode, dropdownClassName, maxTagCount</li>
|
||||
* <li>__config__ (29): formId, visibility, jnpfKey, noShow, tipLabel, tableFixed, dragDisabled,
|
||||
* className, label, trigger, showLabel, required, tableName, renderKey, layout, tagIcon, tag,
|
||||
* regList, tableAlign, span, defaultValue, dataType, dictionaryType, propsUrl, propsName,
|
||||
* useCache, templateJson</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>注意: radio 是 noTableAllowList + noColumnShowList (config.ts:22, 24), 不能添加到子表/列表展示.
|
||||
*/
|
||||
public class RadioFieldBuilder implements FieldBuilder {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String jnpfKey() { return "radio"; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildFormField(FieldBuildContext ctx) {
|
||||
try {
|
||||
Map<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (跟 componentMap.ts radio 0 误差对齐)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("jnpfKey", "radio");
|
||||
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", "change");
|
||||
config.put("showLabel", true);
|
||||
config.put("required", ctx.required);
|
||||
config.put("tableName", "");
|
||||
config.put("renderKey", System.currentTimeMillis());
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-radio");
|
||||
config.put("tag", "JnpfRadio");
|
||||
config.put("regList", new ArrayList<>());
|
||||
config.put("tableAlign", "left");
|
||||
config.put("span", 24);
|
||||
config.put("defaultValue", ctx.defaultValue != null ? ctx.defaultValue : null);
|
||||
// 字典数据源 (4 字段, componentMap.ts:243-248)
|
||||
config.put("dataType", "static");
|
||||
config.put("dictionaryType", "");
|
||||
config.put("propsUrl", "");
|
||||
config.put("propsName", "");
|
||||
config.put("useCache", true);
|
||||
config.put("templateJson", new ArrayList<>());
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (跟 componentMap.ts radio 0 误差对齐)
|
||||
// ============================================================
|
||||
field.put("__vModel__", ctx.field);
|
||||
field.put("field", ctx.field);
|
||||
field.put("on", new LinkedHashMap<String, Object>() {{
|
||||
put("change", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n\n}");
|
||||
}});
|
||||
field.put("style", new LinkedHashMap<String, Object>() {{
|
||||
put("width", "100%");
|
||||
}});
|
||||
// options (默认 2 个, componentMap.ts:254-263)
|
||||
if (ctx.options != null) {
|
||||
field.put("options", ctx.options);
|
||||
} else {
|
||||
field.put("options", new ArrayList<Object>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("fullName", "选项一");
|
||||
put("id", "1");
|
||||
}});
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("fullName", "选项二");
|
||||
put("id", "2");
|
||||
}});
|
||||
}});
|
||||
}
|
||||
// props (label/value 字段映射, componentMap.ts:264-267)
|
||||
field.put("props", new LinkedHashMap<String, Object>() {{
|
||||
put("label", "fullName");
|
||||
put("value", "id");
|
||||
}});
|
||||
// direction: horizontal/vertical (RRadio.vue:8-11, componentMap.ts:268)
|
||||
field.put("direction", "horizontal");
|
||||
// optionType: default/button (RRadio.vue, componentMap.ts:269)
|
||||
field.put("optionType", "default");
|
||||
// buttonStyle: solid/outline (RRadio.vue, componentMap.ts:270)
|
||||
field.put("buttonStyle", "solid");
|
||||
// size: default/small/medium/large (RRadio.vue, componentMap.ts:271)
|
||||
field.put("size", "default");
|
||||
field.put("disabled", false);
|
||||
field.put("id", ctx.field);
|
||||
field.put("fullName", ctx.label);
|
||||
field.put("fullNameI18nCode", new ArrayList<>(Arrays.asList("")));
|
||||
field.put("dropdownClassName", "");
|
||||
field.put("maxTagCount", null);
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("RadioFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
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.23 select 控件 formData 0 误差生成器 (Task 1.22 P0).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="select" / tag="JnpfSelect" (下拉选择).
|
||||
* baseline 源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:324 (select 完整 schema).
|
||||
* workSystem 出现 12 次, 是高频控件.
|
||||
*
|
||||
* <p>输出结构 (44 字段 = 19 顶层 + 25 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (19): __config__, __vModel__, field, on, style, options, props, placeholder, clearable,
|
||||
* disabled, filterable, multiple, id, fullName, fullNameI18nCode, dropdownClassName, maxTagCount,
|
||||
* allowCreate, defaultActiveFirstOption</li>
|
||||
* <li>__config__ (25): formId, visibility, jnpfKey, noShow, tipLabel, tableFixed, dragDisabled,
|
||||
* className, label, trigger, showLabel, required, tableName, renderKey, layout, tagIcon, tag,
|
||||
* regList, tableAlign, span, dictionaryType, defaultValue, dataType, propsUrl, propsName, useCache, templateJson</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class SelectFieldBuilder implements FieldBuilder {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String jnpfKey() { return "select"; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildFormField(FieldBuildContext ctx) {
|
||||
try {
|
||||
Map<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (跟 componentMap.ts select schema 0 误差对齐)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("jnpfKey", "select");
|
||||
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", "change");
|
||||
config.put("showLabel", true);
|
||||
config.put("required", ctx.required);
|
||||
config.put("tableName", "");
|
||||
config.put("renderKey", System.currentTimeMillis());
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-select");
|
||||
config.put("tag", "JnpfSelect");
|
||||
config.put("regList", new ArrayList<>());
|
||||
config.put("tableAlign", "left");
|
||||
config.put("span", 24);
|
||||
config.put("dictionaryType", "");
|
||||
config.put("defaultValue", ctx.defaultValue != null ? ctx.defaultValue : "");
|
||||
// 字典数据源 (4 字段, componentMap.ts:346-351)
|
||||
config.put("dataType", "static");
|
||||
config.put("propsUrl", "");
|
||||
config.put("propsName", "");
|
||||
config.put("useCache", true);
|
||||
config.put("templateJson", new ArrayList<>());
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (跟 componentMap.ts select 顶层 0 误差对齐)
|
||||
// ============================================================
|
||||
field.put("__vModel__", ctx.field);
|
||||
field.put("field", ctx.field);
|
||||
// on (change 事件, 默认 JS 模板)
|
||||
field.put("on", new LinkedHashMap<String, Object>() {{
|
||||
put("change", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n\n}");
|
||||
}});
|
||||
field.put("style", new LinkedHashMap<String, Object>() {{
|
||||
put("width", "100%");
|
||||
}});
|
||||
// options (默认 2 个, componentMap.ts:357-366)
|
||||
if (ctx.options != null) {
|
||||
field.put("options", ctx.options);
|
||||
} else {
|
||||
field.put("options", new ArrayList<Object>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("fullName", "选项一");
|
||||
put("id", "1");
|
||||
}});
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("fullName", "选项二");
|
||||
put("id", "2");
|
||||
}});
|
||||
}});
|
||||
}
|
||||
// props (label/value 字段映射, componentMap.ts:367-370)
|
||||
field.put("props", new LinkedHashMap<String, Object>() {{
|
||||
put("label", "fullName");
|
||||
put("value", "id");
|
||||
}});
|
||||
field.put("placeholder", "请选择");
|
||||
field.put("clearable", true);
|
||||
field.put("disabled", false);
|
||||
field.put("filterable", false);
|
||||
field.put("multiple", false);
|
||||
field.put("id", ctx.field);
|
||||
field.put("fullName", ctx.label);
|
||||
field.put("fullNameI18nCode", new ArrayList<>(Arrays.asList("")));
|
||||
// v13.23 拓展 (RSelect.vue 衍生字段, JNPF 真实 formData 接受)
|
||||
field.put("dropdownClassName", "");
|
||||
field.put("maxTagCount", null);
|
||||
field.put("allowCreate", false);
|
||||
field.put("defaultActiveFirstOption", true);
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("SelectFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
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.23 tableGrid 控件 formData 0 误差生成器 (Task 1.22 P0).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="tableGrid" / tag="Table" (表格容器).
|
||||
* baseline 源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:2114 (tableGrid 完整 schema).
|
||||
* + RTableGrid.vue (borderType/borderColor/borderWidth)
|
||||
* + RTableGridTd.vue (backgroundColor)
|
||||
*
|
||||
* <p>输出结构 (16 字段 = 2 顶层 + 14 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (2): __config__, __vModel__</li>
|
||||
* <li>__config__ (14): formId, visibility, jnpfKey, noShow, label, showLabel, className, required,
|
||||
* layout, span, dragDisabled, tagIcon, tag, defaultValue, borderType, borderColor, borderWidth,
|
||||
* children (含 tableGridTr -> tableGridTd 嵌套)</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>特殊性:
|
||||
* <ol>
|
||||
* <li>布局控件, tag="Table" (不是 JnpfXXX 前缀, componentMap.ts:2120)</li>
|
||||
* <li>children 含 tableGridTr 嵌套, 每个 tr 含 tableGridTd 嵌套 (merged/colspan/rowspan/backgroundColor)</li>
|
||||
* <li>__config__ 顶层有 borderType/borderColor/borderWidth (RTableGrid.vue, RTableGridTd.vue)</li>
|
||||
* <li>仅 defaultValue 是顶层 (componentMap.ts:2123), __config__ 也有</li>
|
||||
* </ol>
|
||||
*/
|
||||
public class TableGridFieldBuilder implements FieldBuilder {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String jnpfKey() { return "tableGrid"; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildFormField(FieldBuildContext ctx) {
|
||||
try {
|
||||
Map<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (跟 componentMap.ts tableGrid 0 误差对齐)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("jnpfKey", "tableGrid");
|
||||
config.put("noShow", false);
|
||||
// tableGrid 是 showLabel=false (componentMap.ts:2119)
|
||||
config.put("label", "");
|
||||
config.put("showLabel", false);
|
||||
config.put("className", new ArrayList<>());
|
||||
config.put("required", false);
|
||||
// 布局控件 layout="rowFormItem" (componentMap.ts:2124)
|
||||
config.put("layout", "rowFormItem");
|
||||
config.put("span", 24);
|
||||
config.put("dragDisabled", false);
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-tableGrid");
|
||||
// tag="Table" 不是 JnpfTableGrid (componentMap.ts:2120)
|
||||
config.put("tag", "Table");
|
||||
// defaultValue 是 [] (componentMap.ts:2123)
|
||||
config.put("defaultValue", new ArrayList<>());
|
||||
// borderType: none/solid/dashed/dotted (RTableGrid.vue:5-10)
|
||||
config.put("borderType", "solid");
|
||||
// borderColor: 默认 #E2E0E0 (componentMap.ts:2130)
|
||||
config.put("borderColor", "#E2E0E0");
|
||||
// borderWidth: 默认 1 (componentMap.ts:2131)
|
||||
config.put("borderWidth", 1);
|
||||
// children: 默认 1 个 tr 含 1 个 td (componentMap.ts:2132-2151)
|
||||
config.put("children", new ArrayList<Object>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("title", "tr");
|
||||
put("__config__", new LinkedHashMap<String, Object>() {{
|
||||
put("jnpfKey", "tableGridTr");
|
||||
put("children", new ArrayList<Object>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("title", "td");
|
||||
put("__config__", new LinkedHashMap<String, Object>() {{
|
||||
put("jnpfKey", "tableGridTd");
|
||||
put("merged", false);
|
||||
put("colspan", 1);
|
||||
put("rowspan", 1);
|
||||
put("children", new ArrayList<>());
|
||||
// backgroundColor: RTableGridTd.vue:7
|
||||
put("backgroundColor", "");
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (跟 componentMap.ts:2123 defaultValue 0 误差对齐)
|
||||
// ============================================================
|
||||
field.put("__vModel__", ctx.field);
|
||||
// 顶层也保留 defaultValue, componentMap.ts:2123
|
||||
// (注意: JNPF 接受双 defaultValue, __config__.defaultValue 优先)
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("TableGridFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
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.23 userSelect 控件 formData 0 误差生成器 (Task 1.22 P0).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="userSelect" / tag="JnpfUserSelect" (用户选择).
|
||||
* baseline 源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:1026 (userSelect 完整 schema).
|
||||
* 高级控件, 出现 15 次 (workSystem 为主).
|
||||
*
|
||||
* <p>输出结构 (35 字段 = 15 顶层 + 20 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (15): __config__, __vModel__, field, on, style, placeholder, selectType, ableIds,
|
||||
* ableRelationIds, relationField, multiple, clearable, disabled, id, fullName</li>
|
||||
* <li>__config__ (20): formId, visibility, jnpfKey, noShow, tipLabel, tableFixed, dragDisabled,
|
||||
* className, label, trigger, showLabel, required, tableName, renderKey, layout, tagIcon, tag,
|
||||
* regList, tableAlign, span, defaultValue, defaultCurrent</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>特殊性: selectType 控制可选范围 (all/custom/org/pos/role/group), relationField 用于联动.
|
||||
*/
|
||||
public class UserSelectFieldBuilder implements FieldBuilder {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String jnpfKey() { return "userSelect"; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String buildFormField(FieldBuildContext ctx) {
|
||||
try {
|
||||
Map<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (跟 componentMap.ts userSelect 0 误差对齐)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("jnpfKey", "userSelect");
|
||||
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", "change");
|
||||
config.put("showLabel", true);
|
||||
config.put("required", ctx.required);
|
||||
config.put("tableName", "");
|
||||
config.put("renderKey", System.currentTimeMillis());
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-user");
|
||||
config.put("tag", "JnpfUserSelect");
|
||||
config.put("regList", new ArrayList<>());
|
||||
config.put("tableAlign", "left");
|
||||
config.put("span", 24);
|
||||
config.put("defaultValue", ctx.defaultValue != null ? ctx.defaultValue : null);
|
||||
config.put("defaultCurrent", false);
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (跟 componentMap.ts userSelect 0 误差对齐)
|
||||
// ============================================================
|
||||
field.put("__vModel__", ctx.field);
|
||||
field.put("field", ctx.field);
|
||||
field.put("on", new LinkedHashMap<String, Object>() {{
|
||||
put("change", "({ data, rowIndex, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n\n}");
|
||||
}});
|
||||
field.put("style", new LinkedHashMap<String, Object>() {{
|
||||
put("width", "100%");
|
||||
}});
|
||||
field.put("placeholder", "请选择");
|
||||
// selectType: all=全部 custom=自定义 org/pos/role/group=联动
|
||||
field.put("selectType", "all");
|
||||
// ableIds: 自定义时存可选 id 列表
|
||||
field.put("ableIds", new ArrayList<>());
|
||||
// ableRelationIds: 关联组件联动时的可选 id
|
||||
field.put("ableRelationIds", new ArrayList<>());
|
||||
// relationField: 关联的 form 字段 (org/pos/role/group 时必填)
|
||||
field.put("relationField", "");
|
||||
field.put("multiple", false);
|
||||
field.put("clearable", true);
|
||||
field.put("disabled", false);
|
||||
field.put("id", ctx.field);
|
||||
field.put("fullName", ctx.label);
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("UserSelectFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,4 +26,11 @@ ssw.dacli.form.builder.field.CarouselFieldBuilder
|
||||
ssw.dacli.form.builder.field.ColorPickerFieldBuilder
|
||||
ssw.dacli.form.builder.field.RateFieldBuilder
|
||||
ssw.dacli.form.builder.field.SliderFieldBuilder
|
||||
ssw.dacli.form.builder.field.SelectFieldBuilder
|
||||
ssw.dacli.form.builder.field.UserSelectFieldBuilder
|
||||
ssw.dacli.form.builder.field.GroupTitleFieldBuilder
|
||||
ssw.dacli.form.builder.field.RadioFieldBuilder
|
||||
ssw.dacli.form.builder.field.DividerFieldBuilder
|
||||
ssw.dacli.form.builder.field.TableGridFieldBuilder
|
||||
ssw.dacli.form.builder.field.CascaderFieldBuilder
|
||||
ssw.dacli.form.builder.table.SubTableFieldBuilder
|
||||
@@ -0,0 +1,116 @@
|
||||
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.23 Task 1.22 P0 - CascaderFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>校验 cascader 级联选择控件 formData 关键结构 (jnpfKey=cascader / tag=JnpfCascader / options 含 children).
|
||||
* baseline 0 误差源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:377
|
||||
*/
|
||||
public class CascaderFieldBuilderTest {
|
||||
|
||||
private static final ObjectMapper M = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
public void testCascaderField_basic() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_region";
|
||||
ctx.label = "地区";
|
||||
ctx.required = false;
|
||||
|
||||
String json = new CascaderFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
|
||||
// 顶层关键键
|
||||
assertNotNull(parsed.get("__config__"));
|
||||
assertNotNull(parsed.get("__vModel__"));
|
||||
assertEquals("f_region", parsed.get("__vModel__").asText());
|
||||
|
||||
// __config__ 关键键
|
||||
var cfg = parsed.get("__config__");
|
||||
assertEquals("cascader", cfg.get("jnpfKey").asText());
|
||||
assertEquals("JnpfCascader", cfg.get("tag").asText());
|
||||
assertEquals("地区", cfg.get("label").asText());
|
||||
assertEquals("colFormItem", cfg.get("layout").asText());
|
||||
assertEquals("icon-ym icon-ym-generator-cascader", cfg.get("tagIcon").asText());
|
||||
// cascader defaultValue 是 []
|
||||
assertTrue(cfg.get("defaultValue").isArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCascaderField_required() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_region";
|
||||
ctx.label = "地区";
|
||||
ctx.required = true;
|
||||
|
||||
String json = new CascaderFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
assertTrue(parsed.get("__config__").get("required").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCascaderField_baselineKeyStructure() throws Exception {
|
||||
// 跟 baseline componentMap.ts:377-433 cascader schema 关键结构对齐检查
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_region";
|
||||
ctx.label = "地区";
|
||||
|
||||
String json = new CascaderFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
var cfg = parsed.get("__config__");
|
||||
|
||||
// __config__ 必有结构
|
||||
assertNotNull(cfg.get("visibility"));
|
||||
assertNotNull(cfg.get("formId"));
|
||||
assertNotNull(cfg.get("jnpfKey"));
|
||||
assertNotNull(cfg.get("noShow"));
|
||||
assertNotNull(cfg.get("required"));
|
||||
assertNotNull(cfg.get("span"));
|
||||
assertNotNull(cfg.get("tag"));
|
||||
assertNotNull(cfg.get("layout"));
|
||||
assertNotNull(cfg.get("regList"));
|
||||
// 字典数据源
|
||||
assertNotNull(cfg.get("dataType"));
|
||||
assertNotNull(cfg.get("dictionaryType"));
|
||||
|
||||
// 顶层必有
|
||||
assertNotNull(parsed.get("options"));
|
||||
assertNotNull(parsed.get("props"));
|
||||
assertNotNull(parsed.get("placeholder"));
|
||||
assertNotNull(parsed.get("clearable"));
|
||||
assertNotNull(parsed.get("disabled"));
|
||||
assertNotNull(parsed.get("filterable"));
|
||||
assertNotNull(parsed.get("multiple"));
|
||||
assertNotNull(parsed.get("style"));
|
||||
assertNotNull(parsed.get("on"));
|
||||
// cascader 特有: props 含 children 字段
|
||||
assertNotNull(parsed.get("props").get("children"));
|
||||
// options 含嵌套 children
|
||||
var opts = parsed.get("options");
|
||||
assertTrue(opts.isArray() && opts.size() >= 1);
|
||||
assertNotNull(opts.get(0).get("children"));
|
||||
// on 含 change + blur 双事件
|
||||
assertNotNull(parsed.get("on").get("change"));
|
||||
assertNotNull(parsed.get("on").get("blur"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCascaderField_dumpToFile() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_region";
|
||||
ctx.label = "地区";
|
||||
ctx.required = true;
|
||||
String json = new CascaderFieldBuilder().buildFormField(ctx);
|
||||
Path out = Paths.get("../scripts/CascaderFieldBuilder-output.json");
|
||||
Files.createDirectories(out.getParent());
|
||||
Files.writeString(out, json);
|
||||
assertTrue(Files.exists(out));
|
||||
assertTrue(Files.size(out) > 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
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.23 Task 1.22 P0 - DividerFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>校验 divider 分割线控件 formData 关键结构 (jnpfKey=divider / tag=JnpfDivider / content).
|
||||
* baseline 0 误差源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:1931
|
||||
*/
|
||||
public class DividerFieldBuilderTest {
|
||||
|
||||
private static final ObjectMapper M = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
public void testDividerField_basic() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_divider";
|
||||
ctx.label = "分割线";
|
||||
ctx.required = false;
|
||||
|
||||
String json = new DividerFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
|
||||
// 顶层关键键
|
||||
assertNotNull(parsed.get("__config__"));
|
||||
assertNotNull(parsed.get("__vModel__"));
|
||||
assertEquals("f_divider", parsed.get("__vModel__").asText());
|
||||
|
||||
// __config__ 关键键
|
||||
var cfg = parsed.get("__config__");
|
||||
assertEquals("divider", cfg.get("jnpfKey").asText());
|
||||
assertEquals("JnpfDivider", cfg.get("tag").asText());
|
||||
assertEquals("icon-ym icon-ym-generator-divider", cfg.get("tagIcon").asText());
|
||||
assertEquals("colFormItem", cfg.get("layout").asText());
|
||||
assertEquals(24, cfg.get("span").asInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDividerField_required() throws Exception {
|
||||
// divider 是布局控件, required 恒为 false
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_divider";
|
||||
ctx.label = "分割线";
|
||||
ctx.required = true;
|
||||
|
||||
String json = new DividerFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
assertFalse(parsed.get("__config__").get("required").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDividerField_baselineKeyStructure() throws Exception {
|
||||
// 跟 baseline componentMap.ts:1931-1950 divider schema 关键结构对齐检查
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_divider";
|
||||
ctx.label = "分割线";
|
||||
|
||||
String json = new DividerFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
var cfg = parsed.get("__config__");
|
||||
|
||||
// __config__ 必有结构
|
||||
assertNotNull(cfg.get("visibility"));
|
||||
assertNotNull(cfg.get("formId"));
|
||||
assertNotNull(cfg.get("jnpfKey"));
|
||||
assertNotNull(cfg.get("noShow"));
|
||||
assertNotNull(cfg.get("required"));
|
||||
assertNotNull(cfg.get("span"));
|
||||
assertNotNull(cfg.get("tag"));
|
||||
assertNotNull(cfg.get("layout"));
|
||||
// showLabel=false 是 divider 特征
|
||||
assertFalse(cfg.get("showLabel").asBoolean());
|
||||
|
||||
// 顶层必有
|
||||
assertNotNull(parsed.get("content"));
|
||||
assertNotNull(parsed.get("contentPosition"));
|
||||
// divider content 默认 "我是分割线" (componentMap.ts:1948)
|
||||
assertEquals("我是分割线", parsed.get("content").asText());
|
||||
// contentPosition 默认 "center" (componentMap.ts:1949)
|
||||
assertEquals("center", parsed.get("contentPosition").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDividerField_dumpToFile() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_divider";
|
||||
ctx.label = "分割线";
|
||||
ctx.required = false;
|
||||
String json = new DividerFieldBuilder().buildFormField(ctx);
|
||||
Path out = Paths.get("../scripts/DividerFieldBuilder-output.json");
|
||||
Files.createDirectories(out.getParent());
|
||||
Files.writeString(out, json);
|
||||
assertTrue(Files.exists(out));
|
||||
assertTrue(Files.size(out) > 50);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
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.23 Task 1.22 P0 - GroupTitleFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>校验 groupTitle 分组标题控件 formData 关键结构 (jnpfKey=groupTitle / tag=JnpfGroupTitle / content).
|
||||
* baseline 0 误差源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:1910
|
||||
*/
|
||||
public class GroupTitleFieldBuilderTest {
|
||||
|
||||
private static final ObjectMapper M = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
public void testGroupTitleField_basic() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_title";
|
||||
ctx.label = "基本信息";
|
||||
ctx.required = false;
|
||||
|
||||
String json = new GroupTitleFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
|
||||
// 顶层关键键
|
||||
assertNotNull(parsed.get("__config__"));
|
||||
assertNotNull(parsed.get("__vModel__"));
|
||||
assertEquals("f_title", parsed.get("__vModel__").asText());
|
||||
|
||||
// __config__ 关键键
|
||||
var cfg = parsed.get("__config__");
|
||||
assertEquals("groupTitle", cfg.get("jnpfKey").asText());
|
||||
assertEquals("JnpfGroupTitle", cfg.get("tag").asText());
|
||||
assertEquals("icon-ym icon-ym-generator-group", cfg.get("tagIcon").asText());
|
||||
// 布局控件, layout="colFormItem" + span=24
|
||||
assertEquals("colFormItem", cfg.get("layout").asText());
|
||||
assertEquals(24, cfg.get("span").asInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupTitleField_required() throws Exception {
|
||||
// groupTitle 是布局控件, required 恒为 false
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_title";
|
||||
ctx.label = "基本信息";
|
||||
ctx.required = true; // 即使传 true 也应保持 false
|
||||
|
||||
String json = new GroupTitleFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
// groupTitle 是 layout 控件, required 永远 false
|
||||
assertFalse(parsed.get("__config__").get("required").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupTitleField_baselineKeyStructure() throws Exception {
|
||||
// 跟 baseline componentMap.ts:1910-1930 groupTitle schema 关键结构对齐检查
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_title";
|
||||
ctx.label = "基本信息";
|
||||
|
||||
String json = new GroupTitleFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
var cfg = parsed.get("__config__");
|
||||
|
||||
// __config__ 必有结构
|
||||
assertNotNull(cfg.get("visibility"));
|
||||
assertNotNull(cfg.get("formId"));
|
||||
assertNotNull(cfg.get("jnpfKey"));
|
||||
assertNotNull(cfg.get("noShow"));
|
||||
assertNotNull(cfg.get("required"));
|
||||
assertNotNull(cfg.get("span"));
|
||||
assertNotNull(cfg.get("tag"));
|
||||
assertNotNull(cfg.get("layout"));
|
||||
// showLabel=false 是 groupTitle 特征
|
||||
assertFalse(cfg.get("showLabel").asBoolean());
|
||||
|
||||
// 顶层必有
|
||||
assertNotNull(parsed.get("content"));
|
||||
assertNotNull(parsed.get("contentPosition"));
|
||||
// contentPosition 默认 "left"
|
||||
assertEquals("left", parsed.get("contentPosition").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupTitleField_dumpToFile() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_title";
|
||||
ctx.label = "基本信息";
|
||||
ctx.required = false;
|
||||
String json = new GroupTitleFieldBuilder().buildFormField(ctx);
|
||||
Path out = Paths.get("../scripts/GroupTitleFieldBuilder-output.json");
|
||||
Files.createDirectories(out.getParent());
|
||||
Files.writeString(out, json);
|
||||
assertTrue(Files.exists(out));
|
||||
assertTrue(Files.size(out) > 50);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
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.23 Task 1.22 P0 - RadioFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>校验 radio 单选控件 formData 关键结构 (jnpfKey=radio / tag=JnpfRadio / options / direction / optionType).
|
||||
* baseline 0 误差源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:221
|
||||
*/
|
||||
public class RadioFieldBuilderTest {
|
||||
|
||||
private static final ObjectMapper M = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
public void testRadioField_basic() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_gender";
|
||||
ctx.label = "性别";
|
||||
ctx.required = false;
|
||||
|
||||
String json = new RadioFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
|
||||
// 顶层关键键
|
||||
assertNotNull(parsed.get("__config__"));
|
||||
assertNotNull(parsed.get("__vModel__"));
|
||||
assertEquals("f_gender", parsed.get("__vModel__").asText());
|
||||
|
||||
// __config__ 关键键
|
||||
var cfg = parsed.get("__config__");
|
||||
assertEquals("radio", cfg.get("jnpfKey").asText());
|
||||
assertEquals("JnpfRadio", cfg.get("tag").asText());
|
||||
assertEquals("性别", cfg.get("label").asText());
|
||||
assertEquals("colFormItem", cfg.get("layout").asText());
|
||||
assertEquals("icon-ym icon-ym-generator-radio", cfg.get("tagIcon").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadioField_required() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_gender";
|
||||
ctx.label = "性别";
|
||||
ctx.required = true;
|
||||
|
||||
String json = new RadioFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
assertTrue(parsed.get("__config__").get("required").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadioField_baselineKeyStructure() throws Exception {
|
||||
// 跟 baseline componentMap.ts:221-273 radio schema 关键结构对齐检查
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_gender";
|
||||
ctx.label = "性别";
|
||||
|
||||
String json = new RadioFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
var cfg = parsed.get("__config__");
|
||||
|
||||
// __config__ 必有结构
|
||||
assertNotNull(cfg.get("visibility"));
|
||||
assertNotNull(cfg.get("formId"));
|
||||
assertNotNull(cfg.get("jnpfKey"));
|
||||
assertNotNull(cfg.get("noShow"));
|
||||
assertNotNull(cfg.get("required"));
|
||||
assertNotNull(cfg.get("span"));
|
||||
assertNotNull(cfg.get("tag"));
|
||||
assertNotNull(cfg.get("layout"));
|
||||
assertNotNull(cfg.get("regList"));
|
||||
// 字典数据源
|
||||
assertNotNull(cfg.get("dataType"));
|
||||
assertNotNull(cfg.get("dictionaryType"));
|
||||
|
||||
// 顶层必有
|
||||
assertNotNull(parsed.get("options"));
|
||||
assertNotNull(parsed.get("props"));
|
||||
assertNotNull(parsed.get("direction"));
|
||||
assertNotNull(parsed.get("optionType"));
|
||||
assertNotNull(parsed.get("buttonStyle"));
|
||||
assertNotNull(parsed.get("size"));
|
||||
assertNotNull(parsed.get("disabled"));
|
||||
assertNotNull(parsed.get("style"));
|
||||
assertNotNull(parsed.get("on"));
|
||||
// 默认值
|
||||
assertEquals("horizontal", parsed.get("direction").asText());
|
||||
assertEquals("default", parsed.get("optionType").asText());
|
||||
assertEquals("solid", parsed.get("buttonStyle").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadioField_dumpToFile() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_gender";
|
||||
ctx.label = "性别";
|
||||
ctx.required = true;
|
||||
String json = new RadioFieldBuilder().buildFormField(ctx);
|
||||
Path out = Paths.get("../scripts/RadioFieldBuilder-output.json");
|
||||
Files.createDirectories(out.getParent());
|
||||
Files.writeString(out, json);
|
||||
assertTrue(Files.exists(out));
|
||||
assertTrue(Files.size(out) > 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
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.23 Task 1.22 P0 - SelectFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>校验 select 下拉控件 formData 关键结构 (jnpfKey=select / tag=JnpfSelect / options / props / dictionaryType).
|
||||
* baseline 0 误差源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:324
|
||||
*/
|
||||
public class SelectFieldBuilderTest {
|
||||
|
||||
private static final ObjectMapper M = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
public void testSelectField_basic() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_status";
|
||||
ctx.label = "状态";
|
||||
ctx.required = false;
|
||||
|
||||
String json = new SelectFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
|
||||
// 顶层关键键
|
||||
assertNotNull(parsed.get("__config__"));
|
||||
assertNotNull(parsed.get("__vModel__"));
|
||||
assertEquals("f_status", parsed.get("__vModel__").asText());
|
||||
|
||||
// __config__ 关键键
|
||||
var cfg = parsed.get("__config__");
|
||||
assertEquals("select", cfg.get("jnpfKey").asText());
|
||||
assertEquals("JnpfSelect", cfg.get("tag").asText());
|
||||
assertEquals("状态", cfg.get("label").asText());
|
||||
assertEquals("colFormItem", cfg.get("layout").asText());
|
||||
assertEquals("icon-ym icon-ym-generator-select", cfg.get("tagIcon").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectField_required() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_status";
|
||||
ctx.label = "状态";
|
||||
ctx.required = true;
|
||||
|
||||
String json = new SelectFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
assertTrue(parsed.get("__config__").get("required").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectField_baselineKeyStructure() throws Exception {
|
||||
// 跟 baseline componentMap.ts:324-376 select schema 关键结构对齐检查
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_status";
|
||||
ctx.label = "状态";
|
||||
|
||||
String json = new SelectFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
var cfg = parsed.get("__config__");
|
||||
|
||||
// __config__ 必有结构
|
||||
assertNotNull(cfg.get("visibility"));
|
||||
assertNotNull(cfg.get("formId"));
|
||||
assertNotNull(cfg.get("jnpfKey"));
|
||||
assertNotNull(cfg.get("noShow"));
|
||||
assertNotNull(cfg.get("required"));
|
||||
assertNotNull(cfg.get("span"));
|
||||
assertNotNull(cfg.get("tag"));
|
||||
assertNotNull(cfg.get("layout"));
|
||||
assertNotNull(cfg.get("regList"));
|
||||
// 字典数据源 4 字段
|
||||
assertNotNull(cfg.get("dataType"));
|
||||
assertNotNull(cfg.get("dictionaryType"));
|
||||
assertNotNull(cfg.get("useCache"));
|
||||
assertNotNull(cfg.get("templateJson"));
|
||||
|
||||
// 顶层必有
|
||||
assertNotNull(parsed.get("options"));
|
||||
assertNotNull(parsed.get("props"));
|
||||
assertNotNull(parsed.get("placeholder"));
|
||||
assertNotNull(parsed.get("clearable"));
|
||||
assertNotNull(parsed.get("disabled"));
|
||||
assertNotNull(parsed.get("filterable"));
|
||||
assertNotNull(parsed.get("multiple"));
|
||||
assertNotNull(parsed.get("style"));
|
||||
assertNotNull(parsed.get("on"));
|
||||
// options 必有 id + fullName
|
||||
var opts = parsed.get("options");
|
||||
assertTrue(opts.isArray() && opts.size() >= 2);
|
||||
assertNotNull(opts.get(0).get("id"));
|
||||
assertNotNull(opts.get(0).get("fullName"));
|
||||
// props 必有 label + value
|
||||
assertNotNull(parsed.get("props").get("label"));
|
||||
assertNotNull(parsed.get("props").get("value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectField_dumpToFile() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_status";
|
||||
ctx.label = "状态";
|
||||
ctx.required = true;
|
||||
String json = new SelectFieldBuilder().buildFormField(ctx);
|
||||
Path out = Paths.get("../scripts/SelectFieldBuilder-output.json");
|
||||
Files.createDirectories(out.getParent());
|
||||
Files.writeString(out, json);
|
||||
assertTrue(Files.exists(out));
|
||||
assertTrue(Files.size(out) > 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
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.23 Task 1.22 P0 - TableGridFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>校验 tableGrid 表格容器控件 formData 关键结构 (jnpfKey=tableGrid / tag=Table / children 嵌套 tr+td).
|
||||
* baseline 0 误差源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:2114
|
||||
*/
|
||||
public class TableGridFieldBuilderTest {
|
||||
|
||||
private static final ObjectMapper M = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
public void testTableGridField_basic() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_grid";
|
||||
ctx.label = "表格";
|
||||
ctx.required = false;
|
||||
|
||||
String json = new TableGridFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
|
||||
// 顶层关键键
|
||||
assertNotNull(parsed.get("__config__"));
|
||||
assertNotNull(parsed.get("__vModel__"));
|
||||
assertEquals("f_grid", parsed.get("__vModel__").asText());
|
||||
|
||||
// __config__ 关键键
|
||||
var cfg = parsed.get("__config__");
|
||||
assertEquals("tableGrid", cfg.get("jnpfKey").asText());
|
||||
// tag="Table" (不是 JnpfTableGrid)
|
||||
assertEquals("Table", cfg.get("tag").asText());
|
||||
assertEquals("icon-ym icon-ym-generator-tableGrid", cfg.get("tagIcon").asText());
|
||||
// 布局控件 layout="rowFormItem"
|
||||
assertEquals("rowFormItem", cfg.get("layout").asText());
|
||||
assertEquals(24, cfg.get("span").asInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTableGridField_required() throws Exception {
|
||||
// tableGrid 是布局控件, required 恒为 false
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_grid";
|
||||
ctx.label = "表格";
|
||||
ctx.required = true;
|
||||
|
||||
String json = new TableGridFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
assertFalse(parsed.get("__config__").get("required").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTableGridField_baselineKeyStructure() throws Exception {
|
||||
// 跟 baseline componentMap.ts:2114-2154 tableGrid schema 关键结构对齐检查
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_grid";
|
||||
ctx.label = "表格";
|
||||
|
||||
String json = new TableGridFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
var cfg = parsed.get("__config__");
|
||||
|
||||
// __config__ 必有结构
|
||||
assertNotNull(cfg.get("visibility"));
|
||||
assertNotNull(cfg.get("formId"));
|
||||
assertNotNull(cfg.get("jnpfKey"));
|
||||
assertNotNull(cfg.get("noShow"));
|
||||
assertNotNull(cfg.get("required"));
|
||||
assertNotNull(cfg.get("span"));
|
||||
assertNotNull(cfg.get("tag"));
|
||||
assertNotNull(cfg.get("layout"));
|
||||
// showLabel=false
|
||||
assertFalse(cfg.get("showLabel").asBoolean());
|
||||
// tableGrid 特有: 边框 3 字段
|
||||
assertNotNull(cfg.get("borderType"));
|
||||
assertNotNull(cfg.get("borderColor"));
|
||||
assertNotNull(cfg.get("borderWidth"));
|
||||
// children 嵌套 tr -> td
|
||||
var children = cfg.get("children");
|
||||
assertTrue(children.isArray() && children.size() >= 1);
|
||||
var firstTr = children.get(0);
|
||||
assertEquals("tableGridTr", firstTr.get("__config__").get("jnpfKey").asText());
|
||||
var firstTd = firstTr.get("__config__").get("children").get(0);
|
||||
assertEquals("tableGridTd", firstTd.get("__config__").get("jnpfKey").asText());
|
||||
// td 字段: merged/colspan/rowspan/backgroundColor
|
||||
var tdCfg = firstTd.get("__config__");
|
||||
assertNotNull(tdCfg.get("merged"));
|
||||
assertNotNull(tdCfg.get("colspan"));
|
||||
assertNotNull(tdCfg.get("rowspan"));
|
||||
assertNotNull(tdCfg.get("backgroundColor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTableGridField_dumpToFile() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_grid";
|
||||
ctx.label = "表格";
|
||||
ctx.required = false;
|
||||
String json = new TableGridFieldBuilder().buildFormField(ctx);
|
||||
Path out = Paths.get("../scripts/TableGridFieldBuilder-output.json");
|
||||
Files.createDirectories(out.getParent());
|
||||
Files.writeString(out, json);
|
||||
assertTrue(Files.exists(out));
|
||||
assertTrue(Files.size(out) > 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
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.23 Task 1.22 P0 - UserSelectFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>校验 userSelect 用户选择控件 formData 关键结构 (jnpfKey=userSelect / tag=JnpfUserSelect / selectType).
|
||||
* baseline 0 误差源: jnpf/前端/jnpf-web-apps-main/src/components/FormGenerator/src/helper/componentMap.ts:1026
|
||||
*/
|
||||
public class UserSelectFieldBuilderTest {
|
||||
|
||||
private static final ObjectMapper M = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
public void testUserSelectField_basic() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_user";
|
||||
ctx.label = "用户";
|
||||
ctx.required = false;
|
||||
|
||||
String json = new UserSelectFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
|
||||
// 顶层关键键
|
||||
assertNotNull(parsed.get("__config__"));
|
||||
assertNotNull(parsed.get("__vModel__"));
|
||||
assertEquals("f_user", parsed.get("__vModel__").asText());
|
||||
|
||||
// __config__ 关键键
|
||||
var cfg = parsed.get("__config__");
|
||||
assertEquals("userSelect", cfg.get("jnpfKey").asText());
|
||||
assertEquals("JnpfUserSelect", cfg.get("tag").asText());
|
||||
assertEquals("用户", cfg.get("label").asText());
|
||||
assertEquals("colFormItem", cfg.get("layout").asText());
|
||||
assertEquals("icon-ym icon-ym-generator-user", cfg.get("tagIcon").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserSelectField_required() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_user";
|
||||
ctx.label = "用户";
|
||||
ctx.required = true;
|
||||
|
||||
String json = new UserSelectFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
assertTrue(parsed.get("__config__").get("required").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserSelectField_baselineKeyStructure() throws Exception {
|
||||
// 跟 baseline componentMap.ts:1026-1062 userSelect schema 关键结构对齐检查
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_user";
|
||||
ctx.label = "用户";
|
||||
|
||||
String json = new UserSelectFieldBuilder().buildFormField(ctx);
|
||||
var parsed = M.readTree(json);
|
||||
var cfg = parsed.get("__config__");
|
||||
|
||||
// __config__ 必有结构
|
||||
assertNotNull(cfg.get("visibility"));
|
||||
assertNotNull(cfg.get("formId"));
|
||||
assertNotNull(cfg.get("jnpfKey"));
|
||||
assertNotNull(cfg.get("noShow"));
|
||||
assertNotNull(cfg.get("required"));
|
||||
assertNotNull(cfg.get("span"));
|
||||
assertNotNull(cfg.get("tag"));
|
||||
assertNotNull(cfg.get("layout"));
|
||||
assertNotNull(cfg.get("regList"));
|
||||
// userSelect 特有: defaultCurrent
|
||||
assertNotNull(cfg.get("defaultCurrent"));
|
||||
|
||||
// 顶层必有
|
||||
assertNotNull(parsed.get("selectType"));
|
||||
assertNotNull(parsed.get("ableIds"));
|
||||
assertNotNull(parsed.get("ableRelationIds"));
|
||||
assertNotNull(parsed.get("relationField"));
|
||||
assertNotNull(parsed.get("multiple"));
|
||||
assertNotNull(parsed.get("clearable"));
|
||||
assertNotNull(parsed.get("disabled"));
|
||||
assertNotNull(parsed.get("placeholder"));
|
||||
assertNotNull(parsed.get("style"));
|
||||
assertNotNull(parsed.get("on"));
|
||||
// selectType 默认 = "all"
|
||||
assertEquals("all", parsed.get("selectType").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserSelectField_dumpToFile() throws Exception {
|
||||
FieldBuildContext ctx = new FieldBuildContext();
|
||||
ctx.field = "f_user";
|
||||
ctx.label = "用户";
|
||||
ctx.required = true;
|
||||
String json = new UserSelectFieldBuilder().buildFormField(ctx);
|
||||
Path out = Paths.get("../scripts/UserSelectFieldBuilder-output.json");
|
||||
Files.createDirectories(out.getParent());
|
||||
Files.writeString(out, json);
|
||||
assertTrue(Files.exists(out));
|
||||
assertTrue(Files.size(out) > 100);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user