processUtils.js 4.1 KB

1
  1. var _projectConfig=new ProjectConfig,requestUrlPrefixProxy=_projectConfig.proxyPath+_projectConfig.activitiServiceConfig.gatewayRoute+_projectConfig.activitiServiceConfig.adminPath,ProcessUtil=function(){var n={saveBtn:{visible:!0},sendBtn:{visible:!0},rejectBtn:{visible:!0}};function t(e,t){var n=requestUrlPrefixProxy+"/activiti/userTaskInst/isNeedSelectUser",s={id:e,processVars:JSON.stringify(t)},o=$.ajax(n,{async:!1,type:"POST",traditional:!0,data:s}).responseJSON;if(o&&"success"===o.type)return o.data;var i="判断下一流程任务失败!";throw direwolfCommonTips("error",o&&o.message||i),new Error(i)}function r(n,s,o,i){var e=o.variables;if(!t(n,e))return a(n,null,o,s,i);c(n,e,function(e,t){s(!0,"sendConfirmed",null,e)&&a(n,t,o,s,i)})}function a(e,t,n,s,o){var i=requestUrlPrefixProxy+"/activiti/userTaskInst/completeTask",r=$.ajax(i,{data:{id:e,businessDataId:n.businessId,suggestion:n.suggestion,processVars:JSON.stringify(n.variables),candidateInfoList:JSON.stringify(t)},type:"POST",traditional:!0,async:!1}),a=r.responseJSON&&"success"===r.responseJSON.type;return a||direwolfCommonTips("error",r.responseJSON&&r.responseJSON.message||"发送流程失败!"),s(a,"afterSend"),o(a),a}function c(e,t,o){var n="500px",s="850px",i=(new AesUtil).aesEncrypt(JSON.stringify({id:e,processVars:JSON.stringify(t)}),"DIREWOLF_KEY____","DIREWOLF_IV_____"),r=requestUrlPrefixProxy+"/activiti/userTaskDef/getNextTasksTree?p_procData="+i.replace(/\+/g,"_"),a=getRelativePath()+"candidateSelection.html?url="+r;$(document.activeElement).blur(),top.layer.open({type:2,area:[s,n],title:"选择候选人员/单位/部门/角色",maxmin:!0,content:a,btn:["确定","关闭"],yes:function(e,t){var n=t.find("iframe")[0].contentWindow,s=n.getSelectedCandidate();if(!s||0==s.length)return direwolfCommonTips("warning","请选择至少一个任务下的候选人。"),!1;o(s,n.getUserTaskCandidateInfo()),top.layer.close(e)},cancel:function(e){setTimeout(function(){top.layer.close(e)},100)}})}function i(e,t){$.ajax({async:!1,type:"POST",url:requestUrlPrefixProxy+"/activiti/userTaskInst/turnDownTask?userTaskInstId="+e+"&suggestion="+t,error:function(){direwolfCommonTips("error","驳回任务失败!")},success:function(e){e.type;return"success"===e.type?(top.layer.closeAll(),direwolfCommonTips("success",e.message),!0):(direwolfCommonTips("error","驳回任务失败:"+e.message),!1)}})}return{getBtnCfg:function(){return n},setBtnVisble:function(e,t){Object.keys(n).includes(e)&&((n[e].visible=t)?$("#"+e).show():$("#"+e).hide())},addBtn:function(e){0!==$("#taskHandleToolbar").length?($("#taskHandleToolbar").append('<a id="'+e.id+'" href="javascript:void(0)"class="btn btn-sm btn-default" onclick="return false;"><i class="fa fa-fw fa-'+e.icon+'" style="float: initial;"></i>'+(e.text||"未设置")+" </a>"),$("#"+e.id).click(e.onClick)):direwolfCommonTips("error","添加按钮失败!未找到待办页面工具栏。")},isNeedSelCandidate:t,popupCandidateSelWin:c,sendProcessUsingAnchor:function(t,n,s){var e,o=function(){return!0},i={};0<n.length&&"function"==typeof n[0].processEvent&&(o=n[0].processEvent),e=o(!0,"beforeSend",function(e){e&&e.proceed&&(i=n[0].processData,r(t,o,i,s))}),0<n.length&&(i=n[0].processData),e&&r(t,o,i,s)},sendProcess:function(t,n,e,s){n(!0,"beforeSend",function(e){e&&e.proceed&&(processData=e.processData,r(t,n,processData,s))})&&r(t,n,e,s)},rejectProcessTaskUsingAnchor:function(n,s){0<s.length&&"function"==typeof s[0].processEvent&&(processEvent=s[0].processEvent),top.layer.open({type:0,title:"任务驳回",content:"是否驳回任务?",btn:["确定","关闭"],yes:function(e,t){t.find("iframe")[0];setTimeout(function(){top.layer.closeAll()},100);i(n,s[0].processData.suggestion);processEvent(void 0,"afterReject")},cancel:function(e){setTimeout(function(){top.layer.closeAll()},100)}})},rejectProcessTask:function(n,s,o){top.layer.open({type:0,title:"任务驳回",content:"是否驳回任务?",btn:["确定","关闭"],yes:function(e,t){t.find("iframe")[0];setTimeout(function(){top.layer.closeAll()},100);i(n,o);s(void 0,"afterReject")},cancel:function(e){setTimeout(function(){top.layer.closeAll()},100)}})}}}();