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.
 
 
 
 

913 lines
32 KiB

  1. var car_no = 0;
  2. var have_car_no = 0; //已有有的车号
  3. var line_distance = 0;
  4. var base_cost = [];
  5. function getweek() {
  6. var week = "week=";
  7. for (var i = 1; i < $(".weeklist input").length; i++) {
  8. if ($(".weeklist input").eq(i).is(":checked")) {
  9. week += $(".weeklist input").eq(i).val()
  10. }
  11. }
  12. return week
  13. }
  14. function getalltime() {
  15. var allstation = "allstation=";
  16. for (var i = 0; i < $(".replace-lineinfo tr").length; i++) {
  17. var allattr = [];
  18. var atime = parseInt($(".replace-lineinfo tr").eq(i).children("td:eq(0)").children(".hour").val()) * 60 + parseInt($(".replace-lineinfo tr").eq(i).children("td:eq(0)").children(".minute").val());
  19. var astationid = $(".replace-lineinfo tr").eq(i).children("td:eq(1)").attr("alineid");
  20. var aupdowntype = $(".replace-lineinfo tr").eq(i).children("td:eq(2)").children("select").val();
  21. var amouth = $(".replace-lineinfo tr").eq(i).children("td:eq(3)").children("select").val();
  22. if (amouth == null) {
  23. amouth = 0;
  24. }
  25. allattr.push(astationid);
  26. allattr.push(atime);
  27. allattr.push(aupdowntype);
  28. allattr.push(amouth);
  29. var astation = '{' + allattr.join() + '}'
  30. allstation += astation;
  31. }
  32. ;
  33. return allstation;
  34. }
  35. function getallcar() {
  36. var allcar = "allcar=";
  37. for (var i = 0; i < $(".car-select").length; i++) {
  38. var allattr = [];
  39. var acartype = $(".car-select").eq(i).children(".car-item").val();
  40. //TODO 发现:已有的车号保持不变,新增的都是0。。7-29待确认 已改,测试中
  41. // 经发现,使用html()谷歌浏览器自动翻译后自动在<i></i>里面添加<font></font>标签导致参数错误,故改成text()
  42. // var acarnum =acarnum=$(".car-select").eq(i).children("i").html();
  43. var acarnum = acarnum = $(".car-select").eq(i).children("i").text();
  44. // if(have_car_no-1<i){
  45. // acarnum='0';
  46. // }
  47. if (acarnum > have_car_no) {
  48. acarnum = '0';
  49. }
  50. // acarnum='0';
  51. var acarseat = $(".car-select").eq(i).children(".ifseat").val();
  52. //..品牌
  53. var car_brand = $('.car-select').eq(i).children(".car-brand").val();
  54. if (!car_brand) {
  55. car_brand = 288;
  56. }
  57. var car_supplier = $('.car-select').eq(i).children(".supplier-list").val();
  58. var car_cost = $('.car-select').eq(i).children(".cost-type").val();
  59. var car_cost_price = $('.car-select').eq(i).children(".cost_price").val();
  60. var send_bus_res_id = $('.car-select').eq(i).children(".supplier-list").attr('data-send-bus-res-id');
  61. var send_bus_res_json = '';
  62. if (send_bus_res_id != 0) {
  63. send_bus_res_json = getJsonHtml(send_bus_res_id);
  64. }
  65. if (!/^\d+(\.\d{1,2})?$/.test(car_cost_price)) {
  66. alert("请输入价格");
  67. return false;
  68. }
  69. if (send_bus_res_json!=''&&((car_cost_price!=send_bus_res_json.cost_price)||(car_cost!=send_bus_res_json.cost_type)||(car_supplier!=send_bus_res_json.cost_motorcade_id))){
  70. alert("已经派车的车次不能进行数据修改,请联系管理员");
  71. return false;
  72. }
  73. allattr.push(acarnum);
  74. allattr.push(acartype);
  75. allattr.push(acarseat);
  76. allattr.push(car_brand);
  77. allattr.push(car_supplier);
  78. allattr.push(car_cost);
  79. allattr.push(car_cost_price);
  80. var acar = '{' + allattr.join() + '}'
  81. allcar += acar;
  82. }
  83. return allcar;
  84. }
  85. function gettickettype() {
  86. var allticket = "allticket=";
  87. // var starareaid = $(".stararea").eq(0).attr("starareaid");
  88. // var endareaid = $(".endarea").eq(0).attr("endareaid");
  89. //console.log(starareaid)
  90. var judge = false;
  91. for (var i = 0; i < $(".ticket_sel").length; i++) {
  92. if ($(".ticket_sel").eq(i).is(":checked")) {
  93. judge = true;
  94. var index = $(".ticket_sel").eq(i).parent().parent().index();
  95. var allattr = [];
  96. var starareaid = $(".adult").eq(index).children(".stararea").attr("starareaid");
  97. var endareaid = $(".adult").eq(index).children(".endarea").attr("endareaid");
  98. var seatid = $(".adult").eq(index).children(".seatid").attr("seatid");
  99. var crowd = $(".adult").eq(index).children(".crowdid").attr("crowdid");
  100. var aticketnum = $(".adult").eq(index).children(".ticketnum").children("input").val();
  101. if (!aticketnum) {
  102. aticketnum = 0;
  103. }
  104. allattr.push(starareaid);
  105. allattr.push(endareaid);
  106. allattr.push(seatid);
  107. allattr.push(crowd);
  108. allattr.push(aticketnum);
  109. var aticket = '{' + allattr.join() + '}'
  110. allticket += aticket;
  111. }
  112. }
  113. if (judge == false) {
  114. return false;
  115. }
  116. return allticket
  117. }
  118. function addweek(week) {
  119. for (var i = 0; i < week.length; i++) {
  120. var day = week.slice(i, i + 1)
  121. console.log(day)
  122. for (var n = 0; n < $(".aday").length; n++) {
  123. if (day == $(".aday").eq(n).val()) {
  124. $(".aday").eq(n).attr("checked", "true")
  125. }
  126. }
  127. }
  128. }
  129. function havecar(car) {
  130. console.log(123456)
  131. }
  132. function auto_update_cost(obj) {
  133. var acartype = $(obj).parent().children(".car-item").val();
  134. var car_cost = $(obj).parent().children(".cost-type").val();
  135. var car_supplier = $(obj).parent().children(".supplier-list").val();
  136. if (typeof(base_cost[car_supplier][acartype]) != "undefined" && car_cost == "477") {
  137. var cost_price_auto = Math.round(base_cost[car_supplier][acartype] * line_distance);
  138. $(obj).parent().children(".cost_price").val(cost_price_auto);
  139. }
  140. }
  141. $(document).ready(function () {
  142. $(".startime").on("change", function () {
  143. $(".data-erro").html("")
  144. })
  145. $('.date-picker').datepicker({
  146. autoclose: true
  147. }).next().on('click', function () {
  148. $(this).prev().focus();
  149. });
  150. var addcar = $(".car-select").outerHTML();
  151. var ticket2 = $(".noble").outerHTML();
  152. var addcar = $(".car-select").outerHTML();
  153. //$(".car-select").remove();
  154. $(".storage").on("click", function () {
  155. if ($('.storage').html() != "保存") {
  156. return;
  157. }
  158. console.log('保存次数');
  159. $('.storage').html('保存中...');
  160. //var week = getweek ();
  161. // if($(".add-line").val()==''){
  162. // $(".addline-erro").html("必填项");
  163. // return;
  164. // };
  165. if ($(".startime").val() == '') {
  166. $(".data-erro").html("必填项")
  167. return;
  168. }
  169. ;
  170. // if(week==false){
  171. // $(".week-erro").html("必填项");
  172. // return;
  173. // };
  174. if ($(".car-type").html() == '') {
  175. $(".car-erro").html("必填项");
  176. return;
  177. }
  178. ;
  179. if (gettickettype() == false) {
  180. $(".ticket-erro").html("以上票种必须选中一个");
  181. return;
  182. }
  183. ;
  184. //var lineid = getval(".add-line","runid");
  185. var id = runid;
  186. var startime = getval(".startime", "val");
  187. //var endtime = getval(".endtime","val");
  188. var alltime = getalltime();
  189. var allcar = getallcar();
  190. if (allcar == false) {
  191. return false;
  192. }
  193. var allticket = gettickettype();
  194. var sellday = getval(".sellday", "val");
  195. var all = getdata(id, startime, alltime, allcar, allticket, sellday);
  196. console.log(all);
  197. // $.getJSON("./st-xm/Api/run_bus_update.php?" + all, function (data) {
  198. // if (data.errcode == 0) {
  199. // window.location.href = "./carList.html";
  200. // } else {
  201. // alert(data.errinfo);
  202. // $('.storage').html('保存');
  203. // }
  204. // })
  205. $.ajax({
  206. url: "./st-xm/Api/run_bus_update.php?" + all,
  207. type: 'get',
  208. dataType: 'json',
  209. success: function (data) {
  210. if (data.code == '0') {
  211. swal({
  212. title: '修改成功',
  213. type: 'success',
  214. timer: 20000,
  215. confirmButtonText: 'OK'
  216. }).then(
  217. function () { window.location.href = "./carList.html"; },
  218. function (dismiss) {
  219. window.location.href = "./carList.html";
  220. }
  221. )
  222. } else {
  223. swal(
  224. '修改失败',
  225. data.info,
  226. 'error'
  227. );
  228. $('.storage').html('保存');
  229. }
  230. },
  231. error: function (e) {
  232. console.log(e);
  233. }
  234. })
  235. // if(/week=\s+/.test(week)){
  236. // console.log("weektrue");
  237. // }else{
  238. // alert("bitian") ;
  239. // return;
  240. // }
  241. //console.log(week);
  242. //console.log(startime);
  243. //console.log(endtime);
  244. //console.log($(".add-line").html());
  245. //console.log(allcar);
  246. //console.log(allticket);
  247. //location.href="st-xm/Api/run_bus_new_save.php?"+all;
  248. })
  249. // alert(1)
  250. var runid = 'runid=' + window.location.search.replace(/[^0-9]/ig, "")
  251. var url = './st-xm/Api/runEditControll.php?method=getRunInfo&user_id=1&run_id=' + window.location.search.replace(/[^0-9]/ig, "");
  252. $.getJSON(url, function (data) {
  253. console.log(url);
  254. console.log(data)
  255. $('.addtime').css('display', 'block');
  256. base_cost = data.base_cost;
  257. var ticket1 = $(".adult").outerHTML();
  258. $(".adult").remove();
  259. var linehtml = $(".add-line").outerHTML();
  260. $(".add-line").remove();
  261. $(".sellday").val(data.sellday)
  262. if (data.line) {
  263. var linename = linehtml.replace(/linename|alineid/g, function (match) {
  264. switch (match) {
  265. case "linename":
  266. return data.line.name;
  267. case "alineid":
  268. return data.line.lineid;
  269. }
  270. });
  271. $(".replaceline").append(linename)
  272. }
  273. $(".startime").val(data.time)
  274. //addweek(data.week);
  275. // $.each(data.hascartype,function(i,v){
  276. // var cartype = [];
  277. // $.each(v,function(i,v){
  278. // if(v.sel==1){
  279. // var acar = additemall("option",v.cartype,{"value":v.id,selected:"true"})
  280. // }else{
  281. // var acar = additemall("option",v.cartype,{"value":v.id})
  282. // }
  283. // cartype.push(acar)
  284. // })
  285. // var acartype = addcar.replace("cartype",cartype.join());
  286. // $(".car-type").append(acartype);
  287. // });
  288. var allcartype = $(".car-item").outerHTML();
  289. var ahtml = [];
  290. $.each(data.hascar, function (i, v) {
  291. car_no = v.carnum; //保存当前车号
  292. var acar = addcar.replace(/num|cartype|supplier_list|cost_type|cost-price|selseat|del|删除/g, function (match) {
  293. switch (match) {
  294. case "num":
  295. have_car_no = v.carnum; //将已有的最大车号保存起来 update by fuhc 2016-07-28
  296. return v.carnum;
  297. case "cartype":
  298. return (function (seat, id) {
  299. var html = [];
  300. $.each(seat, function (i, v) {
  301. if (id == v.id) {
  302. var str = "<option selected value = " + v.id + ">" + v.cartype + "</option>"
  303. }
  304. // else{
  305. // var str = "<option value = "+v.id+">"+v.cartype+"</option>"
  306. // }
  307. html.push(str);
  308. })
  309. return html.join("");
  310. })(data.cartype, v.id);
  311. case "supplier_list":
  312. var str = '';
  313. for (var i = 0; i < data.supplier_list.length; i++) {
  314. if (v.cost_motorcade_id == data.supplier_list[i].supplier_id) {
  315. str += "<option selected value = " + data.supplier_list[i].supplier_id + ">" + data.supplier_list[i].bus_team + "</option>";
  316. } else {
  317. str += "<option value = " + data.supplier_list[i].supplier_id + ">" + data.supplier_list[i].bus_team + "</option>";
  318. }
  319. }
  320. if (v.send_bus_res_id == 0) {
  321. str = '<select class="supplier-list" data-send-bus-res-id="0" onchange="auto_update_cost(this)" >' + str + '</select>';
  322. } else {
  323. str = '<select class="supplier-list" data-send-bus-res-id="' + setJsonHtml(v) + '" onchange="auto_update_cost(this)" disabled>' + str + '</select>';
  324. }
  325. return str;
  326. case "cost_type":
  327. var str = '';
  328. for (var i = 0; i < data.cost_type.length; i++) {
  329. if (v.cost_type == data.cost_type[i].type_id) {
  330. str += "<option selected value = " + data.cost_type[i].type_id + ">" + data.cost_type[i].type_name + "</option>";
  331. } else {
  332. str += "<option value = " + data.cost_type[i].type_id + ">" + data.cost_type[i].type_name + "</option>";
  333. }
  334. }
  335. if (v.send_bus_res_id == 0) {
  336. str = '<select class="cost-type" onchange="auto_update_cost(this)" >' + str + '</select>';
  337. } else {
  338. str = '<select class="cost-type" onchange="auto_update_cost(this)" disabled>' + str + '</select>';
  339. }
  340. return str;
  341. case "cost-price":
  342. var str = '<input class="cost_price" type="text" value="' + v.cost_price + '">元';
  343. if (v.send_bus_res_id != 0) {
  344. str = '<input class="cost_price" type="text" value="' + v.cost_price + '" readonly>元';
  345. }
  346. return str;
  347. case "selseat":
  348. return v.selectseat == "156" ? "<option value='156' selected>可选</option><option value='157'>不可选</option>" : "<option value='156'>可选</option><option value='157' selected>不可选</option>"
  349. case "del":
  350. return "";
  351. case "删除":
  352. return "";
  353. }
  354. })
  355. ahtml.push(acar);
  356. });
  357. $(".car-type").html(ahtml.join(""));
  358. $(".car-select .del").on("click", function () {
  359. $(this).parent().remove();
  360. });
  361. var linehtml = [];
  362. var tickethtml = [];
  363. $(".add-cartype").on("click", function () {
  364. //将车号++
  365. car_no++;
  366. $("car-erro").html("");
  367. var cartype = [];
  368. //artype.push("<i>0</i>");
  369. $.each(data.cartype, function (i, v) {
  370. var acar = additemall("option", v.cartype, {
  371. "value": v.id
  372. })
  373. cartype.push(acar)
  374. })
  375. //artype.push("<option value='156' selected>可选</option><option value='157'>不可选</option>");
  376. var acartype = addcar.replace(/cartype|supplier_list|cost_type|cost-price|num|selseat/g, function (match) {
  377. switch (match) {
  378. case "cartype":
  379. return cartype.join("");
  380. case "num":
  381. // 先保证能添加车辆 返回0
  382. // return "0";
  383. return car_no;
  384. case "supplier_list":
  385. var str = '';
  386. for (var i = 0; i < data.supplier_list.length; i++) {
  387. str += "<option value = " + data.supplier_list[i].supplier_id + ">" + data.supplier_list[i].bus_team + "</option>";
  388. }
  389. str = '<select class="supplier-list" data-send-bus-res-id="0" onchange="auto_update_cost(this)">' + str + '</select>';
  390. return str;
  391. case "cost_type":
  392. var str = '';
  393. for (var i = 0; i < data.cost_type.length; i++) {
  394. str += "<option value = " + data.cost_type[i].type_id + ">" + data.cost_type[i].type_name + "</option>";
  395. }
  396. str = '<select class="cost-type" onchange="auto_update_cost(this)" >' + str + '</select>';
  397. return str;
  398. case "cost-price":
  399. var str = '<input class="cost_price" type="text" value="0">元';
  400. return str;
  401. case "selseat":
  402. return "<option value='156' selected>可选</option><option value='157'>不可选</option>";
  403. }
  404. ;
  405. });
  406. var tmp = acartype.replace(/disabled/g, "");
  407. console.log(tmp);
  408. $(".car-type").append(tmp);
  409. $(".car-select .del").unbind();
  410. $(".car-select .del").on("click", function () {
  411. $(this).parent().remove();
  412. });
  413. })
  414. line_distance = data.line_distance;
  415. $("#disp_line_distance").html(line_distance + "公里");
  416. $.each(data.station, function (i, v) {
  417. var td1 = addTd(addTime(v.DATE_TIME));
  418. var td2 = additemall("td", v.SITES, {
  419. alineid: v.STATION_RES_ID
  420. });
  421. // if(i==0){var td3= addTd('<select style="width: 50px" disabled><option value="108">上</option></select>')}
  422. // else{var td3=addTd(addUpdownType(v.UP_DOWN_TYPE))};
  423. var td3 = addTd(addUpdownType(v.UP_DOWN_TYPE));
  424. var td4 = addTd(addMouth(v.TICKET_GATE, v.CHECKPORT));
  425. linehtml.push(addItem("tr", "aline", td1.concat(td2, td3, td4)))
  426. })
  427. $.each(data.ticket, function (i, v) {
  428. if (v.SEAT == "普通座") {
  429. var seatid = 72;
  430. } else if (v.SEAT == "贵宾座") {
  431. var seatid = 73;
  432. } else if (v.SEAT == "儿童特票座") {
  433. var seatid = 74;
  434. }
  435. ;
  436. if (v.CROWD == "成人") {
  437. var crowdid = 159;
  438. } else if (v.CROWD == "儿童") {
  439. var crowdid = 160;
  440. } else if (v.CROWD == "老人") {
  441. var crowdid = 161;
  442. } else if (v.CROWD == "军残") {
  443. var crowdid = 162;
  444. } else {
  445. var crowdid = 0;
  446. }
  447. ;
  448. //var html = [];
  449. var atciket = ticket1.replace(/checked="checked"|SID|EID|START_AREA|END_AREA|SEAT|CROWD|PRICE|MAX_COUNT|PROD_ID|aseatid|acrowdid/g, function (match) {
  450. switch (match) {
  451. case 'checked="checked"':
  452. return v.sel == 1 ? 'checked="checked"' : "";
  453. case "SID":
  454. return v.SID;
  455. case "EID":
  456. return v.EID;
  457. case "aseatid":
  458. return seatid;
  459. case "acrowdid":
  460. return crowdid;
  461. case "START_AREA":
  462. return v.START_AREA;
  463. case "END_AREA":
  464. return v.END_AREA;
  465. case "SEAT":
  466. return v.SEAT;
  467. case "CROWD":
  468. return v.CROWD;
  469. case "MAX_COUNT":
  470. return v.MAX_COUNT;
  471. case "PROD_ID":
  472. return v.PROD_ID;
  473. case "PRICE":
  474. return v.PRICE;
  475. }
  476. })
  477. tickethtml.push(atciket)
  478. })
  479. $(".replace-lineinfo").html(linehtml).attr("lineid", data.station[1].PROD_ID);
  480. $(".able-ticket").html(tickethtml.join());
  481. $(".ticket_sel").on("click", function () {
  482. $(".ticket-erro").html("");
  483. })
  484. var hourinfo = [];
  485. $.each($('.hour'), function (i, v) {
  486. var val = $('.hour').eq(i).val();
  487. if (val < 10) {
  488. val = "0" + val;
  489. }
  490. var arr = [i, val]
  491. hourinfo.push(arr)
  492. })
  493. var minuteinfo = [];
  494. $.each($('.minute'), function (i, v) {
  495. var val = $('.minute').eq(i).val()
  496. if (val < 10) {
  497. val = "0" + val;
  498. }
  499. var arr = [i, val]
  500. minuteinfo.push(arr)
  501. })
  502. $(".hour").on("change", function () {
  503. var index = $(this).parent().parent().index();
  504. var max = $(".hour").length;
  505. var dangvalue = $(this).val();
  506. for (var i = 0; i < hourinfo.length; i++) {
  507. if (index == hourinfo[i][0]) { //获得下标
  508. var nextindex = hourinfo[i][0] + 1;
  509. var myaddvalue = dangvalue - hourinfo[i][1];
  510. console.log('myaddvalue=====' + myaddvalue);
  511. for (var t = nextindex; t < max; t++) {
  512. var myvalue = hourinfo[t][1]; //获得下一个input值
  513. var addvalue = myaddvalue + parseInt(myvalue);
  514. if (addvalue > 23) {
  515. addvalue -= 24
  516. }
  517. {
  518. $(".hour").eq(t).find("option").removeAttr("selected");
  519. $(".hour").eq(t).find("option").eq(addvalue).attr("selected", "true")
  520. hourinfo[t][1] = addvalue;
  521. }
  522. }
  523. // if(myaddvalue<0){
  524. // hourinfo[i][1]=myaddvalue;
  525. // }else{
  526. // for(var t = nextindex;t<max;t++){
  527. // var myvalue = hourinfo[t][1];//获得下一个input值
  528. // var addvalue = myaddvalue+parseInt(myvalue);
  529. //
  530. // if(addvalue>23){addvalue-=24}{
  531. // $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addvalue).attr("selected","true")
  532. //
  533. // hourinfo[t][1]=addvalue;
  534. // }
  535. //
  536. // }
  537. // }
  538. }
  539. }
  540. hourinfo[index][1] = dangvalue;
  541. })
  542. $(".minute").on("change", function () {
  543. var index = $(this).parent().parent().index();
  544. var max = $(".minute").length;
  545. var dangvalue = parseInt($(this).val());
  546. for (var i = 0; i < minuteinfo.length; i++) {
  547. if (index == minuteinfo[i][0]) { //获得下标
  548. var nextindex = parseInt(minuteinfo[i][0]) + 1;
  549. var addnum = dangvalue - parseInt(minuteinfo[i][1]);
  550. for (var t = nextindex; t < max; t++) {
  551. var myhourvalue = hourinfo[t][1];
  552. var myminutevalue = minuteinfo[t][1];
  553. var addvalue = addnum + parseInt(myminutevalue);
  554. if (addvalue >= 60) {
  555. addvalue -= 60;
  556. var addhour = parseInt(hourinfo[t][1]) + 1;
  557. }
  558. if (typeof addhour == "undefined") {
  559. $(".minute").eq(t).find("option").removeAttr("selected");
  560. $(".minute").eq(t).find("option").eq(addvalue).attr("selected", "true")
  561. minuteinfo[t][1] = addvalue;
  562. } else {
  563. $(".minute").eq(t).find("option").removeAttr("selected");
  564. $(".minute").eq(t).find("option").eq(addvalue).attr("selected", "true")
  565. minuteinfo[t][1] = addvalue;
  566. $(".hour").eq(t).find("option").removeAttr("selected");
  567. $(".hour").eq(t).find("option").eq(addhour).attr("selected", "true");
  568. hourinfo[t][1] = addhour;
  569. }
  570. }
  571. // if(addnum<0){minuteinfo[i][1]=addnum}
  572. // else{
  573. // for(var t = nextindex;t<max;t++){
  574. // var myhourvalue = hourinfo[t][1];
  575. // var myminutevalue = minuteinfo[t][1];
  576. //
  577. // var addvalue = addnum+parseInt(myminutevalue);
  578. //
  579. // if(addvalue>=60){addvalue-=60; var addhour = parseInt(hourinfo[t][1])+1;}
  580. // if(typeof addhour=="undefined"){
  581. // $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true")
  582. //
  583. // minuteinfo[t][1]=addvalue;
  584. //
  585. //
  586. // }else{
  587. // $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true")
  588. //
  589. // minuteinfo[t][1]=addvalue;
  590. //
  591. // $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addhour).attr("selected","true");
  592. // hourinfo[t][1]=addhour;
  593. // }
  594. // }
  595. // }
  596. }
  597. }
  598. minuteinfo[index][1] = dangvalue;
  599. })
  600. })
  601. $('.date-picker').datepicker({
  602. autoclose: true
  603. });
  604. $('.allweek').on('change', function () {
  605. if ($(this).is(":checked")) {
  606. for (var i = 0; i < $(".week").length; i++) {
  607. $(".week").eq(i).click()
  608. }
  609. } else {
  610. for (var i = 0; i < $(".week").length; i++) {
  611. $(".week").eq(i).removeAttr("checked");
  612. }
  613. }
  614. })
  615. // $(".storage").on("click",function(){
  616. // var lineid = 'lineid='+$(".add-line").attr('dataid');
  617. // var time = 'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val();
  618. // var pass = [];
  619. // (function(){
  620. // var line =[];
  621. // for(var i = 0;i<$(".aline").length;i++){
  622. // var aline = [];
  623. // aline.push("time="+$(".aline").eq(i).find(".hour").val()+":"+$(".aline").eq(i).find(".minute").val());
  624. // aline.push("site="+$(".aline").find("td").eq(1).html());
  625. // aline.push("updown="+$(".aline").find(".updown").val());
  626. // aline.push("mouth="+$(".aline").find(".mouth").val());
  627. // line.push(aline.join(""));
  628. // }
  629. // })()
  630. // url = 'lineid='+$(".add-line").attr('dataid')+'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val()
  631. // })
  632. })
  633. function addItem(label, classname, cent) {
  634. var html = ['<' + label + ' class=' + classname + '>'];
  635. html.push(cent);
  636. html.push('</' + label + '>');
  637. return html.join("")
  638. }
  639. function addLi(html) {
  640. var li = ['<li>'];
  641. li.push(html);
  642. li.push('</li>');
  643. li = li.join("");
  644. return li
  645. }
  646. function addTime(time) {
  647. var time = time.split(":");
  648. var newHour = parseInt(time[0]),
  649. newMinute = parseInt(time[1]);
  650. var html = ['<select class="hour">'];
  651. for (var i = 0; i < 24; i++) {
  652. if (i == newHour) {
  653. if (i < 10) {
  654. html.push('<option selected value=' + i + '>0' + i + '</option>')
  655. } else {
  656. html.push('<option selected value=' + i + '>' + i + '</option>')
  657. }
  658. } else {
  659. if (i < 10) {
  660. html.push('<option value=' + i + '>0' + i + '</option>')
  661. } else {
  662. html.push('<option value=' + i + '>' + i + '</option>')
  663. }
  664. }
  665. }
  666. html.push('</select style="width: 50px">:<select class="minute">')
  667. for (var t = 0; t < 60; t++) {
  668. if (t == newMinute) {
  669. if (t < 10) {
  670. html.push('<option selected value=' + t + '>0' + t + '</option>')
  671. } else {
  672. html.push('<option selected value=' + t + '>' + t + '</option>')
  673. }
  674. } else {
  675. if (t < 10) {
  676. html.push('<option value=' + t + '>0' + t + '</option>')
  677. } else {
  678. html.push('<option value=' + t + '>' + t + '</option>')
  679. }
  680. }
  681. }
  682. html.push('</select>');
  683. html = html.join("")
  684. return html
  685. }
  686. function addUpdownType(type) {
  687. var typeid = null;
  688. var alltypeid = [108, 109, 110, 114]
  689. if (type == 108) {
  690. typeid = "仅上客"
  691. } else if (type == 109) {
  692. typeid = "同时上下客"
  693. } else if (type == 110) {
  694. typeid = "仅下客"
  695. } else if (type == 114) {
  696. typeid = "不停靠"
  697. }
  698. var html = ['<select style="width: 100px" class="updown">'],
  699. alltype = ['仅上客', '同时上下客', '仅下客', '不停靠']
  700. for (var i = 0; i < 4; i++) {
  701. if (typeid == alltype[i]) {
  702. html.push('<option selected value=' + alltypeid[i] + '>' + alltype[i] + '</option>')
  703. } else {
  704. html.push('<option value = ' + alltypeid[i] + '>' + alltype[i] + '</option>')
  705. }
  706. }
  707. html.push('</select>');
  708. html = html.join("");
  709. return html;
  710. }
  711. function addMouth(maxNum, num) {
  712. var html = ['<select class="mouth" style="width: 55px">'];
  713. for (var i = 0; i < maxNum.length; i++) {
  714. for (var n in maxNum[i]) {
  715. if (n == num) {
  716. html.push('<option selected value = ' + n + '>' + maxNum[i][n] + '</option>')
  717. } else {
  718. html.push('<option value=' + n + '>' + maxNum[i][n] + '</option>')
  719. }
  720. }
  721. }
  722. ;
  723. html.push("</select>");
  724. if (maxNum <= 0) {
  725. html = ['-'];
  726. }
  727. html = html.join("")
  728. return html;
  729. }
  730. function addTd(html) {
  731. var td = ['<td>'];
  732. td.push(html);
  733. td.push('</td>');
  734. td = td.join("")
  735. return td;
  736. }
  737. function addTr(html) {
  738. var tr = ['<tr>'];
  739. tr.push(html)
  740. tr.push('</tr>');
  741. tr = tr.join("")
  742. return tr;
  743. }
  744. jQuery.fn.outerHTML = function (s) {
  745. return (s) ? this.before(s).remove() : $("<Hill_man>").append(this.eq(0).clone()).html();
  746. }
  747. function additemall(lable, cen, attr) {
  748. var html = ['<' + lable + ' ' + (function (attr) {
  749. if (typeof(attr) == "undefined") {
  750. return ""
  751. } else {
  752. var arr = [];
  753. for (i in attr) {
  754. arr.push(i + '="' + attr[i] + '"')
  755. }
  756. ;
  757. return arr.join(" ")
  758. }
  759. })(attr) + '>'];
  760. html.push(cen);
  761. html.push('</' + lable + '>');
  762. return html.join("")
  763. }
  764. function getdata() {
  765. var val = [];
  766. Array.prototype.push.apply(val, arguments);
  767. return val.join("&");
  768. }
  769. function getval(dom, value) {
  770. var val = null;
  771. if (value == "val" || value == "value") {
  772. val = $(dom).eq(0).val()
  773. } else if (value == "html") {
  774. val = $(dom).eq(0).html()
  775. } else {
  776. val = $(dom).eq(0).attr(value);
  777. var name = value;
  778. return name + "=" + val;
  779. }
  780. var name = $(dom).eq(0).attr("name");
  781. return name + "=" + val
  782. }
  783. //html存入json
  784. function setJsonHtml(data) {
  785. if (typeof(data) == "object") {
  786. var jsonArrayFinal = JSON.stringify(data);
  787. jsonArrayFinal = jsonArrayFinal.replace(/ /g, '');
  788. jsonArrayFinal = jsonArrayFinal.replace(/"/g, '&quot;');
  789. return jsonArrayFinal;
  790. }
  791. }
  792. //取出html存入的json
  793. function getJsonHtml(data) {
  794. if (data) {
  795. var data_info = JSON.parse(data);
  796. return data_info;
  797. }
  798. }