05 Apex 集成 Activiti

Demo 链接: https://pan.baidu.com/s/1H6UxTvtQwyDFqrgr2Qs9PA 提取码: z4p2

05.1 获取流程信息:

select

流程节点, 处理人, 开始时间, 结束时间, 审批意见 from bpm.v_process_hi where PROC_INST_ID_ = :P13_PID order by 结束时间 desc

05.2 获取流程跟踪图片:

select ACT_GE_BYTEARRAY.BYTES_ from bpm.ACT_GE_BYTEARRAY 

  inner join bpm.act_re_procdef on act_re_procdef.DEPLOYMENT_ID_ =  ACT_GE_BYTEARRAY.DEPLOYMENT_ID_ 
  and act_re_procdef.DGRM_RESOURCE_NAME_ = ACT_GE_BYTEARRAY.name_
  inner JOIN bpm.ACT_HI_PROCINST on ACT_HI_PROCINST.PROC_DEF_ID_ = act_re_procdef.id_ and ACT_HI_PROCINST.PROC_INST_ID_ = :P13_PID
  ;

05.3 执行审核:

function processTask(taskid,action){
    if($('#P10_NOTE').val().length > 0){
            $.ajax({
            "type":"POST",
            async:false,
            "url":"http://office.test.cc:8080/activiti-webapp-rest2/service/runtime/tasks/"+taskid+'/comments',
            headers:{"Authorization":activtiKey},
            "data":JSON.stringify({
                "message":$('#P10_NOTE').val(),
                "saveProcessInstanceId":true
                }),        
             contentType:"application/json; charset=utf-8",
             success:function(data){
                log('success'+data);
                },
             error:function(xhr){
                log('error'+xhr.status);
                }
            });  
        }
    //设置变量
        $.ajax({
        "type":"PUT",
        "url":"http://office.test.cc:8080/activiti-webapp-rest2/service/runtime/tasks/"+taskid+"/variables",
         headers:{
             "Authorization":activtiKey
             //,"X-HTTP-Method-Override":"PUT"
                 },
        "data":JSON.stringify([{
            "name":'pass',
            "value":action,
            "type":"string",
            "scope":"local"
            }]),        
         contentType:"application/json; charset=utf-8",
         success:function(data){
            log('success'+data);
                //完成审核开始
                    $.ajax({
                        "type":"POST",
                        "url":"http://office.test.cc:8080/activiti-webapp-rest2/service/runtime/tasks/"+taskid,
                         headers:{"Authorization":activtiKey},
                        "data":JSON.stringify({
                            "action":'complete',
                            "variables":[{
                                            "name":'pass',
                                            "value":action,
                                            "type":"string",
                                            "scope":"local"
                                            }]
                            }),        
                         contentType:"application/json; charset=utf-8",
                         success:function(data){
                            log('success'+data);
                             showPageSuccess('操作成功')
                             setTimeout("$('#tasklist',window.parent.document).trigger('apexrefresh')",500);
                             
                             $('.ui-widget-overlay',window.parent.document).remove();
                             $('.ui-dialog',window.parent.document).remove();
                             
                            },
                         error:function(xhr){
                            log('error'+xhr.status);
                             showPageSuccess('操作失败')
                            }
                    });     
                 //完成审核结束
            },
         error:function(xhr){
            log('设置变量 error'+xhr.status);
            }
    });       
}

05.4执行申请

function doApply(){
     
    var ok = true;
    $.ajax({
        "type":"POST",
        async:false,
        "url":"http://office.test.cc:8080/activiti-webapp-rest2/service/runtime/process-instances",
        headers:{"Authorization":activtiKey},
        "data":JSON.stringify({
            "processDefinitionKey":"cg_process",
            "variables":[
                {"name":"apply_staff","value":$('#P4_STAFF').val()},
                {"name":"sfpxxm","value":$('input[name="P4_TEAM"]:radio:checked').val()},                
                {"name":"formid","value":$('#P4_ID').val()},
                {"name":"assigneeList","value":$('#P4_DIRECTOR').val().split(',')},
                {"name":"cg_emails","value":$('#P4_CGMAILS').val().split(',')},                
                {"name":"wenme_email","value":$('#P4_WMMAIL').val()},
                {"name":"rlzycsh","value":$('#P4_RLZYCFZR').val()},
                {"name":"wsjbrsh","value":$('#P4_WSJBR').val()},                
                {"name":"sczbcsh","value":$('#P4_SCZBCFZR').val()},
                {"name":"gsbsh","value":$('#P4_GSBFZR').val()},
                {"name":"zgldList","value":$('#P4_ZGLD').val().split(',')},
                {"name":"zjlsh","value":$('#P4_GSZJL').val()},
                {"name":"wszbysh","value":$('#P4_WSZBY').val()},
                {"name":"gsbsh","value":$('#P4_GSBFZR').val()},
                ]
            }),        
         contentType:"application/json; charset=utf-8",
         success:function(data){
             console.log('流程开始 pid: '+data.id);
                    $.ajax({
                        "type":"POST",
                        async:false,
                        "url":"http://office.test.cc:8080/activiti-webapp-rest2/service/query/tasks",
                        headers:{"Authorization":activtiKey},
                        "data":JSON.stringify({
                            "processInstanceId":data.id
                            }),        
                         contentType:"application/json; charset=utf-8",
                         success:function(data){
                             console.log('自动设置第一个节点 tid: '+data.data[0].id);
                             data.data[0].id
                                $.ajax({
                                "type":"POST",
                                "url":"http://office.test.cc:8080/activiti-webapp-rest2/service/runtime/tasks/"+data.data[0].id,
                                headers:{"Authorization":activtiKey},
                                "data":JSON.stringify({
                                    "action":'complete'
                                    }),        
                                 contentType:"application/json; charset=utf-8",
                                 success:function(data){
                                         apex.server.process(
                                             "update_status",{},{dataType:'text',success:function(pData){
                                             }}
                                         );
                                        apex.message.alert('申报成功',function(){
                                            window.location.reload();
                                        })                                                                         
                                    },
                                 error:function(xhr){
                                    console.log('自动设置第一个节点失败');
                                    }
                                });                             
                            console.log('success'+data);
                            },
                             error:function(xhr){
                            console.log('error'+xhr.status);
                            }
                    });         
            },
         error:function(xhr){
             apex.message.alert('申报失败,请联系管理员',function(){})
            console.log('error'+xhr.status);
            }
    });
}else{
    apex.message.alert('申报失败,请联系管理员',function(){})
}
}


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部