因为这个项目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、效果图