| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- // 通用分页
- 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 += '<li><a title="上一页" style="cursor:pointer" onclick="getData(' + (page - 1) + ',\''
- + module + '\')">«</a></li>';
- for ( var i = page - 2; i < page + 3; i++) {
- if (i > 0 && i <= lastPage) {
- html += '<li';
- if (i == page)
- html += ' class="active"';
- html += '><a style="cursor:pointer" onclick="getData(' + i + ',\'' + module
- + '\')">' + i + '</a></li>';
- }
- }
- if (lastPage != 0 && page != lastPage)
- html += '<li><a title="下一页" style="cursor:pointer" onclick="getData(' + (page + 1) + ',\''
- + module + '\')">»</a></li>';
- $("#pagination").html(html);
- $("#tableContent").find("a:first-child").trigger("click");
- }
- });
- }
- // 生成模版table内容
- function createTableContent(item, module) {
- var html = '';
- if (module === 'template') {
- html = '<a id="'
- + item.id
- + '" name="'
- + item.name
- + '" data-xml=\''
- + item.bpmnStr
- + '\' onclick="openTemp(this,\''
- + item.name
- + '\',\''
- + item.glCount
- + '\',\''
- + item.label
- + '\',\''
- + module
- + '\')" style="cursor:pointer" class="mbData list-group-item">'
- + '<small class="pull-right text-muted">' + item.createDateStr
- + '</small><div id="mbName" class="inline" data-toggle="tooltip" title="'+item.name+'" style="width:43%;font-weight:bold;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">' + item.name + '</div>'
- + '<div class="inline pull-right" style="width:35px"><b class="badge bg-default pull-left" style="font-weight:400;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" data-toggle="tooltip" title="'
- + item.glCount + '">' +item.glCount + '</b></div>'
- + '<div class="inline" data-toggle="tooltip" title="'+item.label+'" style="width:100%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">' + item.label + '</div></a>';
- $('#tableContent').append(html);
-
- } else if (module === 'definition') {
- //alert(item.templateName);
- html = '<a id="'+ item.id+ '" name="'+ item.name+ '" data-templateid = "'+item.glTemplateId+'"'
- + 'data-xml="" onclick="openTemp(this,\''
- + item.name
- + '\',\''
- + item.templateName
- + '\',\''
- + item.id
- + '\',\''
- + module
- + '\')" style="cursor:pointer" class="mbData list-group-item">'
- + '<small class="pull-right text-muted">'
- + item.createDateStr
- + '</small><div id="" class="inline" data-toggle="tooltip" title="'+item.name+'" style="width:100%;font-weight:bold;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">'
- + item.name
- + '</div>'
- +
- '<br /><div class="inline" data-toggle="tooltip" title="'+item.id+'" style="width:48%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">'
- + item.id
- + '</div><div class="inline pull-right" style="max-width:48%"><b class="badge bg-default pull-left" style="max-width:100%;background-color:white;color:black;font-weight:400;border:1px solid rgb(35, 212, 181);overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" data-toggle="tooltip" title="'
- + item.templateName + '">' +item.templateName + '</b></div></a>';
-
- $('#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 = '<a id="'+ item.id+ '" name="'+ item.processdefinitionName+ '" data-templateId="'+item.templateId+'" data-nodeToId="" data-xml="" onclick="openTemp(this,\''
- + item.processdefinitionName
- + '\',\''
- + status
- + '\',\''
- + item.memo
- + '\',\''
- + module
- + '\')" style="cursor:pointer" class="mbData list-group-item">'
- + '<small class="pull-right text-muted">' + item.createDateStr+ '</small><div id="" class="inline" data-toggle="tooltip" title="'+item.processdefinitionName+'" style="width:49%;font-weight:bold;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">' + item.processdefinitionName + '</div>'
- + '<br /><div id="" class="inline" data-toggle="tooltip" title="'+item.memo+'" style="width:80%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">' + item.memo + '</div><span class="badge pull-right" style="display:inline-block;background-color:white;color:black;font-weight:400;border:1px solid rgb(35, 212, 181)" >' + status + '</span></a>';
- $('#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 += '<button id="modalClose" type="button" class="btn btn-default" onclick="closeModal()">关闭</button>';
- } else if (button[i].type === 'save') {
- buttonHtml += '<button type="button" class="btn btn-primary" onclick="actChildFun(\'saveModel\')">保存</button>';
- } else {
- buttonHtml += '<button type="button" class="btn btn-primary" onclick="'
- + button[i].fun + '">' + button[i].text + '</button>';
- }
- }
- }
- html += '<div class="modal fade" id="myModal" style="display:flex"><div class="modal-content" ';
- html += 'style="margin:auto;height:' + height + 'px;width:' + width
- + 'px">';
- html += '<div class="modal-header"><button id="modalCloseIcon" type="button" class="close" onclick="closeModal()" >×</button><h4 class="modal-title" id="myModalLabel">';
- html += title + '</h4></div><div class="modal-body">';
- html += '<iframe id="myModalIFrame" src="' + url + '" style="height:';
- if(button==null||button.length==0){
- html += (height - 56);
- }else{
- html += (height - 120);
- }
- html += 'px;width:' + width
- + 'px;margin:-15px;margin-bottom:-20px;border:none"></iframe>';
- if(button!=null&&button.length!=0)
- html += '</div><div class="modal-footer">' + buttonHtml + '</div>';
- html += '</div></div>';
- $('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);
- }
|