feat(ai-recipe): typed list columns to match converter house-style
AI 生成页的列直接显原始值(布尔列显「true/false」),与转换器 house-style 的
「是/否」「日期格式化」不一致——live 验收时 boolean 列肉眼可见 true。本次按
blueprint field type 纯导出列渲染类型(不依赖 colMeta 枚举/引用元数据):
- boolean → type:mapping, map:{true/1:"是", false/0:"否"}
- date → type:date, format:YYYY-MM-DD
- datetime → type:datetime, format:YYYY-MM-DD HH:mm:ss
- string/integer/number 保持纯文本(默认渲染即正确)
同时在 PageComponentRegistry 注册 mapping/date/datetime 三个标准 amis 列渲染器
(display 类,转换页本就用,否则 typed-page-schema 门会拒含 type 的列 → 409)。
maintenance 与 tree 列均应用。
验证:platform-metadata 397 + platform-ai 61 测试绿;8093 live 重生成
EIP4AI_HSDEMO,served schema ENABLED 列=mapping,浏览器实证「启用」列显
「是」(原 true),0 console error;已清测试数据。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,10 @@ public final class PageComponentRegistry {
|
|||||||
"ajax", "dialog", "drawer", "link", "url", "reload", "submit", "reset", "cancel", "copy",
|
"ajax", "dialog", "drawer", "link", "url", "reload", "submit", "reset", "cancel", "copy",
|
||||||
"download", "toast", "confirm"));
|
"download", "toast", "confirm"));
|
||||||
register(map, "tpl", "display", List.of("template-text"), List.of());
|
register(map, "tpl", "display", List.of("template-text"), List.of());
|
||||||
|
// 列表/详情列渲染器(转换器 house-style 同款):布尔/枚举 → mapping(是/否),日期 → date/datetime。
|
||||||
|
register(map, "mapping", "display", List.of("value-map"), List.of());
|
||||||
|
register(map, "date", "display", List.of("date-format"), List.of());
|
||||||
|
register(map, "datetime", "display", List.of("datetime-format"), List.of());
|
||||||
register(map, "static", "display", List.of("readonly"), List.of());
|
register(map, "static", "display", List.of("readonly"), List.of());
|
||||||
register(map, "static-text", "display", List.of("readonly"), List.of());
|
register(map, "static-text", "display", List.of("readonly"), List.of());
|
||||||
register(map, "wrapper", "layout", List.of("container"), List.of());
|
register(map, "wrapper", "layout", List.of("container"), List.of());
|
||||||
|
|||||||
@@ -122,10 +122,40 @@ public final class PageBlueprintCompiler {
|
|||||||
ObjectNode column = columns.addObject();
|
ObjectNode column = columns.addObject();
|
||||||
column.put("name", field.name());
|
column.put("name", field.name());
|
||||||
column.put("label", field.label());
|
column.put("label", field.label());
|
||||||
|
applyColumnRender(column, field.type());
|
||||||
}
|
}
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列渲染类型(对齐转换器 house-style):布尔列 → mapping(是/否),日期/时间列 → date/datetime
|
||||||
|
* 格式化;string/integer/number 保持纯文本(amis 默认渲染即正确)。纯由 blueprint field type
|
||||||
|
* 推导,不依赖实体枚举/引用元数据(那需 colMeta,recipe 无)。
|
||||||
|
*/
|
||||||
|
private void applyColumnRender(ObjectNode column, String fieldType) {
|
||||||
|
switch (fieldType) {
|
||||||
|
case "boolean" -> {
|
||||||
|
column.put("type", "mapping");
|
||||||
|
ObjectNode map = column.putObject("map");
|
||||||
|
map.put("true", "是");
|
||||||
|
map.put("false", "否");
|
||||||
|
map.put("1", "是");
|
||||||
|
map.put("0", "否");
|
||||||
|
}
|
||||||
|
case "date" -> {
|
||||||
|
column.put("type", "date");
|
||||||
|
column.put("format", "YYYY-MM-DD");
|
||||||
|
}
|
||||||
|
case "datetime" -> {
|
||||||
|
column.put("type", "datetime");
|
||||||
|
column.put("format", "YYYY-MM-DD HH:mm:ss");
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
// string / integer / number:纯文本默认渲染即可。
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 顶部查询区:按 string 列生成文本搜索;若无 string 列则回退按 displayField 搜索。 */
|
/** 顶部查询区:按 string 列生成文本搜索;若无 string 列则回退按 displayField 搜索。 */
|
||||||
private ObjectNode searchFilter(PageBlueprint blueprint) {
|
private ObjectNode searchFilter(PageBlueprint blueprint) {
|
||||||
ObjectNode filter = objectMapper.createObjectNode();
|
ObjectNode filter = objectMapper.createObjectNode();
|
||||||
@@ -231,6 +261,7 @@ public final class PageBlueprintCompiler {
|
|||||||
ObjectNode column = columns.addObject();
|
ObjectNode column = columns.addObject();
|
||||||
column.put("name", field.name());
|
column.put("name", field.name());
|
||||||
column.put("label", field.label());
|
column.put("label", field.label());
|
||||||
|
applyColumnRender(column, field.type());
|
||||||
}
|
}
|
||||||
ObjectNode op = columns.addObject();
|
ObjectNode op = columns.addObject();
|
||||||
op.put("type", "operation");
|
op.put("type", "operation");
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ class PageBlueprintCompilerTest {
|
|||||||
ArrayNode columns = (ArrayNode) crud.path("columns");
|
ArrayNode columns = (ArrayNode) crud.path("columns");
|
||||||
assertEquals(2, columns.size());
|
assertEquals(2, columns.size());
|
||||||
assertEquals("NAME", columns.get(0).path("name").asText());
|
assertEquals("NAME", columns.get(0).path("name").asText());
|
||||||
|
assertTrue(columns.get(0).path("type").asText().isBlank()); // string 列纯文本
|
||||||
|
assertEquals("mapping", columns.get(1).path("type").asText()); // boolean 列 → 是/否 mapping
|
||||||
|
assertEquals("是", columns.get(1).path("map").path("true").asText());
|
||||||
|
assertEquals("否", columns.get(1).path("map").path("false").asText());
|
||||||
for (int i = 0; i < columns.size(); i++) {
|
for (int i = 0; i < columns.size(); i++) {
|
||||||
assertFalse("operation".equals(columns.get(i).path("type").asText()));
|
assertFalse("operation".equals(columns.get(i).path("type").asText()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user