f9af10d4a26127c260f7c996d76188c0baa374df.svn-base 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /**
  2. * 两个json合并方法
  3. *
  4. * @param des
  5. * @param src
  6. * @param override
  7. * @return
  8. *
  9. * 例:
  10. *
  11. * var a ={"a":"1","b":"2"}
  12. * var b ={"c":"3","d":"4","e":"5"}
  13. * var c = extend({}, [a,b]);
  14. * alert(c.a);
  15. */
  16. function concatJson(des, src, override){
  17. if(src instanceof Array){
  18. for(var i = 0, len = src.length; i < len; i++)
  19. concatJson(des, src[i], override);
  20. }
  21. for( var i in src){
  22. if(override || !(i in des)){
  23. des[i] = src[i];
  24. }
  25. }
  26. return des;
  27. }
  28. /**
  29. * 添加或者修改json数据
  30. * @param jsonStr
  31. * @param name
  32. * @param value
  33. * @return
  34. *
  35. * 例:setJson(null,"name","aaa")
  36. */
  37. function setJson(jsonStr,name,value){
  38. if(!jsonStr)jsonStr="{}";
  39. var jsonObj = JSON.parse(jsonStr);
  40. jsonObj[name] = value;
  41. return JSON.stringify(jsonObj);
  42. }
  43. /**
  44. * 删除JSON数据
  45. * @param jsonStr
  46. * @param name
  47. * @return
  48. *
  49. * 例:deleteJson(myjsonStr,"age")
  50. */
  51. function deleteJson(jsonStr,name){
  52. if(!jsonStr)return null;
  53. var jsonObj = JSON.parse(jsonStr);
  54. delete jsonObj[name];
  55. return JSON.stringify(jsonObj);
  56. }
  57. /**
  58. * 查询区域表单
  59. *
  60. * @param obj
  61. * @return 返回json对象 如{"CODE_401":"E1SI","NAME_401":"全新"}
  62. */
  63. function getQueryFormParams(obj){
  64. var params = obj.formToArray();
  65. var json = null;
  66. for(var i=0;i<params.length;i++){
  67. json = setJson(json,params[i].name,params[i].value);
  68. }
  69. var queryParams = eval('(' + json + ')');
  70. return queryParams;
  71. }
  72. /**
  73. * 交通数据查询
  74. * 地图定位
  75. * @return
  76. */
  77. function getMapPointDialog(linexy,code,point_x,point_y){
  78. var pointdata = linexy+"-"+code+"-"+point_x+"-"+point_y ;
  79. var diag = new top.Dialog();
  80. // diag.Title = "查看定位信息";s
  81. // diag.URL = $.pathname() +"/page/business/common/detailInfo.html",
  82. diag.URL = $.pathname() +"/page/business/common/locationmap.html"+'?params='+pointdata;
  83. //diag.InnerHtml = '地图窗口<br/>classid:'+classid+'<br/>code:'+code+'<br/>condition:'+condition;
  84. diag.show();
  85. }
  86. /**
  87. * 查询表的数据构造
  88. * 下拉框数据
  89. * @param obj 下拉框对象
  90. * @param tableName 表名
  91. * @param columnName 字段名
  92. * @param condition 条件
  93. * @return
  94. */
  95. function getSelectOptions(obj,tableName,columnName,condition){
  96. var url = $.pathname() + "/ws/sys/constantService/getSelectConstant/";
  97. var params = {
  98. "name" : tableName,
  99. "column" : columnName,
  100. "condition":condition
  101. };
  102. $.post(url,params,function(result){
  103. obj.data("data",result);
  104. obj.render();
  105. },"json");
  106. }
  107. /***
  108. * 删除数组中的某一元素
  109. * @param n 数组下标
  110. * @return
  111. *
  112. concat方法:返回一个新数组,这个新数组是由两个或更多数组组合而成的。
  113.       这里就是返回this.slice(0,n)/this.slice(n+1,this.length)
  114.       组成的新数组,这中间,刚好少了第n项。
  115. slice方法: 返回一个数组的一段,两个参数,分别指定开始和结束的位置。
  116. */
  117. function delArray(array,n){
  118. if(n<0)
  119. return array;
  120. else
  121. return array.slice(0,n).concat(array.slice(n+1,array.length));
  122. }
  123. /**
  124. * 得到日期查询条件 (日期从,日期到)
  125. * startDate 开始时间
  126. * endDate 结束时间
  127. * fieldName 字段名称
  128. * */
  129. function getDateCondition(startDate, endDate, fieldName){
  130. var condition = "";
  131. if((startDate != undefined && startDate != '') && (endDate!= undefined && endDate !='')){
  132. condition = fieldName+" between '"+startDate+" 00:00:00' and '"+endDate+" 23:59:59' and ";
  133. }else if((startDate!=undefined && startDate!='') && (endDate==undefined || endDate=='')){
  134. condition = fieldName+" >= '"+startDate+" 00:00:00' and ";
  135. }else if((endDate!=undefined && endDate!='') && (startDate==undefined || startDate=='')){
  136. condition = fieldName+" <= '"+endDate+" 23:59:59' and ";
  137. }
  138. return condition;
  139. }
  140. /***
  141. * 下拉js
  142. * @param $field
  143. * @param tableName
  144. */
  145. function getSelectBox($field,tableName){
  146. var url = $.pathname() + '/ws/sys/constantService/getQuiConstantByName/';
  147. $.post(url,{name:tableName},function(data){
  148. $field.data("data",data);
  149. $field.render();
  150. },"json");
  151. }