/** * Created by weidy on 2019/8/30 * 所有的执行中的流程.所有的已挂起流程,所有的已终止流程,所有的已完成流程公用页面 */ layui.define(['layer','element','form','table','vciWebDataGrid','flow','process/vciWebProExecuteTask','vciWebFileManager'],function(exports){ /** * 主区域为待办任务的列表 * 下方的区域分为三个选项卡【关联数据】【流程历史】【流程图】 * 主区域的待办任务列表的后台路径与主页中的挂件一致 * 主页中的查看数据的后台路径与此页面的【关联数据】中一致 */ var ExecutPro = function(){ this.moduleKey = "vciWebProAllProcessInfo"; this.id='vciWebProAllProcessInfo'; this.sourceData={}; this.columns = []; this.historyColumns = []; this.backPath = path;//默认流程和项目的路径是一样的 this.isDebug = false; this.url={ dataDefine:'/webProcessDefineController/getDataDefine',//从后台获取显示关联数据的列表的code data:'/webProcessDefineController/getDataByTask', history:'/webProcessDefineController/getHistory', picture:'/webProcessDefineController/getProcessPic', dataGridDetail:'/webTrailorderplanController/getOrderItemByOidUnAccept',//trailorderplan获取详细 executing:'/webProcessDefineController/getAllExecutingProcess',//执行中的流程 suspended:'/webProcessDefineController/getAllSuspendedProcess',//已挂起流程 end:'/webProcessDefineController/getAllEndProcess',//已终止流程 finish:'/webProcessDefineController/getAllFinishProcess',//已完成流程 done:'/webProcessDefineController/getMyDoneProcessTask',//已办任务 endProcess:'/webProcessCommandController/endProcess',//终止流程 suspendProcess:'/webProcessCommandController/suspendProcess',//冻结流程 resumeProcess:'/webProcessCommandController/resumeProcess'//回复流程 }; 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(){//返回这个组件的基础html var me = this; if(me.sourceData && "page" in me.sourceData){ me.id = me.id + "_" + me.sourceData.page; } var html = [ '
', '
',//主列表的按钮 '', '', '', '', '
', '
', '
',//主列表 '
', '
', '
',//主列表的按钮 '
', '
' ,//底部选项卡 '
    ', '
  • 关联数据
  • ', '
  • 关联文件
  • ', '
  • 审批历史
  • ', '
  • 流程图
  • ', '
', '
', '
', //默认显示关联数据 '
', // ' ', // '', // ' ', '', '
', '
', '
', '
', '
,' , '
', '
' , '
', '
' , '
点击图片可以放大查看流程图
', '
', '
', '
', '
' ].join(""); return 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();//主列表中列。 table.render({ elem:'#table_' + me.id, id:'table_' + me.id, url:me.backPath + me.getUrlByPage(), page:{ limit:me.limit.task, page:1 }, height:400, 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.oid); me.showFileDataTable(record.executionid); 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(); }; 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){//获取数据表格中的相关定义 var me = this; var table = layui.table; if(me.defaults.dataShowByOid && layui.util.isNotNull(executionId)){ //要从后台去查询定义了 $webUtil.post(me.url.dataDefine,{executionId:executionId},function(result){ if(result.success){ me.renderDataTable(result.obj.btmType,result.obj.tableCode,executionId); }else{ me.renderDataTable(me.defaults.dataTableBtmType,me.defaults.dataTableCode,executionId); //最终展示表格 } },function(){ $webUtil.showErrorMsg("连接服务出现了问题"); },me.backPath,true); }else{ me.renderDataTable(me.defaults.dataTableBtmType,me.defaults.dataTableCode,taskOid);//最终展示表格 } }; this.VIEWDETAIL = function(){ var that = this,table = layui.table; var id = "data_"+ that.id; var detailDialog = layui['view/tech/vciUnapproveTech']; var btm = $webUtil.getOidFromGrid(id,true,true,"btmname"); var oid = $webUtil.getOidFromGrid(id,true,true); if(!btm){ $webUtil.showErrorMsg("请选择数据"); return false } if(btm =="importrecord"){ detailDialog.VIEWDETAIL(id); }else if(btm =="trailorderplan"){ that.trailorderplanDetail(oid) } else{ $webUtil.showErrorMsg("没有明细") } }; this.showFileDataTable = function(executionid){ var that = this; if(!that.fileDataTable){ var vciFileManager = layui.vciWebFileManager; 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(); 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.backPath + that.url.history, 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,taskOid){ var that = this; var url = ""; if(layui.util.isNotNull(taskOid) && layui.util.isNotNull(executionId)){ url = that.backPath + that.url.picture + "?taskOid=" + taskOid + "&executionId=" + encodeURI(executionId); } $("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 }] } }); }; }; var ep = new ExecutPro(); exports('process/vciWebProAllProcessInfo',ep); });