fix -- 修改流程定义模块,主页面显示最新版本的流程部署,添加“版本管理”页面。优化查询方法。
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
package com.ruoyi.web.controller.workflow;
|
package com.ruoyi.web.controller.workflow;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.workflow.domain.dto.FlowProcDefDto;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.workflow.domain.dto.FlowSaveXmlVo;
|
|
||||||
import com.ruoyi.workflow.service.IFlowDefinitionService;
|
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import com.ruoyi.workflow.domain.dto.FlowSaveXmlVo;
|
||||||
|
import com.ruoyi.workflow.domain.vo.FlowDefinitionVo;
|
||||||
|
import com.ruoyi.workflow.service.IFlowDefinitionService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
@@ -32,14 +35,14 @@ import java.util.Map;
|
|||||||
* 工作流程定义
|
* 工作流程定义
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author XuanXuan
|
* @author KonBAI
|
||||||
* @date 2021-04-03
|
* @date 2022-01-17
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(tags = "流程定义")
|
@Api(tags = "流程定义")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/workflow/definition")
|
@RequestMapping("/workflow/definition")
|
||||||
public class FlowDefinitionController {
|
public class FlowDefinitionController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IFlowDefinitionService flowDefinitionService;
|
private IFlowDefinitionService flowDefinitionService;
|
||||||
@@ -52,45 +55,57 @@ public class FlowDefinitionController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping(value = "/list")
|
@GetMapping(value = "/list")
|
||||||
@ApiOperation(value = "流程定义列表", response = FlowProcDefDto.class)
|
@ApiOperation(value = "流程定义列表", response = FlowDefinitionVo.class)
|
||||||
public R list(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
|
public TableDataInfo<FlowDefinitionVo> list(PageQuery pageQuery) {
|
||||||
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize) {
|
return flowDefinitionService.list(pageQuery);
|
||||||
return R.success(flowDefinitionService.list(pageNum, pageSize));
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列出指定流程的发布版本列表
|
||||||
|
* @param processKey 流程定义Key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/publishList")
|
||||||
|
@ApiOperation(value = "流程定义列表", response = FlowDefinitionVo.class)
|
||||||
|
public TableDataInfo<FlowDefinitionVo> publishList(@ApiParam(value = "流程定义Key", required = true) @RequestParam String processKey,
|
||||||
|
PageQuery pageQuery) {
|
||||||
|
return flowDefinitionService.publishList(processKey, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "导入流程文件", notes = "上传bpmn20的xml文件")
|
@ApiOperation(value = "导入流程文件", notes = "上传bpmn20的xml文件")
|
||||||
@PostMapping("/import")
|
@PostMapping("/import")
|
||||||
public R importFile(@RequestParam(required = false) String name,
|
public R<Void> importFile(@RequestParam(required = false) String name,
|
||||||
@RequestParam(required = false) String category,
|
@RequestParam(required = false) String category,
|
||||||
MultipartFile file) {
|
MultipartFile file) {
|
||||||
try (InputStream in = file.getInputStream()) {
|
try (InputStream in = file.getInputStream()) {
|
||||||
flowDefinitionService.importFile(name, category, in);
|
flowDefinitionService.importFile(name, category, in);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入失败:", e);
|
log.error("导入失败:", e);
|
||||||
return R.success(e.getMessage());
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return R.success("导入成功");
|
return success("导入成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "读取xml文件")
|
@ApiOperation(value = "读取xml文件")
|
||||||
@GetMapping("/readXml/{deployId}")
|
@GetMapping("/readXml/{definitionId}")
|
||||||
public R readXml(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String deployId) {
|
public R<String> readXml(@ApiParam(value = "流程定义ID") @PathVariable(value = "definitionId") String definitionId) {
|
||||||
try {
|
try {
|
||||||
return flowDefinitionService.readXml(deployId);
|
return R.success(null, flowDefinitionService.readXml(definitionId));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return R.error("加载xml文件异常");
|
return R.error("加载xml文件异常", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "读取图片文件")
|
@ApiOperation(value = "读取图片文件")
|
||||||
@GetMapping("/readImage/{deployId}")
|
@GetMapping("/readImage/{definitionId}")
|
||||||
public void readImage(@ApiParam(value = "流程定义id") @PathVariable(value = "deployId") String deployId, HttpServletResponse response) {
|
public void readImage(@ApiParam(value = "流程定义id") @PathVariable(value = "definitionId") String definitionId,
|
||||||
|
HttpServletResponse response) {
|
||||||
try (OutputStream os = response.getOutputStream()) {
|
try (OutputStream os = response.getOutputStream()) {
|
||||||
BufferedImage image = ImageIO.read(flowDefinitionService.readImage(deployId));
|
BufferedImage image = ImageIO.read(flowDefinitionService.readImage(definitionId));
|
||||||
response.setContentType("image/png");
|
response.setContentType("image/png");
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
ImageIO.write(image, "png", os);
|
ImageIO.write(image, "png", os);
|
||||||
@@ -103,51 +118,52 @@ public class FlowDefinitionController {
|
|||||||
|
|
||||||
@ApiOperation(value = "保存流程设计器内的xml文件")
|
@ApiOperation(value = "保存流程设计器内的xml文件")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public R save(@RequestBody FlowSaveXmlVo vo) {
|
public R<Void> save(@RequestBody FlowSaveXmlVo vo) {
|
||||||
try (InputStream in = new ByteArrayInputStream(vo.getXml().getBytes(StandardCharsets.UTF_8))) {
|
try (InputStream in = new ByteArrayInputStream(vo.getXml().getBytes(StandardCharsets.UTF_8))) {
|
||||||
flowDefinitionService.importFile(vo.getName(), vo.getCategory(), in);
|
flowDefinitionService.importFile(vo.getName(), vo.getCategory(), in);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入失败:", e);
|
log.error("导入失败:", e);
|
||||||
return R.success(e.getMessage());
|
return success(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return R.success("导入成功");
|
return success("导入成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "根据流程定义id启动流程实例")
|
@ApiOperation(value = "根据流程定义id启动流程实例")
|
||||||
@PostMapping("/start/{procDefId}")
|
@PostMapping("/start/{procDefId}")
|
||||||
public R start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
|
public R<Void> start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
|
||||||
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
|
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
|
||||||
return flowDefinitionService.startProcessInstanceById(procDefId, variables);
|
flowDefinitionService.startProcessInstanceById(procDefId, variables);
|
||||||
|
return success("流程启动成功");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "激活或挂起流程定义")
|
@ApiOperation(value = "激活或挂起流程定义")
|
||||||
@PutMapping(value = "/updateState")
|
@PutMapping(value = "/updateState")
|
||||||
public R updateState(@ApiParam(value = "1:激活,2:挂起", required = true) @RequestParam Integer state,
|
public R<Void> updateState(@ApiParam(value = "ture:挂起,false:激活", required = true) @RequestParam Boolean suspended,
|
||||||
@ApiParam(value = "流程部署ID", required = true) @RequestParam String deployId) {
|
@ApiParam(value = "流程定义ID", required = true) @RequestParam String definitionId) {
|
||||||
flowDefinitionService.updateState(state, deployId);
|
flowDefinitionService.updateState(suspended, definitionId);
|
||||||
return R.success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "删除流程")
|
@ApiOperation(value = "删除流程")
|
||||||
@DeleteMapping(value = "/delete")
|
@DeleteMapping(value = "/delete")
|
||||||
public R delete(@ApiParam(value = "流程部署ID", required = true) @RequestParam String deployId) {
|
public R<Void> delete(@ApiParam(value = "流程部署ID", required = true) @RequestParam String deployId) {
|
||||||
flowDefinitionService.delete(deployId);
|
flowDefinitionService.delete(deployId);
|
||||||
return R.success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "指定流程办理人员列表")
|
@ApiOperation(value = "指定流程办理人员列表")
|
||||||
@GetMapping("/userList")
|
@GetMapping("/userList")
|
||||||
public R userList(SysUser user) {
|
public R<List<SysUser>> userList(SysUser user) {
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
return R.success(list);
|
return R.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "指定流程办理组列表")
|
@ApiOperation(value = "指定流程办理组列表")
|
||||||
@GetMapping("/roleList")
|
@GetMapping("/roleList")
|
||||||
public R roleList(SysRole role) {
|
public R<List<SysRole>> roleList(SysRole role) {
|
||||||
List<SysRole> list = sysRoleService.selectRoleList(role);
|
List<SysRole> list = sysRoleService.selectRoleList(role);
|
||||||
return R.success(list);
|
return R.success(list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.ruoyi.workflow.domain.dto;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>流程定义<p>
|
|
||||||
*
|
|
||||||
* @author XuanXuan
|
|
||||||
* @date 2021-04-03
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@ApiModel("流程定义")
|
|
||||||
public class FlowProcDefDto implements Serializable {
|
|
||||||
|
|
||||||
@ApiModelProperty("流程id")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@ApiModelProperty("流程名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@ApiModelProperty("流程key")
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
@ApiModelProperty("流程分类")
|
|
||||||
private String category;
|
|
||||||
|
|
||||||
@ApiModelProperty("配置表单名称")
|
|
||||||
private String formName;
|
|
||||||
|
|
||||||
@ApiModelProperty("配置表单id")
|
|
||||||
private Long formId;
|
|
||||||
|
|
||||||
@ApiModelProperty("版本")
|
|
||||||
private int version;
|
|
||||||
|
|
||||||
@ApiModelProperty("部署ID")
|
|
||||||
private String deploymentId;
|
|
||||||
|
|
||||||
@ApiModelProperty("流程定义状态: 1:激活 , 2:中止")
|
|
||||||
private int suspensionState;
|
|
||||||
|
|
||||||
@ApiModelProperty("部署时间")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date deploymentTime;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package com.ruoyi.workflow.domain.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程定义视图对象 workflow_definition
|
||||||
|
*
|
||||||
|
* @author KonBAI
|
||||||
|
* @date 2022-01-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("流程定义视图对象")
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class FlowDefinitionVo {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程定义ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "流程定义ID")
|
||||||
|
@ApiModelProperty("流程定义ID")
|
||||||
|
private String definitionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "流程名称")
|
||||||
|
@ApiModelProperty("流程名称")
|
||||||
|
private String processName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程Key
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "流程Key")
|
||||||
|
@ApiModelProperty("流程Key")
|
||||||
|
private String processKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类编码
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "分类编码")
|
||||||
|
@ApiModelProperty("分类编码")
|
||||||
|
private String categoryCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("版本")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "表单ID")
|
||||||
|
@ApiModelProperty("表单ID")
|
||||||
|
private Long formId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "表单名称")
|
||||||
|
@ApiModelProperty("表单名称")
|
||||||
|
private String formName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "部署ID")
|
||||||
|
@ApiModelProperty("部署ID")
|
||||||
|
private String deploymentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程定义状态: 1:激活 , 2:中止
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "流程定义状态: 1:激活 , 2:中止")
|
||||||
|
@ApiModelProperty("流程定义状态: 1:激活 , 2:中止")
|
||||||
|
private Boolean suspended;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "部署时间")
|
||||||
|
@ApiModelProperty("部署时间")
|
||||||
|
private Date deploymentTime;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.ruoyi.workflow.service;
|
package com.ruoyi.workflow.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.workflow.domain.dto.FlowProcDefDto;
|
import com.ruoyi.workflow.domain.vo.FlowDefinitionVo;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -20,11 +20,17 @@ public interface IFlowDefinitionService {
|
|||||||
/**
|
/**
|
||||||
* 流程定义列表
|
* 流程定义列表
|
||||||
*
|
*
|
||||||
* @param pageNum 当前页码
|
* @param pageQuery 分页参数
|
||||||
* @param pageSize 每页条数
|
|
||||||
* @return 流程定义分页列表数据
|
* @return 流程定义分页列表数据
|
||||||
*/
|
*/
|
||||||
Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize);
|
TableDataInfo<FlowDefinitionVo> list(PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param processKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
TableDataInfo<FlowDefinitionVo> publishList(String processKey, PageQuery pageQuery);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入流程文件
|
* 导入流程文件
|
||||||
@@ -37,10 +43,10 @@ public interface IFlowDefinitionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取xml
|
* 读取xml
|
||||||
* @param deployId
|
* @param definitionId 流程定义ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
R readXml(String deployId) throws IOException;
|
String readXml(String definitionId) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据流程定义ID启动流程实例
|
* 根据流程定义ID启动流程实例
|
||||||
@@ -50,16 +56,16 @@ public interface IFlowDefinitionService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
R startProcessInstanceById(String procDefId, Map<String, Object> variables);
|
void startProcessInstanceById(String procDefId, Map<String, Object> variables);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 激活或挂起流程定义
|
* 激活或挂起流程定义
|
||||||
*
|
*
|
||||||
* @param state 状态
|
* @param suspended 状态
|
||||||
* @param deployId 流程部署ID
|
* @param definitionId 流程定义ID
|
||||||
*/
|
*/
|
||||||
void updateState(Integer state, String deployId);
|
void updateState(Boolean suspended, String definitionId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,8 +78,8 @@ public interface IFlowDefinitionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取图片文件
|
* 读取图片文件
|
||||||
* @param deployId
|
* @param definitionId 流程定义ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
InputStream readImage(String deployId);
|
InputStream readImage(String definitionId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,54 +2,56 @@ package com.ruoyi.workflow.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.LoginUtils;
|
import com.ruoyi.common.utils.LoginUtils;
|
||||||
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
||||||
import com.ruoyi.flowable.common.enums.FlowComment;
|
import com.ruoyi.flowable.common.enums.FlowComment;
|
||||||
import com.ruoyi.workflow.domain.dto.FlowProcDefDto;
|
|
||||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||||
|
import com.ruoyi.system.domain.SysForm;
|
||||||
|
import com.ruoyi.workflow.domain.vo.FlowDefinitionVo;
|
||||||
import com.ruoyi.workflow.service.IFlowDefinitionService;
|
import com.ruoyi.workflow.service.IFlowDefinitionService;
|
||||||
import com.ruoyi.workflow.service.ISysDeployFormService;
|
import com.ruoyi.workflow.service.ISysDeployFormService;
|
||||||
import com.ruoyi.system.domain.SysForm;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.flowable.bpmn.model.BpmnModel;
|
import org.flowable.bpmn.model.BpmnModel;
|
||||||
import org.flowable.engine.repository.Deployment;
|
import org.flowable.engine.repository.Deployment;
|
||||||
|
import org.flowable.engine.repository.DeploymentBuilder;
|
||||||
import org.flowable.engine.repository.ProcessDefinition;
|
import org.flowable.engine.repository.ProcessDefinition;
|
||||||
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.flowable.image.impl.DefaultProcessDiagramGenerator;
|
import org.flowable.image.impl.DefaultProcessDiagramGenerator;
|
||||||
import org.flowable.task.api.Task;
|
import org.flowable.task.api.Task;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程定义
|
* 流程定义
|
||||||
*
|
*
|
||||||
* @author XuanXuan
|
* @author KonBAI
|
||||||
* @date 2021-04-03
|
* @date 2022-01-17
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService {
|
public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService {
|
||||||
|
|
||||||
@Resource
|
private final ISysDeployFormService sysDeployFormService;
|
||||||
private ISysDeployFormService sysDeployFormService;
|
|
||||||
|
|
||||||
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exist(String processDefinitionKey) {
|
public boolean exist(String processDefinitionKey) {
|
||||||
ProcessDefinitionQuery processDefinitionQuery
|
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
|
||||||
= repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey);
|
.processDefinitionKey(processDefinitionKey);
|
||||||
long count = processDefinitionQuery.count();
|
long count = processDefinitionQuery.count();
|
||||||
return count > 0;
|
return count > 0;
|
||||||
}
|
}
|
||||||
@@ -58,37 +60,78 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
|||||||
/**
|
/**
|
||||||
* 流程定义列表
|
* 流程定义列表
|
||||||
*
|
*
|
||||||
* @param pageNum 当前页码
|
* @param pageQuery 分页参数
|
||||||
* @param pageSize 每页条数
|
|
||||||
* @return 流程定义分页列表数据
|
* @return 流程定义分页列表数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize) {
|
public TableDataInfo<FlowDefinitionVo> list(PageQuery pageQuery) {
|
||||||
Page<FlowProcDefDto> page = new Page<>();
|
Page<FlowDefinitionVo> page = new Page<>();
|
||||||
// 流程定义列表数据查询
|
// 流程定义列表数据查询
|
||||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
|
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
|
||||||
// .latestVersion()
|
.latestVersion()
|
||||||
.orderByProcessDefinitionKey().asc();
|
.orderByProcessDefinitionKey().asc();
|
||||||
page.setTotal(processDefinitionQuery.count());
|
long pageTotal = processDefinitionQuery.count();
|
||||||
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageNum - 1, pageSize);
|
if (pageTotal <= 0) {
|
||||||
|
return TableDataInfo.build();
|
||||||
|
}
|
||||||
|
List<ProcessDefinition> definitionList = processDefinitionQuery.listPage(pageQuery.getPageNum() - 1, pageQuery.getPageSize());
|
||||||
|
|
||||||
List<FlowProcDefDto> dataList = new ArrayList<>();
|
List<FlowDefinitionVo> definitionVoList = new ArrayList<>();
|
||||||
for (ProcessDefinition processDefinition : processDefinitionList) {
|
for (ProcessDefinition processDefinition : definitionList) {
|
||||||
String deploymentId = processDefinition.getDeploymentId();
|
String deploymentId = processDefinition.getDeploymentId();
|
||||||
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
|
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
|
||||||
FlowProcDefDto reProcDef = new FlowProcDefDto();
|
FlowDefinitionVo vo = new FlowDefinitionVo();
|
||||||
BeanUtils.copyProperties(processDefinition, reProcDef);
|
vo.setDefinitionId(processDefinition.getId());
|
||||||
|
vo.setProcessKey(processDefinition.getKey());
|
||||||
|
vo.setProcessName(processDefinition.getName());
|
||||||
|
vo.setVersion(processDefinition.getVersion());
|
||||||
|
vo.setCategoryCode(processDefinition.getCategory());
|
||||||
|
vo.setDeploymentId(processDefinition.getDeploymentId());
|
||||||
|
vo.setSuspended(processDefinition.isSuspended());
|
||||||
SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(deploymentId);
|
SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(deploymentId);
|
||||||
if (Objects.nonNull(sysForm)) {
|
if (Objects.nonNull(sysForm)) {
|
||||||
reProcDef.setFormName(sysForm.getFormName());
|
vo.setFormId(sysForm.getFormId());
|
||||||
reProcDef.setFormId(sysForm.getFormId());
|
vo.setFormName(sysForm.getFormName());
|
||||||
}
|
}
|
||||||
// 流程定义时间
|
// 流程定义时间
|
||||||
reProcDef.setDeploymentTime(deployment.getDeploymentTime());
|
vo.setCategoryCode(deployment.getCategory());
|
||||||
dataList.add(reProcDef);
|
vo.setDeploymentTime(deployment.getDeploymentTime());
|
||||||
|
definitionVoList.add(vo);
|
||||||
}
|
}
|
||||||
page.setRecords(dataList);
|
page.setRecords(definitionVoList);
|
||||||
return page;
|
page.setTotal(pageTotal);
|
||||||
|
return TableDataInfo.build(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<FlowDefinitionVo> publishList(String processKey, PageQuery pageQuery) {
|
||||||
|
Page<FlowDefinitionVo> page = new Page<>();
|
||||||
|
// 创建查询条件
|
||||||
|
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
|
||||||
|
.processDefinitionKey(processKey)
|
||||||
|
.orderByProcessDefinitionVersion().asc();
|
||||||
|
long pageTotal = processDefinitionQuery.count();
|
||||||
|
if (pageTotal <= 0) {
|
||||||
|
return TableDataInfo.build();
|
||||||
|
}
|
||||||
|
// 根据查询条件,查询所有版本
|
||||||
|
List<ProcessDefinition> processDefinitionList = processDefinitionQuery
|
||||||
|
.listPage(pageQuery.getPageNum() - 1, pageQuery.getPageSize());
|
||||||
|
List<FlowDefinitionVo> flowDefinitionVoList = processDefinitionList.stream().map(item -> {
|
||||||
|
FlowDefinitionVo vo = new FlowDefinitionVo();
|
||||||
|
vo.setDefinitionId(item.getId());
|
||||||
|
vo.setProcessKey(item.getKey());
|
||||||
|
vo.setProcessName(item.getName());
|
||||||
|
vo.setVersion(item.getVersion());
|
||||||
|
vo.setCategoryCode(item.getCategory());
|
||||||
|
vo.setDeploymentId(item.getDeploymentId());
|
||||||
|
vo.setSuspended(item.isSuspended());
|
||||||
|
// BeanUtil.copyProperties(item, vo);
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
page.setRecords(flowDefinitionVoList);
|
||||||
|
page.setTotal(pageTotal);
|
||||||
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,51 +143,54 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
|||||||
* @param in
|
* @param in
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void importFile(String name, String category, InputStream in) {
|
public void importFile(String name, String category, InputStream in) {
|
||||||
Deployment deploy = repositoryService.createDeployment().addInputStream(name + BPMN_FILE_SUFFIX, in).name(name).category(category).deploy();
|
String processName = name + BPMN_FILE_SUFFIX;
|
||||||
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();
|
// 创建流程部署
|
||||||
repositoryService.setProcessDefinitionCategory(definition.getId(), category);
|
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment()
|
||||||
|
.name(processName)
|
||||||
|
.key(name)
|
||||||
|
.category(category)
|
||||||
|
.addInputStream(processName, in);
|
||||||
|
// 部署
|
||||||
|
deploymentBuilder.deploy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取xml
|
* 读取xml
|
||||||
*
|
*
|
||||||
* @param deployId
|
* @param definitionId 流程定义ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R readXml(String deployId) throws IOException {
|
public String readXml(String definitionId) throws IOException {
|
||||||
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
|
InputStream inputStream = repositoryService.getProcessModel(definitionId);
|
||||||
InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName());
|
return IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
|
||||||
String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
|
|
||||||
return R.success("", result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取xml
|
* 读取xml
|
||||||
*
|
*
|
||||||
* @param deployId
|
* @param definitionId 流程定义ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public InputStream readImage(String deployId) {
|
public InputStream readImage(String definitionId) {
|
||||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
|
|
||||||
//获得图片流
|
//获得图片流
|
||||||
DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
|
DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
|
||||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionId);
|
||||||
//输出为图片
|
//输出为图片
|
||||||
return diagramGenerator.generateDiagram(
|
return diagramGenerator.generateDiagram(
|
||||||
bpmnModel,
|
bpmnModel,
|
||||||
"png",
|
"png",
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
"宋体",
|
"宋体",
|
||||||
"宋体",
|
"宋体",
|
||||||
"宋体",
|
"宋体",
|
||||||
null,
|
null,
|
||||||
1.0,
|
1.0,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,12 +203,12 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public R startProcessInstanceById(String procDefId, Map<String, Object> variables) {
|
public void startProcessInstanceById(String procDefId, Map<String, Object> variables) {
|
||||||
try {
|
try {
|
||||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
|
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
|
||||||
.latestVersion().singleResult();
|
.latestVersion().singleResult();
|
||||||
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
|
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
|
||||||
return R.error("流程已被挂起,请先激活流程");
|
throw new ServiceException("流程已被挂起,请先激活流程");
|
||||||
}
|
}
|
||||||
// variables.put("skip", true);
|
// variables.put("skip", true);
|
||||||
// variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
|
// variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
|
||||||
@@ -175,17 +221,15 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
|||||||
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
|
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
|
||||||
if (Objects.nonNull(task)) {
|
if (Objects.nonNull(task)) {
|
||||||
if (!StrUtil.equalsAny(task.getAssignee(), UserIdStr)) {
|
if (!StrUtil.equalsAny(task.getAssignee(), UserIdStr)) {
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
throw new ServiceException("数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!");
|
||||||
return R.error("数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!");
|
|
||||||
}
|
}
|
||||||
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), LoginUtils.getNickName() + "发起流程申请");
|
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), LoginUtils.getNickName() + "发起流程申请");
|
||||||
// taskService.setAssignee(task.getId(), UserIdStr);
|
// taskService.setAssignee(task.getId(), UserIdStr);
|
||||||
taskService.complete(task.getId(), variables);
|
taskService.complete(task.getId(), variables);
|
||||||
}
|
}
|
||||||
return R.success("流程启动成功");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return R.error("流程启动错误");
|
throw new ServiceException("流程启动错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,19 +237,17 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
|||||||
/**
|
/**
|
||||||
* 激活或挂起流程定义
|
* 激活或挂起流程定义
|
||||||
*
|
*
|
||||||
* @param state 状态
|
* @param suspended 是否暂停状态
|
||||||
* @param deployId 流程部署ID
|
* @param definitionId 流程定义ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Integer state, String deployId) {
|
public void updateState(Boolean suspended, String definitionId) {
|
||||||
ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
|
if (!suspended) {
|
||||||
// 激活
|
// 激活
|
||||||
if (state == 1) {
|
repositoryService.activateProcessDefinitionById(definitionId, true, null);
|
||||||
repositoryService.activateProcessDefinitionById(procDef.getId(), true, null);
|
} else {
|
||||||
}
|
// 挂起
|
||||||
// 挂起
|
repositoryService.suspendProcessDefinitionById(definitionId, true, null);
|
||||||
if (state == 2) {
|
|
||||||
repositoryService.suspendProcessDefinitionById(procDef.getId(), true, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,16 @@ export function listDefinition(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询指定流程发布的版本列表
|
||||||
|
export function publishList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/workflow/definition/publishList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 部署流程实例
|
// 部署流程实例
|
||||||
export function definitionStart(procDefId,data) {
|
export function definitionStart(procDefId,data) {
|
||||||
return request({
|
return request({
|
||||||
@@ -54,9 +64,9 @@ export function roleList(query) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 读取xml文件
|
// 读取xml文件
|
||||||
export function readXml(deployId) {
|
export function readXml(definitionId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/workflow/definition/readXml/' + deployId,
|
url: '/workflow/definition/readXml/' + definitionId,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -85,24 +95,6 @@ export function saveXml(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增流程定义
|
|
||||||
export function addDeployment(data) {
|
|
||||||
return request({
|
|
||||||
url: '/system/deployment',
|
|
||||||
method: 'post',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改流程定义
|
|
||||||
export function updateDeployment(data) {
|
|
||||||
return request({
|
|
||||||
url: '/system/deployment',
|
|
||||||
method: 'put',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除流程定义
|
// 删除流程定义
|
||||||
export function delDeployment(query) {
|
export function delDeployment(query) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<process-designer :key="`designer-${loadIndex}`" :flowEntryInfo="formFlowEntryData" @save="onSaveFlowEntry" />
|
<process-designer
|
||||||
|
v-loading="loading"
|
||||||
|
:key="`designer-${loadIndex}`"
|
||||||
|
:flowEntryInfo="formFlowEntryData"
|
||||||
|
@save="onSaveFlowEntry"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -14,6 +19,7 @@ export default {
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
loadIndex: 0,
|
loadIndex: 0,
|
||||||
|
loading: false,
|
||||||
formFlowEntryData: {
|
formFlowEntryData: {
|
||||||
entryId: undefined,
|
entryId: undefined,
|
||||||
processDefinitionName: undefined,
|
processDefinitionName: undefined,
|
||||||
@@ -39,10 +45,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
const deployId = this.$route.query && this.$route.query.deployId;
|
const definitionId = this.$route.query && this.$route.query.definitionId;
|
||||||
// 查询流程xml
|
// 查询流程xml
|
||||||
if (deployId) {
|
if (definitionId) {
|
||||||
this.getModelDetail(deployId);
|
this.getModelDetail(definitionId);
|
||||||
}
|
}
|
||||||
this.getDicts("sys_process_category").then(res => {
|
this.getDicts("sys_process_category").then(res => {
|
||||||
this.categorys = res.data;
|
this.categorys = res.data;
|
||||||
@@ -50,11 +56,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** xml 文件 */
|
/** xml 文件 */
|
||||||
getModelDetail(deployId) {
|
getModelDetail(definitionId) {
|
||||||
|
this.loading = true;
|
||||||
// 发送请求,获取xml
|
// 发送请求,获取xml
|
||||||
readXml(deployId).then(res =>{
|
readXml(definitionId).then(res =>{
|
||||||
this.formFlowEntryData.bpmnXml = res.data;
|
this.formFlowEntryData.bpmnXml = res.data;
|
||||||
this.loadIndex = deployId;
|
this.loadIndex = definitionId;
|
||||||
|
this.loading = false;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSaveFlowEntry ({ saveData, modeler }) {
|
onSaveFlowEntry ({ saveData, modeler }) {
|
||||||
|
|||||||
@@ -67,18 +67,17 @@
|
|||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" fit :data="definitionList" border @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" fit :data="definitionList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<el-table-column label="流程编号" align="center" prop="deploymentId" :show-overflow-tooltip="true"/>
|
<el-table-column label="流程标识" align="center" prop="processKey" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="流程标识" align="center" prop="key" :show-overflow-tooltip="true" />
|
|
||||||
<el-table-column label="流程分类" align="center" prop="category" />
|
|
||||||
<el-table-column label="流程名称" align="center" :show-overflow-tooltip="true">
|
<el-table-column label="流程名称" align="center" :show-overflow-tooltip="true">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button type="text" @click="handleReadImage(scope.row)">
|
<el-button type="text" @click="handleProcessView(scope.row)">
|
||||||
<span>{{ scope.row.name }}</span>
|
<span>{{ scope.row.processName }}</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="流程分类" align="center" prop="categoryCode" />
|
||||||
<el-table-column label="业务表单" align="center" :show-overflow-tooltip="true">
|
<el-table-column label="业务表单" align="center" :show-overflow-tooltip="true">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button v-if="scope.row.formId" type="text" @click="handleForm(scope.row.formId)">
|
<el-button v-if="scope.row.formId" type="text" @click="handleForm(scope.row.formId)">
|
||||||
@@ -94,33 +93,44 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="状态" align="center">
|
<el-table-column label="状态" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-tag type="success" v-if="scope.row.suspensionState === 1">激活</el-tag>
|
<el-tag type="success" v-if="!scope.row.suspended">激活</el-tag>
|
||||||
<el-tag type="warning" v-if="scope.row.suspensionState === 2">挂起</el-tag>
|
<el-tag type="warning" v-if="scope.row.suspended">挂起</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180"/>
|
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180"/>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="mini"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleLoadXml(scope.row)"
|
||||||
|
>编辑</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="mini"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-hasPermi="['system:deployment:remove']"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
>删除</el-button>
|
||||||
<el-dropdown>
|
<el-dropdown>
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link">
|
||||||
更多操作<i class="el-icon-arrow-down el-icon--right"></i>
|
<i class="el-icon-d-arrow-right el-icon--right"></i>更多
|
||||||
</span>
|
</span>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item icon="el-icon-edit-outline" @click.native="handleLoadXml(scope.row)">
|
<el-dropdown-item
|
||||||
编辑
|
icon="el-icon-view"
|
||||||
</el-dropdown-item>
|
@click.native="handleProcessView(scope.row)"
|
||||||
<el-dropdown-item icon="el-icon-connection" @click.native="handleAddForm(scope.row)" v-if="scope.row.formId == null">
|
>流程图</el-dropdown-item>
|
||||||
配置表单
|
<el-dropdown-item
|
||||||
</el-dropdown-item>
|
icon="el-icon-connection"
|
||||||
<el-dropdown-item icon="el-icon-video-pause" @click.native="handleUpdateSuspensionState(scope.row)" v-if="scope.row.suspensionState === 1">
|
@click.native="handleAddForm(scope.row)"
|
||||||
挂起
|
v-if="scope.row.formId == null"
|
||||||
</el-dropdown-item>
|
>配置表单</el-dropdown-item>
|
||||||
<el-dropdown-item icon="el-icon-video-play" @click.native="handleUpdateSuspensionState(scope.row)" v-if="scope.row.suspensionState === 2">
|
<el-dropdown-item
|
||||||
激活
|
icon="el-icon-price-tag"
|
||||||
</el-dropdown-item>
|
@click.native="handlePublish(scope.row)"
|
||||||
<el-dropdown-item icon="el-icon-delete" @click.native="handleDelete(scope.row)" v-hasPermi="['system:deployment:remove']">
|
>版本管理</el-dropdown-item>
|
||||||
删除
|
|
||||||
</el-dropdown-item>
|
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</template>
|
</template>
|
||||||
@@ -128,27 +138,13 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination
|
||||||
v-show="total>0"
|
v-show="total > 0"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page.sync="queryParams.pageNum"
|
:page.sync="queryParams.pageNum"
|
||||||
:limit.sync="queryParams.pageSize"
|
:limit.sync="queryParams.pageSize"
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 添加或修改流程定义对话框 -->
|
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
||||||
<el-form-item label="看看" prop="name">
|
|
||||||
<el-input v-model="form.name" placeholder="请输入看看" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
||||||
<el-button @click="cancel">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- bpmn20.xml导入对话框 -->
|
<!-- bpmn20.xml导入对话框 -->
|
||||||
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||||
<el-upload
|
<el-upload
|
||||||
@@ -181,18 +177,76 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 流程图 -->
|
<!-- 流程图 -->
|
||||||
<el-dialog :title="processViewerData.title" :visible.sync="processViewerData.open" width="70%" append-to-body>
|
<el-dialog :title="processView.title" :visible.sync="processView.open" width="70%" append-to-body>
|
||||||
<process-viewer :xml="xmlData" :style="{height: '400px'}" />
|
<process-viewer :xml="processView.xmlData" :style="{height: '400px'}" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!--表单配置详情-->
|
<!-- 版本管理 -->
|
||||||
|
<el-dialog title="版本管理" :visible.sync="publish.open" width="50%" append-to-body>
|
||||||
|
<el-table v-loading="publish.loading" :data="publish.dataList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="流程标识" align="center" prop="processKey" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="流程名称" align="center" :show-overflow-tooltip="true">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" @click="handleProcessView(scope.row)">
|
||||||
|
<span>{{ scope.row.processName }}</span>
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="流程版本" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="状态" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag type="success" v-if="!scope.row.suspended">激活</el-tag>
|
||||||
|
<el-tag type="warning" v-if="scope.row.suspended">挂起</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="mini"
|
||||||
|
icon="el-icon-video-pause"
|
||||||
|
v-if="!scope.row.suspended"
|
||||||
|
@click.native="handleUpdateSuspended(scope.row)"
|
||||||
|
>挂起</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="mini"
|
||||||
|
icon="el-icon-video-play"
|
||||||
|
v-if="scope.row.suspended"
|
||||||
|
@click.native="handleUpdateSuspended(scope.row)"
|
||||||
|
>激活</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="mini"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-hasPermi="['system:deployment:remove']"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination
|
||||||
|
v-show="publishTotal > 0"
|
||||||
|
:total="publishTotal"
|
||||||
|
:page.sync="publishQueryParams.pageNum"
|
||||||
|
:limit.sync="publishQueryParams.pageSize"
|
||||||
|
@pagination="getPublishList"
|
||||||
|
/>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 表单配置详情 -->
|
||||||
<el-dialog :title="formTitle" :visible.sync="formConfOpen" width="50%" append-to-body>
|
<el-dialog :title="formTitle" :visible.sync="formConfOpen" width="50%" append-to-body>
|
||||||
<div class="test-form">
|
<div class="test-form">
|
||||||
<parser :key="new Date().getTime()" :form-conf="formConf" />
|
<parser :key="new Date().getTime()" :form-conf="formConf" />
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!--挂载表单-->
|
<!-- 挂载表单 -->
|
||||||
<el-dialog :title="formDeployTitle" :visible.sync="formDeployOpen" width="60%" append-to-body>
|
<el-dialog :title="formDeployTitle" :visible.sync="formDeployOpen" width="60%" append-to-body>
|
||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
<el-col :span="10" :xs="24">
|
<el-col :span="10" :xs="24">
|
||||||
@@ -233,7 +287,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listDefinition, updateState, delDeployment, addDeployment, updateDeployment, exportDeployment, definitionStart, readXml} from "@/api/workflow/definition";
|
import { listDefinition, publishList, updateState, delDeployment, exportDeployment, definitionStart, readXml} from "@/api/workflow/definition";
|
||||||
import { getToken } from "@/utils/auth";
|
import { getToken } from "@/utils/auth";
|
||||||
import { getForm, addDeployForm ,listForm } from "@/api/workflow/form";
|
import { getForm, addDeployForm ,listForm } from "@/api/workflow/form";
|
||||||
import Parser from '@/utils/generator/parser'
|
import Parser from '@/utils/generator/parser'
|
||||||
@@ -261,10 +315,17 @@ export default {
|
|||||||
total: 0,
|
total: 0,
|
||||||
// 流程定义表格数据
|
// 流程定义表格数据
|
||||||
definitionList: [],
|
definitionList: [],
|
||||||
// 弹出层标题
|
publish: {
|
||||||
title: "",
|
open: false,
|
||||||
// 是否显示弹出层
|
loading: false,
|
||||||
open: false,
|
dataList: []
|
||||||
|
},
|
||||||
|
publishTotal: 0,
|
||||||
|
publishQueryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
processKey: ""
|
||||||
|
},
|
||||||
formConfOpen: false,
|
formConfOpen: false,
|
||||||
formTitle: "",
|
formTitle: "",
|
||||||
formDeployOpen: false,
|
formDeployOpen: false,
|
||||||
@@ -272,9 +333,10 @@ export default {
|
|||||||
formList: [],
|
formList: [],
|
||||||
formTotal:0,
|
formTotal:0,
|
||||||
formConf: {}, // 默认表单数据
|
formConf: {}, // 默认表单数据
|
||||||
processViewerData: {
|
processView: {
|
||||||
title: '',
|
title: '',
|
||||||
open: false,
|
open: false,
|
||||||
|
xmlData:"",
|
||||||
},
|
},
|
||||||
// bpmn.xml 导入
|
// bpmn.xml 导入
|
||||||
upload: {
|
upload: {
|
||||||
@@ -315,8 +377,6 @@ export default {
|
|||||||
deployId: null
|
deployId: null
|
||||||
},
|
},
|
||||||
currentRow: null,
|
currentRow: null,
|
||||||
// xml
|
|
||||||
xmlData:"",
|
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
@@ -332,15 +392,18 @@ export default {
|
|||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listDefinition(this.queryParams).then(response => {
|
listDefinition(this.queryParams).then(response => {
|
||||||
this.definitionList = response.data.records;
|
this.definitionList = response.rows;
|
||||||
this.total = response.data.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 取消按钮
|
getPublishList() {
|
||||||
cancel() {
|
this.publish.loading = true;
|
||||||
this.open = false;
|
publishList(this.publishQueryParams).then(response => {
|
||||||
this.reset();
|
this.publish.dataList = response.rows;
|
||||||
|
this.publishTotal = response.total;
|
||||||
|
this.publish.loading = false;
|
||||||
|
})
|
||||||
},
|
},
|
||||||
// 表单重置
|
// 表单重置
|
||||||
reset() {
|
reset() {
|
||||||
@@ -371,31 +434,20 @@ export default {
|
|||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map(item => item.id)
|
this.ids = selection.map(item => item.id)
|
||||||
this.single = selection.length!==1
|
this.single = selection.length !== 1
|
||||||
this.multiple = !selection.length
|
this.multiple = !selection.length
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
|
||||||
handleAdd() {
|
|
||||||
this.reset();
|
|
||||||
this.open = true;
|
|
||||||
this.title = "添加流程定义";
|
|
||||||
},
|
|
||||||
/** 跳转到流程设计页面 */
|
/** 跳转到流程设计页面 */
|
||||||
handleLoadXml(row){
|
handleLoadXml(row){
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
path: '/definition/designer/index',
|
path: '/definition/designer/index',
|
||||||
query: { deployId: row.deploymentId }
|
query: { definitionId: row.definitionId }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/** 流程图查看 */
|
handlePublish(row) {
|
||||||
handleReadImage(row) {
|
this.publishQueryParams.processKey = row.processKey;
|
||||||
let deploymentId = row.deploymentId;
|
this.publish.open = true;
|
||||||
this.processViewerData.title = "流程图";
|
this.getPublishList();
|
||||||
// 发送请求,获取xml
|
|
||||||
readXml(deploymentId).then(res => {
|
|
||||||
this.xmlData = res.data;
|
|
||||||
this.processViewerData.open = true;
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
/** 表单查看 */
|
/** 表单查看 */
|
||||||
handleForm(formId){
|
handleForm(formId){
|
||||||
@@ -411,6 +463,16 @@ export default {
|
|||||||
this.$modal.msgSuccess(res.msg);
|
this.$modal.msgSuccess(res.msg);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/** 查看流程图 */
|
||||||
|
handleProcessView(row) {
|
||||||
|
let definitionId = row.definitionId;
|
||||||
|
this.processView.title = "流程图";
|
||||||
|
// 发送请求,获取xml
|
||||||
|
readXml(definitionId).then(res => {
|
||||||
|
this.processView.xmlData = res.data;
|
||||||
|
this.processView.open = true;
|
||||||
|
})
|
||||||
|
},
|
||||||
/** 挂载表单弹框 */
|
/** 挂载表单弹框 */
|
||||||
handleAddForm(row){
|
handleAddForm(row){
|
||||||
this.formDeployParam.deployId = row.deploymentId
|
this.formDeployParam.deployId = row.deploymentId
|
||||||
@@ -453,18 +515,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 挂起/激活流程 */
|
/** 挂起/激活流程 */
|
||||||
handleUpdateSuspensionState(row){
|
handleUpdateSuspended(row) {
|
||||||
let state = 1;
|
|
||||||
if (row.suspensionState === 1) {
|
|
||||||
state = 2
|
|
||||||
}
|
|
||||||
const params = {
|
const params = {
|
||||||
deployId: row.deploymentId,
|
definitionId: row.definitionId,
|
||||||
state: state
|
suspended: !row.suspended
|
||||||
}
|
}
|
||||||
updateState(params).then(res => {
|
updateState(params).then(res => {
|
||||||
this.$modal.msgSuccess(res.msg)
|
this.$modal.msgSuccess(res.msg)
|
||||||
this.getList();
|
this.getPublishList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
@@ -477,26 +535,6 @@ export default {
|
|||||||
this.title = "修改流程定义";
|
this.title = "修改流程定义";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
|
||||||
submitForm() {
|
|
||||||
this.$refs["form"].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
if (this.form.id != null) {
|
|
||||||
updateDeployment(this.form).then(response => {
|
|
||||||
this.$modal.msgSuccess("修改成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
addDeployment(this.form).then(response => {
|
|
||||||
this.$modal.msgSuccess("新增成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
// const ids = row.deploymentId || this.ids;
|
// const ids = row.deploymentId || this.ids;
|
||||||
|
|||||||
Reference in New Issue
Block a user