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 += '