vue + SpringBoot + flowable 实现工作流审批功能 (流程图部署)

目录

搭建前端vue项目

vue init webpack project_name 初始化项目

导入 element-ui 框架 

npm install element-ui -s

设置 element-ui 全局配置 编辑 main.js 文件

        import ElementUI from "element-ui"; // ui框架导入        import 'element-ui/lib/theme-chalk/index.css' // ui css 样式导入

导入 axios

        npm install axios

        npm install  workflow-bpmn-modeler

添加main.js 配置文件

搭建后端springBoot项目

导入pom文件

编写yml 配置文件

自动更新异常问题 数据源配置添加&nullCatalogMeansCurrent=true

前端基础配置 bpmn 文件使用

截图展示前端样式

流程分类

 人员users 属性​编辑

组 groups 属性

@save 保存方法参数

后端接口

实体类 接受前端传过来的数据

flowUtils 工作流工具类

保存之后 数据库保存到 ACT_RE_DEPLOYMENT、xml 数据保存到 ACT_GE_BYTEARRAY​编辑


搭建前端vue项目

vue init webpack project_name 初始化项目

导入 element-ui 框架 

  1. npm install element-ui -s

设置 element-ui 全局配置 编辑 main.js 文件

        import ElementUI from "element-ui"; // ui框架导入
        import 'element-ui/lib/theme-chalk/index.css' // ui css 样式导入

导入 axios

        npm install axios

        npm install  workflow-bpmn-modeler

添加main.js 配置文件

import ElementUI from "element-ui"; // ui框架导入
import 'element-ui/lib/theme-chalk/index.css' // ui css 样式导入
import axios from 'axios'
Vue.prototype.$axios = axios
Vue.config.productionTip = false
Vue.use(ElementUI)

搭建后端springBoot项目

导入pom文件

        <!--    web 框架    -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
        <!--    安全认证框架    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency> -->
        <!--    数据源    -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.28</version>
        </dependency>

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
        <!-- flowable 工作流jar -->
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter</artifactId>
            <version>6.3.0</version>
        </dependency>

编写yml 配置文件

server:
  port: 8001

spring:
  security:

    user:
      name: admin
      password: admin
  # 数据源配置     
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: bhz
    password: Bhz123456
    url: jdbc:mysql://localhost:3306/csvn?serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true

  mvc:
    view:
      suffix: .html
flowable:
  #  是否主动更新创建flowable关联表
  database-schema-update: true
  idm:
    enabled: true
  async-executor-activate: false
# mapper 映射文件配置
mybatis:
  mapper-locations: classpath:mapper/*.xml
  configuration:
    map-underscore-to-camel-case: true

自动更新异常问题 数据源配置添加&nullCatalogMeansCurrent=true

问题参考: Flowable工作流启动错误:java.sql.SQLSyntaxErrorException: Table ‘act_ge_property‘ doesn‘t exist_java flowable 在流程启动之后报错,事物回滚了,流程正常启动了-CSDN博客


前端基础配置 bpmn 文件使用

import bpmnModeler from 'workflow-bpmn-modeler'
参数(常用)数据类型含义

:xml

String流程图展示xml字符串
@savefunction模型保存方法
:users[{name:'',id:''}]用户信息
:groups[{name:'',id:''}]组信息
:categorys[{name:'',id:''}]流程分类
:is-viewtrue|false是否可编辑 

截图展示前端样式

流程分类

 人员users 属性
组 groups 属性

@save 保存方法参数
    save(bpmn) {
      console.log(bpmn)
    }

后端接口

实体类 接受前端传过来的数据

package com.bu.sys.flow.dto;

import lombok.Data;

/**
 * @author haizhuangbu
 * @date 2024/5/17 20:54
 * @mark FlowDto
 */
@Data
public class FlowDto {

    private ProcessDto process;

    private String xml;

    private String svg;


}

flowUtils 工作流工具类

package com.bu.utils;

import com.bu.sys.flow.dto.FlowDto;
import com.bu.sys.flow.dto.ProcessDto;
import org.flowable.engine.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author haizhuangbu
 * @date 2024/5/17 17:42
 * @mark FlowUtils 工作流工具
 */
@Component
public class FlowUtils {

    @Autowired
    private RepositoryService repositoryService; // 流程图部署

    @Autowired
    private RuntimeService runtimeService; // 启动流程

    @Autowired
    private TaskService taskService; // 任务执行

    @Autowired
    private IdentityService identityService; // 用户信息

    @Autowired
    private HistoryService historyService; // 历史信息


    public void saveFlow(FlowDto flowDto) {
        ProcessDto process = flowDto.getProcess();
        repositoryService.createDeployment()
                // 第一参数 流程名称、第二个参数 xml 类型
                .addString(process.getName(), flowDto.getXml())
                .category(process.getCategory())
                .name(process.getName())
                .key(process.getName())
                .deploy();
    }


}

保存之后 数据库保存到 ACT_RE_DEPLOYMENT、xml 数据保存到 ACT_GE_BYTEARRAY


  • 13
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
VueFlowable是两个独立的技术,可以结合使用来构建一个完整的前后端应用程序。Vue是一个流行的JavaScript框架,用于构建用户界面,而Flowable是一个开源的工作流引擎,用于管理和执行业务流程。 结合VueFlowable可以实现以下功能: 1. 前端界面:使用Vue构建用户界面,包括表单、列表、按钮等组件,以及与后端交互的逻辑。 2. 后端流程管理:使用Flowable定义和管理业务流程,包括流程的创建、启动、审批、撤销等操作。 3. 前后端交互:通过RESTful API或其他方式,将前端界面与后端的Flowable引擎进行交互,实现流程的执行和数据的传递。 具体实现步骤如下: 1. 搭建Vue项目:使用Vue CLI等工具创建一个Vue项目,并安装所需的依赖。 2. 设计前端界面:根据业务需求,设计并实现前端界面,包括表单、列表、按钮等组件。 3. 集成Flowable:将Flowable的相关依赖添加到Vue项目中,并配置与Flowable引擎的连接。 4. 定义流程:使用Flowable的设计器或代码方式定义业务流程,包括流程节点、流程变量、流程表单等。 5. 前后端交互:通过API调用,将前端界面与Flowable引擎进行交互,实现流程的启动、审批等操作。 6. 测试和调试:对整个应用进行测试和调试,确保前后端的功能和交互正常。 通过Vue+Flowable的组合,可以实现一个完整的前后端应用程序,包括用户界面的设计和开发,以及业务流程的定义和管理。这样的应用程序可以用于各种场景,如请假审批、订单处理、工作流程管理等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值