赞
踩
/** var title_a = ""; var title_b = ""; var title_c = ""; $.ajax({ type : 'POST', dataType : "json", async : false, url : basePath+"/sales/listsp.do?_id="+_id, success : function(data) { console.log(data.length);//data._start_time if(data.length > 0){ var _st = data[0]._start_time; var year = _st.substring(0,4); var month = _st.substring(5,7); title_a = "截止"+year+"年12月31日"; title_b = "截止"+(parseInt(year) + 1)+"年12月31日"; title_c = "截止"+(parseInt(year) + 2)+"年12月31日"; } } }); * 计算工作日 */ function getWorkDays(){ var _start_time = $('#_start_time').datebox('getValue'); var _end_time = $('#_end_time').datebox('getValue'); if(_start_time.length != 10 || _end_time.length != 10){ return; } var beginDate = new Date(_start_time.replace(/-/g, "/")); var endDate = new Date(_end_time.replace(/-/g, "/")); //日期差值,即包含周六日、以天为单位的工时,86400000=1000*60*60*24. var workDayVal = (endDate - beginDate)/86400000 + 1; //工时的余数 var remainder = workDayVal % 7; //工时向下取整的除数 var divisor = Math.floor(workDayVal / 7); var weekendDay = 2 * divisor; //起始日期的星期,星期取值有(1,2,3,4,5,6,0) var nextDay = beginDate.getDay(); //从起始日期的星期开始 遍历remainder天 for(var tempDay = remainder; tempDay>=1; tempDay--) { //第一天不用加1 if(tempDay == remainder) { nextDay = nextDay + 0; } else if(tempDay != remainder) { nextDay = nextDay + 1; } //周日,变更为0 if(nextDay == 7) { nextDay = 0; } //周六日 if(nextDay == 0 || nextDay == 6) { weekendDay = weekendDay + 1; } } //实际工时(天) = 起止日期差 - 周六日数目。 workDayVal = workDayVal - weekendDay; $('#_time_limit').numberbox('setValue',workDayVal); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。