fix framework p2 custom views
This commit is contained in:
@@ -95,7 +95,7 @@ public final class EngineclassDelta {
|
||||
EngineclassDelta::processFormRemoveCrudAnchor);
|
||||
|
||||
// 流程监控:ProcessMonitorComponentNew 原有「处理 / 高级处理 / 结束流程」。
|
||||
// 高级处理接网关 Groovy 执行端点,按旧系统绑定 processid/businessKey。
|
||||
// 高级处理接网关 Groovy 执行端点,按旧系统绑定 processid/businessKey;列表数据源改走 Flowable 全量实例。
|
||||
register("com.dsasp.client.wf.ui.process.monitor.ProcessMonitorComponentNew",
|
||||
EngineclassDelta::processMonitorDetailButton,
|
||||
EngineclassDelta::processMonitorAdvancedScriptButton,
|
||||
@@ -627,11 +627,12 @@ public final class EngineclassDelta {
|
||||
/** 流程监控 CRUD 刷新锚点,供结束流程后精准 reload。 */
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void processMonitorCrudAnchor(Map<String, Object> schema, ConversionResult result) {
|
||||
replaceCrudApi(schema, "/api/workflow/process/monitor-amis");
|
||||
Object bodyObj = schema.get("body");
|
||||
if (bodyObj instanceof Map<?, ?> body && "crud".equals(body.get("type"))) {
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "process-monitor-crud");
|
||||
if (result != null) {
|
||||
result.note("engineclass[ProcessMonitorComponentNew] 设置流程监控 CRUD 刷新锚点");
|
||||
result.note("engineclass[ProcessMonitorComponentNew] 改写流程监控数据源并设置 CRUD 刷新锚点");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ public class TemplateToAmisConverter {
|
||||
* 缺省 null(普通数据驱动页/旧重载/单测)→ 不注入任何 delta,默认引擎页不变。
|
||||
*/
|
||||
private String currentEngineclass;
|
||||
private static final String ENTITY_FORM_PREFIX = "ENTITY_FORM:";
|
||||
private static final Set<String> SYSTEM_FORM_COLUMNS = Set.of(
|
||||
"CREATETIME", "CREATEBY", "UPDATETIME", "UPDATEBY", "VERSION", "ISACTIVE");
|
||||
|
||||
public TemplateToAmisConverter(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
@@ -335,9 +338,10 @@ public class TemplateToAmisConverter {
|
||||
} else if ("1".equals(align)) {
|
||||
col.put("className", "text-center");
|
||||
}
|
||||
if ("true".equals(f.attributeValue("hidden"))) {
|
||||
if ("true".equals(f.attributeValue("hidden"))
|
||||
|| "true".equalsIgnoreCase(f.attributeValue("iskeycolumn", ""))) {
|
||||
col.put("toggled", false);
|
||||
result.note("display@field " + name + " hidden=true → columns-toggler 默认隐藏");
|
||||
result.note("display@field " + name + " hidden=true/iskeycolumn=true → columns-toggler 默认隐藏");
|
||||
}
|
||||
columns.add(col);
|
||||
}
|
||||
@@ -345,7 +349,7 @@ public class TemplateToAmisConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* F2-16:加载实体所有列的元数据映射 columnName→[referenceid, enumeratetype]。
|
||||
* F2-16:加载实体所有列的元数据映射 columnName→[referenceid, enumeratetype, refTargetTable]。
|
||||
* entityId 为空/解析失败时返回空 map(安全降级,不影响已有转换路径)。
|
||||
*/
|
||||
private Map<String, String[]> loadColumnMeta(String entityId, ConversionResult result) {
|
||||
@@ -356,14 +360,18 @@ public class TemplateToAmisConverter {
|
||||
try {
|
||||
Map<String, String[]> meta = new LinkedHashMap<>();
|
||||
jdbcTemplate.query(
|
||||
"SELECT UPPER(COLUMNNAME), REFERENCEID, ENUMERATETYPE "
|
||||
+ "FROM SYS_ENTITYATTRIBUTE WHERE ENTITYID=?",
|
||||
"SELECT UPPER(ea.COLUMNNAME), ea.REFERENCEID, ea.ENUMERATETYPE, UPPER(e2.TABLENAME) "
|
||||
+ "FROM SYS_ENTITYATTRIBUTE ea "
|
||||
+ "LEFT JOIN SYS_REFERENCE r ON UPPER(r.SYS_REFERENCE_ID)=UPPER(ea.REFERENCEID) "
|
||||
+ "LEFT JOIN SYS_ENTITY e2 ON UPPER(e2.SYS_ENTITY_ID)=UPPER(r.ENTITYID) "
|
||||
+ "WHERE ea.ENTITYID=?",
|
||||
rs -> {
|
||||
String col = rs.getString(1);
|
||||
String ref = rs.getString(2);
|
||||
String enu = rs.getString(3);
|
||||
String target = rs.getString(4);
|
||||
if (col != null) {
|
||||
meta.put(col, new String[]{ref, enu});
|
||||
meta.put(col, new String[]{ref, enu, target});
|
||||
}
|
||||
},
|
||||
entityId);
|
||||
@@ -385,6 +393,7 @@ public class TemplateToAmisConverter {
|
||||
if (meta == null) return;
|
||||
String refId = meta[0];
|
||||
String enumType = meta[1];
|
||||
String refTargetTable = meta.length > 2 ? meta[2] : null;
|
||||
if (refId == null) return;
|
||||
|
||||
switch (refId) {
|
||||
@@ -422,14 +431,16 @@ public class TemplateToAmisConverter {
|
||||
result.note("F2-16 display@field " + name + " referenceid=BOOLEAN → type=mapping(否/是)");
|
||||
}
|
||||
default -> {
|
||||
// 真引用列:referenceid 是 36 位 UUID(经 SYS_REFERENCE 指向另一实体),与引擎
|
||||
// GeneralPO.get_DisplayValue 的 dt.length()==36 判定同口径。列表列绑到 <COL>_DISPLAY__,
|
||||
// 由 REST 读层 UserColumnResolver 填目标实体显示名;原始 id 列保留供编辑表单 select。
|
||||
// 真引用列:referenceid 能经 SYS_REFERENCE 指向另一实体。历史库里既有 36 位 UUID,也有
|
||||
// 旧式自定义引用标识(如 SYS_SERVICEFLOW.ENTITYID → SYS_REFERENCE → SYS_ENTITY)。
|
||||
// 列表列绑到 <COL>_DISPLAY__,由 REST 读层 UserColumnResolver 填目标实体显示名;原始 id
|
||||
// 列保留供编辑表单 select。
|
||||
// 其余(NVARCHAR/CHAR/INTEGER/DECIMAL 等类型字面)不注入特殊渲染。
|
||||
if (refId.length() == 36 && refId.indexOf('-') >= 0 && !name.endsWith("_DISPLAY__")) {
|
||||
if (refTargetTable != null && !refTargetTable.isBlank() && !name.endsWith("_DISPLAY__")) {
|
||||
col.put("name", name + "_DISPLAY__");
|
||||
result.note("display@field " + name + " referenceid=引用(" + refId
|
||||
+ ") → 列绑 " + name + "_DISPLAY__(REST 层 UserColumnResolver 填显示名)");
|
||||
+ "→" + refTargetTable + ") → 列绑 " + name
|
||||
+ "_DISPLAY__(REST 层 UserColumnResolver 填显示名)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,6 +506,7 @@ public class TemplateToAmisConverter {
|
||||
}
|
||||
Map<String, Object> searchItem = UiTypeMapper.mapField(f, result, "search", colMeta);
|
||||
enrichFieldRefs(searchItem, f, result);
|
||||
inlineEnumerateOptions(searchItem, "search", result);
|
||||
items.add(searchItem);
|
||||
}
|
||||
if (items.isEmpty()) {
|
||||
@@ -507,6 +519,28 @@ public class TemplateToAmisConverter {
|
||||
return filter;
|
||||
}
|
||||
|
||||
private void inlineEnumerateOptions(Map<String, Object> item, String origin, ConversionResult result) {
|
||||
if (!"select".equals(item.get("type")) || !(item.get("source") instanceof String source)) {
|
||||
return;
|
||||
}
|
||||
String prefix = "/api/poc/dict/";
|
||||
if (!source.startsWith(prefix)) {
|
||||
return;
|
||||
}
|
||||
String dict = source.substring(prefix.length()).trim();
|
||||
if (dict.isBlank() || dict.contains("?") || dict.contains("${")) {
|
||||
return;
|
||||
}
|
||||
List<Map<String, Object>> options = enumerateOptions(dict, result);
|
||||
if (options.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
item.remove("source");
|
||||
item.put("options", options);
|
||||
result.note(origin + "@field " + item.getOrDefault("name", "")
|
||||
+ " 枚举字典 " + dict + " → 内联 options(" + options.size() + "项),避免远程下拉空载");
|
||||
}
|
||||
|
||||
/**
|
||||
* F3-1:判断一个 search 段字段是否为主键/外键 UUID 列,应从查询区排除。
|
||||
*/
|
||||
@@ -809,7 +843,9 @@ public class TemplateToAmisConverter {
|
||||
dlg.put("type", "dialog");
|
||||
dlg.put("title", title);
|
||||
|
||||
if (templateId == null || templateId.isBlank() || templateId.startsWith("MISSING_")) {
|
||||
boolean entityGeneratedForm = isEntityGeneratedForm(templateId);
|
||||
if (templateId == null || templateId.isBlank()
|
||||
|| (!entityGeneratedForm && templateId.startsWith("MISSING_"))) {
|
||||
Map<String, Object> tpl = new LinkedHashMap<>();
|
||||
tpl.put("type", "tpl");
|
||||
tpl.put("tpl", "该单据未配编辑表单");
|
||||
@@ -840,7 +876,14 @@ public class TemplateToAmisConverter {
|
||||
// service 加载页面 schema(强制 GET,format=amis 信封)
|
||||
Map<String, Object> service = new LinkedHashMap<>();
|
||||
service.put("type", "service");
|
||||
service.put("schemaApi", "get:/api/page/schema/" + templateId + "?format=amis");
|
||||
if (entityGeneratedForm) {
|
||||
String entityId = templateId.substring(ENTITY_FORM_PREFIX.length());
|
||||
service.put("body", buildEntityFallbackForm(entityId, tableName, result));
|
||||
result.note("dialog[" + title + "] 无显式 EDITFORM → 使用实体元数据通用表单(entityId="
|
||||
+ entityId + ",table=" + tableName + ")");
|
||||
} else {
|
||||
service.put("schemaApi", "get:/api/page/schema/" + templateId + "?format=amis");
|
||||
}
|
||||
if (readOnly) {
|
||||
service.put("static", true);
|
||||
}
|
||||
@@ -859,7 +902,8 @@ public class TemplateToAmisConverter {
|
||||
result.note("dialog[" + title + "] 接 load 服务 " + loadService
|
||||
+ " → service.api POST 按 " + primaryKey
|
||||
+ " 加载本体数据(result 拍平,readOnly 保留 static 只读,透传编辑模板解析 picker 默认值)");
|
||||
} else if ((primaryKey == null || primaryKey.isBlank())
|
||||
} else if (!entityGeneratedForm
|
||||
&& (primaryKey == null || primaryKey.isBlank())
|
||||
&& tableName != null && !tableName.isBlank()) {
|
||||
// B:新建(添加)dialog——无选中行/无 load 服务。接默认值端点服务端解析 initvalue 宏
|
||||
// ({CURRENTUSER}/{CURRENTDEPART}/{CURRENTTIME} 等)+ {AUTOGENERATECODE} 流水号,
|
||||
@@ -927,10 +971,16 @@ public class TemplateToAmisConverter {
|
||||
}
|
||||
|
||||
private static String editTemplateQuery(String templateId) {
|
||||
return templateId != null && !templateId.isBlank() && !templateId.startsWith("MISSING_")
|
||||
return templateId != null && !templateId.isBlank()
|
||||
&& !templateId.startsWith("MISSING_")
|
||||
&& !isEntityGeneratedForm(templateId)
|
||||
? "?__egtpl=" + templateId : "";
|
||||
}
|
||||
|
||||
private static boolean isEntityGeneratedForm(String templateId) {
|
||||
return templateId != null && templateId.startsWith(ENTITY_FORM_PREFIX);
|
||||
}
|
||||
|
||||
/** 兼容旧调用:read 按钮无 methods,使用默认确认/取消。 */
|
||||
private Map<String, Object> buildFormDialog(String title, String templateId,
|
||||
String primaryKey, boolean readOnly,
|
||||
@@ -1040,7 +1090,16 @@ public class TemplateToAmisConverter {
|
||||
}
|
||||
}
|
||||
|
||||
// ── 第四级:MISSING 诚实降级 ─────────────────────────────────────────────
|
||||
// ── 第四级:实体元数据通用表单兜底 ─────────────────────────────────
|
||||
// 配置类 CRUD 常见形态:按钮只给 servicename,没有 pageid,也没有单独 EDITFORM 包壳。
|
||||
// 老系统仍能按实体属性打开编辑页;迁移后不能直接降级成「未配编辑表单」。
|
||||
if (hasEntityFormAttributes(entityId)) {
|
||||
result.note("button pageid=" + pageId + " entityId=" + entityId
|
||||
+ " 无显式编辑表单 → 使用实体元数据通用表单兜底");
|
||||
return ENTITY_FORM_PREFIX + entityId.trim();
|
||||
}
|
||||
|
||||
// ── 第五级:MISSING 诚实降级 ─────────────────────────────────────────────
|
||||
result.degrade("button pageid=" + pageId
|
||||
+ " 无 type=7 包壳、无同实体 editform、view_page 也不存在 → 诚实降级");
|
||||
return "MISSING_" + (pageId != null ? pageId : "empty");
|
||||
@@ -1058,6 +1117,230 @@ public class TemplateToAmisConverter {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasEntityFormAttributes(String entityId) {
|
||||
if (entityId == null || entityId.isBlank()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Integer cnt = jdbcTemplate.queryForObject(
|
||||
"SELECT COUNT(*) FROM SYS_ENTITYATTRIBUTE "
|
||||
+ "WHERE ENTITYID=? AND COALESCE(ISACTIVE,1)=1",
|
||||
Integer.class, entityId);
|
||||
return cnt != null && cnt > 0;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 无显式 EDITFORM 的配置型 CRUD 兜底:按 SYS_ENTITYATTRIBUTE 生成基础编辑表单。
|
||||
* 仅用于最后一级回退;已配置 pageid/type=7/view_page 的页面不走这里。
|
||||
*/
|
||||
private Map<String, Object> buildEntityFallbackForm(String entityId, String tableName,
|
||||
ConversionResult result) {
|
||||
List<Map<String, Object>> items = new ArrayList<>();
|
||||
try {
|
||||
jdbcTemplate.query(
|
||||
"SELECT TRIM(a.COLUMNNAME), COALESCE(NULLIF(TRIM(a.DISPLAYNAME),''), TRIM(a.COLUMNNAME)), "
|
||||
+ "a.REFERENCEID, a.REFERENCEVALUE, a.ENUMERATETYPE, UPPER(e2.TABLENAME), "
|
||||
+ "COALESCE(a.ISMANDATORY,0), COALESCE(a.ISREADONLY,0), COALESCE(a.ISIDENTIFIER,0), "
|
||||
+ "COALESCE(a.FIELDLENGTH,0), a.DEFAULTVALUE "
|
||||
+ "FROM SYS_ENTITYATTRIBUTE a "
|
||||
+ "LEFT JOIN SYS_REFERENCE r ON UPPER(r.SYS_REFERENCE_ID)=UPPER(a.REFERENCEID) "
|
||||
+ "LEFT JOIN SYS_ENTITY e2 ON UPPER(e2.SYS_ENTITY_ID)=UPPER(r.ENTITYID) "
|
||||
+ "WHERE a.ENTITYID=? AND COALESCE(a.ISACTIVE,1)=1 "
|
||||
+ "ORDER BY a.ENTITYDISPLAYSEQ NULLS LAST, a.COLUMNNAME",
|
||||
rs -> {
|
||||
EntityFormAttr attr = new EntityFormAttr(
|
||||
rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4),
|
||||
rs.getString(5), rs.getString(6), rs.getInt(7) == 1,
|
||||
rs.getInt(8) == 1, rs.getInt(9) == 1, rs.getInt(10),
|
||||
rs.getString(11));
|
||||
Map<String, Object> item = entityFallbackItem(attr, result);
|
||||
if (item != null) {
|
||||
items.add(item);
|
||||
}
|
||||
},
|
||||
entityId);
|
||||
} catch (Exception e) {
|
||||
result.degrade("实体元数据通用表单生成失败 entityId=" + entityId + ": " + safeMsg(e));
|
||||
}
|
||||
|
||||
Map<String, Object> form = new LinkedHashMap<>();
|
||||
form.put("type", "form");
|
||||
form.put("id", UiTypeMapper.EDIT_FORM_ID);
|
||||
form.put("title", "");
|
||||
form.put("mode", "horizontal");
|
||||
form.put("horizontal", new LinkedHashMap<>(Map.of("leftFixed", 120)));
|
||||
form.put("body", buildFormRows(items));
|
||||
form.put("actions", new ArrayList<>());
|
||||
result.note("实体元数据通用表单 table=" + tableName + " entityId=" + entityId
|
||||
+ " → 字段 " + items.size() + " 个");
|
||||
return form;
|
||||
}
|
||||
|
||||
private Map<String, Object> entityFallbackItem(EntityFormAttr attr, ConversionResult result) {
|
||||
if (attr.columnName() == null || attr.columnName().isBlank()) {
|
||||
return null;
|
||||
}
|
||||
String name = attr.columnName().trim().toUpperCase();
|
||||
String ref = attr.referenceId() == null ? "" : attr.referenceId().trim();
|
||||
String enumType = attr.enumerateType() == null ? "" : attr.enumerateType().trim();
|
||||
String refValue = attr.referenceValue() == null ? "" : attr.referenceValue().trim();
|
||||
String targetTable = attr.refTargetTable() == null ? "" : attr.refTargetTable().trim();
|
||||
boolean hidden = attr.identifier() || SYSTEM_FORM_COLUMNS.contains(name);
|
||||
|
||||
Map<String, Object> item = new LinkedHashMap<>();
|
||||
item.put("name", name);
|
||||
item.put("label", attr.label() == null || attr.label().isBlank() ? name : attr.label().trim());
|
||||
if (hidden) {
|
||||
item.put("hidden", true);
|
||||
} else if (attr.mandatory()) {
|
||||
item.put("required", true);
|
||||
}
|
||||
if (attr.readonly()) {
|
||||
item.put("disabled", true);
|
||||
}
|
||||
if (attr.defaultValue() != null && !attr.defaultValue().isBlank()) {
|
||||
item.put("value", scalarValue(attr.defaultValue().trim()));
|
||||
}
|
||||
|
||||
String codeLanguage = fallbackCodeLanguage(name, attr.label(), ref, attr.fieldLength());
|
||||
if (codeLanguage != null) {
|
||||
applyEntityFallbackEditor(item, codeLanguage);
|
||||
result.note("entity-form@field " + name + " → editor(language=" + codeLanguage + ")");
|
||||
} else if (!targetTable.isBlank() || ("LIST".equalsIgnoreCase(ref) && !refValue.isBlank())) {
|
||||
String pickerSource = "LIST".equalsIgnoreCase(ref) && !refValue.isBlank() ? refValue : ref;
|
||||
applyEntityFallbackPicker(item, pickerSource, "LIST".equalsIgnoreCase(ref));
|
||||
result.note("entity-form@field " + name + " reference=" + ref
|
||||
+ " → picker(source=/api/picker/" + pickerSource + "/list)");
|
||||
} else if (!enumType.isBlank() || "BOOLEAN".equalsIgnoreCase(ref)) {
|
||||
item.put("type", "select");
|
||||
item.put("clearable", true);
|
||||
String dict = enumType.isBlank() ? "YESNO" : enumType;
|
||||
List<Map<String, Object>> options = enumerateOptions(dict, result);
|
||||
if (options.isEmpty()) {
|
||||
item.put("source", "/api/poc/dict/" + dict);
|
||||
} else {
|
||||
item.put("options", options);
|
||||
}
|
||||
} else if ("DATE".equalsIgnoreCase(ref)) {
|
||||
item.put("type", "input-date");
|
||||
} else if ("TIME".equalsIgnoreCase(ref)) {
|
||||
item.put("type", "input-datetime");
|
||||
} else if (isNumericReference(ref)) {
|
||||
item.put("type", "input-number");
|
||||
} else if (attr.fieldLength() > 1000 || name.contains("XML") || name.contains("CONTENT")) {
|
||||
item.put("type", "textarea");
|
||||
item.put("minRows", 6);
|
||||
} else {
|
||||
item.put("type", "input-text");
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> enumerateOptions(String enumerateType, ConversionResult result) {
|
||||
if (enumerateType == null || enumerateType.isBlank()) {
|
||||
return List.of();
|
||||
}
|
||||
Map<String, String> mapping = loadEnumerateMapping(enumerateType, result);
|
||||
if (mapping.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
List<Map<String, Object>> options = new ArrayList<>();
|
||||
for (Map.Entry<String, String> e : mapping.entrySet()) {
|
||||
Map<String, Object> opt = new LinkedHashMap<>();
|
||||
opt.put("label", e.getValue());
|
||||
opt.put("value", scalarValue(e.getKey()));
|
||||
options.add(opt);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
private static Object scalarValue(String raw) {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
String v = raw.trim();
|
||||
if (v.matches("-?\\d+")) {
|
||||
try {
|
||||
return Integer.parseInt(v);
|
||||
} catch (NumberFormatException ignore) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
if ("true".equalsIgnoreCase(v)) {
|
||||
return true;
|
||||
}
|
||||
if ("false".equalsIgnoreCase(v)) {
|
||||
return false;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
private static String fallbackCodeLanguage(String name, String label, String ref, int fieldLength) {
|
||||
String n = name == null ? "" : name.toUpperCase();
|
||||
String l = label == null ? "" : label;
|
||||
String r = ref == null ? "" : ref.toUpperCase();
|
||||
if (n.contains("XML") || "XML".equals(r) || l.contains("XML")) {
|
||||
return "xml";
|
||||
}
|
||||
if (n.contains("SCRIPT") || l.contains("脚本")) {
|
||||
return "groovy";
|
||||
}
|
||||
if (fieldLength > 10000 && (n.contains("CONTENT") || l.contains("内容"))) {
|
||||
return "xml";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void applyEntityFallbackEditor(Map<String, Object> item, String language) {
|
||||
item.put("type", "editor");
|
||||
item.put("language", language);
|
||||
item.put("size", "lg");
|
||||
item.put("options", Map.of(
|
||||
"minimap", Map.of("enabled", false),
|
||||
"wordWrap", "on",
|
||||
"fontSize", 14));
|
||||
}
|
||||
|
||||
private static void applyEntityFallbackPicker(Map<String, Object> item, String source, boolean multiple) {
|
||||
item.put("type", "picker");
|
||||
item.put("clearable", true);
|
||||
item.put("source", "/api/picker/" + source + "/list");
|
||||
item.put("labelField", "_label");
|
||||
item.put("valueField", "_id");
|
||||
item.put("modalMode", "dialog");
|
||||
item.put("modalSize", "lg");
|
||||
if (multiple) {
|
||||
item.put("multiple", true);
|
||||
item.put("overflowConfig", Map.of("maxTagCount", 1, "displayPosition", List.of("select")));
|
||||
}
|
||||
Map<String, Object> searchBox = new LinkedHashMap<>();
|
||||
searchBox.put("type", "search-box");
|
||||
searchBox.put("name", "q");
|
||||
searchBox.put("placeholder", "输入关键字搜索");
|
||||
Map<String, Object> pickerSchema = new LinkedHashMap<>();
|
||||
pickerSchema.put("mode", "table");
|
||||
pickerSchema.put("headerToolbar", List.of(searchBox));
|
||||
pickerSchema.put("footerToolbar", List.of("pagination"));
|
||||
item.put("pickerSchema", pickerSchema);
|
||||
}
|
||||
|
||||
private static boolean isNumericReference(String ref) {
|
||||
if (ref == null) {
|
||||
return false;
|
||||
}
|
||||
return switch (ref.toUpperCase()) {
|
||||
case "INTEGER", "LONG", "SHORT", "BIGINTEGER", "DECIMAL", "DOUBLE", "FLOAT", "NUMBER" -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
private record EntityFormAttr(String columnName, String label, String referenceId, String referenceValue,
|
||||
String enumerateType, String refTargetTable, boolean mandatory,
|
||||
boolean readonly, boolean identifier, int fieldLength, String defaultValue) {}
|
||||
|
||||
/**
|
||||
* mapField 之后的「引用字段」富化(需查元数据,故在转换器侧而非纯静态 {@link UiTypeMapper}):
|
||||
* <ul>
|
||||
@@ -1614,6 +1897,7 @@ public class TemplateToAmisConverter {
|
||||
Map<String, Object> formItem = UiTypeMapper.mapField(f, result, "editform", colMeta);
|
||||
enrichFieldRefs(formItem, f, result);
|
||||
applyFilterscriptCascade(formItem, f, pageScripts, result);
|
||||
inlineEnumerateOptions(formItem, "editform", result);
|
||||
formItems.add(formItem);
|
||||
}
|
||||
result.note("form@pageid=" + pageId + " → 解析 view_page 取得 " + formItems.size() + " 字段");
|
||||
@@ -1739,6 +2023,7 @@ public class TemplateToAmisConverter {
|
||||
Map<String, Object> formItem = UiTypeMapper.mapField(f, result, "editform", colMeta, pageScripts);
|
||||
enrichFieldRefs(formItem, f, result);
|
||||
applyFilterscriptCascade(formItem, f, pageScripts, result);
|
||||
inlineEnumerateOptions(formItem, "editform", result);
|
||||
formItems.add(formItem);
|
||||
}
|
||||
}
|
||||
@@ -2029,7 +2314,7 @@ public class TemplateToAmisConverter {
|
||||
private static boolean isWideField(Map<String, Object> item) {
|
||||
String type = String.valueOf(item.get("type"));
|
||||
return switch (type) {
|
||||
case "input-rich-text", "input-file", "textarea", "input-table", "service" -> true;
|
||||
case "input-rich-text", "input-file", "textarea", "input-table", "service", "editor" -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ final class UiTypeMapper {
|
||||
}
|
||||
case "EditGrid", "FormEditGrid" -> {
|
||||
// 表单内嵌可编辑子表(主子表的子表侧)→ amis input-table;
|
||||
// 子列取自 <editgridtemplate> CDATA 内 <component><editgrid><field>。
|
||||
// 子列取自 <editgridtemplate>/<formeditgridtemplate> CDATA。
|
||||
item.put("type", "input-table");
|
||||
item.put("id", editGridId(name)); // A1:供行内脚本 setValue 当前行经 componentId 定位
|
||||
// 尊重老模板 showaddbutton:false → 无内联「+ 新增」(grid 顶部/行尾「+」)。
|
||||
@@ -160,7 +160,7 @@ final class UiTypeMapper {
|
||||
item.put("columns", buildEditGridColumns(f, result, name));
|
||||
item.put("needConfirm", false); // 单元格改即生效,免每行「确认」拦住 onEvent.change 联动
|
||||
result.degrade(origin + "@field " + name + " uitype=" + uitype
|
||||
+ " → input-table 子表(主子表子表侧,列取自 editgridtemplate;保存联动 updateSubTable 待后端)");
|
||||
+ " → input-table 子表(主子表子表侧,列取自 editgrid/formeditgrid template;保存联动 updateSubTable 待后端)");
|
||||
}
|
||||
case "ComboBox" -> {
|
||||
item.put("type", "select");
|
||||
@@ -733,22 +733,29 @@ final class UiTypeMapper {
|
||||
return onEvent;
|
||||
}
|
||||
|
||||
/** 解析 EditGrid 的 {@code <editgridtemplate>} CDATA,把内嵌 editgrid 字段转成 input-table 列。 */
|
||||
/** 解析 EditGrid/FormEditGrid 的 CDATA,把内嵌子表字段转成 input-table 列。 */
|
||||
private static List<Map<String, Object>> buildEditGridColumns(Element f, ConversionResult result, String name) {
|
||||
List<Map<String, Object>> columns = new ArrayList<>();
|
||||
Element tpl = f.element("editgridtemplate");
|
||||
String tplKind = "editgridtemplate";
|
||||
if (tpl == null) {
|
||||
tpl = f.element("formeditgridtemplate");
|
||||
tplKind = "formeditgridtemplate";
|
||||
}
|
||||
String tplXml = tpl != null ? tpl.getText() : null;
|
||||
if (tplXml == null || tplXml.isBlank()) {
|
||||
result.note("editgrid " + name + " 无 editgridtemplate → 空子表列");
|
||||
result.note("editgrid " + name + " 无 editgridtemplate/formeditgridtemplate → 空子表列");
|
||||
return columns;
|
||||
}
|
||||
try {
|
||||
Document doc = DocumentHelper.parseText(tplXml.trim());
|
||||
Element editgrid = doc.getRootElement().element("editgrid");
|
||||
Element editgrid = childGridElement(doc.getRootElement());
|
||||
if (editgrid == null) {
|
||||
return columns;
|
||||
}
|
||||
for (Element sub : editgrid.elements("field")) {
|
||||
Element display = editgrid.element("display");
|
||||
List<Element> subFields = display != null ? display.elements("field") : editgrid.elements("field");
|
||||
for (Element sub : subFields) {
|
||||
if ("true".equals(sub.attributeValue("hidden"))) {
|
||||
continue;
|
||||
}
|
||||
@@ -798,13 +805,27 @@ final class UiTypeMapper {
|
||||
col.put("quickEdit", quickEdit);
|
||||
columns.add(col);
|
||||
}
|
||||
result.note("editgrid " + name + " → input-table " + columns.size() + " 列(取自 editgridtemplate)");
|
||||
result.note("editgrid " + name + " → input-table " + columns.size() + " 列(取自 " + tplKind + ")");
|
||||
} catch (Exception e) {
|
||||
result.note("editgrid " + name + " editgridtemplate 解析失败: " + e.getClass().getSimpleName());
|
||||
result.note("editgrid " + name + " editgrid/formeditgrid template 解析失败: " + e.getClass().getSimpleName());
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
private static Element childGridElement(Element root) {
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
if ("editgrid".equals(root.getName()) || "formeditgrid".equals(root.getName())) {
|
||||
return root;
|
||||
}
|
||||
Element editgrid = root.element("editgrid");
|
||||
if (editgrid != null) {
|
||||
return editgrid;
|
||||
}
|
||||
return root.element("formeditgrid");
|
||||
}
|
||||
|
||||
private static void applyLength(Map<String, Object> item, Element f) {
|
||||
String max = f.attributeValue("maxlength");
|
||||
if (max != null && !max.isBlank()) {
|
||||
|
||||
Reference in New Issue
Block a user