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.
 
 
 
 

363 lines
11 KiB

  1. //var base_url="http://temp.zhizhuchuxing.com";
  2. var base_url="";
  3. //var base_url="http://127.0.0.1:8020/%E8%9C%98%E8%9B%9B2.0%E8%83%BD%E5%86%99PHP";
  4. function show_detail(index) {
  5. var obj1 = document.getElementById("content_" + index);
  6. var cstr1 = obj1.style.display;
  7. if(cstr1 == 'block') {
  8. obj1.style.display = 'none';
  9. } else {
  10. obj1.style.display = 'block';
  11. }
  12. }
  13. window.onload = function() {
  14. $('#id-date-picker-1').val(getDateTime(0));
  15. var res_id = getPar('res_id');
  16. var res_name = getPar('res_name');
  17. $('#h1_title').html(res_name);
  18. var start_date = $('#id-date-picker-1').val();
  19. var end_date = start_date;
  20. // var url = "./st-xm/Api/car_team_controll.php?method=getDriverRunByCompany&start_date=" + start_date + "&end_date=" + end_date + "&res_id=" + res_id;
  21. var url=base_url+"/st-xm/Api/car_team_controll.php?method=getDriverRunByCompany&start_date=" + start_date + "&end_date=" + end_date + "&res_id=" + res_id;
  22. get_data_for_url(url);
  23. }
  24. function selectDate(date) {
  25. var res_id = getPar('res_id');
  26. var start_date = $('#id-date-picker-1').val();
  27. var end_date = start_date;
  28. var search_res = $('#search_res_name').val();
  29. var url =base_url+"/st-xm/Api/car_team_controll.php?method=getDriverRunByCompany&start_date=" + start_date + "&end_date=" + end_date + "&res_id=" + res_id+ "&search_res=" + search_res;
  30. get_data_for_url(url);
  31. }
  32. function get_data_for_url(url) {
  33. //根据
  34. console.log(url);
  35. $.getJSON(url, function(res_data) {
  36. console.log(res_data);
  37. $('#warn_info').html('');
  38. if(res_data['code'] != "0") {
  39. // alert(res_data['info']);
  40. // 用其它方式来提醒
  41. $('#warn_info').html(res_data['info']);
  42. }
  43. var driver_run = res_data['driver_run'];
  44. if(!driver_run) {
  45. return;
  46. }
  47. var titleHTML = '';
  48. for(var i = 0, m = driver_run.length; i < m; i++) {
  49. var dict = driver_run[i];
  50. titleHTML += '<li class="li_title" onclick="show_detail(' + i + ')">'
  51. titleHTML += '<span>' + dict['run_date'] + ' 【' + dict['run_time'] + '】</span>';
  52. titleHTML += '<span>' + dict['prod_name'] + '</span>';
  53. titleHTML += '<span>' + dict['driver_name'] + '</span>';
  54. titleHTML += '<span>' + dict['driver_mobile'] + '</span>';
  55. if(dict['customer'].length > 0) {
  56. titleHTML += '<span id="count" style="color:blue;">【' + dict['ticket_count'] + '人】</span>';
  57. } else {
  58. titleHTML += '<span style="color:red;">无乘客</span>';
  59. }
  60. titleHTML += '</li>';
  61. titleHTML += '<li class="li_content" style="display: none;" id="content_' + i + '">';
  62. titleHTML += '<span style="color:red;width:60px;">编号</span><span style="width:200px;color:red">姓名</span><span style="color:red">手机号</span><span style="display:none;color:red">订单号</span><span style="color:red">上车站</span><span style="display:none;color:red">下车站</span><span style="width:60px;color:red">人数</span></br>';
  63. for(var j = 0, n = dict['customer'].length; j < n; j++) {
  64. var twoDict = dict['customer'][j];
  65. titleHTML += '<span style="width:60px">' + parseInt(j + 1) + '</span>';
  66. titleHTML += '<span style="width:200px">' + twoDict['customer_name'] + '</span>';
  67. titleHTML += '<a href="tel:'+twoDict['customer_mobile']+'"><span>' + twoDict['customer_mobile'] + '</span></a>';
  68. // titleHTML += '<span>' + twoDict['parent_order_id'] + '</span>';
  69. titleHTML += '<span>' + twoDict['start_station_res_name'] + '</span>';
  70. // titleHTML += '<span>' + twoDict['end_station_res_name'] + '</span>';
  71. titleHTML += '<span style="width:60px">' + twoDict['ticket_count'] + '</span>';
  72. titleHTML += '<hr style="margin-top:0px;margin-bottom:0px;border:0;border-top:1px solid #eee;">'
  73. titleHTML += '</br>';
  74. }
  75. titleHTML += '</li>';
  76. }
  77. if(titleHTML) {
  78. $('#all_ul').html(titleHTML);
  79. } else {
  80. $('#all_ul').html('');
  81. }
  82. });
  83. }
  84. function getPar(par) {
  85. //获取当前URL
  86. var local_url = document.location.href;
  87. local_url = decodeURI(local_url);
  88. //获取要取得的get参数位置
  89. var get = local_url.indexOf(par + "=");
  90. if(get == -1) {
  91. return "";
  92. }
  93. //截取字符串
  94. var get_par = local_url.slice(par.length + get + 1);
  95. //判断截取后的字符串是否还有其他get参数
  96. var nextPar = get_par.indexOf("&");
  97. if(nextPar != -1) {
  98. get_par = get_par.slice(0, nextPar);
  99. }
  100. return get_par;
  101. }
  102. /*
  103. function get_before_day() {
  104. var dateStr=$('#id-date-picker-1').val();
  105. var t_temp_sdate = dateStr.split('-');
  106. var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
  107. now.setDate(now.getDate() - 0 - 1);
  108. var year = ";" + now.getFullYear() + ";";
  109. var month = ";" + now.getMonth() + ";";
  110. var day = ";" + now.getDate() + ";";
  111. if(year.length < 4) {
  112. year = "0" + year;
  113. }
  114. if(month.length < 4) {
  115. month = "0" + month;
  116. }
  117. if(day.length < 4) {
  118. day = "0" + day;
  119. }
  120. var datestr = year + "-" + month + "-" + day;
  121. datestr = datestr.replace(/;/g, "");
  122. $('#id-date-picker-1').val(datestr);
  123. selectDate(dateStr);
  124. }
  125. // 得到明天的
  126. function get_after_day() {
  127. var dateStr=$('#id-date-picker-1').val();
  128. var t_temp_sdate = dateStr.split('-');
  129. var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
  130. now.setDate(now.getDate() - 0 + 1);
  131. var year = ";" + now.getFullYear() + ";";
  132. var month = ";" + now.getMonth() + ";";
  133. var day = ";" + now.getDate() + ";";
  134. if(year.length < 4) {
  135. year = "0" + year;
  136. }
  137. if(month.length < 4) {
  138. month = "0" + month;
  139. }
  140. if(day.length < 4) {
  141. day = "0" + day;
  142. }
  143. var datestr = year + "-" + month + "-" + day;
  144. datestr = datestr.replace(/;/g, "");
  145. $('#id-date-picker-1').val(datestr);
  146. selectDate(dateStr);
  147. }
  148. */
  149. function get_current_day() {
  150. var dateStr=$('#id-date-picker-1').val();
  151. selectDate(dateStr);
  152. }
  153. function get_before_day() {
  154. var dateStr=$('#id-date-picker-1').val()
  155. d = new Date(dateStr);
  156. d = +d - 10006060 / 3 * 24;
  157. d = new Date(d);
  158. //return d;
  159. //格式化
  160. var year = ";" + d.getFullYear() + ";";
  161. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  162. var day = ";" + d.getDate() + ";";
  163. if(year.length < 4) {
  164. year = "0" + year;
  165. }
  166. if(month.length < 4) {
  167. month = "0" + month;
  168. }
  169. if(day.length < 4) {
  170. day = "0" + day;
  171. }
  172. var datestr = year + "-" + month + "-" + day;
  173. datestr = datestr.replace(/;/g, "");
  174. $('#id-date-picker-1').val(datestr);
  175. selectDate(dateStr);
  176. }
  177. function get_after_day(){
  178. var dateStr=$('#id-date-picker-1').val()
  179. d = new Date(dateStr);
  180. d = +d + 10006060 / 3 * 24;
  181. d = new Date(d);
  182. //return d;
  183. //格式化
  184. var year = ";" + d.getFullYear() + ";";
  185. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  186. var day = ";" + d.getDate() + ";";
  187. if(year.length < 4) {
  188. year = "0" + year;
  189. }
  190. if(month.length < 4) {
  191. month = "0" + month;
  192. }
  193. if(day.length < 4) {
  194. day = "0" + day;
  195. }
  196. var datestr = year + "-" + month + "-" + day;
  197. datestr = datestr.replace(/;/g, "");
  198. $('#id-date-picker-1').val(datestr);
  199. selectDate(dateStr);
  200. }
  201. function getDateTime(nTypeFlag) {
  202. var tNowTime = new Date();
  203. var myYear = ';' + tNowTime.getFullYear() + ';';
  204. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  205. var myDay = ';' + tNowTime.getDate() + ';';
  206. var myHour = ';' + tNowTime.getHours() + ';';
  207. var myMinu = ';' + tNowTime.getMinutes() + ';';
  208. var mySecond = ';' + tNowTime.getSeconds() + ';';
  209. if(myMonth.length < 4) myMonth = '0' + myMonth;
  210. if(myDay.length < 4) myDay = '0' + myDay;
  211. if(myHour.length < 4) myHour = '0' + myHour;
  212. if(myMinu.length < 4) myMinu = '0' + myMinu;
  213. if(mySecond.length < 4) mySecond = '0' + mySecond;
  214. var cNewTimeStr;
  215. //alert(tNowTime);
  216. switch(nTypeFlag + 1 - 1) {
  217. case 0:
  218. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  219. break;
  220. case 1:
  221. cNewTimeStr = myYear + myMonth + myDay;
  222. break;
  223. case 2:
  224. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  225. break;
  226. case 3:
  227. cNewTimeStr = myHour + myMinu + mySecond;
  228. break;
  229. case 4:
  230. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  231. break;
  232. case 5:
  233. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  234. break;
  235. case 6:
  236. cNewTimeStr = myYear;
  237. break;
  238. case 7:
  239. cNewTimeStr = myYear + '-' + myMonth;
  240. break;
  241. case 8: //得到上一个月的今天
  242. var date = getDateTime(0);
  243. var arr = date.split('-');
  244. var year = arr[0]; //获取当前日期的年份
  245. var month = arr[1]; //获取当前日期的月份
  246. var day = arr[2]; //获取当前日期的日
  247. var days = new Date(year, month, 0);
  248. days = days.getDate(); //获取当前日期中月的天数
  249. var year2 = year;
  250. var month2 = parseInt(month) - 1;
  251. if(month2 == 0) {
  252. year2 = parseInt(year2) - 1;
  253. month2 = 12;
  254. }
  255. var day2 = day;
  256. var days2 = new Date(year2, month2, 0);
  257. days2 = days2.getDate();
  258. if(day2 > days2) {
  259. day2 = days2;
  260. }
  261. if(month2 < 10) {
  262. month2 = '0' + month2;
  263. }
  264. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  265. break;
  266. case 9: //得到下一个月的今天
  267. var date = getDateTime(0);
  268. var arr = date.split('-');
  269. var year = arr[0]; //获取当前日期的年份
  270. var month = arr[1]; //获取当前日期的月份
  271. var day = arr[2]; //获取当前日期的日
  272. var days = new Date(year, month, 0);
  273. days = days.getDate(); //获取当前日期中的月的天数
  274. var year2 = year;
  275. var month2 = parseInt(month) + 1;
  276. if(month2 == 13) {
  277. year2 = parseInt(year2) + 1;
  278. month2 = 1;
  279. }
  280. var day2 = day;
  281. var days2 = new Date(year2, month2, 0);
  282. days2 = days2.getDate();
  283. if(day2 > days2) {
  284. day2 = days2;
  285. }
  286. if(month2 < 10) {
  287. month2 = '0' + month2;
  288. }
  289. var t2 = year2 + '-' + month2 + '-' + day2;
  290. return t2;
  291. break;
  292. case 10: //昨日日期
  293. var dateStr = getDateTime(0);
  294. var t_temp_sdate = dateStr.split('-');
  295. var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
  296. now.setDate(now.getDate() - 0 - 1);
  297. var year = ";" + now.getFullYear() + ";";
  298. var month = ";" + now.getMonth() + ";";
  299. var day = ";" + now.getDate() + ";";
  300. if(year.length < 4) {
  301. year = "0" + year;
  302. }
  303. if(month.length < 4) {
  304. month = "0" + month;
  305. }
  306. if(day.length < 4) {
  307. day = "0" + day;
  308. }
  309. var datestr = year + "-" + month + "-" + day;
  310. datestr = datestr.replace(/;/g, "");
  311. return datestr;
  312. break;
  313. case 11: //明日日期
  314. var dateStr = getDateTime(0);
  315. var t_temp_sdate = dateStr.split('-');
  316. var now = new Date(t_temp_sdate[0], t_temp_sdate[1], t_temp_sdate[2]);
  317. now.setDate(now.getDate() - 0 + 1);
  318. var year = ";" + now.getFullYear() + ";";
  319. var month = ";" + now.getMonth() + ";";
  320. var day = ";" + now.getDate() + ";";
  321. if(year.length < 4) {
  322. year = "0" + year;
  323. }
  324. if(month.length < 4) {
  325. month = "0" + month;
  326. }
  327. if(day.length < 4) {
  328. day = "0" + day;
  329. }
  330. var datestr = year + "-" + month + "-" + day;
  331. datestr = datestr.replace(/;/g, "");
  332. return datestr;
  333. break;
  334. default:
  335. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  336. break;
  337. }
  338. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  339. return cNewTimeStr;
  340. }