基于jeecgboot-vue3的Flowable流程-流程处理(二)

因为这个项目license问题无法开源,更多技术支持与服务请加入我的知识星球。

对应VForm3,原先的后端解析也要做调整

1、获取历史任务的表单信息

// 获取历史任务节点表单数据值
                    List<HistoricVariableInstance> listHistoricVariableInstance = historyService.createHistoricVariableInstanceQuery()
                    .processInstanceId(procInsId)
                    .taskId(histIns.getTaskId())
                    .list();  
                    
                    Map<String, Object> variables = new HashedMap<String, Object>();
                    Map<String, Object> formconf = new HashedMap<String, Object>();
                    
                    for(HistoricVariableInstance historicVariableInstance:listHistoricVariableInstance) {
                    	variables.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue());
                    }
                    formconf.put("formValue", variables);
                     // 获取历史任务节点表单参数
                    if(Objects.nonNull(histIns.getTaskId())) {
    	        		HistoricTaskInstance taskIns = historyService.createHistoricTaskInstanceQuery()
    	                    .taskId(histIns.getTaskId())
    	                    .includeIdentityLinks()
    	                    .includeProcessVariables()
    	                    .includeTaskLocalVariables()
    	                    .finished()
    	                    .singleResult();
    	                if (Objects.nonNull(taskIns)) {
    	                {
    	                  String formId = taskIns.getFormKey();
    	                  SysForm sysForm = sysDeployFormService.selectCurSysDeployForm(formId, deployId, taskIns.getTaskDefinitionKey());
    	                  if (Objects.nonNull(sysForm)) {
    	                	  Map<String, Object> formModel = JSONObject.parseObject(sysForm.getFormContent(), Map.class);
    	                	  //formconf.put("config", JSONObject.parseObject(sysForm.getFormContent()).get("config"));
    	                	  //formconf.put("list", JSONObject.parseObject(sysForm.getFormContent()).get("list"));
    	                	  formconf.put("formModel",formModel);
    	                	  formconf.put("formData", variables);
    		              }
    	                }
    	        	  }
                    }    
                    flowTask.setTaskFormValues(formconf);

2、完成按钮的流程处理代码,主要是校验,同时打开对话框

/** 审批任务选择 */
  const handleComplete = () => {
    console.log('taskFormBuilder=', taskFormBuilder);
    const taskFormRef = taskFormBuilder.value;
    console.log('taskFormRef=', taskFormRef);
    const isExistTaskForm = taskFormRef !== null;
    // 若无任务表单,则 taskFormPromise 为 true,即不需要校验
    taskFormRef?.validateForm(async (valid: boolean) => {
      console.log("valid",valid)
      if (valid) {
        if (isExistTaskForm) {
          //校验通过
          completeOpen.value = true;
          completeTitle.value = '审批流程';
          getTreeselect();
        }
      }  
    });
  };

3、支持完成方法

/** 审批任务 */
  const taskComplete = (approved) => {
    if (taskForm.hasOwnProperty('values')) {
      if (
        (!taskForm.values.hasOwnProperty('approval') || (taskForm.values.hasOwnProperty('approval') && taskForm.values.approval === '')) &&
        checkSendUser.value
      ) {
        if (!taskForm.hasOwnProperty('nextUsers') || (taskForm.hasOwnProperty('nextUsers') && taskForm.nextUsers === '')) {
          createMessage.error('请选择流程接收人员或选择下一审批人');
          return;
        }
      } else if (checkSendUser.value && taskForm.values.hasOwnProperty('approval') && taskForm.values.approval.split(',').length > 1) {
        createMessage.error('目前流程只能选择一个接收人员');
        return;
      }
    }

    if (!taskForm.comment) {
      createMessage.error('请输入审批意见');
      return;
    }
    const taskFormRef = taskFormBuilder.value;
    const isExistTaskForm = taskFormRef !== null;
    if (isExistTaskForm) {
      //流程里的设置表单
      console.log("taskFormRef",taskFormRef);
      taskForm.values.taskformvalues = taskFormRef.formDataModel;
    }
    if (startUserForm.isStartUserNode && startUserForm.editFormType === 'oa') {
      refStartBuilder.value.validate();
      const approval = taskForm.values.approval;
      const data = refStartBuilder.value.getFormData();
      formData.value = JSON.parse(JSON.stringify(data)); //需要转换一下
      const variables = formData.value;
      console.log('variables=', variables);
      taskForm.variables = variables;
      taskForm.values = variables;
      if (approval) {
        taskForm.values.approval = approval;
      }
    }
    if (startUserForm.isStartUserNode && startUserForm.editFormType === 'zdyyw') {
      //createMessage.error("目前还不支持自定义表单的编辑修改功能!!!");
      //$refs.refCustomForm.submitForm();
    }
    if (startUserForm.isStartUserNode && startUserForm.editFormType === 'online') {
      createMessage.error('目前还不支持online表单的编辑修改功能!!!');
      //$refs.refViewOnlForm.submitForm();
    }
    taskForm.approved = approved; //对特殊通用同意拒绝排它网关的处理
    taskForm.ccUsers = taskForm.ccUsers?.join(',');
    taskForm.nextUsers = taskForm.nextUsers?.join(',');
    console.log('taskForm=', taskForm);
    complete(taskForm).then((response) => {
      createMessage.success(response.message);
      goBack();
    });
  };

4、效果图

最近更新

  1. TCP协议是安全的吗?

    2024-06-15 00:24:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-15 00:24:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-15 00:24:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-15 00:24:02       20 阅读

热门阅读

  1. ant-desigin-vue动态表头并填充数据

    2024-06-15 00:24:02       9 阅读
  2. DataCap 自定义 File 转换器

    2024-06-15 00:24:02       7 阅读
  3. 组合函数的实现

    2024-06-15 00:24:02       8 阅读
  4. CLIPSeg

    CLIPSeg

    2024-06-15 00:24:02      8 阅读
  5. 6.14--CSS

    2024-06-15 00:24:02       8 阅读
  6. kotlin 中的布尔

    2024-06-15 00:24:02       8 阅读
  7. 实体类的注解

    2024-06-15 00:24:02       5 阅读
  8. 主机加固的几点建议

    2024-06-15 00:24:02       10 阅读
  9. C++算法-青蛙跳台阶【面试】

    2024-06-15 00:24:02       8 阅读