fix(platform): implement short message send
This commit is contained in:
@@ -84,6 +84,10 @@ public final class EngineclassDelta {
|
||||
EngineclassDelta::receivedMessageDetailButton);
|
||||
register("com.dsasp.client.tools.message.MessageSendView",
|
||||
EngineclassDelta::sentMessageDetailButton);
|
||||
registerMutator("com.dsasp.client.tools.message.MessageSendView",
|
||||
EngineclassDelta::messageSentViewDelta);
|
||||
registerMutator("com.dsasp.client.tools.message.MessageManageView",
|
||||
EngineclassDelta::messageManageDelta);
|
||||
}
|
||||
|
||||
private EngineclassDelta() {
|
||||
@@ -349,6 +353,164 @@ public final class EngineclassDelta {
|
||||
return btn;
|
||||
}
|
||||
|
||||
/** 已发送消息列表:给 CRUD 稳定 id,供短消息发送弹窗成功后精准刷新。 */
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void messageSentViewDelta(Map<String, Object> schema, ConversionResult result) {
|
||||
Object bodyObj = schema.get("body");
|
||||
if (!(bodyObj instanceof Map<?, ?> body) || !"crud".equals(body.get("type"))) {
|
||||
return;
|
||||
}
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "short-message-sent-crud");
|
||||
if (result != null) {
|
||||
result.note("engineclass[MessageSendView] 设置已发送消息 CRUD 刷新锚点");
|
||||
}
|
||||
}
|
||||
|
||||
/** 短消息 MessageManageView:在 group tabs 上方加「发送消息」弹窗表单。 */
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void messageManageDelta(Map<String, Object> schema, ConversionResult result) {
|
||||
Object bodyObj = schema.get("body");
|
||||
if (!(bodyObj instanceof Map<?, ?> tabs) || !"tabs".equals(tabs.get("type"))) {
|
||||
return;
|
||||
}
|
||||
if (hasSendMessageButton(schema)) {
|
||||
return;
|
||||
}
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "message-tabs");
|
||||
markShortMessageTabServices((Map<String, Object>) bodyObj);
|
||||
|
||||
Map<String, Object> toolbar = new LinkedHashMap<>();
|
||||
toolbar.put("type", "button-toolbar");
|
||||
toolbar.put("className", "m-b-sm");
|
||||
toolbar.put("buttons", List.of(sendMessageButton()));
|
||||
|
||||
List<Object> body = new ArrayList<>();
|
||||
body.add(toolbar);
|
||||
body.add(bodyObj);
|
||||
schema.put("body", body);
|
||||
if (result != null) {
|
||||
result.note("engineclass[MessageManageView] 注入「发送消息」弹窗表单");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void markShortMessageTabServices(Map<String, Object> tabs) {
|
||||
Object tabListObj = tabs.get("tabs");
|
||||
if (!(tabListObj instanceof List<?> tabList)) {
|
||||
return;
|
||||
}
|
||||
for (Object tabObj : tabList) {
|
||||
if (!(tabObj instanceof Map<?, ?> tab)) {
|
||||
continue;
|
||||
}
|
||||
Object bodyObj = tab.get("body");
|
||||
if (!(bodyObj instanceof Map<?, ?> body) || !"service".equals(body.get("type"))) {
|
||||
continue;
|
||||
}
|
||||
String title = tab.get("title") == null ? "" : String.valueOf(tab.get("title"));
|
||||
if ("已发消息".equals(title)) {
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "short-message-sent-service");
|
||||
} else if ("已收消息".equals(title)) {
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "short-message-received-service");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean hasSendMessageButton(Map<String, Object> schema) {
|
||||
Object bodyObj = schema.get("body");
|
||||
if (!(bodyObj instanceof List<?> list) || list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Object first = list.get(0);
|
||||
if (!(first instanceof Map<?, ?> toolbar)) {
|
||||
return false;
|
||||
}
|
||||
Object buttonsObj = toolbar.get("buttons");
|
||||
if (!(buttonsObj instanceof List<?> buttons)) {
|
||||
return false;
|
||||
}
|
||||
return buttons.stream()
|
||||
.filter(Map.class::isInstance)
|
||||
.map(Map.class::cast)
|
||||
.anyMatch(btn -> "发送消息".equals(btn.get("label")));
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendMessageButton() {
|
||||
Map<String, Object> btn = new LinkedHashMap<>();
|
||||
btn.put("type", "button");
|
||||
btn.put("label", "发送消息");
|
||||
btn.put("level", "primary");
|
||||
btn.put("icon", "fa fa-paper-plane");
|
||||
btn.put("actionType", "dialog");
|
||||
btn.put("dialog", sendMessageDialog());
|
||||
return btn;
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendMessageDialog() {
|
||||
Map<String, Object> form = new LinkedHashMap<>();
|
||||
form.put("type", "form");
|
||||
form.put("mode", "horizontal");
|
||||
form.put("api", "POST:/api/notice/send");
|
||||
form.put("reload", "short-message-sent-crud");
|
||||
form.put("horizontal", mapOf("left", 2, "right", 10));
|
||||
form.put("body", List.of(
|
||||
mapOf("type", "input-text", "name", "TITLE", "label", "标题",
|
||||
"required", true, "maxLength", 200),
|
||||
sendMessageReceiverPicker(),
|
||||
mapOf("type", "hidden", "name", "ISREPLY", "value", true),
|
||||
mapOf("type", "textarea", "name", "CONTENT", "label", "内容",
|
||||
"required", true, "minRows", 6, "maxLength", 2000)
|
||||
));
|
||||
|
||||
Map<String, Object> submit = new LinkedHashMap<>();
|
||||
submit.put("type", "button");
|
||||
submit.put("label", "发送");
|
||||
submit.put("level", "primary");
|
||||
submit.put("actionType", "submit");
|
||||
submit.put("close", true);
|
||||
|
||||
Map<String, Object> cancel = mapOf("type", "button", "label", "取消", "actionType", "close");
|
||||
|
||||
Map<String, Object> dialog = new LinkedHashMap<>();
|
||||
dialog.put("type", "dialog");
|
||||
dialog.put("title", "发送消息");
|
||||
dialog.put("size", "md");
|
||||
dialog.put("body", form);
|
||||
dialog.put("actions", List.of(cancel, submit));
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendMessageReceiverPicker() {
|
||||
Map<String, Object> searchBox = mapOf(
|
||||
"type", "search-box",
|
||||
"name", "q",
|
||||
"placeholder", "输入关键字搜索");
|
||||
Map<String, Object> pickerSchema = new LinkedHashMap<>();
|
||||
pickerSchema.put("mode", "table");
|
||||
pickerSchema.put("headerToolbar", List.of(searchBox));
|
||||
pickerSchema.put("footerToolbar", List.of("pagination"));
|
||||
|
||||
Map<String, Object> picker = new LinkedHashMap<>();
|
||||
picker.put("type", "picker");
|
||||
picker.put("name", "TOUSERS");
|
||||
picker.put("label", "接收人");
|
||||
picker.put("required", true);
|
||||
picker.put("multiple", true);
|
||||
picker.put("clearable", true);
|
||||
picker.put("placeholder", "请点击右侧的图标");
|
||||
picker.put("source", "/api/picker/090981ba-0c10-4d84-92dc-80e226594480/list");
|
||||
picker.put("labelField", "_label");
|
||||
picker.put("valueField", "_id");
|
||||
picker.put("modalMode", "dialog");
|
||||
picker.put("modalSize", "lg");
|
||||
picker.put("overflowConfig", mapOf(
|
||||
"maxTagCount", 1,
|
||||
"displayPosition", List.of("select")));
|
||||
picker.put("pickerSchema", pickerSchema);
|
||||
return picker;
|
||||
}
|
||||
|
||||
// ── 用户管理 · 设置主岗位 ──────────────────────────────────────────────
|
||||
/**
|
||||
* 「设置主岗位」按钮:选 1 用户 → 弹窗 form。initApi 拉该用户岗位(SYS_POSITIONUSER_SEARCH by USERID),
|
||||
|
||||
Reference in New Issue
Block a user