| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- /**
- * 过滤掉undefined值,等于默认值,默认 ''
- * @param {*} value
- * @param {*} default_value
- */
- function GDV(value,default_value){
- if(value != undefined){
- return value ;
- }else{
- if(default_value == undefined){
- return '';
- }else{
- return default_value ;
- }
- }
- }
- /**
- * xxx分钟 转化 xx时xx分
- */
- function convertT(minute){
- return parseInt(minute/60) +"时"+minute%60+"分";
- }
- /**
- * 获取当前月份值
- * param: datet Date ,
- * return: month int
- */
- function getM(datet){
- var date = new Date();
- if(date!=undefined && datet instanceof Date){
- date = datet ;
- }
- return date.getMonth() +1 ;
- }
- /**
- * 根据Date 获取天数值
- * parm: string date
- * return int
- */
- function getD(date){
- var datev = new Date(date) ;
- return datev.getDate() ;
- }
- /**
- * 根据收费站id获取该收费站下的人员列表
- * param: fs_station_id , func 异步回调
- * return: String , List Option
- */
- function getFsEmployee(fs_station_id , func){
- var param = {
- "organid":fs_station_id
- }
- post_common_service("user/getFsUserList",param,function(data){
- var resultStr = ''
- if(data.length > 0){
- resultStr = "<option value=''>全部</option>";
- for(var i=0;i<data.length;i++){
- resultStr += "<option value="+data[i].id+">"+data[i].truename+"</option>";
- }
- }
- func(resultStr);
- },function(error){
- });
- }
- /**
- * 根据道管中心id 获取收费站select 列表
- * param: center_manage_id , func 异步回调方法
- * return: String select 下 List<Option>
- */
- function getFsStationList(center_manage_id,func){
- var param = {
- "parentid":center_manage_id
- }
- post_common_service("dept/getDeptInfosByDeptId",param,function(data){
- var str = '';
- if(data.length > 0){
- str = "<option value=''>全部</option>";
- for(var i=0;i<data.length;i++){
- str += "<option value="+data[i].id+">"+data[i].organname+"</option>";
- }
- }
- func(str);
- },function(error){
- });
- }
- /**
- * 写html value
- * @param {*} selector
- * @param {*} val
- */
- function WH(selector,val){
- $(selector).html(val);
- }
- /**
- * 根据选择器 回去value值
- * param: id 选择器
- * return value
- */
- function GV(selector){
- return $(selector).val();
- }
- /**
- * 根据选择器,获取html值
- * param:selector 选择器
- * return: html value
- */
- function GH(selector){
- return $(selector).html();
- }
- /**
- * 根据月份,判断当前月份天数
- * param: month String 月份 ,datet Date 年份
- * return:days( 28,29,30,31 )
- */
- function getDays(mouth,datet){
- //构造当前日期对象
- var date = new Date();
- if(date!=undefined && datet instanceof Date){
- date = datet ;
- }
- //获取年份
- var year = date.getFullYear();
- //定义当月的天数;
- var days ;
- //当月份为二月时,根据闰年还是非闰年判断天数
- if(mouth == 2){
- days= year % 4 == 0 ? 29 : 28;
- }
- else if(mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12){
- //月份为:1,3,5,7,8,10,12 时,为大月.则天数为31;
- days= 31;
- }
- else{
- days= 30;
- }
- return days ;
- }
- /**
- * 根据月份,判断当前月份天数
- * param: datet String 年份
- * return:days( 28,29,30,31 )
- */
- function getDaysByDate(datet){
- //构造当前日期对象
- var date = new Date(datet);
- //获取年份
- var year = date.getFullYear();
- var mouth = date.getMonth() +1 ;
- //定义当月的天数;
- var days ;
- //当月份为二月时,根据闰年还是非闰年判断天数
- if(mouth == 2){
- days= year % 4 == 0 ? 29 : 28;
- }
- else if(mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12){
- //月份为:1,3,5,7,8,10,12 时,为大月.则天数为31;
- days= 31;
- }
- else{
- days= 30;
- }
- return days ;
- }
- var months = new Array();
- var m = new Date().getMonth();
- var mth_pre = 12-m;
- var initDate;
- /**
- * 根据当前年月动态将13个月push数组
- */
- function month_method(){
- // 将上一年的当前月的上个月到12月加入到数组里//改为当前月到上年同月
- for(var i=1;i<=mth_pre+1;i++){
- mth_handle(m,(year-1),(m++));
- }
- // 将当前年的一月份到当前月的上个月加入到数组里(改为当前月)
- for(var i=1;i<=new Date().getMonth()+1;i++){
- mth_handle(i,year,i);
- }
- // 当前年月的上个月(初始化图用)
- if((new Date().getMonth()+'').length == 1){
- initDate = year+"/0"+new Date().getMonth();
- }else{
- initDate = year+"/"+new Date().getMonth();
- }
- }
- // 抽出的方法
- function mth_handle(mth,getYear,num){
- if((mth+'').length==1){
- months.push(((getYear)+'').substr(2)+"/0"+(num));
- }else{
- months.push(((getYear)+'').substr(2)+"/"+(num));
- }
- }
- /**
- * 月份下拉框
- */
- function select_option(){
- var str = $(".div-month select");
- var temp = '';
- for(var i=0;i<months.length;i++){
- temp += "<option value=20"+months[i]+">20"+months[i]+"</option>"
- }
- str.append(temp);
- }
- /**
- * 根据当前月份 获取前13个月份
- */
- function month_method_2(){
- var montharray = new Array();
- var now_month = new Date().getMonth() ;
- for(var i= now_month ; i<13;i++){
- montharray.push( (new Date().getFullYear()-1+'') + "/"+PrefixInteger(i,2) ) ;
- }
- for(var i=1;i<=now_month+1;i++){
- montharray.push( (new Date().getFullYear()+'') + "/"+ PrefixInteger(i,2) );
- }
- return montharray ;
- }
- // 数字前面补0
- function PrefixInteger(num, length) {
- return (Array(length).join('0') + num).slice(-length);
- }
- /**
- *
- * @param {*} str ep:2017/06
- * returns 2017-05-25 23:00:00
- */
- function timeTranslate(str){
- var strs = str.split("/") ;
- var year = strs[0];
- var month = strs[1];
- var month2 = month - 1 ;
- var year2 = year ;
- if( month2 == 0 ){
- year2 = year2 - 1 ;
- month2 = 12 ;
- }
- return year2 + "-"+month2 + "-25 23:00:00" ;
- }
- /**
- *
- * @param {*} datet
- * @param {*} changVal
- */
- function dateChange(datet , changVal ){
- var tempDate = new Date(datet.valueOf() - changVal);
- return tempDate.Format("yyyy-MM-dd HH:mm:ss");
- }
|