• nbcio-boot移植到若依ruoyi-nbcio平台里一formdesigner部分(四)


            到目前为止,虽然基础的formdesigner部分已经完成,但流程用formdesigner提交与审批过程中的显示还有问题。

             1、后端部分

             其中FormConf修改如下:

    1. package com.ruoyi.flowable.core;
    2. import lombok.Data;
    3. import java.util.List;
    4. import java.util.Map;
    5. /**
    6. * 表单属性类
    7. *
    8. * @author KonBAI
    9. * @createTime 2022/8/6 18:54
    10. */
    11. @Data
    12. public class FormConf {
    13. /**
    14. * 标题
    15. */
    16. private String title;
    17. /**
    18. * 表单列表
    19. */
    20. private List> list;
    21. /**
    22. * 表单配置名
    23. */
    24. private Map config;
    25. /**
    26. * 表单列表实际值
    27. */
    28. private Map formValues;
    29. }

       获取流程历史信息修改如下:

    1. /**
    2. * 获取历史流程表单信息
    3. */
    4. private List processFormList(BpmnModel bpmnModel, HistoricProcessInstance historicProcIns) {
    5. List procFormList = new ArrayList<>();
    6. List activityInstanceList = historyService.createHistoricActivityInstanceQuery()
    7. .processInstanceId(historicProcIns.getId()).finished()
    8. .activityTypes(CollUtil.newHashSet(BpmnXMLConstants.ELEMENT_EVENT_START, BpmnXMLConstants.ELEMENT_TASK_USER))
    9. .orderByHistoricActivityInstanceStartTime().asc()
    10. .list();
    11. List processFormKeys = new ArrayList<>();
    12. for (HistoricActivityInstance activityInstance : activityInstanceList) {
    13. // 获取当前节点流程元素信息
    14. FlowElement flowElement = ModelUtils.getFlowElementById(bpmnModel, activityInstance.getActivityId());
    15. // 获取当前节点表单Key
    16. String formKey = ModelUtils.getFormKey(flowElement);
    17. if (formKey == null) {
    18. continue;
    19. }
    20. boolean localScope = Convert.toBool(ModelUtils.getElementAttributeValue(flowElement, ProcessConstants.PROCESS_FORM_LOCAL_SCOPE), false);
    21. Map variables;
    22. if (localScope) {
    23. // 查询任务节点参数,并转换成Map
    24. variables = historyService.createHistoricVariableInstanceQuery()
    25. .processInstanceId(historicProcIns.getId())
    26. .taskId(activityInstance.getTaskId())
    27. .list()
    28. .stream()
    29. .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, HistoricVariableInstance::getValue));
    30. } else {
    31. if (processFormKeys.contains(formKey)) {
    32. continue;
    33. }
    34. variables = historicProcIns.getProcessVariables();
    35. processFormKeys.add(formKey);
    36. }
    37. Map formvariables = new HashedMap();
    38. //遍历Map
    39. if(variables.containsKey("variables")) {
    40. formvariables = (Map)((Map) variables.get("variables")).get("formValue");
    41. }
    42. // 非节点表单此处查询结果可能有多条,只获取第一条信息
    43. List formInfoList = deployFormMapper.selectVoList(new LambdaQueryWrapper()
    44. .eq(WfDeployForm::getDeployId, historicProcIns.getDeploymentId())
    45. .eq(WfDeployForm::getFormKey, formKey)
    46. .eq(localScope, WfDeployForm::getNodeKey, flowElement.getId()));
    47. //@update by Brath:避免空集合导致的NULL空指针
    48. WfDeployFormVo formInfo = formInfoList.stream().findFirst().orElse(null);
    49. if (ObjectUtil.isNotNull(formInfo)) {
    50. // 旧数据 formInfo.getFormName() 为 null
    51. String formName = Optional.ofNullable(formInfo.getFormName()).orElse(StringUtils.EMPTY);
    52. String title = localScope ? formName.concat("(" + flowElement.getName() + ")") : formName;
    53. FormConf formConf = JsonUtils.parseObject(formInfo.getContent(), FormConf.class);
    54. if (null != formConf) {
    55. //ProcessFormUtils.fillFormData(formConf, variables);
    56. formConf.setTitle(title);
    57. formConf.setFormValues(formvariables);
    58. procFormList.add(formConf);
    59. }
    60. }
    61. }
    62. return procFormList;
    63. }

    2、前端部分

     表单信息修改如下:

    1. "表单信息" name="form">
    2. <div v-if="formOpen">
    3. <el-card class="box-card" shadow="never" v-for="(formInfo, index) in formViewData" :key="index">
    4. <el-col :span="20" :offset="2">
    5. <form-viewer ref="formViewer" v-model="formVal[index]" :buildData="formInfo" />
    6. el-col>
    7. el-card>
    8. div>

    流程详细信息修改如下:

    1. getProcessDetails(procInsId, taskId) {
    2. const params = {procInsId: procInsId, taskId: taskId}
    3. detailProcess(params).then(res => {
    4. console.log("detailProcess res=",res);
    5. const data = res.data;
    6. this.xmlData = data.bpmnXml;
    7. this.processFormList = data.processFormList;
    8. this.processFormList.forEach((item, index) => {
    9. this.formVal[index] = JSON.stringify(item.formValues);
    10. this.formViewData[index] = JSON.stringify(item);
    11. });
    12. this.taskFormOpen = data.existTaskForm;
    13. if (this.taskFormOpen) {
    14. this.taskFormData = data.taskFormData;
    15. }
    16. this.historyProcNodeList = data.historyProcNodeList;
    17. this.finishedInfo = data.flowViewer;
    18. this.formOpen = true
    19. })
    20. },

    3、效果图如下:

  • 相关阅读:
    Live800:三点自测,你的客服系统该升级了吗?
    mmdetection--pointpillars-demo运行
    【Python】第十一课 模块
    springboot + activiti实现activiti微服务化
    软件生命周期过程
    CMD常用命令大全「值得收藏」
    数据库内核面试中我不会的问题(6)
    blender 常用修改器
    nginx的重定向(rewrite)
    AWS SAA-C03 #217
  • 原文地址:https://blog.csdn.net/qq_40032778/article/details/132870312