123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- /**
- * 两个json合并方法
- *
- * @param des
- * @param src
- * @param override
- * @return
- *
- * 例:
- *
- * var a ={"a":"1","b":"2"}
- * var b ={"c":"3","d":"4","e":"5"}
- * var c = extend({}, [a,b]);
- * alert(c.a);
- */
- function concatJson(des, src, override){
- if(src instanceof Array){
- for(var i = 0, len = src.length; i < len; i++)
- concatJson(des, src[i], override);
- }
- for( var i in src){
- if(override || !(i in des)){
- des[i] = src[i];
- }
- }
- return des;
- }
- /**
- * 添加或者修改json数据
- * @param jsonStr
- * @param name
- * @param value
- * @return
- *
- * 例:setJson(null,"name","aaa")
- */
- function setJson(jsonStr,name,value){
- if(!jsonStr)jsonStr="{}";
- var jsonObj = JSON.parse(jsonStr);
- jsonObj[name] = value;
- return JSON.stringify(jsonObj);
- }
- /**
- * 删除JSON数据
- * @param jsonStr
- * @param name
- * @return
- *
- * 例:deleteJson(myjsonStr,"age")
- */
- function deleteJson(jsonStr,name){
- if(!jsonStr)return null;
- var jsonObj = JSON.parse(jsonStr);
- delete jsonObj[name];
- return JSON.stringify(jsonObj);
- }
- /**
- * 查询区域表单
- *
- * @param obj
- * @return 返回json对象 如{"CODE_401":"E1SI","NAME_401":"全新"}
- */
- function getQueryFormParams(obj){
- var params = obj.formToArray();
- var json = null;
- for(var i=0;i<params.length;i++){
- json = setJson(json,params[i].name,params[i].value);
- }
- var queryParams = eval('(' + json + ')');
- return queryParams;
- }
- /**
- * 交通数据查询
- * 地图定位
- * @return
- */
- function getMapPointDialog(linexy,code,point_x,point_y){
- var pointdata = linexy+"-"+code+"-"+point_x+"-"+point_y ;
- var diag = new top.Dialog();
- // diag.Title = "查看定位信息";s
- // diag.URL = $.pathname() +"/page/business/common/detailInfo.html",
- diag.URL = $.pathname() +"/page/business/common/locationmap.html"+'?params='+pointdata;
- //diag.InnerHtml = '地图窗口<br/>classid:'+classid+'<br/>code:'+code+'<br/>condition:'+condition;
- diag.show();
- }
- /**
- * 查询表的数据构造
- * 下拉框数据
- * @param obj 下拉框对象
- * @param tableName 表名
- * @param columnName 字段名
- * @param condition 条件
- * @return
- */
- function getSelectOptions(obj,tableName,columnName,condition){
-
- var url = $.pathname() + "/ws/sys/constantService/getSelectConstant/";
- var params = {
- "name" : tableName,
- "column" : columnName,
- "condition":condition
- };
- $.post(url,params,function(result){
- obj.data("data",result);
- obj.render();
- },"json");
- }
- /***
- * 删除数组中的某一元素
- * @param n 数组下标
- * @return
- *
- concat方法:返回一个新数组,这个新数组是由两个或更多数组组合而成的。
- 这里就是返回this.slice(0,n)/this.slice(n+1,this.length)
- 组成的新数组,这中间,刚好少了第n项。
- slice方法: 返回一个数组的一段,两个参数,分别指定开始和结束的位置。
- */
- function delArray(array,n){
- if(n<0)
- return array;
- else
- return array.slice(0,n).concat(array.slice(n+1,array.length));
- }
- /**
- * 得到日期查询条件 (日期从,日期到)
- * startDate 开始时间
- * endDate 结束时间
- * fieldName 字段名称
- * */
- function getDateCondition(startDate, endDate, fieldName){
- var condition = "";
- if((startDate != undefined && startDate != '') && (endDate!= undefined && endDate !='')){
- condition = fieldName+" between '"+startDate+" 00:00:00' and '"+endDate+" 23:59:59' and ";
- }else if((startDate!=undefined && startDate!='') && (endDate==undefined || endDate=='')){
- condition = fieldName+" >= '"+startDate+" 00:00:00' and ";
- }else if((endDate!=undefined && endDate!='') && (startDate==undefined || startDate=='')){
- condition = fieldName+" <= '"+endDate+" 23:59:59' and ";
- }
- return condition;
- }
- /***
- * 下拉js
- * @param $field
- * @param tableName
- */
- function getSelectBox($field,tableName){
- var url = $.pathname() + '/ws/sys/constantService/getQuiConstantByName/';
- $.post(url,{name:tableName},function(data){
- $field.data("data",data);
- $field.render();
- },"json");
- }
|