zoukankan      html  css  js  c++  java
  • 保存查询条件的对象



    1:全部对象声明:

      1 
      2 /**
      3  * 声明:保存查询条件的对象
      4  *
      5  *                           	 var tabIndex=window.parent.cTab.tabs('getTabIndex', window.parent.cTab.tabs('getSelected'));//获取当前页签的序号
      6  *                               var tabTitle= window.parent.cTab.tabs('getSelected').panel('options').title;//拿到当前功能菜单的页签标题
      7  *	                             var tab = window.parent.cTab.tabs('getSelected').panel('options').tab;    // 相应的 tab 对象
      8  *
      9  *                           // var  current_tabTitle = $('.tabs-selected').text();  //获取当前页签的标题
     10  * 在功能页面获取该对象的方法: var atest=window.parent.globalQueryParam;
     11  * 给该对象赋值:
     12  *                  var queryPara={ TabTitle:Title,aa:1,bb:2,cc:4,rr:53[,...]}//TabTitle:tabTitle (或  TabIndex:tabIndex) 这个值是必须要有的
     13  *  	            atest.addParam('aaa',queryPara);
     14  *获取该对象中的值: atest.getParam('aaa')
     15  *清除该对象中的值:	atest.delParam('aaa')
     16  */
     17 window.globalQueryParamCopy={
     18 	/**
     19 	  * 删除:查询条件的参数
     20 	  */
     21 	delParam:function(vopParam){
     22 		  var self=this;
     23 		  if(self[vopParam] !=undefined ){
     24 			  delete self[vopParam];
     25 		  }
     26 		  return self;
     27 	}
     28 };//备份对象
     29 window.globalQueryParam = {
     30 	/**
     31 	 * 添加 查询条件的参数
     32 	 */
     33 	addParam:function(vopParam,queryParam){
     34 	    var self=this;
     35 	    globalQueryParamCopy={};//查询参数备份对象:清空
     36 	    //给查询参数对象 设置值
     37 		if(self[vopParam] != undefined ){
     38 			self.delParam(vopParam);
     39 			self[vopParam]=queryParam;
     40 		}else{
     41 			self[vopParam]=queryParam;
     42 		}
     43 		//备份查询参数对象 调用js深度复制方法,从查询参数对象中复制值;
     44 		 globalQueryParamCopy= JSON.parse( JSON.stringify( self ) );
     45 		return self;
     46 	   },
     47 	 /**
     48 	  * 删除:查询条件的参数
     49 	  */
     50 	delParam:function(vopParam){
     51 		  var self=this;
     52 		  globalQueryParamCopy={};//查询参数备份对象:清空
     53 		  if(self[vopParam] !=undefined ){
     54 			  delete self[vopParam];
     55 		  }
     56 		  //备份查询参数对象 调用js深度复制方法,从查询参数对象中复制值;
     57 	      globalQueryParamCopy= JSON.parse( JSON.stringify( self ) );
     58 		  return self;
     59 	},
     60 	/**
     61 	 *  根据参数,获取保存在globalQueryParam中的查询参数
     62 	 */
     63 	getParam:function(vopParam){
     64 		  var self=this;
     65 		  var param={};
     66 		  if(globalQueryParamCopy[vopParam]!=undefined  ){
     67 			  param=globalQueryParamCopy[vopParam];
     68 		  }
     69 		 return param;
     70 	}
     71 };
     72 
     73  /**
     74   * JS 深度复制
     75   * @param obj
     76   * @returns
     77   */
     78 function cloneObject(obj){
     79 	    	var o = (obj.constructor === Array) ? [] : {};
     80 	 		for(var i in obj){
     81 	 			if(obj.hasOwnProperty(i)){
     82 	 			     o[i] = (typeof obj[i] === "object" )? (obj['alias']!=null?cloneObject(obj['alias']):{}) : ((obj[i] !=undefined)?obj[i]:'');
     83 	 			}
     84 	 		}
     85 	 		return o;
     86 }
     87 
     88 

    2:方法的调用

      1 	window.globalQueryParam = window.parent.globalQueryParam;
      2 	if(window.globalQueryParam.getParam('indexChangeNotice').bdgyear){
      3 		window.bdgyear = window.globalQueryParam.getParam('indexChangeNotice').bdgyear;
      4 	}else{
      5 		window.bdgyear = window.curBdgyear;
      6 	}
      7 
      8 	window.condForm = $("#condForm").getWidget();
      9 	if(window.globalQueryParam.getParam('indexChangeNotice').condition){
     10 		window.condFormConditions = window.condForm.getConditions();
     11 		window.condFormConditions = window.globalQueryParam.getParam('indexChangeNotice').condition;
     12 		window.condForm.setConditions(condFormConditions);//赋值
     13 	}
     14 
     15 	initWidgets();
     16 	initDatabinds();
     17 
     18 	window.condForm.submit();
     19 
     20 	$("#submit").click(function(){
     21 		var flag = false;
     22 		window.condFormConditions = window.condForm.getConditions();
     23 		if(window.condFormConditions != undefined){
     24 			if(condFormConditions.condition!=undefined && condFormConditions.condition.conditions!=undefined && condFormConditions.condition.conditions.length>0){
     25 				flag = true;
     26 			}
     27 		}
     28 
     29 		if(flag){
     30 			if(window.globalQueryParam.getParam('indexChangeNotice').bdgyear
     31 					|| window.globalQueryParam.getParam('indexChangeNotice').condition){
     32 				window.globalQueryParam.getParam('indexChangeNotice').condition = window.condFormConditions;
     33 			}else{
     34 				window.globalQueryParam.addParam('indexChangeNotice',{condition:window.condFormConditions});
     35 			}
     36 		}else{
     37 			if(window.globalQueryParam.getParam('indexChangeNotice').bdgyear
     38 					|| window.globalQueryParam.getParam('indexChangeNotice').condition){
     39 				window.globalQueryParam.getParam('indexChangeNotice').condition = [];
     40 			}else{
     41 				window.globalQueryParam.addParam('indexChangeNotice',{condition:[]});
     42 			}
     43 		}
     44 
     45 		window.condForm.submit();
     46 	});
     47 
     48 	$("#reset").click(function(){
     49 		window.condForm.clear();
     50 	});
  • 相关阅读:
    深入理解JVM(六)——类加载器原理
    深入理解JVM(五)——垃圾回收器
    深入理解JVM(四)——垃圾回收算法
    Let's Encrypt,免费好用的 HTTPS 证书
    开源框架(整理)
    【转】JS组件系列——Bootstrap组件福利篇:几款好用的组件推荐(二)
    C#开源项目大全
    window平台搭建Hudson服务器
    Git 常用命令
    Mongodb Windows 集群
  • 原文地址:https://www.cnblogs.com/ios9/p/8583383.html
Copyright © 2011-2022 走看看