fix(platform): restore approval history drawer
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -2773,7 +2773,7 @@ class TemplateToAmisConverterTest {
|
||||
|
||||
// ── 查看审批按钮(审批列表统一补)─────────────────────────────────────
|
||||
|
||||
/** 审批列表(有提交审批按钮)→ toolbar 统一补「查看审批」按钮(dialog→service 调 trace 端点)。 */
|
||||
/** 审批列表(有提交审批按钮)→ toolbar 统一补「查看审批」按钮(只读审批抽屉:业务单据 + 轨迹)。 */
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void buildToolbar_审批列表补查看审批按钮() {
|
||||
@@ -2783,14 +2783,18 @@ class TemplateToAmisConverterTest {
|
||||
Map<String, Object> schema = converter.convertGraded(xml, new ArrayList<>(), noPage).getSchema();
|
||||
List<Object> toolbar = (List<Object>) body(schema).get("headerToolbar");
|
||||
Map<String, Object> view = btnById(toolbar, "查看审批");
|
||||
assertEquals("dialog", view.get("actionType"));
|
||||
assertEquals(TemplateToAmisConverter.DISABLED_ON_NO_SELECTION, view.get("disabledOn"),
|
||||
"查看审批任何状态可查 → 纯选中态");
|
||||
Map<String, Object> svc = (Map<String, Object>) ((Map<String, Object>) view.get("dialog")).get("body");
|
||||
Map<String, Object> api = (Map<String, Object>) svc.get("api");
|
||||
assertTrue(((String) api.get("url")).contains("/api/flow/business/"), "应调 businessKey→trace 端点");
|
||||
assertTrue(((String) api.get("url")).contains("PM_DEMO_ID"), "应传选中行业务主键");
|
||||
assertTrue(((String) api.get("adaptor")).contains("nodes"), "adaptor 把裸数组包成 amis 信封");
|
||||
Map<String, Object> onEvent = (Map<String, Object>) view.get("onEvent");
|
||||
Map<String, Object> click = (Map<String, Object>) onEvent.get("click");
|
||||
List<Object> actions = (List<Object>) click.get("actions");
|
||||
Map<String, Object> action = (Map<String, Object>) actions.get(0);
|
||||
assertEquals("openApprovalDrawer", action.get("actionType"));
|
||||
Map<String, Object> args = (Map<String, Object>) action.get("args");
|
||||
assertEquals("${selectedItems[0].PM_DEMO_ID}", args.get("businessKey"));
|
||||
assertEquals("PM_DEMO", args.get("businessTable"));
|
||||
assertEquals(true, args.get("readOnly"));
|
||||
assertEquals("read", args.get("mode"));
|
||||
}
|
||||
|
||||
/** 非审批列表(无提交审批按钮)→ 不补查看审批按钮。 */
|
||||
|
||||
Reference in New Issue
Block a user