common_statistic.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /**
  2. * 过滤掉undefined值,等于默认值,默认 ''
  3. * @param {*} value
  4. * @param {*} default_value
  5. */
  6. function GDV(value,default_value){
  7. if(value != undefined){
  8. return value ;
  9. }else{
  10. if(default_value == undefined){
  11. return '';
  12. }else{
  13. return default_value ;
  14. }
  15. }
  16. }
  17. /**
  18. * xxx分钟 转化 xx时xx分
  19. */
  20. function convertT(minute){
  21. return parseInt(minute/60) +"时"+minute%60+"分";
  22. }
  23. /**
  24. * 获取当前月份值
  25. * param: datet Date ,
  26. * return: month int
  27. */
  28. function getM(datet){
  29. var date = new Date();
  30. if(date!=undefined && datet instanceof Date){
  31. date = datet ;
  32. }
  33. return date.getMonth() +1 ;
  34. }
  35. /**
  36. * 根据Date 获取天数值
  37. * parm: string date
  38. * return int
  39. */
  40. function getD(date){
  41. var datev = new Date(date) ;
  42. return datev.getDate() ;
  43. }
  44. /**
  45. * 根据收费站id获取该收费站下的人员列表
  46. * param: fs_station_id , func 异步回调
  47. * return: String , List Option
  48. */
  49. function getFsEmployee(fs_station_id , func){
  50. var param = {
  51. "organid":fs_station_id
  52. }
  53. post_common_service("user/getFsUserList",param,function(data){
  54. var resultStr = ''
  55. if(data.length > 0){
  56. resultStr = "<option value=''>全部</option>";
  57. for(var i=0;i<data.length;i++){
  58. resultStr += "<option value="+data[i].id+">"+data[i].truename+"</option>";
  59. }
  60. }
  61. func(resultStr);
  62. },function(error){
  63. });
  64. }
  65. /**
  66. * 根据道管中心id 获取收费站select 列表
  67. * param: center_manage_id , func 异步回调方法
  68. * return: String select 下 List<Option>
  69. */
  70. function getFsStationList(center_manage_id,func){
  71. var param = {
  72. "parentid":center_manage_id
  73. }
  74. post_common_service("dept/getDeptInfosByDeptId",param,function(data){
  75. var str = '';
  76. if(data.length > 0){
  77. str = "<option value=''>全部</option>";
  78. for(var i=0;i<data.length;i++){
  79. str += "<option value="+data[i].id+">"+data[i].organname+"</option>";
  80. }
  81. }
  82. func(str);
  83. },function(error){
  84. });
  85. }
  86. /**
  87. * 写html value
  88. * @param {*} selector
  89. * @param {*} val
  90. */
  91. function WH(selector,val){
  92. $(selector).html(val);
  93. }
  94. /**
  95. * 根据选择器 回去value值
  96. * param: id 选择器
  97. * return value
  98. */
  99. function GV(selector){
  100. return $(selector).val();
  101. }
  102. /**
  103. * 根据选择器,获取html值
  104. * param:selector 选择器
  105. * return: html value
  106. */
  107. function GH(selector){
  108. return $(selector).html();
  109. }
  110. /**
  111. * 根据月份,判断当前月份天数
  112. * param: month String 月份 ,datet Date 年份
  113. * return:days( 28,29,30,31 )
  114. */
  115. function getDays(mouth,datet){
  116. //构造当前日期对象
  117. var date = new Date();
  118. if(date!=undefined && datet instanceof Date){
  119. date = datet ;
  120. }
  121. //获取年份
  122. var year = date.getFullYear();
  123. //定义当月的天数;
  124. var days ;
  125. //当月份为二月时,根据闰年还是非闰年判断天数
  126. if(mouth == 2){
  127. days= year % 4 == 0 ? 29 : 28;
  128. }
  129. else if(mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12){
  130. //月份为:1,3,5,7,8,10,12 时,为大月.则天数为31;
  131. days= 31;
  132. }
  133. else{
  134. days= 30;
  135. }
  136. return days ;
  137. }
  138. /**
  139. * 根据月份,判断当前月份天数
  140. * param: datet String 年份
  141. * return:days( 28,29,30,31 )
  142. */
  143. function getDaysByDate(datet){
  144. //构造当前日期对象
  145. var date = new Date(datet);
  146. //获取年份
  147. var year = date.getFullYear();
  148. var mouth = date.getMonth() +1 ;
  149. //定义当月的天数;
  150. var days ;
  151. //当月份为二月时,根据闰年还是非闰年判断天数
  152. if(mouth == 2){
  153. days= year % 4 == 0 ? 29 : 28;
  154. }
  155. else if(mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12){
  156. //月份为:1,3,5,7,8,10,12 时,为大月.则天数为31;
  157. days= 31;
  158. }
  159. else{
  160. days= 30;
  161. }
  162. return days ;
  163. }
  164. var months = new Array();
  165. var m = new Date().getMonth();
  166. var mth_pre = 12-m;
  167. var initDate;
  168. /**
  169. * 根据当前年月动态将13个月push数组
  170. */
  171. function month_method(){
  172. // 将上一年的当前月的上个月到12月加入到数组里//改为当前月到上年同月
  173. for(var i=1;i<=mth_pre+1;i++){
  174. mth_handle(m,(year-1),(m++));
  175. }
  176. // 将当前年的一月份到当前月的上个月加入到数组里(改为当前月)
  177. for(var i=1;i<=new Date().getMonth()+1;i++){
  178. mth_handle(i,year,i);
  179. }
  180. // 当前年月的上个月(初始化图用)
  181. if((new Date().getMonth()+'').length == 1){
  182. initDate = year+"/0"+new Date().getMonth();
  183. }else{
  184. initDate = year+"/"+new Date().getMonth();
  185. }
  186. }
  187. // 抽出的方法
  188. function mth_handle(mth,getYear,num){
  189. if((mth+'').length==1){
  190. months.push(((getYear)+'').substr(2)+"/0"+(num));
  191. }else{
  192. months.push(((getYear)+'').substr(2)+"/"+(num));
  193. }
  194. }
  195. /**
  196. * 月份下拉框
  197. */
  198. function select_option(){
  199. var str = $(".div-month select");
  200. var temp = '';
  201. for(var i=0;i<months.length;i++){
  202. temp += "<option value=20"+months[i]+">20"+months[i]+"</option>"
  203. }
  204. str.append(temp);
  205. }
  206. /**
  207. * 根据当前月份 获取前13个月份
  208. */
  209. function month_method_2(){
  210. var montharray = new Array();
  211. var now_month = new Date().getMonth() ;
  212. for(var i= now_month ; i<13;i++){
  213. montharray.push( (new Date().getFullYear()-1+'') + "/"+PrefixInteger(i,2) ) ;
  214. }
  215. for(var i=1;i<=now_month+1;i++){
  216. montharray.push( (new Date().getFullYear()+'') + "/"+ PrefixInteger(i,2) );
  217. }
  218. return montharray ;
  219. }
  220. // 数字前面补0
  221. function PrefixInteger(num, length) {
  222. return (Array(length).join('0') + num).slice(-length);
  223. }
  224. /**
  225. *
  226. * @param {*} str ep:2017/06
  227. * returns 2017-05-25 23:00:00
  228. */
  229. function timeTranslate(str){
  230. var strs = str.split("/") ;
  231. var year = strs[0];
  232. var month = strs[1];
  233. var month2 = month - 1 ;
  234. var year2 = year ;
  235. if( month2 == 0 ){
  236. year2 = year2 - 1 ;
  237. month2 = 12 ;
  238. }
  239. return year2 + "-"+month2 + "-25 23:00:00" ;
  240. }
  241. /**
  242. *
  243. * @param {*} datet
  244. * @param {*} changVal
  245. */
  246. function dateChange(datet , changVal ){
  247. var tempDate = new Date(datet.valueOf() - changVal);
  248. return tempDate.Format("yyyy-MM-dd HH:mm:ss");
  249. }