您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

1461 行
54 KiB

  1. var mygrid = '';
  2. var mycargrid = '';
  3. var mydrivergrid = '';
  4. var alllineposition = null;
  5. var myalineposition = null;
  6. var mycarposition = null;
  7. var mydriverposition = null;
  8. var sort_id = 0;
  9. var type_id = 0;
  10. var page_size = 10;
  11. var cur_sel_bus_group='0';
  12. function ZZLog(str){
  13. var isLog=true;
  14. if(isLog){
  15. console.log(str);
  16. }
  17. }
  18. $(document).ready(function() {
  19. $('#id-date-picker-1').val(getDateTime(0)); // 默认当前日期
  20. $('#id-date-picker-2').val(getDateTime(11)); // 默认明日日期
  21. //$.getJSON("http://192.168.6.132/st-xm/Api/busInfoControll.php?method=getBusList&user_id=1&currpage=2&page_size=20&start_area=上海&end_area=北京&line=sb001&strat_date=2016-05-05&end_date=2016-09-09",function(data){ZZLog(data)})
  22. mygrid = $(".line-info").html(),
  23. mycargrid = $(".acar").outerHTML(),
  24. mydrivergrid = $(".adriver").outerHTML(),
  25. alllineposition = null,
  26. myalineposition = null,
  27. mycarposition = null,
  28. mydriverposition = null;
  29. $(".line-info").remove();
  30. $(".acar").remove();
  31. $(".adriver").remove();
  32. var currpage = getPar('currpage');
  33. var start_date = getPar('start_date');
  34. var end_date = getPar('end_date');
  35. var bus_type = getPar('bus_type');
  36. var bus_group = getPar('bus_group');//线路组合
  37. if(!currpage && !start_date) {
  38. click_search();
  39. }else {
  40. if(currpage==""){
  41. currpage=1;
  42. }
  43. var start_area = getPar('start_area');
  44. var end_area = getPar('end_area');
  45. var line = getPar('line');
  46. var sort = getPar('sort_id');
  47. var type = getPar('type_id');
  48. if(type) {
  49. type_id = type;
  50. }
  51. if(sort) {
  52. sort_id =sort;
  53. }
  54. if(start_area) {
  55. $('#start_area').val(start_area);
  56. }
  57. if(end_area) {
  58. $('#end_area').val(end_area);
  59. }
  60. if(line) {
  61. $('#prod').val(line);
  62. }
  63. if(start_date) {
  64. $('#id-date-picker-1').val(start_date);
  65. }
  66. if(end_date) {
  67. $('#id-date-picker-2').val(end_date);
  68. }
  69. if(bus_type) {
  70. $('#bus_type').val(bus_type);
  71. }
  72. if(bus_group){
  73. $('#bus_group').val(bus_group);
  74. cur_sel_bus_group=bus_group;
  75. }
  76. var url = "./st-xm/Api/busInfoControll.php?method=getBusList&type_id=" + type_id +"&sort_id=" + sort_id + "&currpage=" + currpage + "&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date+ "&bus_type=" + bus_type+"&bus_group="+bus_group;
  77. var page_url = "./branchmoney.html?method=getBusList&user_id=1&type_id=" + type_id +"&sort_id=" + sort_id + "&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date + "&bus_type=" + bus_type+"&bus_group="+bus_group;
  78. get_url_data(url, page_url);
  79. }
  80. })
  81. // 日期符法判断
  82. $(document).ready(function() {
  83. $('#id-date-picker-2').change(function() {
  84. //开始日期
  85. var start_date = $('#id-date-picker-1').val();
  86. if(start_date.trim().length <= 0) {
  87. alert('请选择开始日期!!!');
  88. return;
  89. }
  90. //结束日期
  91. var end_date = $('#id-date-picker-2').val();
  92. if(end_date.trim().length < 0) {
  93. alert('请选择结束日期');
  94. return;
  95. }
  96. // 判断日期是否合理
  97. var date1 = new Date(start_date.replace(/\-/g, '/'));
  98. var date2 = new Date(end_date.replace(/\-/g, '/'));
  99. if(date2 < date1) {
  100. $(this).val(start_date);
  101. // $('#id-date-picker-2').val(start_date);
  102. // alert('结束日期必须大于开始日期!!!');
  103. // $('#id-date-picker-2').val('');
  104. // return;
  105. }
  106. });
  107. $('#id-date-picker-1').change(function() {
  108. //开始日期
  109. var start_date = $('#id-date-picker-1').val();
  110. if(start_date.trim().length <= 0) {
  111. alert('请选择开始日期!!!');
  112. return;
  113. }
  114. //结束日期
  115. var end_date = $('#id-date-picker-2').val();
  116. if(end_date.trim().length < 0) {
  117. alert('请选择结束日期');
  118. return;
  119. }
  120. // 判断日期是否合理
  121. var date1 = new Date(start_date.replace(/\-/g, '/'));
  122. var date2 = new Date(end_date.replace(/\-/g, '/'));
  123. if(date2 < date1) {
  124. $('#id-date-picker-2').val(start_date);
  125. // alert('结束日期必须大于开始日期!!!');
  126. // $('#id-date-picker-1').val('');
  127. // return;
  128. }
  129. });
  130. });
  131. //点击查询
  132. $(document).ready(function() {
  133. $(".searchbtn").on("click", function() {
  134. type_id = 0;
  135. sort_id = 0;
  136. click_search();
  137. });
  138. });
  139. // 复选框事件
  140. function select_checked(index) {
  141. //index=0最上面的全选 index=1表示的是下面所有的
  142. var cur_check = $('.ace')[0];
  143. var checkList = $('.ace');
  144. var checkCount = checkList.length - 1;
  145. var true_count = 0;
  146. for(var i = 1; i < checkList.length; i++) {
  147. if(index == '0') {
  148. checkList[i].checked = cur_check.checked;
  149. } else {
  150. if(checkList[i].checked == false) {
  151. cur_check.checked = false
  152. } else {
  153. true_count = true_count + 1;
  154. }
  155. }
  156. }
  157. //判断下面是否选中完
  158. if(checkCount == true_count) {
  159. cur_check.checked = true;
  160. }
  161. }
  162. function click_search() {
  163. //开始日期
  164. var start_date = $('#id-date-picker-1').val();
  165. cur_sel_bus_group=$('#bus_group').val();
  166. if(start_date.trim().length <= 0) {
  167. alert('请选择开始日期!!!');
  168. return;
  169. }
  170. //结束日期
  171. var end_date = $('#id-date-picker-2').val();
  172. if(end_date.trim().length < 0) {
  173. alert('请选择结束日期');
  174. return;
  175. }
  176. // 判断日期是否合理
  177. var date1 = new Date(start_date.replace(/\-/g, '/'));
  178. var date2 = new Date(end_date.replace(/\-/g, '/'));
  179. if(date2 < date1) {
  180. alert('结束日期必须大于开始日期!!!');
  181. return;
  182. }
  183. var line = $('#prod').val();
  184. var start_area = $('#start_area').val();
  185. var end_area = $('#end_area').val();
  186. var bus_type = $('#bus_type').val();
  187. var bus_group = $('#bus_group').val();
  188. // type_id 就是全部,未派,已派的id 须加一个参数
  189. //..
  190. var url = "./st-xm/Api/busInfoControll.php?method=getBusList&type_id=" + type_id +"&sort_id=" + sort_id+ "&currpage=1&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date + "&bus_type=" + bus_type+"&bus_group="+bus_group;
  191. var page_url = "./branchmoney.html?method=getBusList&user_id=1&type_id=" + type_id+"&sort_id=" + sort_id + "&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date + "&bus_type=" + bus_type+"&bus_group="+bus_group;
  192. get_url_data(url, page_url);
  193. }
  194. function get_url_data(url, page_url) {
  195. ZZLog('调度url=' + url);
  196. $.getJSON(url, function(data) {
  197. ZZLog(data);
  198. if(data.code == 0 || data.code == "0") {
  199. var busgrouphtml='<option value="0" selected="selected">全部</option>';
  200. $.each(data['bus_group_list'],function(i,v){
  201. var tempHTML='<option value="0">全部</option>';
  202. tempHTML=tempHTML.replace('value="0"','value='+v['group_id']);
  203. tempHTML=tempHTML.replace('全部',v['group_name']);
  204. busgrouphtml+=tempHTML;
  205. });
  206. $('#bus_group').html(busgrouphtml);
  207. $('#bus_group').val(cur_sel_bus_group);
  208. var alllisthtml = [];
  209. var tnowtime = Math.round(1000000);
  210. $.each(data.run_no_list, function(i, v) {
  211. //ZZLog(v)
  212. var aline = mygrid.replace(/lineid|line|godate|gotime|carnum|cartime|seat|bus_type|sold|cartype|drivername|costtotale|sendbutton/g, function(match) {
  213. switch(match) {
  214. case "lineid":
  215. return v.id;
  216. case "line":
  217. return v.property + v.prod_name;
  218. case "godate":
  219. return v.run_date;
  220. case "gotime":
  221. return v.run_time;
  222. case "carnum":
  223. var carnum=(Array(2).join(0)+v.bus_order_id).slice(-2);
  224. return carnum;
  225. case "seat":
  226. return v.res_name;
  227. case "bus_type":
  228. return v.bus_type;
  229. case "sold":
  230. var order_url = "order_list.html?tt=" + tnowtime +
  231. "&timelimit=" + '出发时间' +
  232. "&starttime=" + v.run_date +
  233. "&endtime=" + v.run_date +
  234. "&ordersource=" + '' +
  235. "&bus_type=" + '' +
  236. "&orderstatus=" + '' +
  237. "&paystatus=" + '' +
  238. "&billingstatus=" + '' +
  239. "&mealbounce=" + '' +
  240. "&refund=" + '' +
  241. "&moresearch=" + '' +
  242. "&start_area=" + '' +
  243. "&end_area=" + '' +
  244. "&line=" + encodeURIComponent(v.prod_name)
  245. +"&currpage="+'1'
  246. +
  247. "&pagesize=" + '10' +
  248. "&search_bus_no=" + v.bus_order_id +
  249. "&run_time=" + v.run_time;
  250. var tmp_url = '<a target="_blank" onclick="open_new_path(this)" go_path="'+order_url+'">'+v.saled_count+'</a>';
  251. //add by qius on 20170925
  252. tmp_url += '<br /><a style="margin-top: 10px;color:#777777;" onclick="disp_run_bus_passenger( '+ v.run_id + ', '+ v.bus_order_id + ' )" >上下车人数</a>';
  253. return tmp_url;
  254. case "cartype":
  255. return '<div class="acar"><p class="car-show" dataid="' + v.send_bus_res_id + '">' + v.send_bus_res_name + '</p><span clsss="hide">carname</span><span clsss="hide">carseat</span></div>';
  256. case "drivername":
  257. return '<div class="adriver"><p class="adriver-show" dataid="' + v.send_bus_driver_res_id + '">' + v.send_bus_driver_res_name + '</p><span clsss="hide">H9527</span><span clsss="hide">12345679812</span></div>';
  258. case "costtotale":
  259. var ht_str=v.cost_total_price+"</br><button id='edit_"+v.run_id+"' data-total-price="+v.cost_total_price+" data-area="+v.prod_name+" onclick='click_edite("+v.run_id+","+v.bus_order_id+","+v.bus_type+")'>编辑</button>";
  260. return ht_str;
  261. case "sendbutton":
  262. if( v.send_bus_res_id > 0 && v.send_bus_driver_res_id > 0 ) {
  263. return "<a target='_blank' href='http://api.zhizhuchuxing.com/api1.0/send_message_confirm.php?run_id=" + v.run_id+ "&bus_order_id=" + v.bus_order_id + "'>发送</a>";
  264. } else {
  265. return '';
  266. }
  267. };
  268. });
  269. alllisthtml.push(addItem("tr", "alinedrag", aline));
  270. });
  271. $(".replace-lineinfo").html(alllisthtml);
  272. var carhtml = [];
  273. $.each(data.vehicle_list, function(i, v) {
  274. var acar = mycargrid.replace(/carid|carnum|carname|carseat/g, function(match) {
  275. switch(match) {
  276. case "carid":
  277. return v.res_id;
  278. case "carnum":
  279. return v.vihicle_number;
  280. case "carname":
  281. return v.vihicle_brand;
  282. case "carseat":
  283. return v.vihicle_seat;
  284. };
  285. })
  286. carhtml.push(acar);
  287. })
  288. $(".carinfodata").html(carhtml);
  289. var driverhtml = [];
  290. $.each(data.driver_list, function(i, v) {
  291. var driver = mydrivergrid.replace(/driverid|drivername|drivernum|driverphone/g, function(match) {
  292. switch(match) {
  293. case "driverid":
  294. return v.res_id;
  295. case "drivername":
  296. return v.driver_name;
  297. case "drivernum":
  298. return v.driver_number;
  299. case "driverphone":
  300. return v.driver_phone;
  301. };
  302. })
  303. driverhtml.push(driver);
  304. })
  305. $(".driverinfodata").html(driverhtml);
  306. adddriverinEvent();
  307. // adddriveroutEvent();
  308. addcarinEvent();
  309. // addcaroutEvent();
  310. $('#zpage').html('');
  311. getPager(page_url, data.total, data.currpage, page_size, "zpage", "currpage");
  312. }
  313. });
  314. }
  315. var temp_run_id=0;
  316. var temp_bus_order_id=0;
  317. var temp_start_end_area_length=0;
  318. var temp_method_type=0; //结算方式
  319. var temp_remark=''; // 备注
  320. function click_edite(run_id,bus_order_id,bus_type){
  321. temp_run_id=run_id;
  322. temp_bus_order_id=bus_order_id;
  323. temp_method_type=0;
  324. // $('input[type="radio"][name="type"][value="130"]').attr("checked","checked");
  325. var url="./st-xm/Api/busInfoControll.php?method=selectPOI&run_id="+run_id+"&bus_order_id="+bus_order_id;
  326. ZZLog(url);
  327. $.getJSON(url,function(res_data){
  328. ZZLog(res_data);
  329. center_show($('.update_cost_price'));
  330. if(res_data['code']!="0"){
  331. alert(res_data['info']);return;
  332. }
  333. var start_end_areaList=res_data['start_end_areaList'];
  334. var real_start_end=res_data['real_start_end_area'];
  335. temp_start_end_area_length=start_end_areaList.length;
  336. var is_real_area=false;
  337. if(start_end_areaList.length>0){
  338. var HTML='';
  339. for (var i=0,m=start_end_areaList.length;i<m;i++) {
  340. var dict=start_end_areaList[i];
  341. if(real_start_end[0]['s_id']==dict['start_area_id'] && real_start_end[0]['e_id']==dict['end_area_id']){
  342. is_real_area=true; //是真实的出发-目的
  343. }else{
  344. is_real_area=false;
  345. }
  346. var area_HTML='';
  347. temp_method_type=dict['method_type'];
  348. if( (is_real_area == false && bus_type ==256) || (is_real_area == true && bus_type ==255) ) {
  349. area_HTML='<span style="margin-left: 20px;display:none;"><input onchange="change_radio_area('+run_id+','+bus_order_id+')" type="radio" checked="checked" name="area" data-SID="[SID]" data-EID="[EID]" value="[value]" />[上海-乌镇]</span>';
  350. } else {
  351. var check_txt = '';
  352. if( (is_real_area == false && bus_type ==255 && i==1)||(is_real_area == true && bus_type ==256 )) { check_txt = 'checked="checked"'; }
  353. area_HTML='<span style="margin-left: 20px;"><input onchange="change_radio_area('+run_id+','+bus_order_id+')" type="radio" '+check_txt+'name="area" data-SID="[SID]" data-EID="[EID]" value="[value]" />[上海-乌镇]</span>';
  354. }
  355. var tempHTML=area_HTML;
  356. var s_e_id=dict['start_area_id']+","+dict['end_area_id'];
  357. var s_e_area=dict['start_area']+"-"+dict['end_area'];
  358. tempHTML=tempHTML.replace('[value]',s_e_id);
  359. tempHTML=tempHTML.replace('[SID]',dict['start_area_id']);
  360. tempHTML=tempHTML.replace('[EID]',dict['end_area_id']);
  361. tempHTML=tempHTML.replace('[上海-乌镇]',s_e_area);
  362. HTML+=tempHTML
  363. }
  364. $('#start_end_area').html(HTML);
  365. // if(start_end_areaList.length==1){
  366. // $('#start_end_area').css('display','none');
  367. // }else{
  368. // $('#start_end_area').css('display','block');
  369. // }
  370. var HTML2='';
  371. var total_cost_price=0;
  372. var t_prod_name=$('#edit_'+run_id).attr('data-area');
  373. var t_total_price=$('#edit_'+run_id).attr('data-total-price'); // 成本总价
  374. var t_seat_total_price=0; //车座结算的总价只用显示
  375. $('#seat_line').text(t_prod_name);
  376. for (var i=start_end_areaList.length-1;i>=0;i--) {
  377. var dict=start_end_areaList[i];
  378. total_cost_price+=parseInt(dict['cost_price']);
  379. var area_HTML='';
  380. area_HTML='<div style="margin-bottom: 5px;margin-top: 5px;margin-right:5px;">';
  381. area_HTML+='<span style="display:inline-block;width:150px;">[start_end_area]</span>';
  382. area_HTML+='<input oninput="update_price(2)" value="[value]" class="start_area_2" type="text" name="" id="" data-real-sale="[real_sale]" data-area-id="[start_end_area_id]" />';
  383. area_HTML+='</div>';
  384. var tempHTML=area_HTML;
  385. t_seat_total_price+=parseInt(dict['every_total_price'])*parseInt(dict['real_sale']);
  386. tempHTML=tempHTML.replace('[value]',dict['real_sale']==0?0:dict['every_total_price']);
  387. tempHTML=tempHTML.replace('[real_sale]',dict['real_sale']);
  388. tempHTML=tempHTML.replace('[start_end_area]',dict['start_area']+'-'+dict['end_area']+" <b style='color:red;'>x"+dict['real_sale']+"</b>");
  389. tempHTML=tempHTML.replace('[start_end_area_id]',dict['start_area_id']+'-'+dict['end_area_id']);
  390. HTML2+=tempHTML
  391. }
  392. HTML2+='<span style="display: inline-block;float: right;margin-right: 70px;">成本总价:<b id="car_seat_total_price" style="color: red;">'+t_seat_total_price+'</b>元</span>';
  393. $('#car_seat_every_price').html(HTML2);
  394. }else{
  395. $('#start_end_area').html('');
  396. $('#car_seat_every_price').html('');
  397. }
  398. change_radio_area(run_id,bus_order_id,temp_method_type);
  399. });
  400. }
  401. // 改变结算方式
  402. var temp_cur_type=130;
  403. function change_type(type_value){
  404. temp_cur_type=type_value;
  405. $('#cost_remark').val('');
  406. if(type_value==129){
  407. show_change_by_type(2);
  408. if(temp_method_type==129){
  409. $('#cost_remark').val(temp_remark);
  410. }
  411. }else{
  412. show_change_by_type(1);
  413. if(temp_method_type==130){
  414. $('#cost_remark').val(temp_remark);
  415. }
  416. }
  417. }
  418. function show_change_by_type(type){
  419. if(type==1){
  420. $('#start_end_area').css('display','block');
  421. $('#col_1').css('display','block');
  422. $('#car_seat_line').css('display','none');
  423. $('#car_seat_price').css('display','none');
  424. }else{
  425. $('#car_seat_line').css('display','block');
  426. $('#car_seat_price').css('display','block');
  427. $('#start_end_area').css('display','none');
  428. $('#col_1').css('display','none');
  429. }
  430. }
  431. // 改变出发地目的地
  432. function change_radio_area(run_id,bus_order_id,method_id){
  433. //1,{233198,1,6,9172},{200,200,20,20,20,20,10,10,129},这是备注信息333
  434. // run_id=233198;
  435. // bus_order_id=2;
  436. var s_id=$('input[type="radio"][name="area"]:checked').attr('data-SID');
  437. var e_id=$('input[type="radio"][name="area"]:checked').attr('data-EID');
  438. // s_id=6;
  439. // e_id=9172;
  440. var url="./st-xm/Api/busInfoControll.php?method=selectCost&run_id="+run_id+"&bus_order_id="+bus_order_id+"&start_area_id="+s_id+"&end_area_id="+e_id;
  441. ZZLog(url);
  442. $.getJSON(url,function(res_data){
  443. ZZLog(res_data);
  444. if(res_data['code']!="0"){
  445. alert(res_data['info']);return;
  446. }
  447. var costList=res_data['costList'];
  448. $('#cost_price').val('0');
  449. $('#car_price').val('0');
  450. $('#driver_subsidies').val('0');
  451. $('#oil_price').val('0');
  452. $('#food_price').val('0');
  453. $('#road_bridge_price').val('0');
  454. $('#sleep_price').val('0');
  455. $('#cost_remark').val('');
  456. if(costList.length>0){
  457. var dict=costList[0];
  458. $('input[type="radio"][name="type"][value="'+dict['pay_method_id']+'"]').attr("checked",'checked');
  459. var temp_s_e_id=dict['start_area_id']+","+dict['end_area_id'];
  460. $('input[type="radio"][name="area"][value="'+dict['temp_s_e_id']+'"]').attr("checked",'checked');
  461. $('#cost_price').val(dict['cost_price']);
  462. $('#car_price').val(dict['car_price']);
  463. $('#driver_subsidies').val(dict['driver_subsidies']);
  464. $('#oil_price').val(dict['oil_price']);
  465. $('#food_price').val(dict['food_price']);
  466. $('#road_bridge_price').val(dict['road_bridge_price']);
  467. $('#sleep_price').val(dict['sleep_price']);
  468. $('#cost_remark').val(parseInt(dict['pay_method_id'])==130?dict['cost_remark']:"");
  469. temp_remark=dict['cost_remark'];
  470. }
  471. })
  472. }
  473. function update_price(type){
  474. if(type==1){
  475. var car_price=$('#car_price').val();
  476. var driver_subsidies=$('#driver_subsidies').val();
  477. var oil_price=$('#oil_price').val();
  478. var food_price=$('#food_price').val();
  479. var road_bridge_price=$('#road_bridge_price').val();
  480. var sleep_price=$('#sleep_price').val();
  481. if(car_price==""){car_price=0;}
  482. if(driver_subsidies==""){driver_subsidies=0;}
  483. if(oil_price==""){oil_price=0;}
  484. if(food_price==""){food_price=0;}
  485. if(road_bridge_price==""){road_bridge_price=0;}
  486. if(sleep_price==""){sleep_price=0;}
  487. var sum_price=parseInt(car_price);
  488. sum_price+=parseInt(driver_subsidies);
  489. sum_price+=parseInt(oil_price);
  490. sum_price+=parseInt(food_price);
  491. sum_price+=parseInt(road_bridge_price);
  492. sum_price+=parseInt(sleep_price);
  493. $('#cost_price').val(sum_price);
  494. }else{
  495. var sum_price=0;
  496. $('.start_area_2').each(function(index,domEle){
  497. var t_price=$(domEle).val();
  498. var t_sale_count=$(domEle).attr('data-real-sale');
  499. if(isNaN(t_price) || t_price==""){
  500. t_price=0;
  501. }
  502. sum_price+=parseInt(t_price)*parseInt(t_sale_count);
  503. });
  504. $('#car_seat_total_price').text(sum_price);
  505. }
  506. }
  507. // 点击结算保存
  508. $(document).ready(function(){
  509. $('#btn_update_cost_price').on('click',function(e){
  510. if($(this).text()=="保存中..."){
  511. return;
  512. }
  513. $(this).text("保存中");
  514. var cost_price=$('#cost_price').val()!=""?$('#cost_price').val():0;
  515. var car_price=$('#car_price').val()!=""?$('#car_price').val():0;
  516. var driver_subsidies=$('#driver_subsidies').val()!=""?$('#driver_subsidies').val():0;
  517. var oil_price=$('#oil_price').val()!=""?$('#oil_price').val():0;
  518. var food_price=$('#food_price').val()!=""?$('#food_price').val():0;
  519. var road_bridge_price=$('#road_bridge_price').val()!=""?$('#road_bridge_price').val():0;
  520. var sleep_price=$('#sleep_price').val()!=""?$('#sleep_price').val():0;
  521. var cost_remark=$('#cost_remark').val()!=""?$('#cost_remark').val():"";
  522. var s_id=$('input[name="area"]:checked').attr('data-SID');
  523. var e_id=$('input[name="area"]:checked').attr('data-EID');
  524. // temp_run_id=233198;
  525. // temp_bus_order_id=2;
  526. // s_id=6;
  527. // e_id=9172;
  528. var type=$('input[name="type"]:checked').val();
  529. // 拼接参数
  530. var str_main="{"+temp_run_id+","+temp_bus_order_id+","+s_id+","+e_id+"}";
  531. var str_info1="{"+cost_price+","+car_price+","+driver_subsidies+","+oil_price+","+food_price+","+road_bridge_price+","+sleep_price+"}";
  532. var str_info2="";
  533. $('.start_area_2').each(function(index,domEle){
  534. var t_every_price=$(domEle).val();
  535. var t_area_id=$(domEle).attr('data-area-id').replace('-',',');
  536. var t_real_sale=$(domEle).attr('data-real-sale');
  537. str_info2+="{"+temp_run_id+","+temp_bus_order_id+","+t_area_id+","+t_real_sale+","+t_every_price+"}";
  538. });
  539. var str_remark="{"+cost_remark+"}";
  540. ZZLog(str_main+","+str_info1+","+str_info2+","+str_remark);
  541. var str_method='';
  542. if(temp_cur_type==130){
  543. str_method='update_car';
  544. }
  545. if(temp_cur_type==129){
  546. str_method='update_seat';
  547. }
  548. var url="./st-xm/Api/busInfoControll.php?method=updateCost&str_method="+str_method+""+"&str_main="+str_main+"&str_info1="+str_info1+"&str_info2="+str_info2+"&str_remark="+str_remark;
  549. ZZLog(url);
  550. $.getJSON(url,function(res_data){
  551. ZZLog(res_data);
  552. if(res_data['code']!="0"){
  553. alert(res_data['info']);return;
  554. }
  555. alert('保存成功');
  556. click_cancel(null,'.update_cost_price');
  557. refersh_cur_page();
  558. });
  559. });
  560. })
  561. //加载公司
  562. $(document).ready(function() {
  563. var url = "./st-xm/Api/busInfoControll.php?method=getCompanyList";
  564. var company_HTML = '<option value="0">全部</option>';
  565. $.getJSON(url, function(res_data) {
  566. var HTML = '<option value="0">全部</option>';
  567. var com_list = res_data['company_list'];
  568. for(var i = 0, m = com_list.length; i < m; i++) {
  569. var dict = com_list[i];
  570. var tempHTML = '<option value="0">全部</option>';
  571. tempHTML = tempHTML.replace('0', dict['res_id']);
  572. tempHTML = tempHTML.replace('全部', dict['res_name']);
  573. HTML += tempHTML;
  574. }
  575. $('#car_company').html(HTML);
  576. $('#driver_company').html(HTML);
  577. });
  578. });
  579. //type : 0 全部 1 未派 2 已派
  580. function getList(type) {
  581. // 保存类型
  582. type_id = type;
  583. click_search();
  584. //..
  585. }
  586. function sort(type) {
  587. sort_id = type;
  588. click_search();
  589. }
  590. function reset() {
  591. //先拿到run_id
  592. var arr_run_ids = new Array();
  593. var puts = $('.ace');
  594. for(var i = 0; i < puts.length; i++) {
  595. if(puts[i].checked && i != 0) {
  596. arr_run_ids.push($(puts[i]).val());
  597. }
  598. }
  599. if(arr_run_ids.length <= 0) {
  600. alert('请勾选!!!');
  601. return;
  602. }
  603. var run_id_str = arr_run_ids.join(',');
  604. var url = "./st-xm/Api/busInfoControll.php?method=reset&idstr=" + run_id_str;
  605. $.getJSON(url, function(res_data) {
  606. if(res_data['code'] != "0") {
  607. refersh_cur_page();
  608. alert(res_data['info']);
  609. return;
  610. }
  611. alert('操作成功!!!');
  612. $('.ace')[0].checked = false;
  613. // click_search();
  614. refersh_cur_page();
  615. //开始日期
  616. car_change('');
  617. driver_change('');
  618. });
  619. }
  620. function refersh_cur_page(){
  621. var start_date = $('#id-date-picker-1').val();
  622. if(start_date.trim().length <= 0) {
  623. alert('请选择开始日期!!!');
  624. return;
  625. }
  626. //结束日期
  627. var end_date = $('#id-date-picker-2').val();
  628. if(end_date.trim().length < 0) {
  629. alert('请选择结束日期');
  630. return;
  631. }
  632. // 判断日期是否合理
  633. var date1 = new Date(start_date.replace(/\-/g, '/'));
  634. var date2 = new Date(end_date.replace(/\-/g, '/'));
  635. if(date2 < date1) {
  636. alert('结束日期必须大于开始日期!!!');
  637. return;
  638. }
  639. var line = $('#prod').val();
  640. var start_area = $('#start_area').val();
  641. var end_area = $('#end_area').val();
  642. var bus_type = $('#bus_type').val();
  643. var page_url = "./branchmoney.html?method=getBusList&type_id=" + type_id+"&sort_id=" + sort_id + "&page_size=" + page_size + "&start_area=" + start_area + "&end_area=" + end_area + "&line=" + line + "&start_date=" + start_date + "&end_date=" + end_date+"&bus_type="+bus_type;
  644. var listURL=encodeURI(page_url);
  645. window.location.href=listURL;
  646. }
  647. //锁定
  648. function lock() {
  649. //先拿到run_id
  650. var arr_run_ids = new Array();
  651. var puts = $('.ace');
  652. for(var i = 0; i < puts.length; i++) {
  653. if(puts[i].checked && i != 0) {
  654. arr_run_ids.push($(puts[i]).val());
  655. }
  656. }
  657. if(arr_run_ids.length <= 0) {
  658. alert('请勾选!!!');
  659. return;
  660. }
  661. var run_id_str = arr_run_ids.join(',');
  662. var url = "./st-xm/Api/busInfoControll.php?method=lock&idstr=" + run_id_str;
  663. $.getJSON(url, function(res_data) {
  664. if(res_data['code'] != "0") {
  665. alert(res_data['info']);
  666. }
  667. alert('操作成功!!!');
  668. $('.ace')[0].checked = false;
  669. // click_search();
  670. // location.replace(location.href);
  671. refersh_cur_page();
  672. car_change('');
  673. driver_change('');
  674. });
  675. }
  676. //解锁
  677. function unlock() {
  678. //先拿到run_id
  679. var arr_run_ids = new Array();
  680. var puts = $('.ace');
  681. for(var i = 0; i < puts.length; i++) {
  682. if(puts[i].checked && i != 0) {
  683. arr_run_ids.push($(puts[i]).val());
  684. }
  685. }
  686. if(arr_run_ids.length <= 0) {
  687. alert('请勾选!!!');
  688. return;
  689. }
  690. var run_id_str = arr_run_ids.join(',');
  691. var url = "./st-xm/Api/busInfoControll.php?method=unlock&idstr=" + run_id_str;
  692. $.getJSON(url, function(res_data) {
  693. if(res_data['code'] != "0") {
  694. alert(res_data['info']);
  695. }
  696. alert('操作成功!!!');
  697. $('.ace')[0].checked = false;
  698. // click_search();
  699. // location.replace(location.href);
  700. refersh_cur_page();
  701. car_change('');
  702. driver_change('');
  703. });
  704. }
  705. //公司值发生改变
  706. var car_key_word = '';
  707. var car_company = '';
  708. function car_company_change(value) {
  709. car_company = value;
  710. car_load_html(car_key_word, car_company);
  711. }
  712. //车辆值改变
  713. function car_change(value) {
  714. car_key_word = value;
  715. car_load_html(car_key_word, car_company);
  716. }
  717. //..车辆加载
  718. function car_load_html(key_word, company) {
  719. var url = "./st-xm/Api/busInfoControll.php?method=getVehicleList&key_word=" + key_word + "&company=" + company;
  720. $.getJSON(url, function(res_data) {
  721. ZZLog('车辆' + url);
  722. ZZLog(res_data);
  723. var carhtml = [];
  724. $.each(res_data.vehicle_list, function(i, v) {
  725. var acar = mycargrid.replace(/carid|carnum|carname|carseat/g, function(match) {
  726. switch(match) {
  727. case "carid":
  728. return v.res_id;
  729. case "carnum":
  730. return v.vihicle_number;
  731. case "carname":
  732. return v.vihicle_brand;
  733. case "carseat":
  734. return v.vihicle_seat;
  735. };
  736. })
  737. carhtml.push(acar);
  738. })
  739. $(".carinfodata").html(carhtml);
  740. addcarinEvent();
  741. // addcaroutEvent();
  742. });
  743. }
  744. //点击了三个固定的
  745. function click_show_div(objName, self_obj) {
  746. var obj = $(objName);
  747. if (obj.css('display') == 'none') {
  748. center_show(obj);
  749. } else {
  750. obj.css('display', 'none');
  751. }
  752. }
  753. //点击了第二级
  754. function click_two_show_div(father_name, self_name) {
  755. var father = $(father_name);
  756. var self = $(self_name);
  757. father.css('display', 'none');
  758. center_show(self);
  759. }
  760. //点击了关闭
  761. function click_cancel(father_name, self_name) {
  762. if (father_name) {
  763. var father = $(father_name);
  764. center_show(father);
  765. } else {
  766. $('.mask').css('display', 'none');
  767. }
  768. $(self_name).css('display', 'none');
  769. }
  770. //居中显示
  771. var tempDiv = null;
  772. function center_show(show_div) {
  773. tempDiv = show_div;
  774. //显示蒙板
  775. show_div.css('display', 'block');
  776. show_div.css('z-index', 10);
  777. show_div.css('background-color', 'white');
  778. show_div.css('position', 'fixed');
  779. var w = show_div.css('width');
  780. var h = show_div.css('height');
  781. w = w.substr(0, w.length - 2);
  782. h = h.substr(0, h.length - 2);
  783. // var s_left=(window.screen.availWidth-w)/2 +"px";
  784. // var s_top=(window.screen.availHeight-h)/2 +'px';
  785. var s_left = (window.innerWidth - w) / 2 + 'px';
  786. var s_top = (window.innerHeight - h) / 2 + 'px';
  787. show_div.css('left', s_left);
  788. show_div.css('top', s_top);
  789. $('.mask').css('display', 'block');
  790. }
  791. //点击蒙板
  792. function hide_all() {
  793. $('.mask').css('display', 'none');
  794. tempDiv.css('display', 'none');
  795. }
  796. //司机公司改变
  797. var driver_key_word = '';
  798. var driver_company = '';
  799. function driver_company_change(value) {
  800. driver_company = value;
  801. driver_load_html(driver_key_word, driver_company);
  802. }
  803. //司机值改变
  804. function driver_change(value) {
  805. driver_key_word = value;
  806. driver_load_html(driver_key_word, driver_company);
  807. }
  808. //..司机加载
  809. function driver_load_html(key_word, company) {
  810. var url = "./st-xm/Api/busInfoControll.php?method=getDriverList&&key_word=" + key_word + "&company=" + company;
  811. $.getJSON(url, function(res_data) {
  812. ZZLog('司机' + url);
  813. ZZLog(res_data);
  814. var driverhtml = [];
  815. $.each(res_data.driver_list, function(i, v) {
  816. var driver = mydrivergrid.replace(/driverid|drivername|drivernum|driverphone/g, function(match) {
  817. switch(match) {
  818. case "driverid":
  819. return v.res_id;
  820. case "drivername":
  821. return v.driver_name;
  822. case "drivernum":
  823. return v.driver_number;
  824. case "driverphone":
  825. return v.driver_phone;
  826. };
  827. })
  828. driverhtml.push(driver);
  829. })
  830. $(".driverinfodata").html(driverhtml);
  831. adddriverinEvent();
  832. // adddriveroutEvent();
  833. });
  834. }
  835. function addcaroutEvent() {
  836. mycarposition = getrect($(".carinfodata").get(0));
  837. $(".all-lineinfo .acar").on("mousedown", function(e) {
  838. e.stopPropagation();
  839. var that = $(this);
  840. var thathtml = $(this).outerHTML();
  841. var myxy = addItemid("div", "acar", "onlyout", $(this).html());
  842. $(this).addClass("opcity");
  843. var thisxy = getPosition(this);
  844. $('body').append(myxy);
  845. var onlyout = document.getElementById("onlyout");
  846. onlyout.style.position = "absolute";
  847. onlyout.style.left = thisxy[0] + "px";
  848. onlyout.style.top = thisxy[1] + "px";
  849. xy = getPosition(onlyout);
  850. mouseX = e.pageX,
  851. mouseY = e.pageY,
  852. delaX = mouseX - xy[0],
  853. delaY = mouseY - xy[1];
  854. $(document).on('mousemove', function(e) {
  855. onlyout.style.left = (e.pageX - delaX) + 'px';
  856. onlyout.style.top = (e.pageY - delaY) + 'px';
  857. var x = e.pageX,
  858. y = e.pageY;
  859. if(exist(x, y, mycarposition)) {
  860. $(".carinfodata").addClass("curred");
  861. } else {
  862. $(".carinfodata").removeClass("curred");
  863. }
  864. })
  865. $(document).on("mouseup", function(e) {
  866. var x = e.pageX,
  867. y = e.pageY;
  868. if(exist(x, y, mycarposition)) {
  869. $.getJSON("st-xm/Api/busInfoControll.php?method=vehicleDispatch&bus_id=" + that.parent().parent().find("input").val() + "&res_id=" + that.children(".car-show").attr("dataid"), function(data) {
  870. if(data.code == 0) {
  871. ZZLog(data.info)
  872. $("#onlyout").remove();
  873. $(".opcity").remove();
  874. $(".carinfodata").removeClass("curred");
  875. $(document).unbind();
  876. } else {
  877. ZZLog(data.info);
  878. $(".alinedrag").removeClass("curred");
  879. $("#onlyout").remove();
  880. $(".opcity").removeClass("opcity")
  881. $(document).unbind();
  882. }
  883. })
  884. } else {
  885. $("#onlyout").remove();
  886. $(".opcity").removeClass("opcity")
  887. $(document).unbind();
  888. }
  889. })
  890. })
  891. }
  892. function addcarinEvent() {
  893. mycarposition = getrect($(".carinfodata").get(0));
  894. myalineposition = [];
  895. alllineposition = getrect($(".alldrag").get(0));
  896. for(var i = 0; i < $(".alinedrag").length; i++) {
  897. myalineposition.push(getrect($(".alinedrag").get(i)))
  898. };
  899. $(".carinfodata .acar").on("mousedown", function(e) {
  900. e.stopPropagation();
  901. var thathtml = $(this).outerHTML();
  902. var that = $(this);
  903. myxy = addItemid("div", "acar", "onlyin", $(this).html());
  904. $(this).addClass("opcity");
  905. var thisxy = getPosition1(this);
  906. // ZZLog(typeof that);
  907. $('body').append(myxy);
  908. var onlyin = document.getElementById("onlyin");
  909. onlyin.style.position = "absolute";
  910. onlyin.style.left = thisxy[0] + "px";
  911. onlyin.style.top = thisxy[1] + "px";
  912. xy = getPosition(onlyin),
  913. mouseX = e.pageX,
  914. mouseY = e.pageY,
  915. delaX = mouseX - xy[0],
  916. delaY = mouseY - xy[1];
  917. $(document).on('mousemove', function(e) {
  918. onlyin.style.left = (e.pageX - delaX) + 'px';
  919. onlyin.style.top = (e.pageY - delaY) + 'px';
  920. var x = e.pageX,
  921. y = e.pageY;
  922. if(exist(x, y, alllineposition)) {
  923. $(".alinedrag").removeClass("curred");
  924. $(".alinedrag").eq(existArr(x, y, myalineposition)).addClass("curred");
  925. } else {
  926. $(".alinedrag").removeClass("curred");
  927. }
  928. });
  929. $(document).on('mouseup', function(e) {
  930. var x = e.pageX,
  931. y = e.pageY;
  932. if(exist(x, y, alllineposition)) {
  933. var tr = $(".alinedrag").eq(existArr(x, y, myalineposition));
  934. var id = tr.find("input").val();
  935. var url="st-xm/Api/busInfoControll.php?method=vehicleDispatch&bus_id=" + id + "&res_id=" + that.children(".car-show").attr("dataid");
  936. ZZLog(url);
  937. $.getJSON(url, function(data) {
  938. ZZLog(data);
  939. if(data.code == "0") {
  940. ZZLog(data.info);
  941. tr.children(".cardrap").html(thathtml);
  942. $(".alinedrag").removeClass("curred");
  943. $("#onlyin").remove();
  944. $(document).unbind();
  945. $(".opcity").removeClass("opcity");
  946. $(".all-lineinfo .acar").unbind();
  947. // addcaroutEvent();
  948. // 调派成功之后刷新当前页面
  949. // location.replace(location.href);
  950. refersh_cur_page();
  951. } else {
  952. ZZLog(data.info);
  953. alert(data.info);
  954. $(".alinedrag").removeClass("curred");
  955. $("#onlyin").remove();
  956. $(".opcity").removeClass("opcity");
  957. $(document).unbind();
  958. }
  959. });
  960. } else {
  961. $("#onlyin").remove();
  962. $(".opcity").removeClass("opcity");
  963. $(document).unbind();
  964. }
  965. });
  966. });
  967. }
  968. function adddriveroutEvent() {
  969. mydriverposition = getrect($(".driverinfodata").get(0));
  970. ZZLog(mydriverposition)
  971. $(".all-lineinfo .adriver").on("mousedown", function(e) {
  972. //ZZLog(0)
  973. e.stopPropagation();
  974. var that = $(this);
  975. var thathtml = $(this).outerHTML();
  976. var myxy = addItemid("div", "adriver", "onlyout", $(this).html());
  977. $(this).addClass("opcity");
  978. var thisxy = getPosition(this);
  979. $('body').append(myxy);
  980. var onlyout = document.getElementById("onlyout");
  981. onlyout.style.position = "absolute";
  982. onlyout.style.left = thisxy[0] + "px";
  983. onlyout.style.top = thisxy[1] + "px";
  984. xy = getPosition(onlyout);
  985. mouseX = e.pageX,
  986. mouseY = e.pageY,
  987. delaX = mouseX - xy[0],
  988. delaY = mouseY - xy[1];
  989. $(document).on('mousemove', function(e) {
  990. onlyout.style.left = (e.pageX - delaX) + 'px';
  991. onlyout.style.top = (e.pageY - delaY) + 'px';
  992. var x = e.pageX,
  993. y = e.pageY;
  994. if(exist(x, y, mydriverposition)) {
  995. $(".driverinfodata").addClass("curgreen");
  996. } else {
  997. $(".driverinfodata").removeClass("curgreen");
  998. }
  999. })
  1000. $(document).on("mouseup", function(e) {
  1001. var x = e.pageX,
  1002. y = e.pageY;
  1003. if(exist(x, y, mydriverposition)) {
  1004. $.getJSON("st-xm/Api/busInfoControll.php?method=driverDispatch&bus_id=" + that.parent().parent().find("input").val() + "&res_id=" + that.children(".adriver-show").attr("dataid"), function(data) {
  1005. ZZLog(data)
  1006. if(data.code == 0) {
  1007. ZZLog(data.info);
  1008. $("#onlyout").remove();
  1009. $(".opcity").remove();
  1010. $(".driverinfodata").removeClass("curgreen");
  1011. $(document).unbind();
  1012. } else {
  1013. ZZLog(data.info)
  1014. $("#onlyout").remove();
  1015. $(".driverinfodata").removeClass("curgreen");
  1016. $(".opcity").removeClass("opcity")
  1017. $(document).unbind();
  1018. }
  1019. })
  1020. } else {
  1021. $("#onlyout").remove();
  1022. $(".opcity").removeClass("opcity")
  1023. $(document).unbind();
  1024. }
  1025. })
  1026. })
  1027. }
  1028. function adddriverinEvent() {
  1029. mydriverposition = getrect($(".driverinfodata").get(0));
  1030. myalineposition = [];
  1031. alllineposition = getrect($(".alldrag").get(0));
  1032. for(var i = 0; i < $(".alinedrag").length; i++) {
  1033. myalineposition.push(getrect($(".alinedrag").get(i)))
  1034. };
  1035. $(".driverinfodata .adriver").on("mousedown", function(e) {
  1036. e.stopPropagation();
  1037. var that = $(this);
  1038. var thathtml = $(this).outerHTML(),
  1039. myxy = addItemid("div", "adriver", "onlyin", $(this).html());
  1040. $(this).addClass("opcity");
  1041. var thisxy = getPosition1(this);
  1042. ZZLog(typeof that);
  1043. $('body').append(myxy);
  1044. var onlyin = document.getElementById("onlyin");
  1045. onlyin.style.position = "absolute";
  1046. onlyin.style.left = thisxy[0] + "px";
  1047. onlyin.style.top = thisxy[1] + "px";
  1048. xy = getPosition(onlyin),
  1049. mouseX = e.pageX,
  1050. mouseY = e.pageY,
  1051. delaX = mouseX - xy[0],
  1052. delaY = mouseY - xy[1];
  1053. $(document).on('mousemove', function(e) {
  1054. onlyin.style.left = (e.pageX - delaX) + 'px';
  1055. onlyin.style.top = (e.pageY - delaY) + 'px';
  1056. var x = e.pageX,
  1057. y = e.pageY;
  1058. if(exist(x, y, alllineposition)) {
  1059. $(".alinedrag").removeClass("curgreen");
  1060. $(".alinedrag").eq(existArr(x, y, myalineposition)).addClass("curgreen");
  1061. } else {
  1062. $(".alinedrag").removeClass("curgreen");
  1063. }
  1064. });
  1065. $(document).on('mouseup', function(e) {
  1066. var x = e.pageX,
  1067. y = e.pageY;
  1068. if(exist(x, y, alllineposition)) {
  1069. var tr = $(".alinedrag").eq(existArr(x, y, myalineposition));
  1070. var id = tr.find("input").val();
  1071. var url2="st-xm/Api/busInfoControll.php?method=driverDispatch&bus_id=" + id + "&res_id=" + that.children(".adriver-show").attr("dataid");
  1072. ZZLog(url2);
  1073. $.getJSON(url2, function(data) {
  1074. if(data.code == 0) {
  1075. ZZLog(data.info)
  1076. tr.children(".driverdrap").html(thathtml);
  1077. $(".alinedrag").removeClass("curgreen");
  1078. $(".opcity").removeClass("opcity");
  1079. $("#onlyin").remove();
  1080. $(document).unbind();
  1081. $(".all-lineinfo .adriver").unbind();
  1082. // adddriveroutEvent();
  1083. } else {
  1084. ZZLog(data.info)
  1085. alert(data.info);
  1086. $(".alinedrag").removeClass("curgreen");
  1087. $("#onlyin").remove();
  1088. $(".opcity").removeClass("opcity");
  1089. $(document).unbind();
  1090. }
  1091. });
  1092. } else {
  1093. $("#onlyin").remove();
  1094. $(".opcity").removeClass("opcity");
  1095. $(document).unbind();
  1096. }
  1097. });
  1098. });
  1099. }
  1100. function existArr(x, y, area) {
  1101. for(var i = 0; i < area.length; i++) {
  1102. if(x > area[i][0] && x < area[i][2] && y > area[i][1] && y < area[i][3]) {
  1103. return i
  1104. }
  1105. }
  1106. }
  1107. function exist(x, y, area) {
  1108. if(x > area[0] && x < area[2] && y > area[1] && y < area[3]) {
  1109. return true
  1110. } else {
  1111. return false
  1112. }
  1113. }
  1114. function getrect(dom) {
  1115. var rect = [];
  1116. that = dom,
  1117. one = getPosition(dom);
  1118. rect.push(one[0], one[1], one[0] + dom.offsetWidth, one[1] + dom.offsetHeight);
  1119. return rect
  1120. }
  1121. function getPosition(obj) {
  1122. //ZZLog($(obj));
  1123. var topValue = 0,
  1124. leftValue = 0;
  1125. var finalvalue = [];
  1126. while(obj) {
  1127. leftValue += obj.offsetLeft;
  1128. topValue += obj.offsetTop;
  1129. obj = obj.offsetParent;
  1130. }
  1131. finalvalue.push(leftValue, topValue);
  1132. return finalvalue;
  1133. }
  1134. function getPosition1(obj) {
  1135. ZZLog();
  1136. //var topValue = 0,
  1137. // leftValue = 0;
  1138. //var finalvalue = [];
  1139. // while (obj) {
  1140. // leftValue += obj.offsetLeft;
  1141. // topValue += obj.offsetTop;
  1142. // obj = obj.offsetParent;
  1143. // }
  1144. // finalvalue.push(leftValue, topValue);
  1145. return [$(obj).offset().left, $(obj).offset().top];
  1146. }
  1147. function position(x, y, area) {
  1148. for(var i = 0; i < area.length; i++) {
  1149. if(x > area[i][0] && x < area[i][2] && y > area[i][1] && y < area[i][3]) {
  1150. ZZLog(x + "," + y + "," + area[i])
  1151. return true;
  1152. } else {
  1153. ZZLog(x + "," + y + "," + area[i])
  1154. return false;
  1155. }
  1156. }
  1157. }
  1158. function addItem(label, classname, cent) {
  1159. var html = ['<' + label + ' class="' + classname + '">'];
  1160. html.push(cent);
  1161. html.push('</' + label + '>');
  1162. return html.join("")
  1163. }
  1164. function addItemid(label, classname, id, cent) {
  1165. var html = ['<' + label + ' class="' + classname + '" id=' + id + '>'];
  1166. html.push(cent);
  1167. html.push('</' + label + '>');
  1168. return html.join("")
  1169. }
  1170. jQuery.fn.outerHTML = function(s) {
  1171. return(s) ? this.before(s).remove() : $("<Hill_man>").append(this.eq(0).clone()).html();
  1172. }
  1173. function getPar(par) {
  1174. //获取当前URL
  1175. var local_url = document.location.href;
  1176. local_url = decodeURI(local_url);
  1177. //获取要取得的get参数位置
  1178. var get = local_url.indexOf(par + "=");
  1179. if(get == -1) {
  1180. return false;
  1181. }
  1182. //截取字符串
  1183. var get_par = local_url.slice(par.length + get + 1);
  1184. //判断截取后的字符串是否还有其他get参数
  1185. var nextPar = get_par.indexOf("&");
  1186. if(nextPar != -1) {
  1187. get_par = get_par.slice(0, nextPar);
  1188. }
  1189. return get_par;
  1190. }
  1191. function getDateTime(nTypeFlag) {
  1192. var tNowTime = new Date();
  1193. var myYear = ';' + tNowTime.getFullYear() + ';';
  1194. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  1195. var myDay = ';' + tNowTime.getDate() + ';';
  1196. var myHour = ';' + tNowTime.getHours() + ';';
  1197. var myMinu = ';' + tNowTime.getMinutes() + ';';
  1198. var mySecond = ';' + tNowTime.getSeconds() + ';';
  1199. if(myMonth.length < 4) myMonth = '0' + myMonth;
  1200. if(myDay.length < 4) myDay = '0' + myDay;
  1201. if(myHour.length < 4) myHour = '0' + myHour;
  1202. if(myMinu.length < 4) myMinu = '0' + myMinu;
  1203. if(mySecond.length < 4) mySecond = '0' + mySecond;
  1204. var cNewTimeStr;
  1205. //alert(tNowTime);
  1206. switch(nTypeFlag + 1 - 1) {
  1207. case 0:
  1208. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  1209. break;
  1210. case 1:
  1211. cNewTimeStr = myYear + myMonth + myDay;
  1212. break;
  1213. case 2:
  1214. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  1215. break;
  1216. case 3:
  1217. cNewTimeStr = myHour + myMinu + mySecond;
  1218. break;
  1219. case 4:
  1220. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  1221. break;
  1222. case 5:
  1223. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  1224. break;
  1225. case 6:
  1226. cNewTimeStr = myYear;
  1227. break;
  1228. case 7:
  1229. cNewTimeStr = myYear + '-' + myMonth;
  1230. break;
  1231. case 8: //得到上一个月的今天
  1232. var date = getDateTime(0);
  1233. var arr = date.split('-');
  1234. var year = arr[0]; //获取当前日期的年份
  1235. var month = arr[1]; //获取当前日期的月份
  1236. var day = arr[2]; //获取当前日期的日
  1237. var days = new Date(year, month, 0);
  1238. days = days.getDate(); //获取当前日期中月的天数
  1239. var year2 = year;
  1240. var month2 = parseInt(month) - 1;
  1241. if(month2 == 0) {
  1242. year2 = parseInt(year2) - 1;
  1243. month2 = 12;
  1244. }
  1245. var day2 = day;
  1246. var days2 = new Date(year2, month2, 0);
  1247. days2 = days2.getDate();
  1248. if(day2 > days2) {
  1249. day2 = days2;
  1250. }
  1251. if(month2 < 10) {
  1252. month2 = '0' + month2;
  1253. }
  1254. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  1255. break;
  1256. case 9: //得到下一个月的今天
  1257. var date = getDateTime(0);
  1258. var arr = date.split('-');
  1259. var year = arr[0]; //获取当前日期的年份
  1260. var month = arr[1]; //获取当前日期的月份
  1261. var day = arr[2]; //获取当前日期的日
  1262. var days = new Date(year, month, 0);
  1263. days = days.getDate(); //获取当前日期中的月的天数
  1264. var year2 = year;
  1265. var month2 = parseInt(month) + 1;
  1266. if(month2 == 13) {
  1267. year2 = parseInt(year2) + 1;
  1268. month2 = 1;
  1269. }
  1270. var day2 = day;
  1271. var days2 = new Date(year2, month2, 0);
  1272. days2 = days2.getDate();
  1273. if(day2 > days2) {
  1274. day2 = days2;
  1275. }
  1276. if(month2 < 10) {
  1277. month2 = '0' + month2;
  1278. }
  1279. var t2 = year2 + '-' + month2 + '-' + day2;
  1280. return t2;
  1281. break;
  1282. case 10: //昨日日期
  1283. var d = getDateTime(0);
  1284. d = new Date(d);
  1285. d = +d - 1000*60*60*24;
  1286. d = new Date(d);
  1287. //return d;
  1288. //格式化
  1289. var year = ";" + d.getFullYear() + ";";
  1290. var month = ";" + (d.getMonth()+0+1) + ";";
  1291. var day = ";" + d.getDate() + ";";
  1292. if(year.length < 4) {
  1293. year = "0" + year;
  1294. }
  1295. if(month.length < 4) {
  1296. month = "0" + month;
  1297. }
  1298. if(day.length < 4) {
  1299. day = "0" + day;
  1300. }
  1301. var datestr = year + "-" + month + "-" + day;
  1302. datestr = datestr.replace(/;/g, "");
  1303. return datestr;
  1304. break;
  1305. case 11: //明日日期
  1306. var d=getDateTime(0);
  1307. d = new Date(d);
  1308. d = +d + 1000*60*60*24;
  1309. d = new Date(d);
  1310. //return d;
  1311. //格式化
  1312. var year = ";" + d.getFullYear() + ";";
  1313. var month = ";" + (d.getMonth()+0+1) + ";";
  1314. var day = ";" + d.getDate() + ";";
  1315. if(year.length < 4) {
  1316. year = "0" + year;
  1317. }
  1318. if(month.length < 4) {
  1319. month = "0" + month;
  1320. }
  1321. if(day.length < 4) {
  1322. day = "0" + day;
  1323. }
  1324. var datestr = year + "-" + month + "-" + day;
  1325. datestr = datestr.replace(/;/g, "");
  1326. return datestr;
  1327. break;
  1328. default:
  1329. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  1330. break;
  1331. }
  1332. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  1333. return cNewTimeStr;
  1334. }
  1335. //add by qiusong on 2017.09.25
  1336. function disp_run_bus_passenger( run_id, bus_order_id ) {
  1337. $.ajax({
  1338. url: './st-xm/Api/run_bus_passengers_static.php',
  1339. type: "post",
  1340. data: {
  1341. run_id: run_id,
  1342. bus_order_id: bus_order_id
  1343. },
  1344. dataType: "json",
  1345. success: function (data) {
  1346. if (data.code == 0) {
  1347. var disp_table_html = '<table border="1"><tr><td >站点</td><td>上车</td><td>下车</td></tr>';
  1348. for(var i = 0; i < data.data.length; i++) {
  1349. disp_table_html += '<tr><td style="text-align: left;">' + data.data[i].RES_NAME + '</td><td>' + data.data[i].up_num + '</td><td>' + data.data[i].down_num + '</td></tr>';
  1350. }
  1351. disp_table_html += '</table>';
  1352. swal({
  1353. title: '上下车信息',
  1354. type: 'info',
  1355. html: disp_table_html,
  1356. showCloseButton: true
  1357. });
  1358. return;
  1359. } else {
  1360. swal(
  1361. '获取信息失败',
  1362. data.info,
  1363. 'error'
  1364. );
  1365. return;
  1366. }
  1367. },
  1368. fail: function (data) {
  1369. swal(
  1370. '获取信息失败',
  1371. data.info,
  1372. 'error'
  1373. );
  1374. return;
  1375. }
  1376. });
  1377. }