feat(RDMP-3845) - 新增单选、复选的代码逻辑
This commit is contained in:
parent
464e94f368
commit
ce0630f831
@ -22,7 +22,7 @@ import java.util.Map;
|
||||
public class FormFieldDTO {
|
||||
|
||||
/**
|
||||
* 字段类型, 如果是分组:FormContainer,其他表单组件:FormField
|
||||
* 字段类型, 如果是分组:FormContainer,单选复选组件:OptionFormField,其他表单组件:FormField,
|
||||
*/
|
||||
@ApiModelProperty(value = "表单字段类型")
|
||||
@NotBlank(message = "字段类型不能为空")
|
||||
@ -41,6 +41,9 @@ public class FormFieldDTO {
|
||||
* { label: "变洽签单", value: "changeSignatureOrder" },
|
||||
* { label: "通讯录", value: "contacts" },
|
||||
* { label: "金额", value: "amount" },
|
||||
* { label: "复选", value: "checkbox" },
|
||||
* { label: "单选", value: "radio" },
|
||||
*
|
||||
*/
|
||||
@ApiModelProperty(value = "前端的组件类型")
|
||||
private String type;
|
||||
@ -76,6 +79,14 @@ public class FormFieldDTO {
|
||||
@ApiModelProperty(value = "该表单字段的其他扩展属性,期望 JSON 格式")
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 单选复选框的选项
|
||||
* <p>
|
||||
* {@see org.flowable.form.model.OptionFormField}
|
||||
*/
|
||||
@ApiModelProperty(value = "单选复选框的选项,配合 fieldType=OptionFormField 使用")
|
||||
private List<OptionDTO> options;
|
||||
|
||||
/**
|
||||
* 当 fieldType=FormContainer 时,这里的代表内部的集合
|
||||
*/
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.axzo.workflow.common.model.request.form.definition;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 单选复选框的选项入参模型
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2025-11-20 10:57
|
||||
*/
|
||||
@ApiModel("单选复选框的选项入参模型")
|
||||
@Data
|
||||
public class OptionDTO {
|
||||
/**
|
||||
* 选项 ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 选项名称
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.form.api.FormEngineConfigurationApi;
|
||||
import org.flowable.form.api.FormInfo;
|
||||
import org.flowable.form.api.FormInstance;
|
||||
import org.flowable.form.api.FormRepositoryService;
|
||||
import org.flowable.form.api.FormService;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通过审批实例 ID 获取对应的表单定义实体的自定义命令
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2025-11-20 10:18
|
||||
*/
|
||||
public class CustomGetFormModelByProcessInstanceIdCmd extends AbstractCommand<FormInfo> implements Serializable {
|
||||
private final String processInstanceId;
|
||||
|
||||
public CustomGetFormModelByProcessInstanceIdCmd(String processInstanceId) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String paramToJsonString() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("processInstanceId", processInstanceId);
|
||||
return JSON.toJSONString(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FormInfo executeInternal(CommandContext commandContext) {
|
||||
FormEngineConfigurationApi formEngineConfiguration = CommandContextUtil.getFormEngineConfiguration(commandContext);
|
||||
FormService formService = formEngineConfiguration.getFormService();
|
||||
|
||||
FormInstance formInstance = formService.createFormInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||
String formDefinitionId = formInstance.getFormDefinitionId();
|
||||
FormRepositoryService formRepositoryService = formEngineConfiguration.getFormRepositoryService();
|
||||
return formRepositoryService.getFormModelById(formDefinitionId);
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,7 @@ import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstanceLo
|
||||
import cn.axzo.workflow.common.model.response.category.CategoryGroupVarItemVo;
|
||||
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
|
||||
import cn.axzo.workflow.core.engine.cmd.CustomGetFormInstanceLatestValuesCmd;
|
||||
import cn.axzo.workflow.core.engine.cmd.CustomGetFormModelByProcessInstanceIdCmd;
|
||||
import cn.axzo.workflow.core.engine.cmd.CustomGetProcessInstanceVariablesCmd;
|
||||
import cn.axzo.workflow.core.service.BpmnProcessDefinitionService;
|
||||
import cn.axzo.workflow.core.service.BpmnProcessInstanceService;
|
||||
@ -162,6 +163,7 @@ public class PrintAdminController implements PrintAdminApi {
|
||||
bpmnProcessModelService.printTemplateConfig(dto);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取打印模板中可打印的字段, 或者是 WPS 模板中可配置的变量字段
|
||||
*
|
||||
@ -335,16 +337,17 @@ public class PrintAdminController implements PrintAdminApi {
|
||||
// 生成系统字段的变量
|
||||
generateSystemFieldVariables(processInstanceId, result);
|
||||
|
||||
FormInfo formInfo = commandExecutor.execute(new CustomGetFormModelByProcessInstanceIdCmd(processInstanceId));
|
||||
// 将所有变量都转换成 JSON 对象返回
|
||||
convertValueToObject(result);
|
||||
convertValueToObject(result, formInfo);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
private void convertValueToObject(Map<String, Object> result) {
|
||||
private void convertValueToObject(Map<String, Object> result, FormInfo formInfo) {
|
||||
if (CollectionUtils.isEmpty(result)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, FormField> stringFormFieldMap = ((SimpleFormModel) formInfo.getFormModel()).allFieldsAsMap();
|
||||
result.forEach((key, value) -> {
|
||||
if (!(value instanceof String)) {
|
||||
return;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user