// 通用分页 var curPage = 1; // 当前页码 var totalCount, pageSize, totalPage; // 总记录数,每页显示数,总页数 totalPage = Math.floor(totalCount / pageSize) + 1; var likeSearch = '', typeSearch = ''; function getData(page, module) { $.ajax({ url : basePath + 'WFP?module=' + module + '&action=list', type : 'POST', data : { begin : (page - 1) * 20 + 1, limit : 20, likeSearch : likeSearch, typeSearch : typeSearch }, success : function(json) { $("#tableContent").empty(); $("#tableContent").height($("#tableContent").height()); $("#sectionMain").children().hide(); var obj = JSON.parse(json); total = obj.totalCount; pageSize = obj.limit; $.each(obj.data, function(index) { createTableContent(obj.data[index], module); }); // 分页 html = ''; var lastPage = Math.ceil(total / pageSize); if (page > 1) html += '
  • «
  • '; for ( var i = page - 2; i < page + 3; i++) { if (i > 0 && i <= lastPage) { html += '' + i + ''; } } if (lastPage != 0 && page != lastPage) html += '
  • »
  • '; $("#pagination").html(html); $("#tableContent").find("a:first-child").trigger("click"); } }); } // 生成模版table内容 function createTableContent(item, module) { var html = ''; if (module === 'template') { html = '' + '' + item.createDateStr + '
    ' + item.name + '
    ' + '
    ' +item.glCount + '
    ' + '
    ' + item.label + '
    '; $('#tableContent').append(html); } else if (module === 'definition') { //alert(item.templateName); html = '' + '' + item.createDateStr + '
    ' + item.name + '
    ' + '
    ' + item.id + '
    ' +item.templateName + '
    '; $('#tableContent').append(html); }else if (module === 'instance'){ var status = ''; switch(item.status) { case '2': status = '待办'; break; case '5': status = '已办'; break; case '99': status = '回退'; break; case '3': status = '结束'; break; } html = '' + '' + item.createDateStr+ '
    ' + item.processdefinitionName + '
    ' + '
    ' + item.memo + '
    ' + status + '
    '; $('#tableContent').append(html); } } // 渲染具体的定义 function openTemp(obj, name, glCount, label, module) { $("#sectionMain").children().show(); $('#tempName').attr('title', name); $('#tempDesc').attr('title', label); $('#tempRelate').attr('title', glCount); $('#tableContent').children().removeClass('active'); $(obj).addClass('active'); $('#tempName').html(name); $('#tempRelate').html(glCount); $('#tempDesc').html(label); if(module === 'template'){ showBpmn(); }else if(module === 'definition'){ if($(obj).find('.pull-right b').html()!=''){ $('#unRelateDefinitionBtn').show(); }else{ $('#unRelateDefinitionBtn').hide(); } var definitionId = $('#tableContent .active').attr('id'); url = basePath + 'player/design/show.jsp?id='+ definitionId; $("#bpmnShow").attr('src',url); }else if(module === 'instance'){ var instanceId = $('#tableContent .active').attr('id'); url = basePath + 'player/design/play.jsp?id='+instanceId; $("#bpmnPlay").attr('src',url); } } // 渲染流程模版图 function showBpmn() { var bpmnXml = $('#tableContent .active').attr('data-xml'); $("#bpmnShow")[0].contentWindow.setXml(bpmnXml); } // 打开模态窗 function openModal(title, url, height, width, button, isClickClose) { var html = ''; var buttonHtml = ''; if (button != null) { for (i = 0; i < button.length; i++) { if (button[i].type === 'close') { buttonHtml += ''; } else if (button[i].type === 'save') { buttonHtml += ''; } else { buttonHtml += ''; } } } html += ''; $('body').append(html); $('body').find("#myModal").modal({backdrop: 'static', keyboard: false}); } // 关闭模态窗 function closeModal() { $('.modal-backdrop').remove(); $('#myModal').remove(); } // 触发子页面的方法 function actChildFun(funName) { var funText = '$("#myModalIFrame")[0].contentWindow.' + funName + '()'; eval(funText); } // 生成通用的保存、关闭按钮 function createSaveAndClsBtn(isSave, isCls) { var btns = new Array(); if (isSave) { var btn = new Object(); btn.type = 'save'; btns.push(btn); } if (isCls) { var btn = new Object(); btn.type = 'close'; btns.push(btn); } return btns; } function getCounts(module) { $.ajax({ url : basePath + 'WFP?module=' + module + '&action=counts', type : 'POST', success : function(json) { var obj = JSON.parse(json); if(module === 'instance'){ $('#temTotal').html(obj.total); $('#temTodo').html(obj.todo); $('#temDone').html(obj.done); $('#temBack').html(obj.back); $('#temEnd').html(obj.end); } $('#temCount').html(obj.total); $('#temRelateCount').html(obj.gls); $('#temUnrelateCount').html(obj.notGls); } }); } //修复IE9下height100%不生效的样式问题 function resetSectionHeight(){ $('#sectionMain').height($(parent.document).height()-50); }