feat: wire schedule notifications and data import downloads
Some checks failed
ci / build-test-parity (push) Has been cancelled

This commit is contained in:
2026-06-18 09:59:55 +08:00
parent 46dfa9c5a2
commit c9e4d35ca1
6 changed files with 1056 additions and 2 deletions

View File

@@ -107,10 +107,16 @@ public final class EngineclassDelta {
register("com.dsasp.client.tools.schedulejob.ScheduleJobDesignComponent",
EngineclassDelta::scheduleJobScriptButton);
// 数据导入配置管理:DataImportConfigView 加「编辑转换脚本 / 编辑保存脚本」。
// 设置定时任务:ScheduleJobSettingComponent 加「设置提醒人」,结构化编辑 SENDINFO JSON。
register("com.dsasp.client.tools.schedulejob.ScheduleJobSettingComponent",
EngineclassDelta::scheduleJobNotifyButton);
// 数据导入配置管理:DataImportConfigView 加「编辑转换脚本 / 编辑保存脚本 / 下载模板 / 下载基础数据」。
register("com.dsasp.client.dataimport.view.DataImportConfigView",
EngineclassDelta::dataImportConvertScriptButton,
EngineclassDelta::dataImportSaveScriptButton);
EngineclassDelta::dataImportSaveScriptButton,
EngineclassDelta::dataImportTemplateDownloadButton,
EngineclassDelta::dataImportBaseDataDownloadButton);
// 功能/视图管理与自定义列表:先补高级配置 XML 源码编辑入口;可视化设计器另走独立路由。
register("com.dsasp.client.viewframework.component.UserFunDesignComponent",
@@ -576,6 +582,161 @@ public final class EngineclassDelta {
"SYS_DATAIMPORTCONFIG", "SYS_DATAIMPORTCONFIG_ID", pkField, "SAVESCRIPT", "java");
}
private static Map<String, Object> dataImportTemplateDownloadButton(String pkField) {
return downloadButton("下载模板", "fa fa-download",
"/api/dataimport/template?configId=" + selectedSingleFieldExpr(pkField));
}
private static Map<String, Object> dataImportBaseDataDownloadButton(String pkField) {
return downloadButton("下载基础数据", "fa fa-download", "/api/dataimport/basedata");
}
private static Map<String, Object> scheduleJobNotifyButton(String pkField) {
String idExpr = selectedSingleFieldExpr(pkField);
Map<String, Object> form = mapOf(
"type", "form",
"id", "schedulejob-notify-form",
"wrapWithPanel", false,
"initApi", mapOf(
"method", "get",
"url", "/api/schedulejob/" + idExpr + "/notify"),
"api", mapOf(
"method", "post",
"url", "/api/schedulejob/" + idExpr + "/notify",
"data", mapOf("items", "${items}")),
"body", List.of(scheduleJobNotifyTable()));
Map<String, Object> btn = new LinkedHashMap<>();
btn.put("type", "button");
btn.put("id", "设置提醒人");
btn.put("label", "设置提醒人");
btn.put("icon", "fa fa-bell");
btn.put("disabledOn", "${!selectedItems || selectedItems.length !== 1}");
btn.put("actionType", "dialog");
btn.put("dialog", mapOf(
"type", "dialog",
"title", "设置提醒人",
"size", "xl",
"body", form,
"actions", formActions()));
return btn;
}
private static Map<String, Object> scheduleJobNotifyTable() {
Map<String, Object> table = new LinkedHashMap<>();
table.put("type", "input-table");
table.put("name", "items");
table.put("label", false);
table.put("needConfirm", false);
table.put("addable", true);
table.put("removable", true);
table.put("copyable", false);
table.put("columns", List.of(
inputTableColumn("type", "基于", 140, mapOf(
"type", "select",
"name", "type",
"clearable", false,
"options", List.of(
mapOf("label", "用户", "value", "user"),
mapOf("label", "部门", "value", "depart"),
mapOf("label", "岗位", "value", "position"),
mapOf("label", "指定维度岗位类别负责人", "value", "fixedDimension"),
mapOf("label", "所属公司岗位类别", "value", "formSpecifiedDimension"),
mapOf("label", "基于项目角色", "value", "projectRoleType")))),
inputTableColumn("users", "用户", 280, notifyPicker("users",
"76d2f950-ef40-4eff-89ec-98ad9a4976b9"), "${type === 'user'}"),
inputTableColumn("departs", "部门", 280, notifyPicker("departs",
"138b7ca7-befb-4a0c-bfc6-ed8fb4d4e434"), "${type === 'depart'}"),
inputTableColumn("positions", "岗位", 280, notifyPicker("positions",
"feeee51d-d41b-410b-b7a4-67d61ec8c4df"), "${type === 'position'}"),
inputTableColumn("dimensionId", "维度", 180, mapOf(
"type", "select",
"name", "dimensionId",
"source", "/api/schedulejob/dimensions/options",
"clearable", true), "${type === 'fixedDimension'}"),
inputTableColumn("positionTypes", "岗位类别", 280, notifyPicker("positionTypes",
"8c19a765-047e-4a5c-8657-eb16c013ba65"),
"${type === 'fixedDimension' || type === 'formSpecifiedDimension'}"),
inputTableColumn("projectRoles", "项目角色", 260, mapOf(
"type", "checkboxes",
"name", "projectRoles",
"source", "/api/schedulejob/project-role-options"), "${type === 'projectRoleType'}"),
inputTableColumn("content", "原始内容", 220, mapOf(
"type", "input-text",
"name", "content",
"clearable", true),
"${type !== 'user' && type !== 'depart' && type !== 'position' "
+ "&& type !== 'fixedDimension' && type !== 'formSpecifiedDimension' "
+ "&& type !== 'projectRoleType'}"),
inputTableColumn("isSendMessage", "短消息", 80, mapOf(
"type", "checkbox",
"name", "isSendMessage")),
inputTableColumn("isSendMail", "邮件", 80, mapOf(
"type", "checkbox",
"name", "isSendMail")),
inputTableColumn("isSendPhone", "手机", 80, mapOf(
"type", "checkbox",
"name", "isSendPhone"))));
return table;
}
private static Map<String, Object> inputTableColumn(String name, String label, int width,
Map<String, Object> quickEdit) {
return inputTableColumn(name, label, width, quickEdit, null);
}
private static Map<String, Object> inputTableColumn(String name, String label, int width,
Map<String, Object> quickEdit, String visibleOn) {
Map<String, Object> col = new LinkedHashMap<>();
col.put("name", name);
col.put("label", label);
col.put("width", width);
col.put("quickEdit", quickEdit);
if (visibleOn != null && !visibleOn.isBlank()) {
col.put("visibleOn", visibleOn);
}
return col;
}
private static Map<String, Object> notifyPicker(String name, String dialogId) {
Map<String, Object> picker = new LinkedHashMap<>();
picker.put("type", "picker");
picker.put("name", name);
picker.put("multiple", true);
picker.put("joinValues", false);
picker.put("extractValue", false);
picker.put("valueField", "_id");
picker.put("labelField", "_label");
picker.put("source", "/api/picker/" + dialogId + "/list");
picker.put("modalMode", "dialog");
picker.put("overflowConfig", mapOf("maxTagCount", 1));
picker.put("pickerSchema", mapOf(
"mode", "table",
"filter", mapOf(
"title", "",
"body", List.of(mapOf(
"type", "input-text",
"name", "q",
"label", "关键字",
"clearable", true))),
"columns", List.of(mapOf("name", "_label", "label", "名称")),
"footerToolbar", List.of("pagination")));
return picker;
}
private static Map<String, Object> downloadButton(String label, String icon, String url) {
Map<String, Object> btn = new LinkedHashMap<>();
btn.put("type", "button");
btn.put("id", label);
btn.put("label", label);
btn.put("icon", icon);
if (!label.equals("下载基础数据")) {
btn.put("disabledOn", "${!selectedItems || selectedItems.length !== 1}");
}
btn.put("actionType", "download");
btn.put("api", mapOf("method", "get", "url", url));
return btn;
}
private static Map<String, Object> viewTemplateXmlButton(String pkField) {
return fieldEditorButton("高级配置", "fa fa-code",
"VIEW_TEMPLATE", "VIEW_TEMPLATE_ID", pkField, "XML", "xml");

View File

@@ -1210,6 +1210,45 @@ class TemplateToAmisConverterTest {
assertTrue(labels.contains("编辑转换脚本"));
assertTrue(labels.contains("编辑保存脚本"));
assertTrue(labels.contains("下载模板"));
assertTrue(labels.contains("下载基础数据"));
Map<String, Object> download = toolbar.stream()
.filter(o -> o instanceof Map && "下载模板".equals(((Map<String, Object>) o).get("label")))
.map(o -> (Map<String, Object>) o).findFirst().orElseThrow();
assertEquals("download", download.get("actionType"));
Map<String, Object> api = (Map<String, Object>) download.get("api");
assertEquals("/api/dataimport/template?configId=${selectedItems[0].PM_DEMO_ID}", api.get("url"));
}
@Test
@SuppressWarnings("unchecked")
void engineclass_ScheduleJobSettingComponent_注入设置提醒人规则编辑器() {
String xml = "<crud entityid='e1'><display/></crud>";
ConversionResult r = converter.convertGraded(xml, null,
"com.dsasp.client.tools.schedulejob.ScheduleJobSettingComponent",
"设置定时任务", new ArrayList<>(), noPage);
Map<String, Object> crud = body(r.getSchema());
List<Object> toolbar = (List<Object>) crud.get("headerToolbar");
Map<String, Object> notify = toolbar.stream()
.filter(o -> o instanceof Map && "设置提醒人".equals(((Map<String, Object>) o).get("label")))
.map(o -> (Map<String, Object>) o).findFirst().orElseThrow();
assertEquals("dialog", notify.get("actionType"));
Map<String, Object> dialog = (Map<String, Object>) notify.get("dialog");
Map<String, Object> form = (Map<String, Object>) dialog.get("body");
assertEquals("/api/schedulejob/${selectedItems[0].PM_DEMO_ID}/notify",
((Map<String, Object>) form.get("initApi")).get("url"));
List<Object> body = (List<Object>) form.get("body");
Map<String, Object> table = (Map<String, Object>) body.get(0);
assertEquals("input-table", table.get("type"));
List<Map<String, Object>> columns = (List<Map<String, Object>>) table.get("columns");
assertTrue(columns.stream().anyMatch(c -> "users".equals(c.get("name"))));
Map<String, Object> userColumn = columns.stream()
.filter(c -> "users".equals(c.get("name"))).findFirst().orElseThrow();
Map<String, Object> quickEdit = (Map<String, Object>) userColumn.get("quickEdit");
assertEquals("picker", quickEdit.get("type"));
assertEquals("/api/picker/76d2f950-ef40-4eff-89ec-98ad9a4976b9/list", quickEdit.get("source"));
}
/** engineclass=ProcessFormRemoveComponent → 审批表单删除注入查看和历史删除按钮。 */