Flowable 外部表单

  • 内置表单需要在每个节点中去配置,当如果多个节点使用同一套表单属性就要配置多次比较麻烦,修改的时候也要修改多次,外部表单可以定义一次,然后其它节点都去引用同一个表单属性。

  • 外部表单需要定义一个.form后缀的文件。

  • 外部表单不需要在每个节点去指定From属性,而是在每个节点指定Form Key属性即可。

定义.form

FormLeaveProcess.form

json 复制代码
{
  "key":"FormLeaveProcess",
  "name": "请假流程外部表单",
  "fields": [
    {
      "id": "startTime",
      "name": "请假开始时间",
      "type": "date",
      "required": true,
      "placeholder": "empty"
    },
    {
      "id": "endTime",
      "name": "请假结束时间",
      "type": "date",
      "required": true,
      "placeholder": "empty"
    },
    {
      "id": "reason",
      "name": "请假原因",
      "type": "string",
      "required": false,
      "placeholder": "empty"
    }
  ]
}

配置Form Key

部署流程和部署表单

java 复制代码
@Autowired
private RepositoryService repositoryService;

@Autowired
private FormRepositoryService formRepositoryService;

@Test
void deployFormProcess() {
	// 1.部署流程
    Deployment deploy = repositoryService.createDeployment()
            .addClasspathResource("processes/FormLeaveProcess.bpmn20.xml")
            .name("外部表单请假流程")
            .deploy();
    // 2.部署表单
    formRepositoryService.createDeployment()
            .addClasspathResource("processes/FormLeaveProcess.form")
            .name("请假流程外部表单")
            .parentDeploymentId(deploy.getId())
            .deploy();
}

启动流程

java 复制代码
@Autowired
private RuntimeService runtimeService;

@Test
void startProcess() {
    String processDefinitionId = "FormLeaveProcess:2:48920686-8145-11ee-b7ee-0a0a3d6982e3";
    runtimeService.startProcessInstanceWithForm(processDefinitionId, "表单请假流程outcome", null, "huihui的请假流程");
}

完成表单任务

java 复制代码
@Test
void completeFormTask() {
    Map<String, Object> variables = new HashMap<>();
    variables.put("startTime", "20221111");
    variables.put("endTime", "20231110");
    variables.put("reason", "活着不是为了工作,工作是为了活得更有意义");

    String taskId = "0f273f73-8149-11ee-b15c-0a0a3d6982e3";
    String formDefinitionId = "652cb868-8145-11ee-a2f0-0a0a3d6982e3";
    taskService.completeTaskWithForm(taskId, formDefinitionId, "huihui", variables);
}

获取任务对应的表单数据

java 复制代码
@Test
void getTaskFormData() {
    FormInfo taskFormModel = taskService.getTaskFormModel("0f273f73-8149-11ee-b15c-0a0a3d6982e3");
    System.out.println(taskFormModel.getId() + "-" + taskFormModel.getName() + "-" + taskFormModel.getKey());
    SimpleFormModel simpleFormModel = (SimpleFormModel)taskFormModel.getFormModel();
    List<FormField> fields = simpleFormModel.getFields();
    for (FormField field : fields) {
        System.out.println(field.getId() + ":" + field.getType() + ":" + field.getName() + ":" + field.getValue());
    }
}
相关推荐
大龄码农有梦想2 天前
企业工作流系统如何设计用户、部门、角色、岗位、动态关系五类流程办理人?
工作流引擎·flowable·流程引擎·oa·工作流系统·选人规则·bpm平台
RuoyiOffice4 天前
SpringBoot3+Vue3 流程抄送已读:打开详情消红点,待办与知会怎么分开
spring boot·vue3·flowable·spring boot 3·ruoyi office·流程抄送·已读回执
RuoyiOffice6 天前
SpringBoot3+Vue3+Flowable 企业审批平台全链路:从表单设计、节点权限到移动审批怎么落地
spring boot·vue3·uniapp·springboot3·flowable·审批系统·ruoyi office
凤山老林9 天前
Spring Boot 整合 Flowable 的企业级落地指南
数据库·spring boot·后端·flowable·工作流
RuoyiOffice16 天前
SpringBoot3+Vue3 最推荐的开源 OA 系统 2026:流程驱动、资源闭环、多端互通
spring boot·vue3·flowable·oa·协同办公·spring boot 3·开源oa
RuoyiOffice1 个月前
SpringBoot3+Vue3 会议室预订系统:时段冲突三模式检测 + 会前定时提醒与 cancelByBiz
spring boot·vue3·flowable·消息中心·spring boot 3·会议室·时段冲突
大龄码农有梦想1 个月前
Camunda 7 与 Camunda 8 不是升级关系:架构差异与选型边界
activiti·flowable·流程引擎·camunda·开源工作流·开源工作流引擎
天丁o2 个月前
我把一套 Flowable + Spring Boot + Vue 的 BPM 流程引擎整理开源了:从流程设计器到待办闭环
spring boot·vue·工作流引擎·flowable·bpm流程引擎·流程审批
EntyIU2 个月前
Flowable流程开发笔记
笔记·flowable
qq_185198692 个月前
骆驼任务Flowable + Apache Camel 集成
spring·apache·flowable