fix(platform): restore approval history drawer

This commit is contained in:
2026-06-18 02:12:27 +08:00
parent 278b0da422
commit 21e3865dcf
6 changed files with 220 additions and 73 deletions

View File

@@ -704,55 +704,30 @@ public class TemplateToAmisConverter {
}
/**
* 「查看审批」按钮(审批列表通用):dialog → service 调 {@code GET /api/flow/business/${PK}/trace} 拉审批轨迹,
* 表格展示环节/办理人/意见/结果/时间。trace 端点返裸数组,用 adaptor 包成 amis 信封并取出 nodes。
* 「查看审批」按钮(审批列表通用):旧系统按选中行业务主键打开 WorkFlowHistoryDetailPanel。
* EIP4 复用全局 ApprovalDrawer 只读模式,展示业务单据 + 流程轨迹,而不再只弹轨迹表。
*/
private Map<String, Object> buildViewApprovalButton(String table) {
String pk = table + "_ID";
Map<String, Object> api = new LinkedHashMap<>();
api.put("method", "get");
api.put("url", "/api/flow/business/${selectedItems[0]." + pk + "}/trace");
api.put("adaptor",
"return {status:0,msg:'',data:{nodes:Array.isArray(payload)?payload:((payload&&payload.data)||[])}};");
Map<String, Object> args = new LinkedHashMap<>();
args.put("taskName", "审批详情");
args.put("processInstanceId", "${selectedItems[0].processInstanceId || selectedItems[0].PROCESSINSTANCEID || ''}");
args.put("businessKey", "${selectedItems[0]." + pk + "}");
args.put("businessTable", table);
args.put("readOnly", true);
args.put("mode", "read");
List<Object> cols = new ArrayList<>();
cols.add(new LinkedHashMap<>(Map.of("name", "taskName", "label", "审批环节")));
cols.add(new LinkedHashMap<>(Map.of("name", "assigneeName", "label", "办理人")));
cols.add(new LinkedHashMap<>(Map.of("name", "result", "label", "结果")));
cols.add(new LinkedHashMap<>(Map.of("name", "comment", "label", "审批意见")));
// valueFormat:"x" 告诉 amis 输入是 epoch-ms(trace 节点 startTime/endTime=getTime()),否则被当秒解析成乱码年份。
cols.add(new LinkedHashMap<>(Map.of("name", "startTime", "label", "开始时间",
"type", "date", "format", "YYYY-MM-DD HH:mm", "valueFormat", "x")));
cols.add(new LinkedHashMap<>(Map.of("name", "endTime", "label", "完成时间",
"type", "date", "format", "YYYY-MM-DD HH:mm", "valueFormat", "x")));
Map<String, Object> tbl = new LinkedHashMap<>();
tbl.put("type", "table");
tbl.put("source", "${nodes}");
tbl.put("placeholder", "暂无审批记录");
tbl.put("columns", cols);
Map<String, Object> svc = new LinkedHashMap<>();
svc.put("type", "service");
svc.put("api", api);
svc.put("body", tbl);
Map<String, Object> dlg = new LinkedHashMap<>();
dlg.put("type", "dialog");
dlg.put("title", "审批记录");
dlg.put("size", "lg");
dlg.put("body", svc);
dlg.put("actions", List.of(new LinkedHashMap<>(Map.of(
"type", "button", "actionType", "close", "label", "关闭"))));
Map<String, Object> action = new LinkedHashMap<>();
action.put("actionType", "openApprovalDrawer");
action.put("args", args);
Map<String, Object> btn = new LinkedHashMap<>();
btn.put("type", "button");
btn.put("id", "查看审批");
btn.put("label", "查看审批");
btn.put("icon", "fa fa-search");
btn.put("actionType", "dialog");
btn.put("disabledOn", DISABLED_ON_NO_SELECTION);
btn.put("dialog", dlg);
btn.put("onEvent", Map.of("click", Map.of("actions", List.of(action))));
return btn;
}