v13-f1 Task 1.14: calculate + dateCalculate + i18nInput 0 误差 (P1, 前端代码兜底)
This commit is contained in:
1 parent
f1f1cdf19d
commit
18d10a975f
16 files changed
+708
No files matched your search
@@ -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}
|
||||
@@ -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}
|
||||
@@ -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}
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -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}")
|
||||
@@ -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}")
|
||||
@@ -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}")
|
||||
Whitespace-only changes.
@@ -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).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="calculate" / tag="JnpfCalculate" (公式计算).
|
||||
* baseline 0 误差源: scripts/calculate-baseline-samples.jsonl (0 sample, baseline 无此控件).
|
||||
* 字段对齐权威源: JNPF 前端 components/Jnpf/calculate/src/Calculate.vue (defineProps).
|
||||
*
|
||||
* <p>输出结构 (32 字段 = 12 顶层 + 20 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (12): __config__, on, style, placeholder, formula, trigger, precision,
|
||||
* roundType, dataSource, addonAfter, isAmountChinese, isStorage</li>
|
||||
* <li>__config__ (20): formId, jnpfKey, label, tipLabel, showLabel, required, tag, tagIcon,
|
||||
* tableAlign, tableFixed, className, defaultValue, layout, span, dragDisabled,
|
||||
* visibility, tableName, noShow, regList, renderKey</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>calculate 特有字段 (P1 中频 - 公式计算控件):
|
||||
* <ul>
|
||||
* <li>formula: 公式表达式数组 (空数组兜底, 与 JNPF expression prop 对应)</li>
|
||||
* <li>trigger: 触发方式 (change, JNPF 默认)</li>
|
||||
* <li>precision: 精度 (0, 默认无小数)</li>
|
||||
* <li>roundType: 取整方式 (1=四舍五入)</li>
|
||||
* <li>dataSource: 数据源 (0=本表单)</li>
|
||||
* <li>isAmountChinese: 金额大写 (false)</li>
|
||||
* <li>isStorage: 是否入库 (0=不入库)</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>字段对齐策略: 关键字段用 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<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (20 字段, 跟 JNPF Calculate.vue defineOptions 0 误差)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("jnpfKey", "calculate");
|
||||
config.put("label", ctx.label);
|
||||
config.put("tipLabel", "");
|
||||
config.put("showLabel", true);
|
||||
config.put("required", ctx.required);
|
||||
config.put("tag", "JnpfCalculate");
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-calculate");
|
||||
config.put("tableAlign", "left");
|
||||
config.put("tableFixed", "none");
|
||||
config.put("className", new ArrayList<>());
|
||||
config.put("defaultValue", "");
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("span", 24);
|
||||
config.put("dragDisabled", false);
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("tableName", "");
|
||||
config.put("noShow", false);
|
||||
config.put("regList", new ArrayList<>());
|
||||
config.put("renderKey", System.currentTimeMillis());
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (12 字段)
|
||||
// ============================================================
|
||||
field.put("on", new LinkedHashMap<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%");
|
||||
}});
|
||||
field.put("placeholder", "请输入");
|
||||
// calculate 特有字段 - 跟 JNPF Calculate.vue props 对齐
|
||||
field.put("formula", new ArrayList<>()); // 表达式空数组兜底
|
||||
field.put("trigger", "change"); // 触发方式
|
||||
field.put("precision", 0); // 精度
|
||||
field.put("roundType", 1); // 1=四舍五入
|
||||
field.put("dataSource", 0); // 0=本表单
|
||||
field.put("addonAfter", ""); // 附加后缀
|
||||
field.put("isAmountChinese", false); // 金额大写
|
||||
field.put("isStorage", 0); // 不入库
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("CalculateFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
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 dateCalculate 控件 formData 0 误差生成器 (Task 1.14, P1).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="dateCalculate" / tag="JnpfDateCalculate" (日期计算).
|
||||
* baseline 0 误差源: scripts/dateCalculate-baseline-samples.jsonl (0 sample, baseline 无此控件).
|
||||
* 字段对齐权威源: JNPF 前端 components/Jnpf/dateCalculate/src/DateCalculate.vue (defineProps).
|
||||
*
|
||||
* <p>输出结构 (29 字段 = 10 顶层 + 19 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (10): __config__, on, style, placeholder, format, defaultValue, startTime,
|
||||
* endTime, formula, isStorage</li>
|
||||
* <li>__config__ (19): formId, jnpfKey, label, tipLabel, showLabel, required, tag, tagIcon,
|
||||
* tableAlign, tableFixed, className, layout, span, dragDisabled, visibility,
|
||||
* tableName, noShow, regList, renderKey</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>dateCalculate 特有字段 (P1 中频 - 日期计算控件):
|
||||
* <ul>
|
||||
* <li>format: 日期格式 (yyyy-MM-dd, JNPF 默认)</li>
|
||||
* <li>defaultValue: 默认值 (空字符串)</li>
|
||||
* <li>startTime: 起始时间 (空字符串)</li>
|
||||
* <li>endTime: 结束时间 (空字符串)</li>
|
||||
* <li>formula: 公式表达式数组 (空数组兜底)</li>
|
||||
* <li>isStorage: 是否入库 (0=不入库)</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>字段对齐策略: 关键字段用 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<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (19 字段, 跟 JNPF DateCalculate.vue defineOptions 0 误差)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("jnpfKey", "dateCalculate");
|
||||
config.put("label", ctx.label);
|
||||
config.put("tipLabel", "");
|
||||
config.put("showLabel", true);
|
||||
config.put("required", ctx.required);
|
||||
config.put("tag", "JnpfDateCalculate");
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-date-calculate");
|
||||
config.put("tableAlign", "left");
|
||||
config.put("tableFixed", "none");
|
||||
config.put("className", new ArrayList<>());
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("span", 24);
|
||||
config.put("dragDisabled", false);
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("tableName", "");
|
||||
config.put("noShow", false);
|
||||
config.put("regList", new ArrayList<>());
|
||||
config.put("renderKey", System.currentTimeMillis());
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (10 字段)
|
||||
// ============================================================
|
||||
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%");
|
||||
}});
|
||||
field.put("placeholder", "请输入");
|
||||
// dateCalculate 特有字段 - 跟 JNPF DateCalculate.vue props 对齐
|
||||
field.put("format", "yyyy-MM-dd"); // 日期格式
|
||||
field.put("defaultValue", ""); // 默认值
|
||||
field.put("startTime", ""); // 起始时间
|
||||
field.put("endTime", ""); // 结束时间
|
||||
field.put("formula", new ArrayList<>()); // 表达式空数组兜底
|
||||
field.put("isStorage", 0); // 不入库
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("DateCalculateFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
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 i18nInput 控件 formData 0 误差生成器 (Task 1.14, P1).
|
||||
*
|
||||
* <p>对应 JNPF 设计器 jnpfKey="i18nInput" / tag="JnpfI18nInput" (多语言输入框).
|
||||
* baseline 0 误差源: scripts/i18nInput-baseline-samples.jsonl (0 sample, baseline 无此控件).
|
||||
* 字段对齐权威源: JNPF 前端 components/Jnpf/i18nInput/src/props.ts (i18nInputProps).
|
||||
*
|
||||
* <p>输出结构 (29 字段 = 10 顶层 + 19 __config__):
|
||||
* <ul>
|
||||
* <li>顶层 (10): __config__, on, style, placeholder, prefixIcon, suffixIcon, addonBefore,
|
||||
* addonAfter, i18n, maxlength</li>
|
||||
* <li>__config__ (19): formId, jnpfKey, label, tipLabel, showLabel, required, tag, tagIcon,
|
||||
* tableAlign, tableFixed, className, defaultValue, layout, span, dragDisabled,
|
||||
* visibility, tableName, noShow, regList, renderKey</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>i18nInput 特有字段 (P1 中频 - 多语言输入框控件):
|
||||
* <ul>
|
||||
* <li>i18n: 多语言 JSON 字符串 (空字符串兜底, 设计时未填)</li>
|
||||
* <li>prefixIcon: 前缀图标 (空字符串)</li>
|
||||
* <li>suffixIcon: 后缀图标 (空字符串)</li>
|
||||
* <li>maxlength: 最大长度 (null 不限)</li>
|
||||
* <li>addonBefore/addonAfter: 附加元素 (空字符串)</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>字段对齐策略: 关键字段用 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<String, Object> field = new LinkedHashMap<>();
|
||||
|
||||
// ============================================================
|
||||
// __config__ (19 字段, 跟 JNPF I18nInput.vue defineOptions 0 误差)
|
||||
// ============================================================
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
config.put("formId", "formItem" + System.currentTimeMillis());
|
||||
config.put("jnpfKey", "i18nInput");
|
||||
config.put("label", ctx.label);
|
||||
config.put("tipLabel", "");
|
||||
config.put("showLabel", true);
|
||||
config.put("required", ctx.required);
|
||||
config.put("tag", "JnpfI18nInput");
|
||||
config.put("tagIcon", "icon-ym icon-ym-generator-i18nInput");
|
||||
config.put("tableAlign", "left");
|
||||
config.put("tableFixed", "none");
|
||||
config.put("className", new ArrayList<>());
|
||||
config.put("defaultValue", "");
|
||||
config.put("layout", "colFormItem");
|
||||
config.put("span", 24);
|
||||
config.put("dragDisabled", false);
|
||||
config.put("visibility", new ArrayList<>(Arrays.asList("pc", "app")));
|
||||
config.put("tableName", "");
|
||||
config.put("noShow", false);
|
||||
config.put("regList", new ArrayList<>());
|
||||
config.put("renderKey", System.currentTimeMillis());
|
||||
field.put("__config__", config);
|
||||
|
||||
// ============================================================
|
||||
// 顶层 (10 字段)
|
||||
// ============================================================
|
||||
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%");
|
||||
}});
|
||||
field.put("placeholder", "请输入");
|
||||
// i18nInput 特有字段 - 跟 JNPF i18nInputProps 对齐
|
||||
field.put("prefixIcon", ""); // 前缀图标
|
||||
field.put("suffixIcon", ""); // 后缀图标
|
||||
field.put("addonBefore", ""); // 前置附加
|
||||
field.put("addonAfter", ""); // 后置附加
|
||||
field.put("i18n", ""); // 多语言 JSON
|
||||
field.put("maxlength", null); // 不限长度
|
||||
|
||||
return mapper.writeValueAsString(field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("I18nInputFieldBuilder.buildFormField failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,3 +19,6 @@ ssw.dacli.form.builder.field.AreaSelectFieldBuilder
|
||||
ssw.dacli.form.builder.field.SignatureFieldBuilder
|
||||
ssw.dacli.form.builder.field.SignFieldBuilder
|
||||
ssw.dacli.form.builder.field.OcrFieldBuilder
|
||||
ssw.dacli.form.builder.field.CalculateFieldBuilder
|
||||
ssw.dacli.form.builder.field.DateCalculateFieldBuilder
|
||||
ssw.dacli.form.builder.field.I18nInputFieldBuilder
|
||||
@@ -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.14 — CalculateFieldBuilder 单元测试 (4 用例).
|
||||
*
|
||||
* <p>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);
|
||||
}
|
||||
}
|
||||
+106
@@ -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 用例).
|
||||
*
|
||||
* <p>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);
|
||||
}
|
||||
}
|
||||
@@ -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 用例).
|
||||
*
|
||||
* <p>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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user