/** * Created by weidy on 2018/5/4. * 流程的待办任务页面 */ layui.define(['layer','element','form','table','vciWebDataGrid','flow','process/vciWebProExecuteTask','vciWebFileManager'],function(exports){ /** * 主区域为待办任务的列表 * 下方的区域分为三个选项卡【关联数据】【流程历史】【流程图】 * 主区域的待办任务列表的后台路径与主页中的挂件一致 * 点击执行按钮,与主页中挂件的执行按钮一样 * 主页中的查看数据的后台路径与此页面的【关联数据】中一致 * * @constructor */ var ProTask = function(){ this.moduleKey = "vciWebProUndoTab"; this.id='vciWebProUndoTab'; this.sourceData={}; this.columns = []; this.backPath = configData.compatibility ? path : configData.processServicePath;//默认流程和项目的路径是一样的 this.url={ task:'processDefineController/getMyUndoTask', dataDefine:'processDefineController/getDataDefine',//从后台获取显示关联数据的列表的code data:'processDefineController/getDataByTask', history:'processDefineController/getHistory', picture:'processDefineController/getProcessPic', dataGridDetail:'webTrailorderplanController/getOrderItemByOidUnAccept'//trailorderplan获取详细 }; this.defaults = { dataShowByOid:true,//是否根据任务的不同来显示不同的数据列表--如果流程中没有添加dataDisplayTable变量请设置为false dataTableBtmType:"input",//关联数据的表格在的业务类型,用于查询平台中的列表 dataTableCode:"ShowMyTaskLinkDataList"//关联数据的表格代号 }; this.limit={ task:10, data:5, history:5 }; this.getContent=function(){//返回这个组件的基础html var me = this; var html = [ '
', '
',//主列表的按钮 '', //'', '', '
', '
', '
',//主列表 '
', '
', '
',//主列表的按钮 '
', '
' ,//底部选项卡 '
    ', '
  • 关联数据
  • ', '
  • 审批历史
  • ', '
  • 流程图
  • ', '
', '
', '
', //默认显示关联数据 '
', '
', '
' , '
点击图片可以放大查看流程图
', '
', '
', '
', '
' ].join(""); return html; }; this.init=function(){//基础的html被添加后,再执行初始化 var me = this; $webUtil.copyConfig(me,me.moduleKey); var table = layui.table; me.checkColumns();//主列表中列。 me.historyColumns = null; table.render({ elem:'#table_' + me.id, id:'table_' + me.id, url:me.backPath + me.url.task, page:{ limit:me.limit.task, page:1 }, height:400, cols:[me.columns], done:function(res,cur,count){ table.selectRecord('table_' + me.id,[{index:0}]); }, rowClick:function(thisTableFilter,record){ me.showDataTable(record); me.showHistoryPic(record.oid); } }); var searchFieldObject = { name: "任务名称", executionid:"所属流程模板", description:"流程启动时描述" }; $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['process/vciWebProExecuteTask']; executeTask.init(); var taskInfo = []; layui.each(checkData.data,function(_index,_item){ var task = _item; task.taskOid = _item.oid; task.taskName = _item.name; task.executionId=_item.executionid task.creator=_item.creator taskInfo.push(task); }); executeTask.showExecuteWindow(taskInfo,{ fullScreen:true },function(finish){ if(finish){ table.reload('table_' + that.id); } }); }else{ $webUtil.showErrorMsg("没有选择流程任务"); } }); $("[layui-filter='toolbar_" + that.id + "_setAssign']").click(function(){ var table = layui.table; var checkData = table.checkStatus('table_' + that.id); if(checkData && checkData.data && checkData.data.length>0){ if(checkData.data.length>1){ $webUtil.showErrorMsg("每一次只能为一个任务转移负责人"); return false; }else{ var data = checkData.data[0]; //显示负责人 layui.use('process/vciWebProcessAssign',function(){ var processAssign = layui['process/vciWebProcessAssign']; var options={}; options.taskOid = data.oid; options.id = data.oid; options.processTaskTitle = data.name; processAssign.okCallback =function(){ layui.table.reload('table_' + that.id); }; processAssign.init(options.id,options); }); } } }); $("[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.refreshAll = function() { var that = this; that.refresh(); }; this.checkColumns = function(){ var that = this; var table = layui.table; if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列 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:'description', title:'流程启动时描述', width:200 },{ field:'creator_name', title:'上一步操作人', width:120 },{ 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 ''; } } }]; } }; //关联数据 this.showDataTable = function(data){//获取数据表格中的相关定义 var me = this; var compIdFix = data.oid; $webUtil.post(me.url.dataDefine,{executionid:data.executionid},function(result){ if(result.success){ var businessDataComp = layui['process/vciWebProBusinessData'];//业务数据 var processHistoryComp = layui['process/vciWebProHistory'];//操作历史 businessDataComp.businessBtmInProcess = result.obj.UIType; businessDataComp.businessOidsInProcess = result.obj.businessOids; businessDataComp.taskOidInProcess = data.oid; businessDataComp.tableCode = result.obj.tableCode; businessDataComp.detailUrl = result.obj.detailUrl; businessDataComp.UIContentCode = result.obj.UIContentCode; result.obj.UIContentCode && (businessDataComp.UIContentSelectData = data) businessDataComp.viewProcessLinkBusinessToken = result.obj.viewProcessLinkBusinessToken;//用来在查看流程的数据时,告诉后台跳过权限的 businessDataComp.executionidNoInProcess = result.obj.executionidno; businessDataComp.executionid = data.executionid; businessDataComp.id = "vciProcessBusinessData_" +me.id+'_'+ compIdFix; $("#data_div_" + me.id ).html(businessDataComp.getContent()); businessDataComp.init(); processHistoryComp.taskOidInProcess = data.oid; processHistoryComp.executionId=data.executionid; processHistoryComp.id = "vciProcessHistory_" +me.id+'_' + compIdFix; $("#history_div_" + me.id ).html(processHistoryComp.getContent()); processHistoryComp.init(); }else{ $webUtil.showErrorMsg(result.msg); } },function(){ $webUtil.showErrorMsg("连接服务出现了问题"); },me.backPath,true); }; this.showHistoryPic = function(taskOid){ var that = this; var url = ""; if(layui.util.isNotNull(taskOid)){ url = that.backPath + that.url.picture + "?taskOid=" + taskOid + "&" + TOKEN_KEY + "=" + $webUtil.getToken(); } $("img[layer-pid='picture_" + that.id + "']").attr("src",url); }; this.destroy = function(){ var that = this; that.columns = null; var vciWebDataGrid = layui.vciWebDataGrid; vciWebDataGrid.destroy("table_" + 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, width:'100%', start:0, data:[{ alt:alt, pid:0, src:url, thumb:url }] } }); }; }; var pt = new ProTask(); exports('process/vciWebProUndoTab',pt); });