说明:审批表页面在我的待办工作中打开,希望处理完后关闭页面,实现我的待办实时刷新-做表格;同时,该需求也适用于需要从某些工作流管理模块发起审批的情况,比如在招聘需求模块发起的招聘流程;我的绩效管理中的绩效审批等我们先看看之前的实现。这个逻辑实现的功能是从我的to-dolist发起一个审批。审批完成后,会直接跳转到当前页面新建一个oa主页面,即审批页面,并打开我的工作-我的待办标签,实现方法如下:$("#but_back").bind("click",function(){window.top.opener=null;varurl=window.location.href;varisoa=url.indexOf('phicomm.com');//varisoatest=url.indexOf('oatest.phicomm.com');varcurWwwPath=window.document.location.href;varpathName=window.document.location.pathname;varpos=curWwwPath.indexOf(pathName);varlocalhostPaht=curWwwPath.substring(0,pos);varprojectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);if(isoa>0){window.top.open(localhostPaht+'/main/index.action?tableName=mywork','_self');}else{window.top.open(localhostPaht+projectName+'/main/index.action?tableName=mywork','_self');}});桌面js处理逻辑:$(document).ready(function($){//初始化图标initModules(initMenus());refixAppPos();//注册事件regClick();sortable();initIcoRemove();initAppManager();//分析当前URL判断是否需要跳转制定TablegotoTable();});//跳转制定TablefunctiongotoTable(){vartableName=request("tableName");if(""!=tableName&&null!=tableName&&'undefined'!=tableName){openUrl($("#desktop_content_icon_"+tableName));}}上面的方法虽然实现了,跳转到我的pending函数,但存在以下缺陷:跳转在新页面,而不是调用页面,从而形成调用页面和跳转页面两个相同的桌面;新页面与原调用页面不完全相同,调用page如果打开多个标签页,新打开的页面相当于关闭了除我的待办之外的其他标签页,不符合用户需求;用户体验不友好,我们使用js回调实现如下,调用页面当当前页面不为空且不关闭时,我们直接调用页面中的js方法实现其局部刷新/**刷新父窗口关闭弹出窗口*/functionrefreshAndClose(){varjscallback=$.trim($("#jscallback").val());vartype=$.trim($("#type").val());if(window.opener&&!window.opener.closed&&jscallback!=null&&jscallback!=""){if(!type){//该页面的调用页面执行其嵌入或调用的js方法eval("window.opener."+jscallback+"();");}window.close();//当前页面关闭}else{window.top.opener=null;varurl=window.location.href;varisoa=url.indexOf('phicomm.com');varcurWwwPath=window.document.location.href;varpathName=window.document.location.pathname;varpos=curWwwPath.indexOf(pathName);varlocalhostPaht=curWwwPath.substring(0,pos);varprojectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);if(isoa>0){window.top.open(localhostPaht+'/main/index.action?tableName=mywork','_self');}else{window.top.open(localhostPaht+projectName+'/main/index.action?tableName=mywork','_self');}}}调用页面js:grid是需要的table局部刷新。functionopenUrl(url){url=url+"&jscallback=callsus"window.open(url,'_blank');}functioncallsus(){$('#performanceDataGrid').reload();}实现了通过js回调调用页面部分刷新,对其他应用的类似功能具有一定的指导和借鉴意义。本文来自“南湖矿工科技空间”博客,请务必保留此出处http://jncumter.blog.51cto.com/812546/1623739
