/** * Created by dengbk on 2019/4/26. * 执行中的流程.已挂起流程,已终止流程,已完成流程公用页面 */ layui.define(['layer','element','form','table','vciWebDataGrid','flow','process/vciWebProExecuteTask','vciWebFileManager'],function(exports){ /** * 主区域为待办任务的列表 * 下方的区域分为三个选项卡【关联数据】【流程历史】【流程图】 * 主区域的待办任务列表的后台路径与主页中的挂件一致 * 主页中的查看数据的后台路径与此页面的【关联数据】中一致 */ var ExecutPro = function(){ this.moduleKey = "vciWebProExecutingTab"; this.id='vciWebProExecutingTab'; this.sourceData={}; this.columns = []; this.historyColumns = []; this.backPath = configData.compatibility ? path : configData.processServicePath;//默认流程和项目的路径是一样的 this.isDebug = false; this.url={ task:'processDefineController/getMyUndoTask', dataDefine:'processDefineController/getDataDefine',//从后台获取显示关联数据的列表的code data:'processDefineController/getDataByTask', history:'processDefineController/getHistory', picture:'processDefineController/getProcessPic', dataGridDetail:'webTrailorderplanController/getOrderItemByOidUnAccept',//trailorderplan获取详细 executing:'processDefineController/getMyExecutingProcess',//执行中的流程 suspended:'processDefineController/getMySuspendedProcess',//已挂起流程 end:'processDefineController/getMyEndProcess',//已终止流程 finish:'processDefineController/getMyFinishProcess',//已完成流程 done:'processDefineController/getMyDoneProcessTask',//已办任务 endProcess:'webProcessCommandController/endProcess',//终止流程 suspendProcess:'webProcessCommandController/suspendProcess',//冻结流程 resumeProcess:'webProcessCommandController/resumeProcess',//回复流程 getDataByTask:'processDefineController/getDataByTask' }; this.defaults = { dataShowByOid:true,//是否根据任务的不同来显示不同的数据列表--如果流程中没有添加dataDisplayTable变量请设置为false dataTableBtmType:"input",//关联数据的表格在的业务类型,用于查询平台中的列表 dataTableCode:"ShowMyTaskLinkDataList"//关联数据的表格代号 }; this.limit={ task:10, data:5, history:5 }; this.taskDataConfig = { }; this.trailDetailColumns = []; this.getContent = function () { var me = this; if(me.sourceData && "page" in me.sourceData){ me.id = me.id + "_" + me.sourceData.page; } return '
'; }; this.showContent = function () { var html = ""; var that = this; html = [ '
', '
', '
',//主列表的按钮 '', '', '', '', '
', '
',//主列表 '
', '
', '
', '
' ,//底部选项卡 '
    ', '
  • 关联数据
  • ', '
  • 关联文件
  • ', '
  • 审批历史
  • ', '
  • 流程图
  • ', '
', '
', '
', //默认显示关联数据 '
', '
', '
', '
', '
', '
' , '
', '
', '
' , '
点击图片可以放大查看流程图
', '
', '
', '
', '
', '
' ].join(""); $("#UIContent_" + that.id).html(html); }; this.getUrlByPage = function(){ var url = '',that = this,urlArr = that.url; var page = that.sourceData.page; if(page){ for(var item in urlArr){ if(item == page){ url = urlArr[item]; } } if(page == 'executing'){ $("button[layui-filter='toolbar_"+that.id+"_freez']").show(); $("button[layui-filter='toolbar_"+that.id+"_stop']").show() } if(page == 'suspended'){ $("button[layui-filter='toolbar_"+that.id+"_resume']").show() } }else{ url = urlArr.task; } return url; }; this.init=function(){//基础的html被添加后,再执行初始化 var me = this; me.taskDataConfig = null; me.fileDataTable = false; me.historyColumns = null; me.columns = null; $webUtil.copyConfig(me,me.moduleKey); var table = layui.table; me.checkColumns();//主列表中列。 setTimeout(function () { me.showContent(); var easyuiLayout = $('#easyuiLayout_' + me.id) easyuiLayout.css({height: $('#portal_body').height() - 43, width: $('#portal_body').width() - 15}) easyuiLayout.layout(); table.render({ elem:'#table_' + me.id, id:'table_' + me.id, url:me.getUrlByPage(), backPath:me.backPath, page:{ limit:me.limit.task, page:1 }, height:390, cols:[me.columns], done:function(res,cur,count){ var taskOid = ""; var executionId = ""; table.selectRecord('table_' + me.id,[{index:0}]); }, rowClick:function(thisTableFilter,record){ if(record.detailUrl){ $("#"+me.id+'_VIEWDETAIL').show() } me.showDataTable(record.executionid,record); me.showHistoryTable(record.executionid); me.showHistoryPic(record.executionid,record.oid); } }); var searchFieldObject = { name: "流程名称", executionid:"所属流程模板", description:"流程启动时描述" }; if("done" == me.sourceData.page){ searchFieldObject['name'] = '任务名称'; } $webUtil.createSearchHtml(searchFieldObject, $('[layui-filter="toolbar_' + me.id + '"]'), 'table_' +me.id); me.bindListeners(); }, 1); }; this.bindListeners = function(){ var that = this; $("img[layer-pid='picture_" + that.id + "']").click(function(){ that.showImgFullScreen(); }); $("[layui-filter='toolbar_" + that.id + "_execute']").click(function(){ var table = layui.table; var checkData = table.checkStatus('table_' + that.id); if(checkData && checkData.data && checkData.data.length>0){ var executeTask = layui['view/process/vciWebProExecuteTask']; executeTask.init(); var taskInfo = []; layui.each(checkData.data,function(_index,_item){ taskInfo.push({ taskOid:(_item.oid), taskName:_item.name, executionId:(_item.executionid) }); }); executeTask.showExecuteWindow(taskInfo,{ fullScreen:true },function(finish){ if(finish){ table.reload('table_' + that.id); } }); }else{ $webUtil.showErrorMsg("没有选择流程任务"); } }); $("[layui-filter='toolbar_" + that.id + "_VIEWDETAIL']").click(function(){ that.VIEWDETAIL() }); $("[layui-filter='toolbar_" + that.id + "_stop']").click(function(){ that.stop(); }); $("[layui-filter='toolbar_" + that.id + "_freez']").click(function(){ that.freez(); }); $("[layui-filter='toolbar_" + that.id + "_resume']").click(function(){ that.resume(); }); $("[layui-filter='toolbar_" + that.id + "_refresh']").click(function(){ that.refresh(); }); }; this.refresh = function(){ var that = this; var table = layui.table; table.reload("table_" + that.id,{}); }; this.freez = function(){ var that = this; var executionid = $webUtil.getOidFromGrid("table_" + that.id,true,false,'executionid'); if(!executionid){ return; } $webUtil.showConfirmMsg("您确定要冻结这个流程吗?",function(){ $webUtil.post(that.url.suspendProcess,{processOids:executionid},function(result){ if(result.success){ $webUtil.showMsg("冻结流程成功"); that.refresh(); }else{ $webUtil.showErrorMsg(result.msg); } },function(){ // $webUtil.showErrorMsg("连接服务出现了问题"); },that.backPath); }); }; this.stop = function(){ var that = this; var executionid = $webUtil.getOidFromGrid("table_" + that.id,true,false,'executionid'); if(!executionid){ return; } $webUtil.showConfirmMsg("您确定要终止这个流程吗?",function() { $webUtil.post(that.url.endProcess, {processOids: executionid}, function (result) { if (result.success) { $webUtil.showMsg("终止流程成功"); that.refresh(); } else { $webUtil.showErrorMsg(result.msg); } }, function () { // $webUtil.showErrorMsg("连接服务出现了问题"); }, that.backPath); }); }; this.resume = function(){ var that = this; var executionid = $webUtil.getOidFromGrid("table_" + that.id,true,false,'executionid'); if(!executionid){ return; } $webUtil.showConfirmMsg("您确定要冻结这个流程吗?",function() { $webUtil.post(that.url.resumeProcess, {processOids: executionid}, function (result) { if (result.success) { $webUtil.showMsg("恢复流程成功"); that.refresh(); } else { $webUtil.showErrorMsg(result.msg); } }, function () { }, that.backPath); }); }; this.showDataTable = function(executionId,data) {//获取数据表格中的相关定义 var that = this; $webUtil.post(that.url.dataDefine, {executionid: executionId}, function (result) { if (result.success && $webUtil.isNotNull(result.obj.UIType)) { var businessDataComp = layui['process/vciWebProBusinessData'];//业务数据 businessDataComp.businessBtmInProcess = result.obj.UIType; businessDataComp.businessOidsInProcess = result.obj.businessOids; businessDataComp.tableCode = result.obj.tableCode; businessDataComp.detailUrl = result.obj.detailUrl; businessDataComp.UIContentCode = result.obj.UIContentCode; businessDataComp.viewProcessLinkBusinessToken = result.obj.viewProcessLinkBusinessToken;//用来在查看流程的数据时,告诉后台跳过权限的 businessDataComp.executionidNoInProcess = result.obj.executionidno; businessDataComp.executionid = executionId; businessDataComp.maxHeight = $('#border_'+that.id).height() - 45; businessDataComp.maxWidth = $('#portal_body').width() - 10; businessDataComp.id = "vciProcessBusinessData_" + data.oid; businessDataComp.noEdit = false; webUtil.ajax('get', '/uiDataController/getDataAttr', { oid: result.obj.businessOids, btmname: result.obj.UIType }, function (res) { if (res.success) { if (res.data) { businessDataComp.businessDataInProcess = res.data; } else { businessDataComp.businessDataInProcess = [res.obj]; } $("[layui-filter='data_div_" + that.id + "']").html(businessDataComp.getContent()); businessDataComp.init(); } else { webUtil.showErrorMsg(res.msg); } }, function (xhr, err) { webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启"); }, that.backPath,true); }else{ layui.element.tabDelete("tab_" + that.id, "businessData"); } that.showFileDataTable(executionId,result.obj); }, function () { $webUtil.showErrorMsg("连接服务出现了问题"); }, that.backPath,true); }; this.showFileDataTable = function(executionid,obj){ var that = this; if(!that.fileDataTable){ var vciFileManager = layui.vciWebFileManager; var options= { tableId: '#file_' + that.id, url:'processDefineController/dataGridFileInProcess', inProcess: true, dataOid: executionid, dataIsProcessInstance: true, toolbarId: '[layui-filter="file_toolbar_' + that.id + '"]', sourceData:{ viewProcessLinkBusinessToken:obj.viewProcessLinkBusinessToken, executionidNoInProcess:obj.executionidno, businessOidsInProcess:obj.businessOids }, elem:'#file_item_' + that.id } vciFileManager.tableDivId = '#file_' + that.id; vciFileManager.id = "file_" + that.id; vciFileManager.inProcess = true; vciFileManager.dataOid = executionid; vciFileManager.dataIsProcessInstance = true; vciFileManager.toolbarDivId = $('[layui-filter="file_toolbar_' + that.id + '"]'); vciFileManager.init(); vciFileManager.render(vciFileManager.id,options) that.fileDataTable = true; }else{ layui.vciWebFileManager.reloadByWhere("file_" + that.id,executionid); } }; this.renderDataTable = function(btmType,tableCode,executionId,callback){ var me = this; var vciWebDataGrid = layui.vciWebDataGrid; var table = layui.table; if(me.taskDataConfig !=null && me.taskDataConfig.btmType == btmType && me.taskDataConfig.tableCode == tableCode){ table.reload("data_" + me.id,{ where:{ "conditionMap['processOid']":executionId } }); return; } me.taskDataConfig = { btmType:btmType, tableCode:tableCode }; vciWebDataGrid.setConfig("data_" + me.id,{ isLoaded :false, tableId:"data_" + me.id, elemId:"#data_" + me.id, btmType:btmType, tableCode:tableCode, isMuti:true, url:me.backPath + me.url.data, extraParams:{//也可以使用where processOid:executionId }, done:callback }); vciWebDataGrid.init(); vciWebDataGrid.showGridByUrl("data_" + me.id); }; this.checkColumns = function(){ var that = this; var table = layui.table; var page = that.sourceData.page; var finishTimeTitle = "完成时间"; if('suspended' == page){ finishTimeTitle = "冻结时间"; } if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列 if('done' == page){ that.columns = [table.getIndexColumn(),table.getCheckColumn(),{ field:'name', title:'任务名称', width:300 },{ field:'createtime', title:'任务开始时间', width:150, templet:function(d){ return $webUtil.formateDateTimeNoSecond(d.createtime); } },{ field:'creator_name', title:'上一步操作人', width:120, templet:function(d){ return d.creator_name + "(" + d.creator+")"; } },{ field: 'ts', title: '任务完成时间', width: 150, templet: function (d) { return $webUtil.formateDateTimeNoSecond(d.ts); } },{ field: 'executionid', title: '所属流程模板', width: 200, templet: function (d) { if($webUtil.isNotNull(d.executionid) && d.executionid.indexOf(".") > -1){ return d.executionid.substring(0,d.executionid.indexOf(".")); }else{ return d.executionid; } } },{ field:'secretgrade', title:'密级', width:80, templet:function (d) { if(d.secretgrade == '10' || d.secretgrade == 10){ return '非密'; }else if(d.secretgrade == '20' || d.secretgrade == 20){ return '秘密'; }else if(d.secretgrade == '30' || d.secretgrade == 30){ return '机密'; }else{ return ''; } } },{ field:'description', title:'流程启动时描述', width:200 }] }else { that.columns = [table.getIndexColumn(), table.getCheckColumn(), { field: 'name', title: '流程名称', width: 300 }, { field: 'creator_name', title: '发起人', width: 120, templet:function(d){ return d.creator_name + "(" + d.creator +")"; } }, { field: 'createtime', title: '发起时间', width: 150, templet: function (d) { return $webUtil.formateDateTimeNoSecond(d.createtime); } }, { field: 'ts', title: finishTimeTitle, width: 150, hidden: (($webUtil.inArray(['finish', 'suspended'], page)) ? false : true), templet: function (d) { return $webUtil.formateDateTimeNoSecond(d.ts); } },{ field: 'executionid', title: '所属流程模板', width: 200, templet: function (d) { if($webUtil.isNotNull(d.executionid) && d.executionid.indexOf(".") > -1){ return d.executionid.substring(0,d.executionid.indexOf(".")); }else{ return d.executionid; } } },{ field:'description', title:'流程启动时描述', width:200 }] } } }; this.showHistoryTable = function(executionId){ var that = this; var table = layui.table; if(that.historyColumns == null || that.historyColumns.length == 0){ that.checkHistoryColumns(); table.render({ elem:'#history_' + that.id, url:that.url.history, backPath:that.backPath, page:false, where:{ executionId:executionId, showCurrentNode:true }, cols:[that.historyColumns], done:function(res,curr,count){ } }); }else{ table.reload("history_" + that.id,{ where:{ executionId:executionId, showCurrentNode:true } }); } }; this.checkHistoryColumns = function(){ var that = this; var table = layui.table; if(that.historyColumns==null || that.historyColumns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列 that.historyColumns = [table.getIndexColumn(),{ field:'taskName', title:'任务名称', width:150 },{ field:'opinin', title:'执行操作', width:100 },{ field:'createTime', title:'任务开始时间', width:180 },{ field:'node', title:'审批意见', width:200 },{ field:'assigneeName', title:'执行人', width:120 },{ field:'endTime', title:'任务完成时间', width:180 }] } }; this.showHistoryPic = function(executionId){ var that = this; var url = ""; if(layui.util.isNotNull(executionId)){ url = that.backPath + that.url.picture + "?executionId=" + executionId + "&" + TOKEN_KEY + "=" + $webUtil.getToken(); } $("img[layer-pid='picture_" + that.id + "']").attr("src",url); }; this.destroy = function(){ var that = this; that.taskDataConfig = null; that.columns = null; that.historyColumns = null; var vciWebDataGrid = layui.vciWebDataGrid; vciWebDataGrid.destroy("data_" + that.id); }; this.showImgFullScreen = function(){//全屏显示图片 var that = this; var layer = layui.layer; var url = $("img[layer-pid='picture_" + that.id + "']").attr("src"); var alt = "流程图"; if(url && url.indexOf("executionId=")>-1){ alt = url.substring(url.indexOf("executionId=") + "executionId=".length ); if(alt.indexOf(".")>-1){ alt = alt.substring(0,alt.indexOf(".")); } } layer.photos({ photos:{ title:'查看流程图', id:'show_picture_' +that.id, start:0, data:[{ alt:alt, pid:0, src:url, thumb:url }] } }); }; this._VIEWDETAIL = function (){ } }; var ep = new ExecutPro(); exports('process/vciWebProExecutingTab',ep); });