7bdb0bb2d45fb4231d256116fcf197d27e7b152e.svn-base 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /**
  2. * 用于框架调用的一些方法 2016/8/9 康国前加
  3. * 调用方法:1.引用次js
  4. * 2.用 $.方法名 使用方法,如:$.indexOpenSelfWindow(workUrl);
  5. */
  6. ;(function($,window,document,undefined) {
  7. var _this = this;
  8. _this.url = null;
  9. $.extend({
  10. /**
  11. * 本页面加载workUrl
  12. */
  13. indexOpenSelfWindow : function(workUrl){
  14. // var sessionID = top.com.sinosoft.lz.system.user.LoginInfo.getSessionID();
  15. // var cookie = $.getCookie(sessionID+"openerror");
  16. //console.log("cookie:"+cookie);
  17. //if("error"!=cookie){
  18. //console.log(sessionID+"openerror:正确");
  19. //页面至顶
  20. top.window.scrollTo(0,0);
  21. //调用frameWork页面的方法
  22. top.parent.frameWorkShowLoading();
  23. //加载框架iframe
  24. $(top.parent.document.body).find("#frmright").attr('src',workUrl);
  25. /*}else{
  26. //console.log(sessionID+"openerror:错误");
  27. top.window.location = '../';
  28. }*/
  29. },
  30. /**
  31. * 新建页面加载workUrl,保留框架
  32. */
  33. indexOpenNextWindow : function(workUrl){
  34. //alert(workUrl);
  35. //var userInfoStr = top.com.sinosoft.lz.system.user.LoginInfo.getUserInfo();
  36. _this.url = workUrl;
  37. window.open("/nwyj/page/frameWork.html");
  38. //opener.fatherParam={"name":userInfoStr,"idxWorkUrl":workUrl};
  39. },
  40. /**
  41. * 新建页面加载workUrl,不保留框架
  42. */
  43. noIndexOpenNextWindow : function(workUrl){
  44. /*var sessionID = top.com.sinosoft.lz.system.user.LoginInfo.getSessionID();
  45. var cookie = $.getCookie(sessionID+"openerror");
  46. //console.log("cookie:"+cookie);
  47. if("error"!=cookie){*/
  48. //var userInfoStr = top.com.sinosoft.lz.system.user.LoginInfo.getUserInfo();
  49. _this.url = workUrl;
  50. window.open("/nwyj/page/singlePage.html");
  51. //opener.fatherParam={"name":userInfoStr,"idxWorkUrl":workUrl};
  52. /*}else{
  53. //console.log(sessionID+"openerror:错误");
  54. top.window.location = '../';
  55. }*/
  56. },
  57. /**
  58. * 给新建窗口页面传参数
  59. */
  60. paramsToNextWindow : function(){
  61. var userInfoStr = top.com.sinosoft.lz.system.user.LoginInfo.getUserInfo();
  62. return {"name":userInfoStr,"idxWorkUrl":_this.url};
  63. },
  64. /**
  65. * 当页面失效时,在父窗口执行方法
  66. */
  67. reSetTopWindow : function(){
  68. //top.window.location = "../";
  69. },
  70. /**
  71. * 记录用户点击菜单次数
  72. */
  73. indexUserClickNum : function(menu_id,user_id){
  74. // $.ajax({
  75. // url : $.pathname() + '/ws/sys/SysCustomMenuService/setUserClickNum/',
  76. // type : 'post',
  77. // data : {
  78. // menu_id:menu_id,
  79. // user_id:user_id
  80. // },
  81. // dataType : 'text',
  82. // async:false,
  83. // success : function(data) {
  84. // //console.log(user_id+"点击了"+menu_id+"====="+data);
  85. // },
  86. // error : function(e) {
  87. // }
  88. // });
  89. },
  90. /**
  91. * 清除浏览器所有cookies
  92. */
  93. clearAllCookies : function (){
  94. var keys = document.cookie.match(/[^=;]+(?=\=)/g);
  95. if(keys){
  96. for(var i=keys.length;i--;){
  97. document.cookie = keys[i]+'=;expires='+new Date(0).toUTCString();
  98. }
  99. }
  100. },
  101. //设置cookie
  102. setCookie:function(key,value){
  103. var Then = allGetServerTime();
  104. Then.setTime(Then.getTime() + 1866240000000);
  105. document.cookie = key+"=" + value + ";expires="+Then.toGMTString();
  106. },
  107. //删除cookie
  108. getCookie : function (key){
  109. var cookieString = new String(document.cookie);
  110. //console.log("cookieString:"+cookieString);
  111. var cookieArr = cookieString.split(";");
  112. //console.log("cookieArr:"+cookieArr);
  113. for(var i=0; i<cookieArr.length;i++ ){
  114. if(cookieArr[i].indexOf(key)>-1){
  115. //console.log("cookieArr[i]"+cookieArr[i]);
  116. return cookieArr[i].split("=")[1];
  117. }
  118. }
  119. return null;
  120. },
  121. //删除cookie
  122. removeCookie:function(key){
  123. var Then = allGetServerTime();
  124. Then.setTime(Then.getTime() + 1866240000000);
  125. document.cookie = key+"=;expires="+Then.toGMTString();
  126. },
  127. /**
  128. * 全屏显示
  129. * @param dom
  130. */
  131. indexFullScreen : function(dom) {
  132. //非全屏时,进入全屏
  133. var el = document.documentElement;
  134. var rfs = el.requestFullScreen || el.webkitRequestFullScreen ||
  135. el.mozRequestFullScreen || el.msRequestFullScreen;
  136. if(typeof rfs != "undefined" && rfs) {
  137. rfs.call(el);
  138. } else if(typeof window.ActiveXObject != "undefined") {
  139. var wscript = new ActiveXObject("WScript.Shell");
  140. if(wscript != null) {
  141. wscript.SendKeys("{F11}");
  142. }
  143. }
  144. },
  145. /**
  146. * 退出全屏
  147. */
  148. indexExitFullScreen : function() {
  149. //全屏时,退出全屏
  150. var el = document,
  151. cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,
  152. wscript;
  153. if (typeof cfs != "undefined" && cfs) {
  154. cfs.call(el);
  155. return ;
  156. }
  157. if (typeof window.ActiveXObject != "undefined") {
  158. wscript = new ActiveXObject("WScript.Shell");
  159. if (wscript != null) {
  160. wscript.SendKeys("{F11}");
  161. }
  162. }
  163. },
  164. indexDownloadFile : function(name,realName){
  165. },
  166. doEvalClick : function(url){
  167. $.indexOpenSelfWindow(url);
  168. top.Dialog.close();
  169. },
  170. doExamineClick : function(url){//考试
  171. window.open(url);
  172. top.Dialog.close();
  173. },
  174. addFrameTabs : function(arr){
  175. for(var i=0;i<arr.length;i++){
  176. var currentClass = "";
  177. if(i==0) currentClass = "positionTabCurrent";
  178. var $tab = $('<div class=" positiontitab positionTab '+currentClass+'" data-src="'+arr[i].url+'" >' +arr[i].name+'</div>');
  179. $("#positionMsg").append($tab);
  180. }
  181. },
  182. removeFrameTabs : function(){
  183. $(".positionTab").remove();
  184. },
  185. exportExcel : function(url,params,destFileName,fileExt){
  186. $.ajax({
  187. url :url,
  188. type : 'post',
  189. timeout : 150000,
  190. data : params,
  191. async:false,
  192. dataType : 'text',
  193. success : function(data){
  194. var fileUrl = $.pathname() +"/page/business/em/evaluate/inAndOutExcel/getExcel.jsp?exportContent="
  195. + data + "&fileExt="+fileExt+"&destFileName=" + encodeURI(encodeURI(destFileName));
  196. window.open(fileUrl);
  197. },
  198. error : function(e){
  199. top.Dialog.alert("导出Excel失败");
  200. }
  201. });
  202. }
  203. });
  204. })(jQuery,window,document);