f16f7a356c7781eaf5d2d012401fe33ffb2596c5.svn-base 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. //获取当前日期时间,格式:YYYY-MM-DD hh:mm:ss
  2. function getNowDateTime(){
  3. var date=allGetServerTime();
  4. return date.getFullYear()+"-"+(parseInt(date.getMonth())+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
  5. }
  6. //获取当前时间,格式:hh:mm
  7. function getNowTime(){
  8. var date=allGetServerTime();
  9. return (date.getHours()<10?"0"+date.getHours():date.getHours())+":"+(date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes());
  10. //(date.getHours()<10?"0"+date.getHours():date.getHours())+":"+(date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes())+":"+(date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds());
  11. }
  12. //根据高端判断显示的li的数量
  13. function adaptHeight($maincon,height){
  14. $maincon.find("li").each(function(){
  15. $(this).show();
  16. });
  17. $maincon.find("li").each(function(){
  18. if(($(this).offset().top+$(this).height())>height){
  19. $(this).hide();
  20. }
  21. });
  22. }
  23. //增加鼠标移入移除和点击过的效果效果
  24. function enterLeaveClick($com){
  25. $com.find("li").each(function(){
  26. $(this).on("click",function(){
  27. $(this).addClass("_fn_click");
  28. }).on("mouseenter",function(){
  29. $(this).addClass("_fn_enter");
  30. }).on("mouseleave",function(){
  31. $(this).removeClass("_fn_enter");
  32. });
  33. });
  34. }
  35. //解析主页面传递的参数
  36. function resolveUrl(){
  37. var encondeCondition=window.location.search;
  38. var condition= decodeURI(encondeCondition.substring(1,encondeCondition.length));
  39. var conditionArr=condition.split("&");
  40. var condJson={};
  41. for(var item in conditionArr){
  42. var temArr=conditionArr[item].split("=");
  43. condJson[temArr[0]]=temArr[1];
  44. }
  45. return condJson;
  46. }
  47. //加载list
  48. function loadSelect($dom,param){
  49. $dom.empty();
  50. $dom.data("data",param);
  51. $dom.render();
  52. }
  53. //***************************************全屏*************************************************************
  54. // 启动全屏!
  55. function fullScreen(dom) {
  56. //非全屏时,进入全屏
  57. var el = dom,
  58. rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,
  59. wscript;
  60. if(typeof rfs != "undefined" && rfs) {
  61. rfs.call(el);
  62. return ;
  63. }
  64. if(typeof window.ActiveXObject != "undefined") {
  65. wscript = new ActiveXObject("WScript.Shell");
  66. if(wscript) {
  67. wscript.SendKeys("{F11}");
  68. }
  69. }
  70. }
  71. //退出全屏
  72. function exitFullScreen() {
  73. //全屏时,退出全屏
  74. var el = document,
  75. cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,
  76. wscript;
  77. if (typeof cfs != "undefined" && cfs) {
  78. cfs.call(el);
  79. return ;
  80. }
  81. if (typeof window.ActiveXObject != "undefined") {
  82. wscript = new ActiveXObject("WScript.Shell");
  83. if (wscript != null) {
  84. wscript.SendKeys("{F11}");
  85. }
  86. }
  87. //更改页面屏幕显示状态,显示为非全屏
  88. }
  89. //判断浏览器的类型
  90. function getOs() {
  91. if(navigator.userAgent.indexOf("MSIE")>0) {
  92. return "MSIE";
  93. }
  94. if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
  95. return "Firefox";
  96. }
  97. if(isSafari=navigator.userAgent.indexOf("Safari")>0) {
  98. return "Safari";
  99. }
  100. if(isCamino=navigator.userAgent.indexOf("Camino")>0){
  101. return "Camino";
  102. }
  103. if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){
  104. return "Gecko";
  105. }
  106. }
  107. //如果浏览器的类型为IE则默认全屏显示
  108. function defaultScreen(){
  109. if("MSIE"==getOs()){
  110. fullScreen(document.documentElement);
  111. }
  112. }
  113. //将字符串转换为整数,补0操作
  114. function changeQ(param){
  115. if(param=="")return 0;
  116. return parseInt(param);
  117. }
  118. //拼接grid表格表头字段
  119. function appendDisplay(params){
  120. var columns=[];
  121. for(var index=0;index<params.length;index++){
  122. var temp={ display:params[index].key , name:params[index].column, align: 'center', width: 100/params.length+"%"};
  123. columns.push(temp);
  124. }
  125. return columns;
  126. }
  127. /**
  128. * 用户角色判断,是否包指定用户角色
  129. */
  130. function isRole(rolesStr,role){
  131. return rolesStr.indexOf(role)==-1?false:true;
  132. }
  133. /************************************************************************************************/
  134. /**
  135. *获取刷新时间
  136. *时间列表未被选择,选择为空或者该值为0,保持原来的数据不变
  137. *如果有值则变更为改值
  138. */
  139. function getInterval($dom,n){
  140. if($dom.data("selectedNode")==""||$dom.data("selectedNode")==undefined||$dom.data("selectedNode").value==0)return n;
  141. return $dom.data("selectedNode").value;
  142. }
  143. /**
  144. *获取查询历史时间
  145. *如果查询历史的时间为空则默认为当前时间
  146. *如果查询时间不为空,则为当前输入查询的时间;
  147. */
  148. function getTimeChart($dom){
  149. return $dom.val()==""?getNowDateTime():$dom.val();
  150. }
  151. /**
  152. *获取电压等级
  153. *如果为选中则默认为当前选择,
  154. *如果选中,则为当前选中的电压等级
  155. */
  156. function getLevel($dom,levelParams){
  157. if($dom.data("selectedNodes").length>0){
  158. levelParams=[];
  159. $.each($dom.data("selectedNodes"),function(index,item){
  160. levelParams.push({name:item.name,column:item.column});
  161. });
  162. }
  163. return levelParams;
  164. }
  165. /**
  166. *获取部门
  167. *
  168. */
  169. function getDepartment($dom,param){
  170. if($dom.data("selectedNodes").length>0){
  171. HTitle["change"]="";
  172. categorie=[];
  173. childId="";
  174. bindChildId=[];
  175. $.each($dom.data("selectedNodes"),function(index,item){
  176. HTitle["change"]+=',"'+item.name+'"';
  177. categorie.push(item.name);
  178. childId+="'"+item.id+"',";
  179. if(item.id==urlParams["dept_id"]){
  180. parentId=urlParams["parentId"];
  181. }else{
  182. parentId=item.parentId;
  183. }
  184. });
  185. childId=childId.substring(0,childId.lastIndexOf(","));
  186. bindChildId=childId.split(",");
  187. HTitle["change"]=HTitle["change"].substring(1,HTitle["change"].length);
  188. text=HTitle[tState]+param;
  189. }
  190. return false;
  191. }
  192. /**
  193. *移除定时器
  194. *如果定时器不为空则清除定时器
  195. *返回null,清除内存
  196. */
  197. function removeRendChart(interval){
  198. if(interval!=null){
  199. clearInterval(interval);
  200. }
  201. return null;
  202. }
  203. /*
  204. *定时器自动刷新
  205. *如果定时器不为空,先清空定时器,然后进行定时操作
  206. *如果定时器为空,直接进行定时操作
  207. */
  208. function outoRendChart(interval,n,fn){
  209. if(interval!=null){
  210. interval=removeRendChart();
  211. }
  212. interval=setInterval(function(){
  213. fn();
  214. },n*1000);
  215. return interval;
  216. }
  217. /*
  218. *获取x轴数据显示的数量
  219. *如果未选中,选中的不存在或者输入为0,均已原来的数据为准
  220. *否则以选中的个数为准
  221. */
  222. function getN(n){
  223. if($("#n").val()==undefined|| $("#n").val()==0||$("#n").val()=="")return n;
  224. return $("#n").val();
  225. }
  226. /*
  227. *获取选中电压的状态
  228. *如果选中,以选中的为准,
  229. *否则以原来的状态为准
  230. */
  231. function getState(state){
  232. //未选中复选款时退出
  233. if($("input[name=state]:checked").size()<1)return state;
  234. //选中复选框,更新恢复的状态
  235. state=[];
  236. $("input[name=state]:checked").each(function(){
  237. var temp={};
  238. temp.name=$(this).attr("data");
  239. temp.column=$(this).attr("value");
  240. state.push(temp);
  241. });
  242. return state;
  243. }
  244. /*
  245. *获取查询历史的记录的时间
  246. */
  247. function getTime(){
  248. if(""!=$("#startTime").val())startTime=$("#startTime").val();
  249. dateTime=$("#dataTime").val()==""?getNowDateTime():$("#dataTime").val();
  250. }
  251. /*
  252. * 拼接字符串,将历史日期拼接成逗号分隔开的字符串
  253. *
  254. */
  255. function getDateStr(dateArr){
  256. var dateArray=[];
  257. for(var item=0 ;item<dateArr.length; item++){
  258. dateArray.push(dateArr[item]["APPEAR_TIME"])
  259. }
  260. return dateArray.join(",");
  261. }
  262. /*
  263. * 关闭和展开查询菜单面板
  264. */
  265. function switchSearchPlane(){
  266. if($("#choose_content").css("display")==="none"){
  267. $("#choose_content").show();
  268. }else{$("#choose_content").hide();};
  269. }
  270. var resizePage=null;
  271. /*
  272. * 全屏操作
  273. */
  274. function fullScreenOpration(){
  275. var ratio = 0,
  276. screen = window.screen,
  277. ua = navigator.userAgent.toLowerCase();
  278. if (window.devicePixelRatio !== undefined) {
  279. ratio = window.devicePixelRatio;
  280. }else if (~ua.indexOf('msie')) {
  281. if (screen.deviceXDPI && screen.logicalXDPI) {
  282. ratio = screen.deviceXDPI / screen.logicalXDPI;
  283. }
  284. }else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
  285. ratio = window.outerWidth / window.innerWidth;
  286. }
  287. if(Math.abs(window.screen.height -document.body.clientHeight*ratio)>5){
  288. fullScreen(document.documentElement);
  289. }else{
  290. exitFullScreen();
  291. }
  292. }
  293. function isFullScreen(fn_full,fn_exit_full){
  294. var ratio = 0,
  295. screen = window.screen,
  296. ua = navigator.userAgent.toLowerCase();
  297. if (window.devicePixelRatio !== undefined) {
  298. ratio = window.devicePixelRatio;
  299. }else if (~ua.indexOf('msie')) {
  300. if (screen.deviceXDPI && screen.logicalXDPI) {
  301. ratio = screen.deviceXDPI / screen.logicalXDPI;
  302. }
  303. }else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
  304. ratio = window.outerWidth / window.innerWidth;
  305. }
  306. if(Math.abs(window.screen.height -document.body.clientHeight*ratio)>5){
  307. fn_full();
  308. }else{
  309. fn_exit_full();
  310. }
  311. }
  312. /*
  313. * 拼接字符串
  314. */
  315. function appendJSONColumnToStr(params,column,cStr){
  316. var temp=[];
  317. for(var index in params){
  318. temp.push(params[index][column]);
  319. }
  320. return temp.join(cStr);
  321. }