You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

366 lines
14 KiB

  1. var carChartStr = ''
  2. var trcode1Str = ''
  3. var trcode2Str = ''
  4. var trcode3Str = ''
  5. var trfinalStr = ''
  6. var page_size = 20;
  7. var myArray = new Array();
  8. var tempHttpData = null;
  9. /*======================网络请求的Ajax的代码=======================*/
  10. // 创建一个Ajax对象
  11. if (window.ActiveXObject) {
  12. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  13. } else {
  14. var myreq = new XMLHttpRequest();
  15. }
  16. window.onload = function() {
  17. //入住时间初始值
  18. $('#id-date-picker-1').val(getDateTime(0));
  19. carChartStr = $('#carChart').html();
  20. trcode1Str = $('#tr_one').prop('outerHTML');
  21. trcode2Str = $('#tr_two').prop('outerHTML');
  22. trcode3Str = $('#tr_three').prop('outerHTML');
  23. trfinalStr = $('#tr_final').prop('outerHTML');
  24. var prod = getPar('prod');
  25. var start_date = getPar('start_date');
  26. var end_date = getPar('end_date');
  27. var select_status = getPar('select_status');
  28. if (prod && start_date && end_date && select_status) {
  29. $('#id-date-picker-1').val(getDateTime(0))
  30. var myURL = './json/jsonCarChart.html?prod=' + prod + '&start_date=' + start_date + '&end_date=' + end_date + '&select_status=' + select_status;
  31. var myURL2 = './carChart.html?prod=' + prod + '&start_date=' + start_date + '&end_date=' + end_date + '&select_status=' + select_status;
  32. get_virtual_user_list(myURL, myURL2);
  33. }
  34. }
  35. // 请求方法,传入URL
  36. function get_virtual_user_list(myURL, myURL2) {
  37. var tnowtime = getDateTime(4);
  38. if (myURL.indexOf('?') >= 0) {
  39. myURL += '&tt=' + tnowtime;
  40. } else {
  41. myURL += '?tt=' + tnowtime;
  42. }
  43. myreq.open("get", myURL, true);
  44. // 接收的数据交给哪个函数处理
  45. myreq.onreadystatechange = function() {
  46. if (myreq.readyState == 4) {
  47. // newstr 就是接收到的数据
  48. var newstr = myreq.responseText;
  49. var httpData = eval('(' + newstr + ')');
  50. if (httpData['code'] != '0') {
  51. alert(info);
  52. return;
  53. }
  54. tempHttpData = httpData;
  55. var chartInfo = httpData['chartInfo'];
  56. var num1 = -1;
  57. var num21 = -1;
  58. var num22 = -1;
  59. var num23 = -1;
  60. myArray.length = 0;
  61. $('#carChart').css('display','');
  62. if(chartInfo.lentgh<=0){alert('没有查询到符号条件的数据!!!');return;}
  63. for (var i = 0; i < chartInfo.length; i++) {
  64. var tempDict = chartInfo[i];
  65. num1++;
  66. num21 = num1;
  67. num22 = -1;
  68. num23 = -1;
  69. myArray[num1] = new Array();
  70. myArray[num1][0] = '|' + num21 + '|';
  71. myArray[num1][1] = 0; //层级
  72. myArray[num1][2] = -1; //子节点当前展开还是收缩
  73. myArray[num1][3] = tempDict['startTime'];
  74. myArray[num1][4] = tempDict['prodcode'];
  75. myArray[num1][5] = tempDict['prodname'];
  76. myArray[num1][6] = tempDict['carCount'];
  77. myArray[num1][7] = tempDict['seatCount'];
  78. myArray[num1][8] = tempDict['outTicketCount'];
  79. myArray[num1][9] = tempDict['outTicketBalance'];
  80. myArray[num1][10] = tempDict['refundCount'];
  81. myArray[num1][11] = tempDict['refundBalance'];
  82. myArray[num1][12] = tempDict['refundPoundage'];
  83. myArray[num1][13] = tempDict['sellAll'];
  84. myArray[num1][14] = tempDict['income'];
  85. //......
  86. var everyDate = tempDict['everyDate'];
  87. for (var j = 0; j < everyDate.length; j++) {
  88. var dateTemp = everyDate[j];
  89. num1++;
  90. num22 = num1;
  91. num23 = -1;
  92. myArray[num1] = new Array();
  93. myArray[num1][0] = '|' + num21 + '|' + num22 + '|';
  94. myArray[num1][1] = 1;
  95. myArray[num1][2] = -1; //子节点当前展开还是收缩
  96. myArray[num1][3] = dateTemp['startTime'];
  97. myArray[num1][4] = dateTemp['carCount'];
  98. myArray[num1][5] = dateTemp['seatCount'];
  99. myArray[num1][6] = dateTemp['outTicketCount'];
  100. myArray[num1][7] = dateTemp['outTicketBalance'];
  101. myArray[num1][8] = dateTemp['sellAll'];
  102. myArray[num1][9] = dateTemp['income'];
  103. //......
  104. var everyTime = dateTemp['everyTime'];
  105. for (var k = 0; k < everyTime.length; k++) {
  106. var timeTemp = everyTime[k];
  107. num1++;
  108. num23 = num1;
  109. myArray[num1] = new Array();
  110. myArray[num1][0] = '|' + num21 + '|' + num22 + '|' + num23;
  111. myArray[num1][1] = 2;
  112. myArray[num1][2] = -1; //子节点当前展开还是收缩
  113. myArray[num1][3] = timeTemp['startTime'];
  114. myArray[num1][4] = timeTemp['carCount'];
  115. myArray[num1][5] = timeTemp['seatCount'];
  116. myArray[num1][6] = timeTemp['outTicketCount'];
  117. myArray[num1][7] = timeTemp['outTicketBalance'];
  118. myArray[num1][8] = timeTemp['refundCount'];
  119. myArray[num1][9] = timeTemp['refundBalance'];
  120. myArray[num1][10] = timeTemp['refundPoundage'];
  121. myArray[num1][11] = timeTemp['sellAll'];
  122. myArray[num1][12] = timeTemp['income'];
  123. //......
  124. }
  125. }
  126. }
  127. console.log(myArray);
  128. show_table(myURL2);
  129. var all_Count_Str = $('#carChart').html();
  130. var tempHTML = trfinalStr;
  131. tempHTML = tempHTML.replace('[线路]', '');
  132. tempHTML = tempHTML.replace('[车数量]', httpData['all_carCount']);
  133. tempHTML = tempHTML.replace('[座位数]', httpData['all_seatCount']);
  134. tempHTML = tempHTML.replace('[出票数量]', httpData['all_outTicketCount']);
  135. tempHTML = tempHTML.replace('[出票金额]', httpData['all_outTicketBalance']);
  136. tempHTML = tempHTML.replace('[退票数量]', httpData['all_refundCount']);
  137. tempHTML = tempHTML.replace('[退票金额]', httpData['all_refundBalance']);
  138. tempHTML = tempHTML.replace('[退票手续费]', httpData['all_refundPoundage']);
  139. tempHTML = tempHTML.replace('[售票总计]', httpData['all_sellAll']);
  140. tempHTML = tempHTML.replace('[收入总计]', httpData['all_income']);
  141. all_Count_Str += tempHTML;
  142. $('#carChart').html(all_Count_Str)
  143. }
  144. };
  145. myreq.send();
  146. }
  147. function show_table(myURL2) {
  148. var num1 = myArray.length;
  149. var cstr1 = '';
  150. for (var i = 0; i < num1; i++) {
  151. if (myArray[i][1] == 0) {
  152. var tempHTML = trcode1Str;
  153. tempHTML = tempHTML.replace('tr_one', 'list_' + i);
  154. tempHTML = tempHTML.replace('[code]', i);
  155. tempHTML = tempHTML.replace('[出发时间1]', myArray[i][3]);
  156. tempHTML = tempHTML.replace('[线路]', myArray[i][4] + ' ' + myArray[i][5]);
  157. tempHTML = tempHTML.replace('[车数量]', myArray[i][6]);
  158. tempHTML = tempHTML.replace('[座位数]', myArray[i][7]);
  159. tempHTML = tempHTML.replace('[出票数量]', myArray[i][8]);
  160. tempHTML = tempHTML.replace('[出票金额]', myArray[i][9]);
  161. tempHTML = tempHTML.replace('[退票数量]', myArray[i][10]);
  162. tempHTML = tempHTML.replace('[退票金额]', myArray[i][11]);
  163. tempHTML = tempHTML.replace('[退票手续费]', myArray[i][12]);
  164. tempHTML = tempHTML.replace('[售票总计]', myArray[i][13]);
  165. tempHTML = tempHTML.replace('[收入总计]', myArray[i][14]);
  166. cstr1 += tempHTML;
  167. } else if (myArray[i][1] == 1) {
  168. var tempHTML = trcode2Str;
  169. tempHTML = tempHTML.replace('tr_two', 'list_' + i);
  170. tempHTML = tempHTML.replace('[code]', i);
  171. tempHTML = tempHTML.replace('[出发时间2]', myArray[i][3]);
  172. tempHTML = tempHTML.replace('[线路]', '');
  173. tempHTML = tempHTML.replace('[车数量]', myArray[i][4]);
  174. tempHTML = tempHTML.replace('[座位数]', myArray[i][5]);
  175. tempHTML = tempHTML.replace('[出票数量]', myArray[i][6]);
  176. tempHTML = tempHTML.replace('[出票金额]', myArray[i][7]);
  177. tempHTML = tempHTML.replace('[退票数量]', '-');
  178. tempHTML = tempHTML.replace('[退票金额]', '-');
  179. tempHTML = tempHTML.replace('[退票手续费]', '-');
  180. tempHTML = tempHTML.replace('[售票总计]', myArray[i][8]);
  181. tempHTML = tempHTML.replace('[收入总计]', myArray[i][9]);
  182. cstr1 += tempHTML;
  183. } else if (myArray[i][1] == 2) {
  184. var tempHTML = trcode3Str;
  185. tempHTML = tempHTML.replace('tr_three', 'list_' + i);
  186. tempHTML = tempHTML.replace('[code]', i);
  187. tempHTML = tempHTML.replace('[出发时间3]', myArray[i][3]);
  188. tempHTML = tempHTML.replace('[线路]', '');
  189. tempHTML = tempHTML.replace('[车数量]', myArray[i][4]);
  190. tempHTML = tempHTML.replace('[座位数]', myArray[i][5]);
  191. tempHTML = tempHTML.replace('[出票数量]', myArray[i][6]);
  192. tempHTML = tempHTML.replace('[出票金额]', myArray[i][7]);
  193. tempHTML = tempHTML.replace('[退票数量]', myArray[i][8]);
  194. tempHTML = tempHTML.replace('[退票金额]', myArray[i][9]);
  195. tempHTML = tempHTML.replace('[退票手续费]', myArray[i][10]);
  196. tempHTML = tempHTML.replace('[售票总计]', myArray[i][11]);
  197. tempHTML = tempHTML.replace('[收入总计]', myArray[i][12]);
  198. cstr1 += tempHTML;
  199. }
  200. // cstr1 += '<tr id="list_' + i + '" onclick="show_hide_tr(' + i + ')">';
  201. // cstr1 += '<td>';
  202. // //.....
  203. // cstr1 += '</tr>';
  204. }
  205. $('#carChart').html(cstr1)
  206. var currpage = getPar("currpage");
  207. if (currpage) {} else {
  208. currpage = 1;
  209. }
  210. var sum = tempHttpData['total'];
  211. var length = page_size;
  212. var tag = "test";
  213. var userUrl = myURL2;
  214. getPager(userUrl, sum, currpage, length, tag, 'currpage');
  215. }
  216. //function show_hide_tr(myid,myidstr,mylevel)
  217. function show_hide_tr(myid) {
  218. var num1 = myArray.length;
  219. var cstr1 = myArray[myid][0]; // 父标记
  220. var num2 = myArray[myid][1]; // 父级别
  221. var num3 = myArray[myid][2]; // 所属子级别当前应该是展开还是收缩
  222. for (var i = 0; i < num1; i++) {
  223. var cstr2 = myArray[i][0];
  224. // if (charindex(cstr2,cstr1)>=0 && cstr2!=cstr1)
  225. if (cstr2.indexOf(cstr1) >= 0 && cstr2 != cstr1) {
  226. //找到子节点
  227. // var obj1= document.getElementById('list_' + i)
  228. var obj1 = $('#list_' + i);
  229. // num3==-1?obj1.style.display='table-row':obj1.style.display='none';
  230. if (num2 == 1) {
  231. num3 == -1 ? obj1.css('display', 'table-row') : obj1.css('display', 'none');
  232. }
  233. // if (num3 ==1)
  234. if (num3 == -1) {
  235. //展开
  236. // var obj1= document.getElementById('list_' + i) ;
  237. if (myArray[i][1] == 1) {
  238. obj1.css('display', 'table-row');
  239. }
  240. } else {
  241. //收缩
  242. // var obj1= document.getElementById('list_' + i)
  243. var tt = num2 + 1;
  244. obj1.css('display', 'none');
  245. myArray[i][2] = -1;
  246. // if (tt == myArray[i][0]) {//儿子节点
  247. // if (myArray[i][0].indexOf(tt)>=0){
  248. // obj1.style.display = 'table-row';
  249. // }else{
  250. // obj1.style.display = 'none';
  251. // }
  252. }
  253. }
  254. }
  255. myArray[myid][2] = 1 - myArray[myid][2];
  256. }
  257. $(document).ready(function() {
  258. $('#btn_search').click(function() {
  259. //线路
  260. var prod = $('#prod').val();
  261. // if (prod.trim().length <= 0) {alert('请输入线路!!!');return;}
  262. //出发日期
  263. var start_date = $('#id-date-picker-1').val();
  264. if (start_date.trim().length <= 0) {alert('请选择出发日期!!!');return;}
  265. //结束日期
  266. var end_date = $('#id-date-picker-2').val();
  267. if (end_date.trim().length <= 0) {alert('请选择结束日期!!!');return;}
  268. //判断结束日期不能小于开始日期
  269. var date1=new Date(start_date.replace(/\-/g,'/'));
  270. var date2=new Date(end_date.replace(/\-/g,'/'));
  271. if(date2<=date1){alert('结束日期必须大于开始日期!!!');return;}
  272. //销售渠道
  273. var select_status = $("#select_status option:selected").val();
  274. // if (select_status.trim().length <= 0 || select_status == '请选择') {alert('请选择销售渠道!!!');return;}
  275. var user_id = getPar('user_id');
  276. if (!user_id) {
  277. user_id = '1'
  278. };
  279. //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
  280. 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;
  281. // 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'
  282. var myURL2 = './carChart.html?prod=' + prod + '&start_date=' + start_date + '&end_date=' + end_date + '&select_status=' + select_status;
  283. alert('非空判断一切正常----点击了查询' + myURL);
  284. get_virtual_user_list(myURL, myURL2);
  285. });
  286. });
  287. function getPar(par) {
  288. //获取当前URL
  289. var local_url = document.location.href;
  290. local_url = decodeURI(local_url);
  291. //获取要取得的get参数位置
  292. var get = local_url.indexOf(par + "=");
  293. if (get == -1) {
  294. return false;
  295. }
  296. //截取字符串
  297. var get_par = local_url.slice(par.length + get + 1);
  298. //判断截取后的字符串是否还有其他get参数
  299. var nextPar = get_par.indexOf("&");
  300. if (nextPar != -1) {
  301. get_par = get_par.slice(0, nextPar);
  302. }
  303. return get_par;
  304. }
  305. function getDateTime(nTypeFlag) {
  306. var tNowTime = new Date();
  307. var myYear = ';' + tNowTime.getFullYear() + ';';
  308. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  309. var myDay = ';' + tNowTime.getDate() + ';';
  310. var myHour = ';' + tNowTime.getHours() + ';';
  311. var myMinu = ';' + tNowTime.getMinutes() + ';';
  312. var mySecond = ';' + tNowTime.getSeconds() + ';';
  313. if (myMonth.length < 4) myMonth = '0' + myMonth;
  314. if (myDay.length < 4) myDay = '0' + myDay;
  315. if (myHour.length < 4) myHour = '0' + myHour;
  316. if (myMinu.length < 4) myMinu = '0' + myMinu;
  317. if (mySecond.length < 4) mySecond = '0' + mySecond;
  318. var cNewTimeStr;
  319. //alert(tNowTime);
  320. switch (nTypeFlag + 1 - 1) {
  321. case 0:
  322. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  323. break;
  324. case 1:
  325. cNewTimeStr = myYear + myMonth + myDay;
  326. break;
  327. case 2:
  328. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  329. break;
  330. case 3:
  331. cNewTimeStr = myHour + myMinu + mySecond;
  332. break;
  333. case 4:
  334. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  335. break;
  336. case 5:
  337. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  338. break;
  339. case 6:
  340. cNewTimeStr = myYear;
  341. break;
  342. case 7:
  343. cNewTimeStr = myYear + '-' + myMonth;
  344. break;
  345. default:
  346. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  347. break;
  348. }
  349. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  350. return cNewTimeStr;
  351. }