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.
 
 
 
 

795 lines
30 KiB

  1. var addhour = "100";
  2. var line_distance = 0;
  3. var base_cost = [];
  4. function getweek() {
  5. var week = "week=";
  6. var weeknum = '';
  7. for (var i = 1; i < $(".weeklist input").length; i++) {
  8. if ($(".weeklist input").eq(i).is(":checked")) {
  9. weeknum += $(".weeklist input").eq(i).val()
  10. }
  11. }
  12. if (weeknum == '') {
  13. return false;
  14. }
  15. return week += weeknum;
  16. }
  17. function getalltime() {
  18. var allstation = "allstation=";
  19. for (var i = 0; i < $(".replace-lineinfo tr").length; i++) {
  20. var allattr = [];
  21. 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());
  22. var astationid = $(".replace-lineinfo tr").eq(i).children("td:eq(1)").attr("alineid");
  23. var aupdowntype = $(".replace-lineinfo tr").eq(i).children("td:eq(2)").children("select").val();
  24. var amouth = $(".replace-lineinfo tr").eq(i).children("td:eq(3)").children("select").val();
  25. if (amouth == null) {
  26. amouth = 0;
  27. }
  28. allattr.push(astationid);
  29. allattr.push(atime);
  30. allattr.push(aupdowntype);
  31. allattr.push(amouth);
  32. var astation = '{' + allattr.join() + '}'
  33. allstation += astation;
  34. }
  35. ;
  36. return allstation;
  37. }
  38. function auto_update_cost(obj) {
  39. var acartype = $(obj).parent().children(".car-item").val();
  40. var car_cost = $(obj).parent().children(".cost-type").val();
  41. var car_supplier = $(obj).parent().children(".supplier-list").val();
  42. if( typeof(base_cost[car_supplier][acartype]) != "undefined" && car_cost == "477" ) {
  43. var cost_price_auto = Math.round(base_cost[car_supplier][acartype] * line_distance);
  44. $(obj).parent().children(".cost_price").val(cost_price_auto);
  45. }
  46. }
  47. function getallcar() {
  48. var allcar = "allcar=";
  49. for (var i = 0; i < $(".car-select").length; i++) {
  50. var allattr = [];
  51. var acartype = $(".car-select").eq(i).children(".car-item").val();
  52. var acarnum = $(".car-select").eq(i).children(".car_number").val();
  53. var acarseat = $(".car-select").eq(i).children(".ifseat").val();
  54. //..品牌
  55. var car_brand = $('.car-select').eq(i).children(".car-brand").val();
  56. var car_supplier = $('.car-select').eq(i).children(".supplier-list").val();
  57. var car_cost = $('.car-select').eq(i).children(".cost-type").val();
  58. var car_cost_price = $('.car-select').eq(i).children(".cost_price").val();
  59. if (!car_brand) {
  60. car_brand = '';
  61. }
  62. if(!/^\d+(\.\d{1,2})?$/.test(car_cost_price)){
  63. alert("请输入价格");
  64. return false;
  65. }
  66. allattr.push(acartype);
  67. allattr.push(acarnum);
  68. allattr.push(acarseat);
  69. allattr.push(car_brand)
  70. allattr.push(car_supplier);
  71. allattr.push(car_cost);
  72. allattr.push(car_cost_price);
  73. var acar = '{' + allattr.join() + '}'
  74. allcar += acar;
  75. }
  76. return allcar;
  77. }
  78. function gettickettype() {
  79. var allticket = "allticket=";
  80. // var starareaid = $(".stararea").eq(0).attr("starareaid");
  81. // var endareaid = $(".endarea").eq(0).attr("endareaid");
  82. //console.log(starareaid)
  83. var judge = false;
  84. for (var i = 0; i < $(".ticket_sel").length; i++) {
  85. if ($(".ticket_sel").eq(i).is(":checked")) {
  86. judge = true;
  87. var index = $(".ticket_sel").eq(i).parent().parent().index();
  88. var allattr = [];
  89. var starareaid = $(".adult").eq(index).children(".stararea").attr("starareaid");
  90. var endareaid = $(".adult").eq(index).children(".endarea").attr("endareaid");
  91. var seatid = $(".adult").eq(index).children(".seatid").attr("seatid");
  92. var crowd = $(".adult").eq(index).children(".crowdid").attr("crowdid");
  93. if (!crowd || crowd == 0) {
  94. crowd = 334;
  95. }
  96. var aticketnum = $(".adult").eq(index).children(".ticketnum").children("input").val();
  97. allattr.push(starareaid);
  98. allattr.push(endareaid);
  99. allattr.push(seatid);
  100. allattr.push(crowd);
  101. //allattr.push(aticketnum);
  102. allattr.push(0);
  103. var aticket = '{' + allattr.join() + '}'
  104. allticket += aticket;
  105. }
  106. }
  107. if (judge == false) {
  108. return false;
  109. }
  110. return allticket
  111. }
  112. $(document).ready(function () {
  113. $(".startime").on("change", function () {
  114. if ($(".startime").val() != '' || $(".endtime").val() != '') {
  115. $(".data-erro").html("");
  116. }
  117. })
  118. $(".endtime").on("change", function () {
  119. if ($(".startime").val() != '' || $(".endtime").val() != '') {
  120. $(".data-erro").html("");
  121. }
  122. })
  123. $(".add-cartype").on("click", function () {
  124. $(".car-erro").html("")
  125. })
  126. // $(".ticket_sel").on("click",function(){
  127. // $(".ticket-erro").html("")
  128. // })
  129. $(".allweek").on("change", function () {
  130. if ($(this)[0].checked) {
  131. $(".aday").each(function () {
  132. this.checked = true;
  133. })
  134. } else {
  135. $(".aday").each(function () {
  136. this.checked = false;
  137. })
  138. }
  139. })
  140. $(".aday").on("change", function () {
  141. $(".allweek")[0].checked = false;
  142. $(".week-erro").html("")
  143. })
  144. $(".line-item").hide();
  145. var ticket1 = $(".adult").outerHTML();
  146. $(".adult").remove();
  147. var ticket2 = $(".noble").outerHTML();
  148. var addcar = $(".car-select").outerHTML();
  149. $(".car-select").remove();
  150. $(".storage").on("click", function () {
  151. var week = getweek();
  152. if ($(".add-line").val() == '') {
  153. $(".addline-erro").html("必填项");
  154. return;
  155. }
  156. ;
  157. if ($(".startime").val() == '' || $(".endtime").val() == '') {
  158. $(".data-erro").html("必填项")
  159. return;
  160. }
  161. ;
  162. if (week == false) {
  163. $(".week-erro").html("必填项");
  164. return;
  165. }
  166. ;
  167. if ($(".car-type").html() == '') {
  168. $(".car-erro").html("必填项");
  169. return;
  170. }
  171. if (gettickettype() == false) {
  172. $(".ticket-erro").html("必填项");
  173. return;
  174. }
  175. ;
  176. var lineid = getval(".add-line", "lineid");
  177. var startime = getval(".startime", "val");
  178. var endtime = getval(".endtime", "val");
  179. var alltime = getalltime();
  180. var allcar = getallcar();
  181. if(allcar == false){
  182. return false;
  183. }
  184. var allticket = gettickettype();
  185. var sellday = getval(".sellday", "val");
  186. var all = getdata(lineid, startime, endtime, week, alltime, allcar, allticket, sellday);
  187. // if(/week=\s+/.test(week)){
  188. // console.log("weektrue");
  189. // }else{
  190. // alert("bitian") ;
  191. // return;
  192. // }
  193. //console.log(week);
  194. //console.log(startime);
  195. //console.log(endtime);
  196. //console.log($(".add-line").html());
  197. //console.log(allcar);
  198. //console.log(allticket);
  199. if ($('.storage').html() == "保存") {
  200. $('.storage').html('保存中...');
  201. console.log('保存的次数');
  202. $.getJSON("st-xm/Api/run_bus_new_save.php?" + all, function (data) {
  203. $('.storage').html('保存');
  204. if (data.code == "0") {
  205. swal({
  206. title: '保存成功',
  207. text: '车次添加成功',
  208. type: 'success',
  209. timer: 10000,
  210. confirmButtonText: 'OK'
  211. }).then(
  212. function () {
  213. location.href = "carList.html";
  214. },
  215. // handling the promise rejection
  216. function (dismiss) {
  217. location.href = "carList.html";
  218. }
  219. )
  220. } else {
  221. swal({
  222. title: '保存失败',
  223. text: data.info,
  224. type: 'error',
  225. confirmButtonText: 'OK'
  226. });
  227. $('.storage').css('display', '');
  228. console.log(all)
  229. }
  230. // if(data.errcode == 0) {
  231. // alert('保存成功!!!');
  232. // location.href = "carList.html";
  233. // } else {
  234. // alert(data.errinfo);
  235. // $('.storage').css('display', '');
  236. // console.log(all)
  237. // }
  238. })
  239. }
  240. //location.href="st-xm/Api/run_bus_new_save.php?"+all;
  241. //$.getJSON("st-xm/Api/run_bus_new_save.php?"+all,function(){
  242. // console.log("st-xm/Api/run_bus_new_save.php?"+all)
  243. //})
  244. })
  245. $('.add-line').on('keyup', function (ev) {
  246. var val = this.value;
  247. $.getJSON("st-xm/Api/addCarTime.php?method=searchline&word=" + val, function (data) {
  248. $(".line-item").show();
  249. var html = [];
  250. $.each(data, function (i, v) {
  251. html.push('<li lineid=' + v.lineid + '>' + v.name + '</li>')
  252. });
  253. $(".line-item").html(html.join(""));
  254. $(".line-item>li").on("click", function () {
  255. $(".addline-erro").html("")
  256. $(".add-cartype").unbind();
  257. var val = $(this).attr("lineid");
  258. $('.add-line').val($(this).html()).attr("lineid", $(this).attr("lineid"));
  259. $(".line-item").html("");
  260. $.getJSON("st-xm/Api/addCarTime.php?method=throughstation&lineid=" + val, function (data) {
  261. console.log(data);
  262. base_cost = data.base_cost;
  263. $(".car-type").html("")
  264. $(".line-item").hide();
  265. var linehtml = [];
  266. var tickethtml = [];
  267. $(".add-cartype").on("click", function () {
  268. $(".car-erro").html("")
  269. var cartype = [];
  270. $.each(data.addcartype, function (i, v) {
  271. var acar = additemall("option", v.cartype, {
  272. "value": v.id
  273. });
  274. cartype.push(acar);
  275. })
  276. var supplier_str = '';
  277. for (var ii = 0; ii < data.supplier_list.length; ii++) {
  278. supplier_str += '<option value="' + data.supplier_list[ii].supplier_id+'">' + data.supplier_list[ii].bus_team+'</option>'
  279. }
  280. var cost_str = '';
  281. for ( ii = 0; ii < data.cost_type.length; ii++) {
  282. cost_str += '<option value="' + data.cost_type[ii].type_id+'">' + data.cost_type[ii].type_name+'</option>'
  283. }
  284. // alert(cost_str);
  285. //var cartype_str = cartype.join()+supplier_str+cost_str;
  286. var acartype = addcar.replace("cartype", cartype.join());
  287. var acartype = acartype.replace("supplier_list", supplier_str);
  288. var acartype = acartype.replace("cost_type", cost_str);
  289. $(".car-type").append(acartype);
  290. $(".car-select .del").unbind();
  291. $(".car-select .del").on("click", function () {
  292. $(this).parent().remove();
  293. });
  294. });
  295. line_distance = 0;
  296. $.each(data.station, function (i, v) {
  297. line_distance += parseInt(v.DISTANCE);
  298. var td1 = addTd(addTime(v.DATE_TIME));
  299. var td2 = additemall("td", v.SITES, {
  300. alineid: v.RES_ID
  301. });
  302. // if(i==0){var td3= addTd('<select style="width: 50px" disabled><option value="108">上</option></select>')}
  303. // else{var td3=addTd(addUpdownType(v.UP_DOWN_TYPE))};
  304. var td3 = addTd(addUpdownType(v.UP_DOWN_TYPE));
  305. var td4 = addTd(addMouth(v.TICKET_GATE, v.CHECKPORT));
  306. linehtml.push(addItem("tr", "aline", td1.concat(td2, td3, td4)))
  307. });
  308. $("#disp_line_distance").html(line_distance+"公里");
  309. $.each(data.ticket, function (i, v) {
  310. if (v.SEAT == "普通座") {
  311. var seatid = 72;
  312. } else if (v.SEAT == "贵宾座") {
  313. var seatid = 73;
  314. } else if (v.SEAT == "儿童特票座") {
  315. var seatid = 74;
  316. }
  317. ;
  318. if (v.CROWD == "成人") {
  319. var crowdid = 159;
  320. } else if (v.CROWD == "儿童") {
  321. var crowdid = 160;
  322. } else if (v.CROWD == "老人") {
  323. var crowdid = 161;
  324. } else if (v.CROWD == "军残") {
  325. var crowdid = 162;
  326. } else {
  327. var crowdid = 0;
  328. }
  329. ;
  330. // if(i==0){
  331. var atciket = ticket1.replace(/SID|EID|START_AREA|END_AREA|SEAT|CROWD|PRICE|MAX_COUNT|PROD_ID|aseatid|acrowdid/g, function (match) {
  332. switch (match) {
  333. case "SID":
  334. return v.SID;
  335. case "EID":
  336. return v.EID;
  337. case "aseatid":
  338. return seatid;
  339. case "acrowdid":
  340. return crowdid;
  341. case "START_AREA":
  342. return v.START_AREA;
  343. case "END_AREA":
  344. return v.END_AREA;
  345. case "SEAT":
  346. return v.SEAT;
  347. case "CROWD":
  348. return v.CROWD;
  349. case "MAX_COUNT":
  350. return v.MAX_COUNT;
  351. case "PROD_ID":
  352. return v.PROD_ID;
  353. case "PRICE":
  354. return v.PRICE;
  355. }
  356. })
  357. tickethtml.push(atciket)
  358. // }else{
  359. // var atciket = ticket1.replace(/SID|EID|START_AREA|END_AREA|SEAT|CROWD|PRICE|MAX_COUNT|PROD_ID|aseatid|acrowdid/g,function(match){
  360. // switch(match){
  361. // case "SID":
  362. // return v.SID;
  363. // case "EID":
  364. // return v.EID;
  365. // case "aseatid":
  366. // return seatid;
  367. // case "acrowdid":
  368. // return crowdid;
  369. // case "START_AREA":
  370. // return "";
  371. // case "END_AREA":
  372. // return "";
  373. // case "SEAT":
  374. // return v.SEAT;
  375. // case "CROWD":
  376. // return v.CROWD;
  377. // case "MAX_COUNT":
  378. // return v.MAX_COUNT;
  379. // case "PROD_ID":
  380. // return v.PROD_ID;
  381. // case "PRICE":
  382. // return v.PRICE;
  383. // }
  384. // })
  385. // tickethtml.push(atciket)
  386. // }
  387. });
  388. $(".replace-lineinfo").html(linehtml).attr("lineid", data.station[1].PROD_ID);
  389. $(".able-ticket").html(tickethtml.join());
  390. $(".ticket_sel").on("click", function () {
  391. $(".ticket-erro").html("");
  392. })
  393. var hourinfo = [];
  394. $.each($('.hour'), function (i, v) {
  395. var val = $('.hour').eq(i).val()
  396. if (val < 10) {
  397. val = "0" + val;
  398. }
  399. var arr = [i, val]
  400. hourinfo.push(arr)
  401. })
  402. var minuteinfo = [];
  403. $.each($('.minute'), function (i, v) {
  404. var val = $('.minute').eq(i).val()
  405. if (val < 10) {
  406. val = "0" + val;
  407. }
  408. var arr = [i, val]
  409. minuteinfo.push(arr)
  410. })
  411. $(".hour").on("change", function () {
  412. var index = $(this).parent().parent().index();
  413. var max = $(".hour").length;
  414. var dangvalue = $(this).val();
  415. console.log("index:" + index + ";max:" + max + ";dangvalue:" + dangvalue);
  416. console.log("hourinfo:" + hourinfo + ";dangvalue" + dangvalue);
  417. for (var i = 0; i < hourinfo.length; i++) {
  418. if (index == hourinfo[i][0]) {
  419. var nextindex = hourinfo[i][0] + 1;
  420. var myaddvalue = dangvalue - hourinfo[i][1];
  421. for (var t = nextindex; t < max; t++) {
  422. var myvalue = hourinfo[t][1];
  423. var addvalue = myaddvalue + parseInt(myvalue);
  424. console.log("myvalue:" + myvalue + ";addvalue:" + addvalue);
  425. if (addvalue > 23) {
  426. addvalue -= 24
  427. console.log("addvalue:" + addvalue);
  428. } else if (addvalue < 0) {
  429. addvalue += 24
  430. }
  431. // $(".hour").eq(t).find("option").removeAttr("selected");
  432. $(".hour").eq(t).val(addvalue);
  433. hourinfo[t][1] = addvalue;
  434. }
  435. // if(myaddvalue<0){
  436. // hourinfo[i][1]=myaddvalue;
  437. // }else{
  438. // for(var t = nextindex;t<max;t++){
  439. //
  440. // var myvalue = hourinfo[t][1];
  441. // var addvalue = myaddvalue+parseInt(myvalue);
  442. //
  443. // if(addvalue>23){addvalue-=24}{
  444. // $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addvalue).attr("selected","true")
  445. //
  446. // hourinfo[t][1]=addvalue;
  447. // }
  448. // }
  449. // }
  450. }
  451. }
  452. hourinfo[index][1] = dangvalue;
  453. })
  454. $(".minute").on("change", function () {
  455. var index = $(this).parent().parent().index();
  456. var max = $(".minute").length;
  457. var dangvalue = parseInt($(this).val());
  458. for (var i = 0; i < minuteinfo.length; i++) {
  459. if (index == minuteinfo[i][0]) {
  460. var nextindex = parseInt(minuteinfo[i][0]) + 1;
  461. var addnum = dangvalue - parseInt(minuteinfo[i][1]);
  462. for (var t = nextindex; t < max; t++) {
  463. var myhourvalue = hourinfo[t][1];
  464. var myminutevalue = minuteinfo[t][1];
  465. var addvalue = addnum + parseInt(myminutevalue);
  466. if (addvalue >= 60) {
  467. addvalue -= 60;
  468. addhour = parseInt(hourinfo[t][1]) + 1;
  469. } else if (addvalue <= 0) {
  470. addvalue += 60;
  471. addhour = parseInt(hourinfo[t][1]) - 1;
  472. } else {
  473. addhour = "100";
  474. }
  475. if (addhour == "100") {
  476. //$(".minute").eq(t).find("option").removeAttr("selected");
  477. $(".minute").eq(t).val(addvalue);
  478. minuteinfo[t][1] = addvalue;
  479. } else {
  480. // $(".minute").eq(t).find("option").removeAttr("selected");
  481. $(".minute").eq(t).val(addvalue);
  482. minuteinfo[t][1] = addvalue;
  483. // $(".hour").eq(t).find("option").removeAttr("selected");
  484. $(".hour").eq(t).val(addhour);
  485. hourinfo[t][1] = addhour;
  486. }
  487. }
  488. // if(addnum<0){
  489. // minuteinfo[i][1]=addnum
  490. // }
  491. // else{
  492. // for(var t = nextindex;t<max;t++){
  493. // var myhourvalue = hourinfo[t][1];
  494. // var myminutevalue = minuteinfo[t][1];
  495. //
  496. // var addvalue = addnum+parseInt(myminutevalue);
  497. //
  498. // if(addvalue>=60){addvalue-=60; var addhour = parseInt(hourinfo[t][1])+1;}
  499. // if(typeof addhour=="undefined"){
  500. // $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true")
  501. // minuteinfo[t][1]=addvalue;
  502. // }else{
  503. // $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true")
  504. // minuteinfo[t][1]=addvalue;
  505. //
  506. // $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addhour).attr("selected","true");
  507. // hourinfo[t][1]=addhour;
  508. // }
  509. // }
  510. // }
  511. }
  512. }
  513. minuteinfo[index][1] = dangvalue;
  514. })
  515. })
  516. })
  517. })
  518. });
  519. $('.date-picker').datepicker({
  520. autoclose: true
  521. }).next().on('click', function () {
  522. $(this).prev().focus();
  523. });
  524. $('.allweek').on('change', function () {
  525. if ($(this).is(":checked")) {
  526. for (var i = 0; i < $(".week").length; i++) {
  527. $(".week").eq(i).click()
  528. }
  529. } else {
  530. for (var i = 0; i < $(".week").length; i++) {
  531. $(".week").eq(i).removeAttr("checked");
  532. }
  533. }
  534. })
  535. // $(".storage").on("click",function(){
  536. // var lineid = 'lineid='+$(".add-line").attr('dataid');
  537. // var time = 'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val();
  538. // var pass = [];
  539. // (function(){
  540. // var line =[];
  541. // for(var i = 0;i<$(".aline").length;i++){
  542. // var aline = [];
  543. // aline.push("time="+$(".aline").eq(i).find(".hour").val()+":"+$(".aline").eq(i).find(".minute").val());
  544. // aline.push("site="+$(".aline").find("td").eq(1).html());
  545. // aline.push("updown="+$(".aline").find(".updown").val());
  546. // aline.push("mouth="+$(".aline").find(".mouth").val());
  547. // line.push(aline.join(""));
  548. // }
  549. // })()
  550. // url = 'lineid='+$(".add-line").attr('dataid')+'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val()
  551. // console.log(url)
  552. // })
  553. })
  554. function addItem(label, classname, cent) {
  555. var html = ['<' + label + ' class=' + classname + '>'];
  556. html.push(cent);
  557. html.push('</' + label + '>');
  558. return html.join("")
  559. }
  560. function addLi(html) {
  561. var li = ['<li>'];
  562. li.push(html);
  563. li.push('</li>');
  564. li = li.join("");
  565. return li
  566. }
  567. function addTime(time) {
  568. var time = time.split(":");
  569. var newHour = parseInt(time[0]),
  570. newMinute = parseInt(time[1]);
  571. var html = ['<select class="hour">'];
  572. for (var i = 0; i < 24; i++) {
  573. if (i == newHour) {
  574. //..a
  575. if (i < 10) {
  576. html.push('<option selected value=' + i + '>0' + i + '</option>')
  577. } else {
  578. html.push('<option selected value=' + i + '>' + i + '</option>')
  579. }
  580. } else {
  581. if (i < 10) {
  582. html.push('<option value=' + i + '>0' + i + '</option>')
  583. } else {
  584. html.push('<option value=' + i + '>' + i + '</option>')
  585. }
  586. }
  587. }
  588. html.push('</select style="width: 50px">:<select class="minute">')
  589. for (var t = 0; t < 60; t++) {
  590. if (t == newMinute) {
  591. if (t < 10) {
  592. html.push('<option selected value=' + t + '>0' + t + '</option>')
  593. } else {
  594. html.push('<option selected value=' + t + '>' + t + '</option>')
  595. }
  596. } else {
  597. if (t < 10) {
  598. html.push('<option value=' + t + '>0' + t + '</option>')
  599. } else {
  600. html.push('<option value=' + t + '>' + t + '</option>')
  601. }
  602. }
  603. }
  604. html.push('</select>');
  605. html = html.join("")
  606. return html
  607. }
  608. function addUpdownType(type) {
  609. var typeid = null;
  610. var alltypeid = [108, 109, 110, 114]
  611. if (type == 108) {
  612. typeid = "仅上客"
  613. } else if (type == 109) {
  614. typeid = "同时上下客"
  615. } else if (type == 110) {
  616. typeid = "仅下客"
  617. } else if (type == 114) {
  618. typeid = "不停靠"
  619. }
  620. var html = ['<select style="width: 100px" class="updown">'],
  621. alltype = ['仅上客', '同时上下客', '仅下客', '不停靠']
  622. for (var i = 0; i < 4; i++) {
  623. if (typeid == alltype[i]) {
  624. html.push('<option selected value=' + alltypeid[i] + '>' + alltype[i] + '</option>')
  625. } else {
  626. html.push('<option value = ' + alltypeid[i] + '>' + alltype[i] + '</option>')
  627. }
  628. }
  629. html.push('</select>');
  630. html = html.join("")
  631. return html
  632. }
  633. function addMouth(maxNum, num) {
  634. var html = ['<select style="width: 55px" class="mouth">'];
  635. for (var i in maxNum) {
  636. if (i == num) {
  637. html.push('<option selected value = ' + i + '>' + maxNum[i] + '</option>')
  638. // html.push('<option selected value = '+i+'>-</option>')
  639. } else {
  640. html.push('<option value=' + i + '>' + maxNum[i] + '</option>')
  641. }
  642. }
  643. ;
  644. html.push("</select>");
  645. if (maxNum <= 0) {
  646. html = ['-'];
  647. }
  648. html = html.join("")
  649. return html;
  650. }
  651. function addTd(html) {
  652. var td = ['<td>'];
  653. td.push(html);
  654. td.push('</td>');
  655. td = td.join("")
  656. return td;
  657. }
  658. function addTr(html) {
  659. var tr = ['<tr>'];
  660. tr.push(html)
  661. tr.push('</tr>');
  662. tr = tr.join("")
  663. return tr;
  664. }
  665. jQuery.fn.outerHTML = function (s) {
  666. return (s) ? this.before(s).remove() : $("<Hill_man>").append(this.eq(0).clone()).html();
  667. }
  668. function additemall(lable, cen, attr) {
  669. var html = ['<' + lable + ' ' + (function (attr) {
  670. if (typeof(attr) == "undefined") {
  671. return ""
  672. } else {
  673. var arr = [];
  674. for (i in attr) {
  675. arr.push(i + '="' + attr[i] + '"')
  676. }
  677. ;
  678. return arr.join(" ")
  679. }
  680. })(attr) + '>'];
  681. html.push(cen);
  682. html.push('</' + lable + '>');
  683. return html.join("")
  684. }
  685. function getdata() {
  686. var val = [];
  687. Array.prototype.push.apply(val, arguments);
  688. return val.join("&");
  689. }
  690. function getval(dom, value) {
  691. var val = null;
  692. if (value == "val" || value == "value") {
  693. val = $(dom).eq(0).val()
  694. } else if (value == "html") {
  695. val = $(dom).eq(0).html()
  696. } else {
  697. val = $(dom).eq(0).attr(value);
  698. var name = value;
  699. return name + "=" + val;
  700. }
  701. var name = $(dom).eq(0).attr("name");
  702. return name + "=" + val
  703. }
  704. function out_login() {
  705. window.location = 'login.html';
  706. }