fix(converter): NumberField 整型列优先于 mdec(整数输入不显小数)

字段 type=java.lang.Integer/Long/Short/BigInteger 时即便 XML 误定义 mdec 小数位(如排序号 TYPESORT type=Integer 却 mdec=2,旧版显「2.00」),也应整数输入 precision=0+step=1;非整型(Double/BigDecimal)才按 mdec 取小数精度。live 验证:新闻收藏分类 默认类别 排序号显「1」非「1.00」。118 测试绿(+整型/Double 对照单测)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-16 18:25:48 +08:00
parent 7c15bc55f8
commit e2ddf157d5
2 changed files with 31 additions and 2 deletions

View File

@@ -104,7 +104,17 @@ final class UiTypeMapper {
case "NumberField" -> {
item.put("type", "input-number");
String mdec = f.attributeValue("mdec");
if (mdec != null && !mdec.isBlank()) {
// 列类型优先于 mdec:整型列(java.lang.Integer/Long/Short/BigInteger 等)即便 XML 误定义
// mdec 小数位(如排序号 TYPESORT type=java.lang.Integer 却 mdec=2 → 旧版显「2.00」),也应整数输入
// (precision=0 + step=1),不显小数。非整型(Double/BigDecimal)才按 mdec 取小数精度。
String numType = f.attributeValue("type");
boolean isInteger = numType != null && (numType.endsWith(".Integer") || numType.endsWith(".Long")
|| numType.endsWith(".Short") || numType.endsWith(".BigInteger")
|| "int".equals(numType) || "long".equals(numType) || "short".equals(numType));
if (isInteger) {
item.put("precision", 0);
item.put("step", 1);
} else if (mdec != null && !mdec.isBlank()) {
try {
item.put("precision", Integer.parseInt(mdec));
} catch (NumberFormatException ignore) {
@@ -115,7 +125,8 @@ final class UiTypeMapper {
// 如采购明细 AMOUNT vmin=1 / PRICE vmax=9999999.99)。非数值则跳过(容错口径同 mdec)。
applyNumberBound(item, "min", f.attributeValue("vmin"));
applyNumberBound(item, "max", f.attributeValue("vmax"));
result.note(origin + "@field " + name + " uitype=NumberField → input-number(precision=" + mdec
result.note(origin + "@field " + name + " uitype=NumberField → input-number(type=" + numType
+ (isInteger ? ", 整型 precision=0" : ", precision=" + mdec)
+ ", min=" + f.attributeValue("vmin") + ", max=" + f.attributeValue("vmax") + ")");
}
case "CheckBox" -> {