123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- //获取当前日期时间,格式:YYYY-MM-DD hh:mm:ss
- function getNowDateTime(){
- var date=allGetServerTime();
- return date.getFullYear()+"-"+(parseInt(date.getMonth())+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
- }
- //获取当前时间,格式:hh:mm
- function getNowTime(){
- var date=allGetServerTime();
- return (date.getHours()<10?"0"+date.getHours():date.getHours())+":"+(date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes());
- //(date.getHours()<10?"0"+date.getHours():date.getHours())+":"+(date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes())+":"+(date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds());
- }
- //根据高端判断显示的li的数量
- function adaptHeight($maincon,height){
- $maincon.find("li").each(function(){
- $(this).show();
- });
- $maincon.find("li").each(function(){
- if(($(this).offset().top+$(this).height())>height){
- $(this).hide();
- }
-
- });
- }
- //增加鼠标移入移除和点击过的效果效果
- function enterLeaveClick($com){
- $com.find("li").each(function(){
- $(this).on("click",function(){
- $(this).addClass("_fn_click");
- }).on("mouseenter",function(){
- $(this).addClass("_fn_enter");
- }).on("mouseleave",function(){
- $(this).removeClass("_fn_enter");
- });
- });
- }
- //解析主页面传递的参数
- function resolveUrl(){
- var encondeCondition=window.location.search;
- var condition= decodeURI(encondeCondition.substring(1,encondeCondition.length));
- var conditionArr=condition.split("&");
- var condJson={};
- for(var item in conditionArr){
- var temArr=conditionArr[item].split("=");
- condJson[temArr[0]]=temArr[1];
- }
- return condJson;
- }
- //加载list
- function loadSelect($dom,param){
- $dom.empty();
- $dom.data("data",param);
- $dom.render();
- }
- //***************************************全屏*************************************************************
- // 启动全屏!
- function fullScreen(dom) {
- //非全屏时,进入全屏
- var el = dom,
- rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,
- wscript;
- if(typeof rfs != "undefined" && rfs) {
- rfs.call(el);
- return ;
- }
- if(typeof window.ActiveXObject != "undefined") {
- wscript = new ActiveXObject("WScript.Shell");
- if(wscript) {
- wscript.SendKeys("{F11}");
-
- }
- }
-
- }
- //退出全屏
- function exitFullScreen() {
- //全屏时,退出全屏
- var el = document,
- cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,
- wscript;
- if (typeof cfs != "undefined" && cfs) {
- cfs.call(el);
- return ;
- }
- if (typeof window.ActiveXObject != "undefined") {
- wscript = new ActiveXObject("WScript.Shell");
- if (wscript != null) {
- wscript.SendKeys("{F11}");
-
- }
- }
- //更改页面屏幕显示状态,显示为非全屏
- }
-
- //判断浏览器的类型
- function getOs() {
- if(navigator.userAgent.indexOf("MSIE")>0) {
- return "MSIE";
- }
- if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
- return "Firefox";
- }
- if(isSafari=navigator.userAgent.indexOf("Safari")>0) {
- return "Safari";
- }
- if(isCamino=navigator.userAgent.indexOf("Camino")>0){
- return "Camino";
- }
- if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){
- return "Gecko";
- }
- }
- //如果浏览器的类型为IE则默认全屏显示
- function defaultScreen(){
- if("MSIE"==getOs()){
- fullScreen(document.documentElement);
- }
- }
-
- //将字符串转换为整数,补0操作
- function changeQ(param){
- if(param=="")return 0;
- return parseInt(param);
- }
- //拼接grid表格表头字段
- function appendDisplay(params){
- var columns=[];
- for(var index=0;index<params.length;index++){
- var temp={ display:params[index].key , name:params[index].column, align: 'center', width: 100/params.length+"%"};
- columns.push(temp);
- }
- return columns;
- }
- /**
- * 用户角色判断,是否包指定用户角色
- */
- function isRole(rolesStr,role){
- return rolesStr.indexOf(role)==-1?false:true;
- }
- /************************************************************************************************/
- /**
- *获取刷新时间
- *时间列表未被选择,选择为空或者该值为0,保持原来的数据不变
- *如果有值则变更为改值
- */
- function getInterval($dom,n){
- if($dom.data("selectedNode")==""||$dom.data("selectedNode")==undefined||$dom.data("selectedNode").value==0)return n;
- return $dom.data("selectedNode").value;
- }
- /**
- *获取查询历史时间
- *如果查询历史的时间为空则默认为当前时间
- *如果查询时间不为空,则为当前输入查询的时间;
- */
- function getTimeChart($dom){
- return $dom.val()==""?getNowDateTime():$dom.val();
- }
- /**
- *获取电压等级
- *如果为选中则默认为当前选择,
- *如果选中,则为当前选中的电压等级
- */
- function getLevel($dom,levelParams){
- if($dom.data("selectedNodes").length>0){
- levelParams=[];
- $.each($dom.data("selectedNodes"),function(index,item){
- levelParams.push({name:item.name,column:item.column});
- });
- }
- return levelParams;
- }
- /**
- *获取部门
- *
- */
- function getDepartment($dom,param){
- if($dom.data("selectedNodes").length>0){
- HTitle["change"]="";
- categorie=[];
- childId="";
- bindChildId=[];
- $.each($dom.data("selectedNodes"),function(index,item){
- HTitle["change"]+=',"'+item.name+'"';
- categorie.push(item.name);
- childId+="'"+item.id+"',";
- if(item.id==urlParams["dept_id"]){
- parentId=urlParams["parentId"];
- }else{
- parentId=item.parentId;
- }
- });
- childId=childId.substring(0,childId.lastIndexOf(","));
- bindChildId=childId.split(",");
- HTitle["change"]=HTitle["change"].substring(1,HTitle["change"].length);
- text=HTitle[tState]+param;
- }
- return false;
- }
- /**
- *移除定时器
- *如果定时器不为空则清除定时器
- *返回null,清除内存
- */
- function removeRendChart(interval){
- if(interval!=null){
- clearInterval(interval);
- }
- return null;
- }
- /*
- *定时器自动刷新
- *如果定时器不为空,先清空定时器,然后进行定时操作
- *如果定时器为空,直接进行定时操作
- */
- function outoRendChart(interval,n,fn){
- if(interval!=null){
- interval=removeRendChart();
- }
- interval=setInterval(function(){
- fn();
- },n*1000);
- return interval;
- }
- /*
- *获取x轴数据显示的数量
- *如果未选中,选中的不存在或者输入为0,均已原来的数据为准
- *否则以选中的个数为准
- */
- function getN(n){
- if($("#n").val()==undefined|| $("#n").val()==0||$("#n").val()=="")return n;
- return $("#n").val();
- }
-
- /*
- *获取选中电压的状态
- *如果选中,以选中的为准,
- *否则以原来的状态为准
- */
- function getState(state){
- //未选中复选款时退出
- if($("input[name=state]:checked").size()<1)return state;
- //选中复选框,更新恢复的状态
- state=[];
- $("input[name=state]:checked").each(function(){
- var temp={};
- temp.name=$(this).attr("data");
- temp.column=$(this).attr("value");
- state.push(temp);
- });
- return state;
- }
-
- /*
- *获取查询历史的记录的时间
- */
- function getTime(){
- if(""!=$("#startTime").val())startTime=$("#startTime").val();
- dateTime=$("#dataTime").val()==""?getNowDateTime():$("#dataTime").val();
- }
- /*
- * 拼接字符串,将历史日期拼接成逗号分隔开的字符串
- *
- */
- function getDateStr(dateArr){
- var dateArray=[];
- for(var item=0 ;item<dateArr.length; item++){
- dateArray.push(dateArr[item]["APPEAR_TIME"])
- }
- return dateArray.join(",");
- }
-
- /*
- * 关闭和展开查询菜单面板
- */
- function switchSearchPlane(){
- if($("#choose_content").css("display")==="none"){
- $("#choose_content").show();
- }else{$("#choose_content").hide();};
- }
- var resizePage=null;
- /*
- * 全屏操作
- */
- function fullScreenOpration(){
- var ratio = 0,
- screen = window.screen,
- ua = navigator.userAgent.toLowerCase();
- if (window.devicePixelRatio !== undefined) {
- ratio = window.devicePixelRatio;
- }else if (~ua.indexOf('msie')) {
- if (screen.deviceXDPI && screen.logicalXDPI) {
- ratio = screen.deviceXDPI / screen.logicalXDPI;
- }
- }else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
- ratio = window.outerWidth / window.innerWidth;
- }
-
- if(Math.abs(window.screen.height -document.body.clientHeight*ratio)>5){
-
- fullScreen(document.documentElement);
- }else{
-
- exitFullScreen();
- }
- }
- function isFullScreen(fn_full,fn_exit_full){
- var ratio = 0,
- screen = window.screen,
- ua = navigator.userAgent.toLowerCase();
-
- if (window.devicePixelRatio !== undefined) {
- ratio = window.devicePixelRatio;
- }else if (~ua.indexOf('msie')) {
- if (screen.deviceXDPI && screen.logicalXDPI) {
- ratio = screen.deviceXDPI / screen.logicalXDPI;
- }
- }else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
- ratio = window.outerWidth / window.innerWidth;
- }
- if(Math.abs(window.screen.height -document.body.clientHeight*ratio)>5){
- fn_full();
- }else{
- fn_exit_full();
- }
- }
- /*
- * 拼接字符串
- */
- function appendJSONColumnToStr(params,column,cStr){
- var temp=[];
- for(var index in params){
- temp.push(params[index][column]);
- }
- return temp.join(cStr);
- }
|