Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

569 righe
18 KiB

  1. var page_size = 10;
  2. var page_status = 0;
  3. var cur_url='';
  4. var cur_sel_bus_group='0';
  5. /*======================网络请求的Ajax的代码=======================*/
  6. // 创建一个Ajax对象
  7. if (window.ActiveXObject) {
  8. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  9. } else {
  10. var myreq = new XMLHttpRequest();
  11. }
  12. function ZZLog(str){
  13. var isLog=true;
  14. if(isLog){
  15. console.log(str);
  16. }
  17. }
  18. function selectPage(){
  19. page_size = $("#select_curpage").val();
  20. page_status = 1;
  21. }
  22. /**
  23. *
  24. * @param {Object} myURL 返回数据URL接口
  25. * @param {Object} myURL2 当前的URL
  26. */
  27. document.addEventListener('DOMContentLoaded', function() {
  28. carList_html = $("#carList").html();
  29. // 设置出发日期为当前日期
  30. page_size = getPar('page_size');
  31. if(!page_size){
  32. page_size = $("#select_curpage").val();
  33. }else{
  34. $("#select_curpage").val(page_size);
  35. }
  36. var currpage=getPar('currpage');
  37. var start_area = getPar('start_area');
  38. var end_area = getPar('end_area');
  39. var line = getPar('line');
  40. var start_date = getPar('start_date');
  41. var end_date = getPar('end_date');
  42. var select_status = getPar('run_status');
  43. var bus_type = getPar('bus_type');
  44. var bus_group = getPar('bus_group');
  45. if(currpage || start_area || end_area || line || start_date || end_date || select_status || bus_group){
  46. if(currpage==""){
  47. currpage=1;
  48. }
  49. var tnowtime = getDateTime(4);
  50. $('#start_area').val(start_area);
  51. $('#end_area').val(end_area);
  52. $('#prod').val(line);
  53. $('#id-date-picker-1').val(start_date);
  54. $('#id-date-picker-2').val(end_date);
  55. $("#select_status").val(select_status);
  56. $("#bus_type").val(bus_type);
  57. $('#bus_group').val(bus_group);
  58. cur_sel_bus_group=bus_group;
  59. var tnowtime = getDateTime(4);
  60. 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;
  61. 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;
  62. cur_url=myURL2;
  63. get_virtual_user_list(myURL, myURL2);
  64. }else{
  65. $("#id-date-picker-1").val(getDateTime(11));
  66. $("#id-date-picker-2").val(getDateTime(11));
  67. click_search();
  68. }
  69. }, false);
  70. // 请求方法,传入URL
  71. function get_virtual_user_list(myURL, myURL2) {
  72. ZZLog(myURL);
  73. var tnowtime = getDateTime(4);
  74. if (myURL.indexOf('?') >= 0) {
  75. myURL += '&tt=' + tnowtime;
  76. } else {
  77. myURL += '?tt=' + tnowtime;
  78. }
  79. $.getJSON(myURL, function(httpData) {
  80. ZZLog(httpData);
  81. if (httpData['code'] != '0') {
  82. $('#carList').html('');
  83. alert(httpData['info']);
  84. return;
  85. }
  86. if (httpData['run_list'].length <= 0) {
  87. $("#carList").html('');
  88. $('#test').html('');
  89. return;
  90. }
  91. $("#carList").html('');
  92. $('#test').html('');
  93. var total = httpData['total'];
  94. $("#select_curpage_all").val(total);
  95. var carList = httpData['run_list'];
  96. var carListHTML = ''
  97. for (var i = 0; i < carList.length; i++) {
  98. var tempDict = carList[i];
  99. var tempHTML = carList_html;
  100. tempHTML = tempHTML.replace('[dict-json]',JSON.stringify(tempDict));
  101. tempHTML = tempHTML.replace('[data-statu]', tempDict['run_status']);
  102. tempHTML = tempHTML.replace('[car_number]',tempDict['car_number']);
  103. tempHTML = tempHTML.replace('[run_date]', tempDict['run_date']);
  104. tempHTML = tempHTML.replace('[QDH]', tempDict['prod_name']);
  105. tempHTML = tempHTML.replace('[name]', tempDict['run_id']);
  106. tempHTML = tempHTML.replace('[线路]', tempDict['property'] + ' ' + tempDict['prod_name']);
  107. tempHTML = tempHTML.replace('[出发日期]', tempDict['run_date']);
  108. tempHTML = tempHTML.replace('[出发站点时间]', tempDict['start_time'] + ' ' + tempDict['res_name']);
  109. var car_no=tempDict['car_number'];
  110. car_no=(Array(2).join(0)+car_no).slice(-2);
  111. tempHTML = tempHTML.replace('[车次]', car_no);
  112. tempHTML = tempHTML.replace('[座位总数]', tempDict['seat_count']);
  113. tempHTML = tempHTML.replace('[已售座位]', tempDict['sale_seat']);
  114. if (tempDict['saled_count'].trim() == "0" && tempDict['max_count'].trim() == "0") {
  115. tempHTML = tempHTML.replace('[已售人数]', '-');
  116. } else {
  117. // tempHTML = tempHTML.replace('[已售]', tempDict['saled_count'] + '/' + tempDict['max_count']);
  118. tempHTML = tempHTML.replace('[已售人数]', tempDict['saled_count']);
  119. }
  120. tempHTML = tempHTML.replace('[运营状态]', tempDict['run_status']);
  121. tempHTML = tempHTML.replace('[收客状态]', tempDict['receiving']);
  122. var caozuoStr = ''
  123. caozuoStr += '<a target="_blank" href="carDetail.html?run_id=' + tempDict['run_id'] + '">查看</a>&nbsp;';
  124. caozuoStr += '<a target="_blank" href="revisecartime.html?run_id=' + tempDict['run_id'] + '">修改</a>&nbsp;';
  125. tempHTML = tempHTML.replace('[操作]', caozuoStr);
  126. carListHTML += tempHTML;
  127. }
  128. $("#carList").html(carListHTML);
  129. $('.one').css('display', 'table-row');
  130. var bus_group_list=httpData['bus_group_list'];
  131. var busgrouphtml='<option value="0" selected="selected">全部</option>';
  132. for (var i=0,m=bus_group_list.length;i<m;i++) {
  133. var tempDict=bus_group_list[i];
  134. var tempHTML='<option value="0">全部</option>';
  135. tempHTML=tempHTML.replace('value="0"','value='+tempDict['group_id']);
  136. tempHTML=tempHTML.replace('全部',tempDict['group_name']);
  137. busgrouphtml+=tempHTML;
  138. }
  139. $('#bus_group').html(busgrouphtml);
  140. $('#bus_group').val(cur_sel_bus_group);
  141. // *********************************
  142. var currpage = getPar("currpage");
  143. if (!currpage) {
  144. currpage = 1
  145. }
  146. var sum = parseInt(httpData['total']);
  147. var length = page_size;
  148. var tag = "test";
  149. var userUrl = myURL2;
  150. getPager(userUrl, sum, currpage, length, tag, 'currpage');
  151. })
  152. }
  153. var carList_html = ''
  154. // 复选框事件
  155. function select_checked(index) {
  156. //index=0最上面的全选 index=1表示的是下面所有的
  157. var cur_check = $('.ace')[0];
  158. var checkList = $('.ace');
  159. var checkCount = checkList.length - 1;
  160. var true_count = 0;
  161. for (var i = 1; i < checkList.length; i++) {
  162. if (index == '0') {
  163. checkList[i].checked = cur_check.checked;
  164. } else {
  165. if (checkList[i].checked == false) {
  166. cur_check.checked = false
  167. } else {
  168. true_count = true_count + 1;
  169. }
  170. }
  171. }
  172. //判断下面是否选中完
  173. if (checkCount == true_count) {
  174. cur_check.checked = true;
  175. }
  176. var temp_QDH='';
  177. var arr_bool_QDH= new Array();
  178. var arr_bool_statu=new Array();
  179. $('.ace').each(function(index, item) {
  180. if (this.checked && index != 0) {
  181. // arr_run_ids.push($(this).attr('data_QDH'));
  182. var QDH=$(this).attr('data_QDH');
  183. var statu=$(this).attr('data-statu');
  184. temp_QDH=QDH;
  185. if(QDH=="上海-千岛湖" || QDH=="千岛湖-上海" ||QDH=="上海市-千岛湖" || QDH=="千岛湖-上海市"){
  186. arr_bool_QDH.push(true);
  187. }else{
  188. arr_bool_QDH.push(false);
  189. }
  190. if(statu=="待审核"){
  191. arr_bool_statu.push('true');
  192. }else{
  193. arr_bool_statu.push('false');
  194. }
  195. }
  196. });
  197. $('#five_del').addClass('del');
  198. $('#five_del').attr('data-statu','false');
  199. $('#update_car_no').addClass('update_car_no');
  200. $('#update_car_no').attr('data-statu','false');
  201. if(arr_bool_QDH.length>1){
  202. $('#update_car_no').addClass('update_car_no');
  203. $('#update_car_no').attr('data-statu','false');
  204. }else if(arr_bool_QDH.length==1 && (temp_QDH=="上海-千岛湖" || temp_QDH=="千岛湖-上海" || temp_QDH=="上海市-千岛湖" || temp_QDH=="千岛湖-上海市")){
  205. $('#update_car_no').removeClass('update_car_no');
  206. $('#update_car_no').attr('data-statu','true');
  207. }else{
  208. $('#update_car_no').addClass('update_car_no');
  209. $('#update_car_no').attr('data-statu','false');
  210. }
  211. if(arr_bool_statu.indexOf('false')!=-1){
  212. $('#five_del').addClass('del');
  213. $('#five_del').attr('data-statu','false');
  214. }else if(arr_bool_statu.indexOf('true')!=-1){
  215. $('#five_del').removeClass('del');
  216. $('#five_del').attr('data-statu','true');
  217. }else{
  218. $('#five_del').addClass('del');
  219. $('#five_del').attr('data-statu','false');
  220. }
  221. }
  222. //
  223. //结束日期value改变的时候触发
  224. $(document).ready(function() {
  225. var date = new Date();
  226. $('#id-date-picker-2').val(getDateTime(9));
  227. $('#id-date-picker-1').change(function() {
  228. //开始日期
  229. var start_date = $('#id-date-picker-1').val();
  230. if (start_date.trim().length <= 0) {
  231. alert('请选择开始日期!!!');
  232. return;
  233. }
  234. //结束日期
  235. var end_date = $('#id-date-picker-2').val();
  236. if (end_date.trim().length < 0) {
  237. alert('请选择结束日期');
  238. return;
  239. }
  240. // 判断日期是否合理
  241. var date1 = new Date(start_date.replace(/\-/g, '/'));
  242. var date2 = new Date(end_date.replace(/\-/g, '/'));
  243. if (date1>date2 || end_date=="") {
  244. $('#id-date-picker-2').val(start_date);
  245. }
  246. });
  247. $('#id-date-picker-2').change(function() {
  248. //开始日期
  249. var start_date = $('#id-date-picker-1').val();
  250. if (start_date.trim().length <= 0) {
  251. alert('请选择开始日期!!!');
  252. return;
  253. }
  254. //结束日期
  255. var end_date = $('#id-date-picker-2').val();
  256. if (end_date.trim().length < 0) {
  257. alert('请选择结束日期');
  258. return;
  259. }
  260. // 判断日期是否合理
  261. var date1 = new Date(start_date.replace(/\-/g, '/'));
  262. var date2 = new Date(end_date.replace(/\-/g, '/'));
  263. if (date2 < date1) {
  264. alert('结束日期必须大于开始日期!!!');
  265. $('#id-date-picker-2').val('');
  266. return;
  267. }
  268. });
  269. });
  270. //查询按钮click事件
  271. function click_search(){
  272. $('#update_car_no').addClass('update_car_no');
  273. $('#update_car_no').attr('data-statu','false');
  274. $('#five_del').addClass('del');
  275. $('#five_del').attr('data-statu','false');
  276. $('.ace')[0].checked=false;
  277. //出发地
  278. var start_area = $('#start_area').val();
  279. //目的地
  280. var end_area = $('#end_area').val();
  281. //线路
  282. var line = $('#prod').val();
  283. //开始日期
  284. var start_date = $('#id-date-picker-1').val();
  285. if (start_date.trim().length <= 0) {
  286. alert('请选择开始日期!!!');
  287. return;
  288. }
  289. //结束日期
  290. var end_date = $('#id-date-picker-2').val();
  291. if (end_date.trim().length <= 0) {
  292. alert('请选择结束日期!!!');
  293. return;
  294. }
  295. // 判断日期是否合理
  296. var date1 = new Date(start_date.replace(/\-/g, '/'));
  297. var date2 = new Date(end_date.replace(/\-/g, '/'));
  298. if (date2 < date1) {
  299. alert('结束日期必须大于开始日期!!!');
  300. return;
  301. }
  302. //运营状态
  303. var select_status = $("#select_status").val();
  304. if(page_status == 1){
  305. var currpage=getPar('currpage');
  306. }else{
  307. var currpage=1;
  308. }
  309. if (!currpage) {
  310. currpage = '1'
  311. }
  312. //车辆类型
  313. var bus_type = $("#bus_type").val();
  314. var bus_group = $('#bus_group').val();
  315. var tnowtime = getDateTime(4);
  316. 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;
  317. 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;
  318. cur_url=myURL2;
  319. get_virtual_user_list(myURL, myURL2);
  320. }
  321. //点击审核等按钮
  322. function click_five_btn(btn_value) {
  323. //先拿到run_id
  324. var arr_run_ids = new Array();
  325. var temp_run_id=0;
  326. var temp_run_date='';
  327. var temp_line='';
  328. $('.ace').each(function(index, item) {
  329. if (this.checked && index != 0) {
  330. var car_number=$(this).attr('data-carno');
  331. var run_id=$(this).attr('name');
  332. var cstr1="{"+run_id+","+car_number+"}";
  333. arr_run_ids.push(cstr1);
  334. temp_line=$(this).attr('data_QDH');
  335. temp_run_id=$(this).attr('name');
  336. temp_run_date=$(this).attr('data-date');
  337. }
  338. });
  339. if (arr_run_ids.length <= 0) {
  340. alert('请勾选!!!');
  341. return;
  342. }
  343. if(btn_value=="update_car_no"){
  344. var statu=$('#update_car_no').attr('data-statu');
  345. if(statu=='true'){
  346. ZZLog('可用');
  347. var line=temp_line;
  348. var run_id=temp_run_id;
  349. var run_date=temp_run_date;
  350. var next_url="update_car_no.html?line="+line+"&run_id="+run_id+"&start_date="+run_date;
  351. window.open(next_url);
  352. }else{
  353. ZZLog('不可用');
  354. }
  355. }else{
  356. if(btn_value=="4"){
  357. var va_4=$('#five_del').attr('data-statu');
  358. if(va_4!="true"){
  359. alert('只有待审核的才可删除!!!');
  360. return;
  361. }
  362. }
  363. var run_id_str = arr_run_ids.join(',');
  364. ZZLog("/st-xm/Api/run_status_update.php?allrunid=" + run_id_str + "&status=" + btn_value);
  365. $.getJSON("/st-xm/Api/run_status_update.php?allrunid=" + run_id_str + "&status=" + btn_value, function(data) {
  366. ZZLog(data);
  367. if (data.errcode == 0) {
  368. alert("操作成功");
  369. // click_search();
  370. location.replace(cur_url);
  371. } else {
  372. alert(data.errinfo);
  373. }
  374. })
  375. }
  376. }
  377. function getPar(par) {
  378. //获取当前URL
  379. var local_url = document.location.href;
  380. local_url = decodeURI(local_url);
  381. //获取要取得的get参数位置
  382. var get = local_url.indexOf(par + "=");
  383. if (get == -1) {
  384. return false;
  385. }
  386. //截取字符串
  387. var get_par = local_url.slice(par.length + get + 1);
  388. //判断截取后的字符串是否还有其他get参数
  389. var nextPar = get_par.indexOf("&");
  390. if (nextPar != -1) {
  391. get_par = get_par.slice(0, nextPar);
  392. }
  393. return get_par;
  394. }
  395. function getDateTime(nTypeFlag) {
  396. var tNowTime = new Date();
  397. var myYear = ';' + tNowTime.getFullYear() + ';';
  398. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  399. var myDay = ';' + tNowTime.getDate() + ';';
  400. var myHour = ';' + tNowTime.getHours() + ';';
  401. var myMinu = ';' + tNowTime.getMinutes() + ';';
  402. var mySecond = ';' + tNowTime.getSeconds() + ';';
  403. if(myMonth.length < 4) myMonth = '0' + myMonth;
  404. if(myDay.length < 4) myDay = '0' + myDay;
  405. if(myHour.length < 4) myHour = '0' + myHour;
  406. if(myMinu.length < 4) myMinu = '0' + myMinu;
  407. if(mySecond.length < 4) mySecond = '0' + mySecond;
  408. var cNewTimeStr;
  409. //alert(tNowTime);
  410. switch(nTypeFlag + 1 - 1) {
  411. case 0:
  412. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  413. break;
  414. case 1:
  415. cNewTimeStr = myYear + myMonth + myDay;
  416. break;
  417. case 2:
  418. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  419. break;
  420. case 3:
  421. cNewTimeStr = myHour + myMinu + mySecond;
  422. break;
  423. case 4:
  424. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  425. break;
  426. case 5:
  427. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  428. break;
  429. case 6:
  430. cNewTimeStr = myYear;
  431. break;
  432. case 7:
  433. cNewTimeStr = myYear + '-' + myMonth;
  434. break;
  435. case 8: //得到上一个月的今天
  436. var date = getDateTime(0);
  437. var arr = date.split('-');
  438. var year = arr[0]; //获取当前日期的年份
  439. var month = arr[1]; //获取当前日期的月份
  440. var day = arr[2]; //获取当前日期的日
  441. var days = new Date(year, month, 0);
  442. days = days.getDate(); //获取当前日期中月的天数
  443. var year2 = year;
  444. var month2 = parseInt(month) - 1;
  445. if(month2 == 0) {
  446. year2 = parseInt(year2) - 1;
  447. month2 = 12;
  448. }
  449. var day2 = day;
  450. var days2 = new Date(year2, month2, 0);
  451. days2 = days2.getDate();
  452. if(day2 > days2) {
  453. day2 = days2;
  454. }
  455. if(month2 < 10) {
  456. month2 = '0' + month2;
  457. }
  458. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  459. break;
  460. case 9: //得到下一个月的今天
  461. var date = getDateTime(0);
  462. var arr = date.split('-');
  463. var year = arr[0]; //获取当前日期的年份
  464. var month = arr[1]; //获取当前日期的月份
  465. var day = arr[2]; //获取当前日期的日
  466. var days = new Date(year, month, 0);
  467. days = days.getDate(); //获取当前日期中的月的天数
  468. var year2 = year;
  469. var month2 = parseInt(month) + 1;
  470. if(month2 == 13) {
  471. year2 = parseInt(year2) + 1;
  472. month2 = 1;
  473. }
  474. var day2 = day;
  475. var days2 = new Date(year2, month2, 0);
  476. days2 = days2.getDate();
  477. if(day2 > days2) {
  478. day2 = days2;
  479. }
  480. if(month2 < 10) {
  481. month2 = '0' + month2;
  482. }
  483. var t2 = year2 + '-' + month2 + '-' + day2;
  484. return t2;
  485. break;
  486. case 10: //昨日日期
  487. var dateStr=getDateTime(0);
  488. var t_temp_sdate = dateStr.split('-');
  489. var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
  490. now.setDate(now.getDate() - 0 - 1);
  491. var year = ";" + now.getFullYear() + ";";
  492. var month = ";" + now.getMonth() + ";";
  493. var day = ";" + now.getDate() + ";";
  494. if(year.length < 4) {
  495. year = "0" + year;
  496. }
  497. if(month.length < 4) {
  498. month = "0" + month;
  499. }
  500. if(day.length < 4) {
  501. day = "0" + day;
  502. }
  503. var datestr = year + "-" + month + "-" + day;
  504. datestr = datestr.replace(/;/g, "");
  505. return datestr;
  506. break;
  507. case 11: //明日日期
  508. var dateStr=getDateTime(0);
  509. var t_temp_sdate = dateStr.split('-');
  510. var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
  511. now.setDate(now.getDate() - 0 + 1);
  512. var year = ";" + now.getFullYear() + ";";
  513. var month = ";" + now.getMonth() + ";";
  514. var day = ";" + now.getDate() + ";";
  515. if(year.length < 4) {
  516. year = "0" + year;
  517. }
  518. if(month.length < 4) {
  519. month = "0" + month;
  520. }
  521. if(day.length < 4) {
  522. day = "0" + day;
  523. }
  524. var datestr = year + "-" + month + "-" + day;
  525. datestr = datestr.replace(/;/g, "");
  526. return datestr;
  527. break;
  528. default:
  529. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  530. break;
  531. }
  532. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  533. return cNewTimeStr;
  534. }