|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- 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 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;
- 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;
- cur_url=myURL2;
- 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) {
- ZZLog(myURL);
- 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']);
- var car_no=tempDict['car_number'];
- car_no=(Array(2).join(0)+car_no).slice(-2);
- tempHTML = tempHTML.replace('[车次]', car_no);
- 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']);
- tempHTML = tempHTML.replace('[已售人数]', tempDict['saled_count']);
- }
- tempHTML = tempHTML.replace('[运营状态]', tempDict['run_status']);
-
- tempHTML = tempHTML.replace('[收客状态]', tempDict['receiving']);
-
- var caozuoStr = ''
- caozuoStr += '<a target="_blank" href="carDetail.html?run_id=' + tempDict['run_id'] + '">查看</a> ';
- caozuoStr += '<a target="_blank" href="revisecartime.html?run_id=' + tempDict['run_id'] + '">修改</a> ';
- tempHTML = tempHTML.replace('[操作]', caozuoStr);
-
- carListHTML += tempHTML;
- }
- $("#carList").html(carListHTML);
- $('.one').css('display', 'table-row');
-
- var bus_group_list=httpData['bus_group_list'];
- var busgrouphtml='<option value="0" selected="selected">全部</option>';
- for (var i=0,m=bus_group_list.length;i<m;i++) {
- var tempDict=bus_group_list[i];
- var tempHTML='<option value="0">全部</option>';
- tempHTML=tempHTML.replace('value="0"','value='+tempDict['group_id']);
- tempHTML=tempHTML.replace('全部',tempDict['group_name']);
- busgrouphtml+=tempHTML;
- }
- $('#bus_group').html(busgrouphtml);
- $('#bus_group').val(cur_sel_bus_group);
- // *********************************
- var currpage = getPar("currpage");
- if (!currpage) {
- currpage = 1
- }
- var sum = parseInt(httpData['total']);
- var length = page_size;
- var tag = "test";
- var userUrl = myURL2;
- getPager(userUrl, sum, currpage, length, tag, 'currpage');
- })
- }
-
- var carList_html = ''
-
- // 复选框事件
- function select_checked(index) {
- //index=0最上面的全选 index=1表示的是下面所有的
- var cur_check = $('.ace')[0];
- var checkList = $('.ace');
- var checkCount = checkList.length - 1;
- var true_count = 0;
- for (var i = 1; i < checkList.length; i++) {
- if (index == '0') {
- checkList[i].checked = cur_check.checked;
- } else {
- if (checkList[i].checked == false) {
- cur_check.checked = false
- } else {
- true_count = true_count + 1;
- }
- }
- }
- //判断下面是否选中完
- if (checkCount == true_count) {
- cur_check.checked = true;
- }
- var temp_QDH='';
- var arr_bool_QDH= new Array();
- var arr_bool_statu=new Array();
- $('.ace').each(function(index, item) {
- if (this.checked && index != 0) {
- // arr_run_ids.push($(this).attr('data_QDH'));
- var QDH=$(this).attr('data_QDH');
- var statu=$(this).attr('data-statu');
- temp_QDH=QDH;
- if(QDH=="上海-千岛湖" || QDH=="千岛湖-上海" ||QDH=="上海市-千岛湖" || QDH=="千岛湖-上海市"){
- arr_bool_QDH.push(true);
- }else{
- arr_bool_QDH.push(false);
- }
- if(statu=="待审核"){
- arr_bool_statu.push('true');
- }else{
- arr_bool_statu.push('false');
- }
- }
- });
- $('#five_del').addClass('del');
- $('#five_del').attr('data-statu','false');
- $('#update_car_no').addClass('update_car_no');
- $('#update_car_no').attr('data-statu','false');
- if(arr_bool_QDH.length>1){
- $('#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) {
- alert('请选择开始日期!!!');
- return;
- }
- //结束日期
- var end_date = $('#id-date-picker-2').val();
- if (end_date.trim().length < 0) {
- alert('请选择结束日期');
- 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) {
- alert('请选择开始日期!!!');
- return;
- }
- //结束日期
- var end_date = $('#id-date-picker-2').val();
- if (end_date.trim().length < 0) {
- alert('请选择结束日期');
- return;
- }
- // 判断日期是否合理
- var date1 = new Date(start_date.replace(/\-/g, '/'));
- var date2 = new Date(end_date.replace(/\-/g, '/'));
- if (date2 < date1) {
- alert('结束日期必须大于开始日期!!!');
- $('#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;
- //出发地
- 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) {
- alert('请选择开始日期!!!');
- return;
- }
- //结束日期
- var end_date = $('#id-date-picker-2').val();
- if (end_date.trim().length <= 0) {
- alert('请选择结束日期!!!');
- return;
- }
- // 判断日期是否合理
- var date1 = new Date(start_date.replace(/\-/g, '/'));
- var date2 = new Date(end_date.replace(/\-/g, '/'));
- if (date2 < date1) {
- alert('结束日期必须大于开始日期!!!');
- 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;
- 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;
- cur_url=myURL2;
- 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='';
- $('.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');
- }
- });
- if (arr_run_ids.length <= 0) {
- alert('请勾选!!!');
- 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);
- }else{
- ZZLog('不可用');
- }
- }else{
- if(btn_value=="4"){
- var va_4=$('#five_del').attr('data-statu');
- if(va_4!="true"){
- alert('只有待审核的才可删除!!!');
- 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) {
- alert("操作成功");
- // click_search();
- location.replace(cur_url);
- } else {
- alert(data.errinfo);
- }
- })
- }
-
-
-
- }
-
- 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 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;
- }
|