//var base_url="http://temp.zhizhuchuxing.com"; var base_url=""; //var base_url="http://127.0.0.1:8020/%E8%9C%98%E8%9B%9B2.0%E8%83%BD%E5%86%99PHP"; function show_detail(index) { var obj1 = document.getElementById("content_" + index); var cstr1 = obj1.style.display; if(cstr1 == 'block') { obj1.style.display = 'none'; } else { obj1.style.display = 'block'; } } window.onload = function() { $('#id-date-picker-1').val(getDateTime(0)); var res_id = getPar('res_id'); var res_name = getPar('res_name'); $('#h1_title').html(res_name); var start_date = $('#id-date-picker-1').val(); var end_date = start_date; // var url = "./st-xm/Api/car_team_controll.php?method=getDriverRunByCompany&start_date=" + start_date + "&end_date=" + end_date + "&res_id=" + res_id; var url=base_url+"/st-xm/Api/car_team_controll.php?method=getDriverRunByCompany&start_date=" + start_date + "&end_date=" + end_date + "&res_id=" + res_id; get_data_for_url(url); } function selectDate(date) { var res_id = getPar('res_id'); var start_date = $('#id-date-picker-1').val(); var end_date = start_date; var search_res = $('#search_res_name').val(); var url =base_url+"/st-xm/Api/car_team_controll.php?method=getDriverRunByCompany&start_date=" + start_date + "&end_date=" + end_date + "&res_id=" + res_id+ "&search_res=" + search_res; get_data_for_url(url); } function get_data_for_url(url) { //根据 console.log(url); $.getJSON(url, function(res_data) { console.log(res_data); $('#warn_info').html(''); if(res_data['code'] != "0") { // alert(res_data['info']); // 用其它方式来提醒 $('#warn_info').html(res_data['info']); } var driver_run = res_data['driver_run']; if(!driver_run) { return; } var titleHTML = ''; for(var i = 0, m = driver_run.length; i < m; i++) { var dict = driver_run[i]; titleHTML += '
  • ' titleHTML += '' + dict['run_date'] + ' 【' + dict['run_time'] + '】'; titleHTML += '' + dict['prod_name'] + ''; titleHTML += '' + dict['driver_name'] + ''; titleHTML += '' + dict['driver_mobile'] + ''; if(dict['customer'].length > 0) { titleHTML += '【' + dict['ticket_count'] + '人】'; } else { titleHTML += '无乘客'; } titleHTML += '
  • '; titleHTML += ''; } if(titleHTML) { $('#all_ul').html(titleHTML); } else { $('#all_ul').html(''); } }); } function getPar(par) { //获取当前URL var local_url = document.location.href; local_url = decodeURI(local_url); //获取要取得的get参数位置 var get = local_url.indexOf(par + "="); if(get == -1) { return ""; } //截取字符串 var get_par = local_url.slice(par.length + get + 1); //判断截取后的字符串是否还有其他get参数 var nextPar = get_par.indexOf("&"); if(nextPar != -1) { get_par = get_par.slice(0, nextPar); } return get_par; } /* function get_before_day() { var dateStr=$('#id-date-picker-1').val(); var t_temp_sdate = dateStr.split('-'); var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]); now.setDate(now.getDate() - 0 - 1); var year = ";" + now.getFullYear() + ";"; var month = ";" + now.getMonth() + ";"; var day = ";" + now.getDate() + ";"; if(year.length < 4) { year = "0" + year; } if(month.length < 4) { month = "0" + month; } if(day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); $('#id-date-picker-1').val(datestr); selectDate(dateStr); } // 得到明天的 function get_after_day() { var dateStr=$('#id-date-picker-1').val(); var t_temp_sdate = dateStr.split('-'); var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]); now.setDate(now.getDate() - 0 + 1); var year = ";" + now.getFullYear() + ";"; var month = ";" + now.getMonth() + ";"; var day = ";" + now.getDate() + ";"; if(year.length < 4) { year = "0" + year; } if(month.length < 4) { month = "0" + month; } if(day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); $('#id-date-picker-1').val(datestr); selectDate(dateStr); } */ function get_current_day() { var dateStr=$('#id-date-picker-1').val(); selectDate(dateStr); } function get_before_day() { var dateStr=$('#id-date-picker-1').val() d = new Date(dateStr); d = +d - 10006060 / 3 * 24; d = new Date(d); //return d; //格式化 var year = ";" + d.getFullYear() + ";"; var month = ";" + (d.getMonth() + 0 + 1) + ";"; var day = ";" + d.getDate() + ";"; if(year.length < 4) { year = "0" + year; } if(month.length < 4) { month = "0" + month; } if(day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); $('#id-date-picker-1').val(datestr); selectDate(dateStr); } function get_after_day(){ var dateStr=$('#id-date-picker-1').val() d = new Date(dateStr); d = +d + 10006060 / 3 * 24; d = new Date(d); //return d; //格式化 var year = ";" + d.getFullYear() + ";"; var month = ";" + (d.getMonth() + 0 + 1) + ";"; var day = ";" + d.getDate() + ";"; if(year.length < 4) { year = "0" + year; } if(month.length < 4) { month = "0" + month; } if(day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); $('#id-date-picker-1').val(datestr); selectDate(dateStr); } function getDateTime(nTypeFlag) { var tNowTime = new Date(); var myYear = ';' + tNowTime.getFullYear() + ';'; var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';'; var myDay = ';' + tNowTime.getDate() + ';'; var myHour = ';' + tNowTime.getHours() + ';'; var myMinu = ';' + tNowTime.getMinutes() + ';'; var mySecond = ';' + tNowTime.getSeconds() + ';'; if(myMonth.length < 4) myMonth = '0' + myMonth; if(myDay.length < 4) myDay = '0' + myDay; if(myHour.length < 4) myHour = '0' + myHour; if(myMinu.length < 4) myMinu = '0' + myMinu; if(mySecond.length < 4) mySecond = '0' + mySecond; var cNewTimeStr; //alert(tNowTime); switch(nTypeFlag + 1 - 1) { case 0: cNewTimeStr = myYear + '-' + myMonth + '-' + myDay; break; case 1: cNewTimeStr = myYear + myMonth + myDay; break; case 2: cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond; break; case 3: cNewTimeStr = myHour + myMinu + mySecond; break; case 4: cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond; break; case 5: cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日'; break; case 6: cNewTimeStr = myYear; break; case 7: cNewTimeStr = myYear + '-' + myMonth; break; case 8: //得到上一个月的今天 var date = getDateTime(0); var arr = date.split('-'); var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var day = arr[2]; //获取当前日期的日 var days = new Date(year, month, 0); days = days.getDate(); //获取当前日期中月的天数 var year2 = year; var month2 = parseInt(month) - 1; if(month2 == 0) { year2 = parseInt(year2) - 1; month2 = 12; } var day2 = day; var days2 = new Date(year2, month2, 0); days2 = days2.getDate(); if(day2 > days2) { day2 = days2; } if(month2 < 10) { month2 = '0' + month2; } cNewTimeStr = year2 + '-' + month2 + '-' + day2; break; case 9: //得到下一个月的今天 var date = getDateTime(0); var arr = date.split('-'); var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var day = arr[2]; //获取当前日期的日 var days = new Date(year, month, 0); days = days.getDate(); //获取当前日期中的月的天数 var year2 = year; var month2 = parseInt(month) + 1; if(month2 == 13) { year2 = parseInt(year2) + 1; month2 = 1; } var day2 = day; var days2 = new Date(year2, month2, 0); days2 = days2.getDate(); if(day2 > days2) { day2 = days2; } if(month2 < 10) { month2 = '0' + month2; } var t2 = year2 + '-' + month2 + '-' + day2; return t2; break; case 10: //昨日日期 var dateStr = getDateTime(0); var t_temp_sdate = dateStr.split('-'); var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]); now.setDate(now.getDate() - 0 - 1); var year = ";" + now.getFullYear() + ";"; var month = ";" + now.getMonth() + ";"; var day = ";" + now.getDate() + ";"; if(year.length < 4) { year = "0" + year; } if(month.length < 4) { month = "0" + month; } if(day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); return datestr; break; case 11: //明日日期 var dateStr = getDateTime(0); var t_temp_sdate = dateStr.split('-'); var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]); now.setDate(now.getDate() - 0 + 1); var year = ";" + now.getFullYear() + ";"; var month = ";" + now.getMonth() + ";"; var day = ";" + now.getDate() + ";"; if(year.length < 4) { year = "0" + year; } if(month.length < 4) { month = "0" + month; } if(day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); return datestr; break; default: cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond; break; } cNewTimeStr = cNewTimeStr.replace(/;/g, ""); return cNewTimeStr; }