|
- var carChartStr = ''
- var trcode1Str = ''
- var trcode2Str = ''
- var trcode3Str = ''
- var trfinalStr = ''
- var page_size = 20;
- var myArray = new Array();
- var tempHttpData = null;
- /*======================网络请求的Ajax的代码=======================*/
-
- // 创建一个Ajax对象
- if (window.ActiveXObject) {
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- var myreq = new XMLHttpRequest();
- }
- window.onload = function() {
- //入住时间初始值
- $('#id-date-picker-1').val(getDateTime(0));
- carChartStr = $('#carChart').html();
- trcode1Str = $('#tr_one').prop('outerHTML');
- trcode2Str = $('#tr_two').prop('outerHTML');
- trcode3Str = $('#tr_three').prop('outerHTML');
- trfinalStr = $('#tr_final').prop('outerHTML');
-
-
- var prod = getPar('prod');
- var start_date = getPar('start_date');
- var end_date = getPar('end_date');
- var select_status = getPar('select_status');
- if (prod && start_date && end_date && select_status) {
- $('#id-date-picker-1').val(getDateTime(0))
- var myURL = './json/jsonCarChart.html?prod=' + prod + '&start_date=' + start_date + '&end_date=' + end_date + '&select_status=' + select_status;
- var myURL2 = './carChart.html?prod=' + prod + '&start_date=' + start_date + '&end_date=' + end_date + '&select_status=' + select_status;
- get_virtual_user_list(myURL, myURL2);
- }
- }
-
- // 请求方法,传入URL
- function get_virtual_user_list(myURL, myURL2) {
- var tnowtime = getDateTime(4);
- if (myURL.indexOf('?') >= 0) {
- myURL += '&tt=' + tnowtime;
- } else {
- myURL += '?tt=' + tnowtime;
- }
- myreq.open("get", myURL, true);
- // 接收的数据交给哪个函数处理
- myreq.onreadystatechange = function() {
- if (myreq.readyState == 4) {
- // newstr 就是接收到的数据
- var newstr = myreq.responseText;
- var httpData = eval('(' + newstr + ')');
- if (httpData['code'] != '0') {
- alert(info);
- return;
- }
- tempHttpData = httpData;
- var chartInfo = httpData['chartInfo'];
- var num1 = -1;
- var num21 = -1;
- var num22 = -1;
- var num23 = -1;
- myArray.length = 0;
- $('#carChart').css('display','');
- if(chartInfo.lentgh<=0){alert('没有查询到符号条件的数据!!!');return;}
- for (var i = 0; i < chartInfo.length; i++) {
- var tempDict = chartInfo[i];
- num1++;
- num21 = num1;
- num22 = -1;
- num23 = -1;
- myArray[num1] = new Array();
- myArray[num1][0] = '|' + num21 + '|';
- myArray[num1][1] = 0; //层级
- myArray[num1][2] = -1; //子节点当前展开还是收缩
- myArray[num1][3] = tempDict['startTime'];
- myArray[num1][4] = tempDict['prodcode'];
- myArray[num1][5] = tempDict['prodname'];
- myArray[num1][6] = tempDict['carCount'];
- myArray[num1][7] = tempDict['seatCount'];
- myArray[num1][8] = tempDict['outTicketCount'];
- myArray[num1][9] = tempDict['outTicketBalance'];
- myArray[num1][10] = tempDict['refundCount'];
- myArray[num1][11] = tempDict['refundBalance'];
- myArray[num1][12] = tempDict['refundPoundage'];
- myArray[num1][13] = tempDict['sellAll'];
- myArray[num1][14] = tempDict['income'];
- //......
- var everyDate = tempDict['everyDate'];
- for (var j = 0; j < everyDate.length; j++) {
- var dateTemp = everyDate[j];
- num1++;
- num22 = num1;
- num23 = -1;
- myArray[num1] = new Array();
- myArray[num1][0] = '|' + num21 + '|' + num22 + '|';
- myArray[num1][1] = 1;
- myArray[num1][2] = -1; //子节点当前展开还是收缩
- myArray[num1][3] = dateTemp['startTime'];
- myArray[num1][4] = dateTemp['carCount'];
- myArray[num1][5] = dateTemp['seatCount'];
- myArray[num1][6] = dateTemp['outTicketCount'];
- myArray[num1][7] = dateTemp['outTicketBalance'];
- myArray[num1][8] = dateTemp['sellAll'];
- myArray[num1][9] = dateTemp['income'];
- //......
- var everyTime = dateTemp['everyTime'];
- for (var k = 0; k < everyTime.length; k++) {
- var timeTemp = everyTime[k];
- num1++;
- num23 = num1;
- myArray[num1] = new Array();
- myArray[num1][0] = '|' + num21 + '|' + num22 + '|' + num23;
- myArray[num1][1] = 2;
- myArray[num1][2] = -1; //子节点当前展开还是收缩
- myArray[num1][3] = timeTemp['startTime'];
- myArray[num1][4] = timeTemp['carCount'];
- myArray[num1][5] = timeTemp['seatCount'];
- myArray[num1][6] = timeTemp['outTicketCount'];
- myArray[num1][7] = timeTemp['outTicketBalance'];
- myArray[num1][8] = timeTemp['refundCount'];
- myArray[num1][9] = timeTemp['refundBalance'];
- myArray[num1][10] = timeTemp['refundPoundage'];
- myArray[num1][11] = timeTemp['sellAll'];
- myArray[num1][12] = timeTemp['income'];
-
- //......
- }
- }
- }
- console.log(myArray);
- show_table(myURL2);
- var all_Count_Str = $('#carChart').html();
- var tempHTML = trfinalStr;
- tempHTML = tempHTML.replace('[线路]', '');
- tempHTML = tempHTML.replace('[车数量]', httpData['all_carCount']);
- tempHTML = tempHTML.replace('[座位数]', httpData['all_seatCount']);
- tempHTML = tempHTML.replace('[出票数量]', httpData['all_outTicketCount']);
- tempHTML = tempHTML.replace('[出票金额]', httpData['all_outTicketBalance']);
- tempHTML = tempHTML.replace('[退票数量]', httpData['all_refundCount']);
- tempHTML = tempHTML.replace('[退票金额]', httpData['all_refundBalance']);
- tempHTML = tempHTML.replace('[退票手续费]', httpData['all_refundPoundage']);
- tempHTML = tempHTML.replace('[售票总计]', httpData['all_sellAll']);
- tempHTML = tempHTML.replace('[收入总计]', httpData['all_income']);
- all_Count_Str += tempHTML;
- $('#carChart').html(all_Count_Str)
- }
- };
- myreq.send();
- }
- function show_table(myURL2) {
- var num1 = myArray.length;
- var cstr1 = '';
- for (var i = 0; i < num1; i++) {
- if (myArray[i][1] == 0) {
- var tempHTML = trcode1Str;
- tempHTML = tempHTML.replace('tr_one', 'list_' + i);
- tempHTML = tempHTML.replace('[code]', i);
- tempHTML = tempHTML.replace('[出发时间1]', myArray[i][3]);
- tempHTML = tempHTML.replace('[线路]', myArray[i][4] + ' ' + myArray[i][5]);
- tempHTML = tempHTML.replace('[车数量]', myArray[i][6]);
- tempHTML = tempHTML.replace('[座位数]', myArray[i][7]);
- tempHTML = tempHTML.replace('[出票数量]', myArray[i][8]);
- tempHTML = tempHTML.replace('[出票金额]', myArray[i][9]);
- tempHTML = tempHTML.replace('[退票数量]', myArray[i][10]);
- tempHTML = tempHTML.replace('[退票金额]', myArray[i][11]);
- tempHTML = tempHTML.replace('[退票手续费]', myArray[i][12]);
- tempHTML = tempHTML.replace('[售票总计]', myArray[i][13]);
- tempHTML = tempHTML.replace('[收入总计]', myArray[i][14]);
- cstr1 += tempHTML;
- } else if (myArray[i][1] == 1) {
- var tempHTML = trcode2Str;
- tempHTML = tempHTML.replace('tr_two', 'list_' + i);
- tempHTML = tempHTML.replace('[code]', i);
- tempHTML = tempHTML.replace('[出发时间2]', myArray[i][3]);
- tempHTML = tempHTML.replace('[线路]', '');
- tempHTML = tempHTML.replace('[车数量]', myArray[i][4]);
- tempHTML = tempHTML.replace('[座位数]', myArray[i][5]);
- tempHTML = tempHTML.replace('[出票数量]', myArray[i][6]);
- tempHTML = tempHTML.replace('[出票金额]', myArray[i][7]);
- tempHTML = tempHTML.replace('[退票数量]', '-');
- tempHTML = tempHTML.replace('[退票金额]', '-');
- tempHTML = tempHTML.replace('[退票手续费]', '-');
- tempHTML = tempHTML.replace('[售票总计]', myArray[i][8]);
- tempHTML = tempHTML.replace('[收入总计]', myArray[i][9]);
- cstr1 += tempHTML;
- } else if (myArray[i][1] == 2) {
- var tempHTML = trcode3Str;
- tempHTML = tempHTML.replace('tr_three', 'list_' + i);
- tempHTML = tempHTML.replace('[code]', i);
- tempHTML = tempHTML.replace('[出发时间3]', myArray[i][3]);
- tempHTML = tempHTML.replace('[线路]', '');
- tempHTML = tempHTML.replace('[车数量]', myArray[i][4]);
- tempHTML = tempHTML.replace('[座位数]', myArray[i][5]);
- tempHTML = tempHTML.replace('[出票数量]', myArray[i][6]);
- tempHTML = tempHTML.replace('[出票金额]', myArray[i][7]);
- tempHTML = tempHTML.replace('[退票数量]', myArray[i][8]);
- tempHTML = tempHTML.replace('[退票金额]', myArray[i][9]);
- tempHTML = tempHTML.replace('[退票手续费]', myArray[i][10]);
- tempHTML = tempHTML.replace('[售票总计]', myArray[i][11]);
- tempHTML = tempHTML.replace('[收入总计]', myArray[i][12]);
- cstr1 += tempHTML;
- }
-
- // cstr1 += '<tr id="list_' + i + '" onclick="show_hide_tr(' + i + ')">';
- // cstr1 += '<td>';
- // //.....
- // cstr1 += '</tr>';
- }
- $('#carChart').html(cstr1)
- var currpage = getPar("currpage");
- if (currpage) {} else {
- currpage = 1;
- }
- var sum = tempHttpData['total'];
- var length = page_size;
- var tag = "test";
- var userUrl = myURL2;
- getPager(userUrl, sum, currpage, length, tag, 'currpage');
- }
- //function show_hide_tr(myid,myidstr,mylevel)
- function show_hide_tr(myid) {
- var num1 = myArray.length;
- var cstr1 = myArray[myid][0]; // 父标记
- var num2 = myArray[myid][1]; // 父级别
- var num3 = myArray[myid][2]; // 所属子级别当前应该是展开还是收缩
- for (var i = 0; i < num1; i++) {
- var cstr2 = myArray[i][0];
- // if (charindex(cstr2,cstr1)>=0 && cstr2!=cstr1)
- if (cstr2.indexOf(cstr1) >= 0 && cstr2 != cstr1) {
- //找到子节点
- // var obj1= document.getElementById('list_' + i)
- var obj1 = $('#list_' + i);
-
- // num3==-1?obj1.style.display='table-row':obj1.style.display='none';
- if (num2 == 1) {
- num3 == -1 ? obj1.css('display', 'table-row') : obj1.css('display', 'none');
- }
-
- // if (num3 ==1)
- if (num3 == -1) {
- //展开
- // var obj1= document.getElementById('list_' + i) ;
- if (myArray[i][1] == 1) {
- obj1.css('display', 'table-row');
- }
- } else {
- //收缩
- // var obj1= document.getElementById('list_' + i)
- var tt = num2 + 1;
- obj1.css('display', 'none');
- myArray[i][2] = -1;
- // if (tt == myArray[i][0]) {//儿子节点
- // if (myArray[i][0].indexOf(tt)>=0){
- // obj1.style.display = 'table-row';
- // }else{
- // obj1.style.display = 'none';
- // }
- }
- }
- }
- myArray[myid][2] = 1 - myArray[myid][2];
- }
- $(document).ready(function() {
- $('#btn_search').click(function() {
- //线路
- var prod = $('#prod').val();
- // if (prod.trim().length <= 0) {alert('请输入线路!!!');return;}
- //出发日期
- 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 option:selected").val();
- // if (select_status.trim().length <= 0 || select_status == '请选择') {alert('请选择销售渠道!!!');return;}
- var user_id = getPar('user_id');
- if (!user_id) {
- user_id = '1'
- };
- //http://192.168.6.245:8080/st-xm/Api/reportDataControll.php?method=getRunReportData&user_id=1&currpage=1&page_size=20&line=SB0031&strat_date=2016-05-05&end_date=2016-09-09
- var myURL = 'http://192.168.6.245:8080/st-xm/Api/reportDataControll.php?method=getRunReportData&user_id=' + user_id + '&currpage=1&page_size=' + page_size + '&line=' + prod + '&start_date=' + start_date + '&end_date=' + end_date + '&select_status=' + select_status;
- // var myURL='http://192.168.6.245:8080/st-xm/Api/reportDataControll.php?method=getRunReportData&user_id=1&currpage=1&page_size=20&line=SB0031&strat_date=2016-05-05&end_date=2016-09-09'
- var myURL2 = './carChart.html?prod=' + prod + '&start_date=' + start_date + '&end_date=' + end_date + '&select_status=' + select_status;
- alert('非空判断一切正常----点击了查询' + myURL);
- get_virtual_user_list(myURL, myURL2);
- });
- });
-
- 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;
- default:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
- break;
- }
-
- cNewTimeStr = cNewTimeStr.replace(/;/g, "");
-
- return cNewTimeStr;
-
- }
|