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

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

         1、后端部分

         其中FormConf修改如下:

package com.ruoyi.flowable.core;

import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * 表单属性类
 *
 * @author KonBAI
 * @createTime 2022/8/6 18:54
 */
@Data
public class FormConf {
	
	/**
     * 标题
     */
    private String title;

    /**
     * 表单列表
     */
    
    private List> list;

    /**
     * 表单配置名
     */
    
    private Map config;
    
    /**
     * 表单列表实际值
     */
    private Map formValues;
    
}

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

/**
     * 获取历史流程表单信息
     */
    private List processFormList(BpmnModel bpmnModel, HistoricProcessInstance historicProcIns) {
        List procFormList = new ArrayList<>();

        List activityInstanceList = historyService.createHistoricActivityInstanceQuery()
            .processInstanceId(historicProcIns.getId()).finished()
            .activityTypes(CollUtil.newHashSet(BpmnXMLConstants.ELEMENT_EVENT_START, BpmnXMLConstants.ELEMENT_TASK_USER))
            .orderByHistoricActivityInstanceStartTime().asc()
            .list();
        List processFormKeys = new ArrayList<>();
        for (HistoricActivityInstance activityInstance : activityInstanceList) {
            // 获取当前节点流程元素信息
            FlowElement flowElement = ModelUtils.getFlowElementById(bpmnModel, activityInstance.getActivityId());
            // 获取当前节点表单Key
            String formKey = ModelUtils.getFormKey(flowElement);
            if (formKey == null) {
                continue;
            }
            boolean localScope = Convert.toBool(ModelUtils.getElementAttributeValue(flowElement, ProcessConstants.PROCESS_FORM_LOCAL_SCOPE), false);
            Map variables;
            if (localScope) {
                // 查询任务节点参数,并转换成Map
                variables = historyService.createHistoricVariableInstanceQuery()
                    .processInstanceId(historicProcIns.getId())
                    .taskId(activityInstance.getTaskId())
                    .list()
                    .stream()
                    .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, HistoricVariableInstance::getValue));
            } else {
                if (processFormKeys.contains(formKey)) {
                    continue;
                }
                variables = historicProcIns.getProcessVariables();
                processFormKeys.add(formKey);
            }  
           
            Map formvariables = new HashedMap();
            //遍历Map
            if(variables.containsKey("variables")) {
              formvariables = (Map)((Map) variables.get("variables")).get("formValue");
            }
 
            // 非节点表单此处查询结果可能有多条,只获取第一条信息
            List formInfoList = deployFormMapper.selectVoList(new LambdaQueryWrapper()
                .eq(WfDeployForm::getDeployId, historicProcIns.getDeploymentId())
                .eq(WfDeployForm::getFormKey, formKey)
                .eq(localScope, WfDeployForm::getNodeKey, flowElement.getId()));

            //@update by Brath:避免空集合导致的NULL空指针
            WfDeployFormVo formInfo = formInfoList.stream().findFirst().orElse(null);
         
            if (ObjectUtil.isNotNull(formInfo)) {
                // 旧数据 formInfo.getFormName() 为 null
                String formName = Optional.ofNullable(formInfo.getFormName()).orElse(StringUtils.EMPTY);
                String title = localScope ? formName.concat("(" + flowElement.getName() + ")") : formName;
                FormConf formConf = JsonUtils.parseObject(formInfo.getContent(), FormConf.class);
                if (null != formConf) {
                    //ProcessFormUtils.fillFormData(formConf, variables);
                	formConf.setTitle(title);
                	formConf.setFormValues(formvariables);
                    procFormList.add(formConf);
                }
            }
        }
        return procFormList;
    }

2、前端部分

 表单信息修改如下:


        

流程详细信息修改如下:

getProcessDetails(procInsId, taskId) {
      const params = {procInsId: procInsId, taskId: taskId}
      detailProcess(params).then(res => {
        console.log("detailProcess res=",res);
        const data = res.data;
        this.xmlData = data.bpmnXml;
        this.processFormList = data.processFormList;
        this.processFormList.forEach((item, index) => {
          this.formVal[index] = JSON.stringify(item.formValues);
          this.formViewData[index] = JSON.stringify(item);
        });
        this.taskFormOpen = data.existTaskForm;
        if (this.taskFormOpen) {
          this.taskFormData = data.taskFormData;
        }
        this.historyProcNodeList = data.historyProcNodeList;
        this.finishedInfo = data.flowViewer;
        this.formOpen = true
      })
    },

3、效果图如下:

nbcio-boot移植到若依ruoyi-nbcio平台里一formdesigner部分(四)_第1张图片

nbcio-boot移植到若依ruoyi-nbcio平台里一formdesigner部分(四)_第2张图片

你可能感兴趣的:(ruoyi-nbcio,java开发,vue,ruoyi-nbcio,formdesigner,nbcio-boot)