F2-9: 选择窗完整化——searchable搜索、树形模板picker修复、部门树amis-tree端点
- UiTypeMapper: SelectDialog/MultiSelectDialog 生成 searchable:true + source 带 ?q=\${term}&page&perPage(F2-9搜索)
- PickerController: resolveByViewTemplate 支持 <tree> 根元素,取第一个 <node entityid> 解析实体(修复138b7ca7树形模板返回"非法实体")
- OrgController: 新增 GET /api/org/depart-tree/{orgId}/amis-tree,返回 {label,value,children} 嵌套格式供 amis select-tree 消费
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -118,19 +118,27 @@ final class UiTypeMapper {
|
|||||||
// 旧引擎弹窗选择器 → amis select + 远程 source(弹窗数据由 dialogid 指向的模板提供,跨模板引用本批未联动)。
|
// 旧引擎弹窗选择器 → amis select + 远程 source(弹窗数据由 dialogid 指向的模板提供,跨模板引用本批未联动)。
|
||||||
// 注:不用 amis picker——picker 需内嵌 pickerSchema(CRUD),且 6.13 schema 未把 picker 纳入
|
// 注:不用 amis picker——picker 需内嵌 pickerSchema(CRUD),且 6.13 schema 未把 picker 纳入
|
||||||
// 表单项 oneOf,闸一会拒(手册 §8.2 schema 严格性);select+source 双闸皆过,是更保真的降级。
|
// 表单项 oneOf,闸一会拒(手册 §8.2 schema 严格性);select+source 双闸皆过,是更保真的降级。
|
||||||
|
// F2-9:searchable=true + source 带 q=${term} 透传搜索关键字到后端 /api/picker/{id}/list?q=
|
||||||
item.put("type", "select");
|
item.put("type", "select");
|
||||||
item.put("clearable", true);
|
item.put("clearable", true);
|
||||||
item.put("source", "/api/picker/" + f.attributeValue("dialogid", "") + "/list");
|
item.put("searchable", true);
|
||||||
|
item.put("source",
|
||||||
|
"/api/picker/" + f.attributeValue("dialogid", "")
|
||||||
|
+ "/list?q=${term}&page=${page}&perPage=${perPage}");
|
||||||
result.degrade(origin + "@field " + name + " uitype=SelectDialog(dialogid="
|
result.degrade(origin + "@field " + name + " uitype=SelectDialog(dialogid="
|
||||||
+ f.attributeValue("dialogid", "") + ") → select+source 占位(弹窗数据源 /api/picker,需后端实现)");
|
+ f.attributeValue("dialogid", "") + ") → select+source(searchable) /api/picker(F2-9)");
|
||||||
}
|
}
|
||||||
case "MultiSelectDialog" -> {
|
case "MultiSelectDialog" -> {
|
||||||
|
// F2-9:多选 + searchable
|
||||||
item.put("type", "select");
|
item.put("type", "select");
|
||||||
item.put("multiple", true);
|
item.put("multiple", true);
|
||||||
item.put("clearable", true);
|
item.put("clearable", true);
|
||||||
item.put("source", "/api/picker/" + f.attributeValue("dialogid", "") + "/list");
|
item.put("searchable", true);
|
||||||
|
item.put("source",
|
||||||
|
"/api/picker/" + f.attributeValue("dialogid", "")
|
||||||
|
+ "/list?q=${term}&page=${page}&perPage=${perPage}");
|
||||||
result.degrade(origin + "@field " + name + " uitype=MultiSelectDialog(dialogid="
|
result.degrade(origin + "@field " + name + " uitype=MultiSelectDialog(dialogid="
|
||||||
+ f.attributeValue("dialogid", "") + ") → select(multiple)+source 占位(数据源待实现)");
|
+ f.attributeValue("dialogid", "") + ") → select(multiple,searchable)+source /api/picker(F2-9)");
|
||||||
}
|
}
|
||||||
case "MultiFileUploadField", "FileUploadField" -> {
|
case "MultiFileUploadField", "FileUploadField" -> {
|
||||||
// F2-8 附件控件:旧引擎 MultiFileUploadField/FileUploadField → amis input-file。
|
// F2-8 附件控件:旧引擎 MultiFileUploadField/FileUploadField → amis input-file。
|
||||||
|
|||||||
@@ -111,6 +111,59 @@ public class OrgController {
|
|||||||
return okList(rows);
|
return okList(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* F2-9:部门树——amis tree-select 消费格式。
|
||||||
|
*
|
||||||
|
* <p>返回 {@code [{label, value, children:[...]}]} 嵌套结构,供 amis {@code select-tree} 的
|
||||||
|
* {@code source=/api/org/depart-tree/{orgId}/amis-tree} 直接消费。
|
||||||
|
* path 字段即部门名称(VIEW_DEPART_TREE.path 无父路径前缀时为叶节点名),parentid 空串视为根节点。
|
||||||
|
*/
|
||||||
|
@Operation(summary = "部门树(amis tree-select 格式,{label,value,children}嵌套)")
|
||||||
|
@GetMapping("/api/org/depart-tree/{orgId}/amis-tree")
|
||||||
|
public Map<String, Object> departTreeAmis(
|
||||||
|
@Parameter(description = "SYS_ORG.SYS_ORG_ID 公司 ID") @PathVariable String orgId) {
|
||||||
|
List<Map<String, Object>> flat = jdbcTemplate.query(
|
||||||
|
"SELECT trim(view_depart_id) AS id, COALESCE(trim(parentid),'') AS parentid, path, seq "
|
||||||
|
+ "FROM eip3.view_depart_tree WHERE orgid = ? ORDER BY seq",
|
||||||
|
(rs, i) -> {
|
||||||
|
Map<String, Object> m = new LinkedHashMap<>();
|
||||||
|
m.put("id", rs.getString("id"));
|
||||||
|
m.put("parentId", rs.getString("parentid"));
|
||||||
|
// path 字段为"总经理室 > 秘书室"格式;取最后一段作为 label
|
||||||
|
String path = rs.getString("path");
|
||||||
|
String label = path;
|
||||||
|
if (path != null && path.contains(">")) {
|
||||||
|
label = path.substring(path.lastIndexOf(">") + 1).trim();
|
||||||
|
}
|
||||||
|
m.put("label", label);
|
||||||
|
m.put("value", rs.getString("id"));
|
||||||
|
return m;
|
||||||
|
}, orgId);
|
||||||
|
// 构建嵌套树
|
||||||
|
Map<String, Map<String, Object>> byId = new java.util.LinkedHashMap<>();
|
||||||
|
for (Map<String, Object> node : flat) {
|
||||||
|
node.put("children", new java.util.ArrayList<>());
|
||||||
|
byId.put((String) node.get("id"), node);
|
||||||
|
}
|
||||||
|
List<Map<String, Object>> roots = new java.util.ArrayList<>();
|
||||||
|
for (Map<String, Object> node : flat) {
|
||||||
|
String pid = (String) node.get("parentId");
|
||||||
|
if (pid == null || pid.isBlank()) {
|
||||||
|
roots.add(node);
|
||||||
|
} else {
|
||||||
|
Map<String, Object> parent = byId.get(pid);
|
||||||
|
if (parent != null) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Map<String, Object>> children = (List<Map<String, Object>>) parent.get("children");
|
||||||
|
children.add(node);
|
||||||
|
} else {
|
||||||
|
roots.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return okData(roots);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "某公司的部门树(VIEW_DEPART_TREE 层级,经引擎 organizationService.getDepartTreeByOrgId)")
|
@Operation(summary = "某公司的部门树(VIEW_DEPART_TREE 层级,经引擎 organizationService.getDepartTreeByOrgId)")
|
||||||
@GetMapping("/api/org/depart-tree/{orgId}")
|
@GetMapping("/api/org/depart-tree/{orgId}")
|
||||||
public Map<String, Object> departTree(
|
public Map<String, Object> departTree(
|
||||||
|
|||||||
@@ -207,7 +207,23 @@ public class PickerController {
|
|||||||
String entityId;
|
String entityId;
|
||||||
try {
|
try {
|
||||||
Document doc = DocumentHelper.parseText(xml.trim());
|
Document doc = DocumentHelper.parseText(xml.trim());
|
||||||
entityId = doc.getRootElement().attributeValue("entityid");
|
org.dom4j.Element root = doc.getRootElement();
|
||||||
|
entityId = root.attributeValue("entityid");
|
||||||
|
// F2-9:树形模板(<tree> 根无 entityid)→ 取第一个 <node entityid="..."> 的 entityid
|
||||||
|
// 树形模板按节点顺序取根节点(isroot="true")或第一个 node,代表弹窗数据源实体
|
||||||
|
if ((entityId == null || entityId.isBlank()) && "tree".equals(root.getName())) {
|
||||||
|
// 优先取 isroot="true" 的节点
|
||||||
|
for (org.dom4j.Element node : root.elements("node")) {
|
||||||
|
if ("true".equalsIgnoreCase(node.attributeValue("isroot"))) {
|
||||||
|
entityId = node.attributeValue("entityid");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 回退取第一个 node
|
||||||
|
if ((entityId == null || entityId.isBlank()) && !root.elements("node").isEmpty()) {
|
||||||
|
entityId = root.elements("node").get(0).attributeValue("entityid");
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user