var page_size = 10; var page_status = 0; var cur_url=''; var cur_sel_bus_group='0'; /*======================网络请求的Ajax的代码=======================*/ // 创建一个Ajax对象 if (window.ActiveXObject) { var myreq = new ActiveXObject("Microsoft.XMLHTTP"); } else { var myreq = new XMLHttpRequest(); } function ZZLog(str){ var isLog=true; if(isLog){ console.log(str); } } function selectPage(){ page_size = $("#select_curpage").val(); page_status = 1; } /** * * @param {Object} myURL 返回数据URL接口 * @param {Object} myURL2 当前的URL */ document.addEventListener('DOMContentLoaded', function() { carList_html = $("#carList").html(); // 设置出发日期为当前日期 page_size = getPar('page_size'); if(!page_size){ page_size = $("#select_curpage").val(); }else{ $("#select_curpage").val(page_size); } var run_hour = getPar('hour'); var run_minute = getPar('minute'); var currpage=getPar('currpage'); var start_area = getPar('start_area'); var end_area = getPar('end_area'); var line = getPar('line'); var start_date = getPar('start_date'); var end_date = getPar('end_date'); var select_status = getPar('run_status'); var bus_type = getPar('bus_type'); var bus_group = getPar('bus_group'); if(currpage || start_area || end_area || line || start_date || end_date || select_status || bus_group){ if(currpage==""){ currpage=1; } var tnowtime = getDateTime(4); $('#start_area').val(start_area); $('#end_area').val(end_area); $('#prod').val(line); $('#id-date-picker-1').val(start_date); $('#id-date-picker-2').val(end_date); $("#select_status").val(select_status); $("#bus_type").val(bus_type); $('#bus_group').val(bus_group); cur_sel_bus_group=bus_group; var tnowtime = getDateTime(4); var myURL = "./st-xm/Api/runInfoControll.php?method=getRunList&currpage=" + currpage + "&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date + "&run_status=" + select_status + "&bus_type=" + bus_type+"&bus_group="+bus_group+ "&hour=" + run_hour + "&minute=" + run_minute; var myURL2 = "./carList.html?method=getRunList&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date + "&run_status=" + select_status + "&bus_type=" + bus_type+"&bus_group="+bus_group+ "&hour=" + run_hour + "&minute=" + run_minute; cur_url=myURL2; ZZLog(myURL); get_virtual_user_list(myURL, myURL2); }else{ $("#id-date-picker-1").val(getDateTime(11)); $("#id-date-picker-2").val(getDateTime(11)); click_search(); } }, false); // 请求方法,传入URL function get_virtual_user_list(myURL, myURL2) { var tnowtime = getDateTime(4); if (myURL.indexOf('?') >= 0) { myURL += '&tt=' + tnowtime; } else { myURL += '?tt=' + tnowtime; } $.getJSON(myURL, function(httpData) { ZZLog(httpData); if (httpData['code'] != '0') { $('#carList').html(''); alert(httpData['info']); return; } if (httpData['run_list'].length <= 0) { $("#carList").html(''); $('#test').html(''); return; } $("#carList").html(''); $('#test').html(''); var total = httpData['total']; $("#select_curpage_all").val(total); var carList = httpData['run_list']; var carListHTML = '' for (var i = 0; i < carList.length; i++) { var tempDict = carList[i]; var tempHTML = carList_html; tempHTML = tempHTML.replace('[dict-json]',JSON.stringify(tempDict)); tempHTML = tempHTML.replace('[data-statu]', tempDict['run_status']); tempHTML = tempHTML.replace('[car_number]',tempDict['car_number']); tempHTML = tempHTML.replace('[run_date]', tempDict['run_date']); tempHTML = tempHTML.replace('[QDH]', tempDict['prod_name']); tempHTML = tempHTML.replace('[name]', tempDict['run_id']); tempHTML = tempHTML.replace('[线路]', tempDict['property'] + ' ' + tempDict['prod_name']); tempHTML = tempHTML.replace('[出发日期]', tempDict['run_date']); tempHTML = tempHTML.replace('[出发站点时间]', tempDict['start_time'] + ' ' + tempDict['res_name']); tempHTML = tempHTML.replace('[send_bus_no]',tempDict['send_bus_no']); var car_no=tempDict['car_number']; car_no=(Array(2).join(0)+car_no).slice(-2); tempHTML = tempHTML.replace('[车次]', car_no); if(tempDict['motorcade_name'] == null){ tempDict['motorcade_name'] = '-'; } tempHTML = tempHTML.replace('[承运车队]', tempDict['motorcade_name']); var bus_cost = tempDict['cost_price']; if( tempDict['cost_type'] == 477 ) { bus_cost = bus_cost + " 元/车"; } else { bus_cost = bus_cost + " 元/座"; } tempHTML = tempHTML.replace('[用车成本]', bus_cost ); tempHTML = tempHTML.replace('[座位总数]', tempDict['seat_count']); tempHTML = tempHTML.replace('[已售座位]', tempDict['sale_seat']); if (tempDict['saled_count'].trim() == "0" && tempDict['max_count'].trim() == "0") { tempHTML = tempHTML.replace('[已售人数]', '-'); } else { // tempHTML = tempHTML.replace('[已售]', tempDict['saled_count'] + '/' + tempDict['max_count']); var myURL3 = "order_list.html?tt=" + tnowtime + "&timelimit=" + '出发时间' + "&starttime=" + tempDict['run_date'] + "&endtime=" + tempDict['run_date'] + "&ordersource=" + '' + "&bus_type=" + '' + "&orderstatus=" + '' + "&paystatus=" + '' + "&billingstatus=" + '' + "&mealbounce=" + '' + "&refund=" + '' + "&moresearch=" + '' + "&start_area=" + '' + "&end_area=" + '' + "&line=" + encodeURIComponent(tempDict['property']) +"&currpage="+'1' + "&pagesize=" + '10' + "&search_bus_no=" + tempDict['car_number'] + "&run_time=" + tempDict['start_time']; var tmp_url = ''+tempDict['saled_count']+''; tmp_url += '
明细'; tempHTML = tempHTML.replace('[已售人数]', tmp_url); } tempHTML = tempHTML.replace('[运营状态]', tempDict['run_status']); var send_bus_no = tempDict['send_bus_no']; var send_driver_name = tempDict['send_driver_name']; var send_driver_mobile = tempDict['send_driver_mobile']; if( send_bus_no.length > 0 || send_driver_name.length > 0 ){ tempHTML = tempHTML.replace('[收客状态]', "
🚍:" + send_bus_no + "
👨:" + send_driver_name + "
📞:" + send_driver_mobile + "
"); } else { tempHTML = tempHTML.replace('[收客状态]', tempDict['receiving']); } var caozuoStr = '' caozuoStr += '查看  '; caozuoStr += '修改  '; if( send_bus_no.length > 0 || send_driver_name.length > 0 ){ caozuoStr += "出行短信"; } tempHTML = tempHTML.replace('[操作]', caozuoStr); carListHTML += tempHTML; } $("#carList").html(carListHTML); $('.one').css('display', 'table-row'); var bus_group_list=httpData['bus_group_list']; var busgrouphtml=''; for (var i=0,m=bus_group_list.length;i1){ $('#update_car_no').addClass('update_car_no'); $('#update_car_no').attr('data-statu','false'); }else /*if(arr_bool_QDH.length==1 && (temp_QDH=="上海-千岛湖" || temp_QDH=="千岛湖-上海" || temp_QDH=="上海市-千岛湖" || temp_QDH=="千岛湖-上海市"))*/{ $('#update_car_no').removeClass('update_car_no'); $('#update_car_no').attr('data-statu','true'); }/*else{ $('#update_car_no').addClass('update_car_no'); $('#update_car_no').attr('data-statu','false'); }*/ if(arr_bool_statu.indexOf('false')!=-1){ $('#five_del').addClass('del'); $('#five_del').attr('data-statu','false'); }else if(arr_bool_statu.indexOf('true')!=-1){ $('#five_del').removeClass('del'); $('#five_del').attr('data-statu','true'); }else{ $('#five_del').addClass('del'); $('#five_del').attr('data-statu','false'); } } // //结束日期value改变的时候触发 $(document).ready(function() { var date = new Date(); $('#id-date-picker-2').val(getDateTime(9)); $('#id-date-picker-1').change(function() { //开始日期 var start_date = $('#id-date-picker-1').val(); if (start_date.trim().length <= 0) { swal( '操作失败', '请选择开始日期', 'error' ); return; } //结束日期 var end_date = $('#id-date-picker-2').val(); if (end_date.trim().length < 0) { swal( '操作失败', '请选择结束日期', 'error' ); return; } // 判断日期是否合理 var date1 = new Date(start_date.replace(/\-/g, '/')); var date2 = new Date(end_date.replace(/\-/g, '/')); if (date1>date2 || end_date=="") { $('#id-date-picker-2').val(start_date); } }); $('#id-date-picker-2').change(function() { //开始日期 var start_date = $('#id-date-picker-1').val(); if (start_date.trim().length <= 0) { swal( '操作失败', '请选择开始日期', 'error' ); return; } //结束日期 var end_date = $('#id-date-picker-2').val(); if (end_date.trim().length < 0) { swal( '操作失败', '请选择结束日期', 'error' ); return; } // 判断日期是否合理 var date1 = new Date(start_date.replace(/\-/g, '/')); var date2 = new Date(end_date.replace(/\-/g, '/')); if (date2 < date1) { swal( '操作失败', '结束日期必须大于开始日期', 'error' ); $('#id-date-picker-2').val(''); return; } }); }); //查询按钮click事件 function click_search(){ $('#update_car_no').addClass('update_car_no'); $('#update_car_no').attr('data-statu','false'); $('#five_del').addClass('del'); $('#five_del').attr('data-statu','false'); $('.ace')[0].checked=false; cur_sel_bus_group=$('#bus_group').val(); //班次时间 var hour = $(".hour").val(); var minute = $(".minute").val(); //出发地 var start_area = $('#start_area').val(); //目的地 var end_area = $('#end_area').val(); //线路 var line = $('#prod').val(); //开始日期 var start_date = $('#id-date-picker-1').val(); if (start_date.trim().length <= 0) { swal( '操作失败', '请选择开始日期', 'error' ); return; } //结束日期 var end_date = $('#id-date-picker-2').val(); if (end_date.trim().length <= 0) { swal( '操作失败', '请选择结束日期', 'error' ); return; } // 判断日期是否合理 var date1 = new Date(start_date.replace(/\-/g, '/')); var date2 = new Date(end_date.replace(/\-/g, '/')); if (date2 < date1) { swal( '操作失败', '结束日期必须大于开始日期', 'error' ); return; } //运营状态 var select_status = $("#select_status").val(); if(page_status == 1){ var currpage=getPar('currpage'); }else{ var currpage=1; } if (!currpage) { currpage = '1' } //车辆类型 var bus_type = $("#bus_type").val(); var bus_group = $('#bus_group').val(); var tnowtime = getDateTime(4); var myURL = "./st-xm/Api/runInfoControll.php?method=getRunList&currpage=1&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date + "&run_status=" + select_status + "&bus_type=" + bus_type+"&bus_group="+bus_group+"&hour="+hour+"&minute="+minute; var myURL2 = "./carList.html?method=getRunList&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date + "&run_status=" + select_status + "&bus_type=" + bus_type+"&bus_group="+bus_group+"&hour="+hour+"&minute="+minute; cur_url=myURL2; ZZLog(myURL) get_virtual_user_list(myURL, myURL2); } //点击审核等按钮 function click_five_btn(btn_value) { //先拿到run_id var arr_run_ids = new Array(); var temp_run_id=0; var temp_run_date=''; var temp_line=''; var have_send_bus = false; $('.ace').each(function(index, item) { if (this.checked && index != 0) { var car_number=$(this).attr('data-carno'); var run_id=$(this).attr('name'); var cstr1="{"+run_id+","+car_number+"}"; arr_run_ids.push(cstr1); temp_line=$(this).attr('data_QDH'); temp_run_id=$(this).attr('name'); temp_run_date=$(this).attr('data-date'); temp_send_bus_no = $(this).attr('data-sendbusno'); if( temp_send_bus_no.length > 0 ) { have_send_bus = true; } } }); if (arr_run_ids.length <= 0) { swal( '操作失败', '请勾选具体所需操作的车次', 'error' ); return; } if( btn_value=="2" && have_send_bus == true ) { swal( '停运失败', '已派车的车次无法停运', 'error' ); return; } if(btn_value=="update_car_no"){ var statu=$('#update_car_no').attr('data-statu'); if(statu=='true'){ ZZLog('可用'); var line=temp_line; var run_id=temp_run_id; var run_date=temp_run_date; var next_url="update_car_no.html?line="+line+"&run_id="+run_id+"&start_date="+run_date; //window.open(next_url); $.cookie("path_url",cookie_path+next_url,{domain:domain_path}); window.open(system_path); }else{ ZZLog('不可用'); } }else{ if(btn_value=="4"){ var va_4=$('#five_del').attr('data-statu'); if(va_4!="true"){ swal( '删除失败', '只有待审核的车次才可删除', 'error' ); return; } } var run_id_str = arr_run_ids.join(','); ZZLog("/st-xm/Api/run_status_update.php?allrunid=" + run_id_str + "&status=" + btn_value); $.getJSON("/st-xm/Api/run_status_update.php?allrunid=" + run_id_str + "&status=" + btn_value, function(data) { ZZLog(data); if (data.errcode == 0) { swal({ title: '操作成功', type: 'success', timer: 20000, confirmButtonText: 'OK' }).then( function () { location.replace(cur_url); }, // handling the promise rejection function (dismiss) { location.replace(cur_url); } ) } else { swal( '操作失败', data.errinfo, 'error' ); } }) } } 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 false; } //截取字符串 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 open_addcartime(){ $.cookie("path_url",cookie_path+"addcartime.html",{domain:domain_path}); //window.open(system_path); window.location.href ="addcartime.html"; } 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 d=getDateTime(0); d = new Date(d); d = +d - 1000*60*60*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, ""); return datestr; break; case 11: //明日日期 var d=getDateTime(0); d = new Date(d); d = +d + 1000*60*60*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, ""); return datestr; break; default: cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond; break; } cNewTimeStr = cNewTimeStr.replace(/;/g, ""); return cNewTimeStr; } function resetToBegin(obj) { if ($(obj).val()=='-1'){ $(".hour").val(-1); $(".minute").val(-1); } } //add by qiusong on 2017.10.26 function disp_run_bus_passenger( run_id, bus_order_id ) { $.ajax({ url: './st-xm/Api/run_bus_passengers_static.php', type: "post", data: { run_id: run_id, bus_order_id: bus_order_id }, dataType: "json", success: function (data) { if (data.code == 0) { var disp_table_html = ''; for(var i = 0; i < data.data.length; i++) { disp_table_html += ''; } disp_table_html += '
站点上车下车
' + data.data[i].RES_NAME + '' + data.data[i].up_num + '' + data.data[i].down_num + '
'; swal({ title: '上下车信息', type: 'info', html: disp_table_html, showCloseButton: true }); return; } else { swal( '获取信息失败', data.info, 'error' ); return; } }, fail: function (data) { swal( '获取信息失败', data.info, 'error' ); return; } }); }