|
- var car_no = 0;
- var have_car_no = 0; //已有有的车号
- var line_distance = 0;
- var base_cost = [];
- function getweek() {
- var week = "week=";
- for (var i = 1; i < $(".weeklist input").length; i++) {
- if ($(".weeklist input").eq(i).is(":checked")) {
- week += $(".weeklist input").eq(i).val()
- }
- }
- return week
- }
-
- function getalltime() {
- var allstation = "allstation=";
- for (var i = 0; i < $(".replace-lineinfo tr").length; i++) {
- var allattr = [];
- 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());
- var astationid = $(".replace-lineinfo tr").eq(i).children("td:eq(1)").attr("alineid");
- var aupdowntype = $(".replace-lineinfo tr").eq(i).children("td:eq(2)").children("select").val();
- var amouth = $(".replace-lineinfo tr").eq(i).children("td:eq(3)").children("select").val();
- if (amouth == null) {
- amouth = 0;
- }
- allattr.push(astationid);
- allattr.push(atime);
- allattr.push(aupdowntype);
- allattr.push(amouth);
- var astation = '{' + allattr.join() + '}'
- allstation += astation;
- }
- ;
- return allstation;
- }
-
- function getallcar() {
- var allcar = "allcar=";
- for (var i = 0; i < $(".car-select").length; i++) {
- var allattr = [];
-
- var acartype = $(".car-select").eq(i).children(".car-item").val();
- //TODO 发现:已有的车号保持不变,新增的都是0。。7-29待确认 已改,测试中
- // 经发现,使用html()谷歌浏览器自动翻译后自动在<i></i>里面添加<font></font>标签导致参数错误,故改成text()
- // var acarnum =acarnum=$(".car-select").eq(i).children("i").html();
- var acarnum = acarnum = $(".car-select").eq(i).children("i").text();
- // if(have_car_no-1<i){
- // acarnum='0';
- // }
- if (acarnum > have_car_no) {
- acarnum = '0';
- }
- // acarnum='0';
- var acarseat = $(".car-select").eq(i).children(".ifseat").val();
-
- //..品牌
- var car_brand = $('.car-select').eq(i).children(".car-brand").val();
-
- if (!car_brand) {
- car_brand = 288;
- }
- var car_supplier = $('.car-select').eq(i).children(".supplier-list").val();
- var car_cost = $('.car-select').eq(i).children(".cost-type").val();
- var car_cost_price = $('.car-select').eq(i).children(".cost_price").val();
- var send_bus_res_id = $('.car-select').eq(i).children(".supplier-list").attr('data-send-bus-res-id');
- var send_bus_res_json = '';
- if (send_bus_res_id != 0) {
- send_bus_res_json = getJsonHtml(send_bus_res_id);
- }
-
- if (!/^\d+(\.\d{1,2})?$/.test(car_cost_price)) {
- alert("请输入价格");
- return false;
- }
- 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))){
- alert("已经派车的车次不能进行数据修改,请联系管理员");
- return false;
- }
- allattr.push(acarnum);
- allattr.push(acartype);
- allattr.push(acarseat);
- allattr.push(car_brand);
- allattr.push(car_supplier);
- allattr.push(car_cost);
- allattr.push(car_cost_price);
-
- var acar = '{' + allattr.join() + '}'
- allcar += acar;
- }
- return allcar;
- }
-
- function gettickettype() {
- var allticket = "allticket=";
- // var starareaid = $(".stararea").eq(0).attr("starareaid");
- // var endareaid = $(".endarea").eq(0).attr("endareaid");
-
- //console.log(starareaid)
- var judge = false;
- for (var i = 0; i < $(".ticket_sel").length; i++) {
- if ($(".ticket_sel").eq(i).is(":checked")) {
- judge = true;
- var index = $(".ticket_sel").eq(i).parent().parent().index();
-
- var allattr = [];
- var starareaid = $(".adult").eq(index).children(".stararea").attr("starareaid");
- var endareaid = $(".adult").eq(index).children(".endarea").attr("endareaid");
-
- var seatid = $(".adult").eq(index).children(".seatid").attr("seatid");
- var crowd = $(".adult").eq(index).children(".crowdid").attr("crowdid");
- var aticketnum = $(".adult").eq(index).children(".ticketnum").children("input").val();
- if (!aticketnum) {
- aticketnum = 0;
- }
-
- allattr.push(starareaid);
- allattr.push(endareaid);
- allattr.push(seatid);
- allattr.push(crowd);
- allattr.push(aticketnum);
-
- var aticket = '{' + allattr.join() + '}'
- allticket += aticket;
- }
- }
- if (judge == false) {
- return false;
- }
-
- return allticket
- }
-
- function addweek(week) {
- for (var i = 0; i < week.length; i++) {
- var day = week.slice(i, i + 1)
- console.log(day)
- for (var n = 0; n < $(".aday").length; n++) {
- if (day == $(".aday").eq(n).val()) {
- $(".aday").eq(n).attr("checked", "true")
- }
- }
-
- }
-
- }
-
- function havecar(car) {
- console.log(123456)
-
- }
-
- function auto_update_cost(obj) {
- var acartype = $(obj).parent().children(".car-item").val();
- var car_cost = $(obj).parent().children(".cost-type").val();
- var car_supplier = $(obj).parent().children(".supplier-list").val();
- if (typeof(base_cost[car_supplier][acartype]) != "undefined" && car_cost == "477") {
- var cost_price_auto = Math.round(base_cost[car_supplier][acartype] * line_distance);
- $(obj).parent().children(".cost_price").val(cost_price_auto);
- }
- }
-
- $(document).ready(function () {
-
- $(".startime").on("change", function () {
- $(".data-erro").html("")
- })
- $('.date-picker').datepicker({
- autoclose: true
- }).next().on('click', function () {
- $(this).prev().focus();
- });
-
- var addcar = $(".car-select").outerHTML();
- var ticket2 = $(".noble").outerHTML();
- var addcar = $(".car-select").outerHTML();
- //$(".car-select").remove();
-
- $(".storage").on("click", function () {
-
- if ($('.storage').html() != "保存") {
- return;
- }
- console.log('保存次数');
- $('.storage').html('保存中...');
- //var week = getweek ();
-
- // if($(".add-line").val()==''){
-
- // $(".addline-erro").html("必填项");
- // return;
- // };
-
- if ($(".startime").val() == '') {
- $(".data-erro").html("必填项")
-
- return;
- }
- ;
- // if(week==false){
- // $(".week-erro").html("必填项");
- // return;
- // };
-
- if ($(".car-type").html() == '') {
- $(".car-erro").html("必填项");
- return;
- }
- ;
-
- if (gettickettype() == false) {
- $(".ticket-erro").html("以上票种必须选中一个");
-
- return;
- }
- ;
-
- //var lineid = getval(".add-line","runid");
- var id = runid;
- var startime = getval(".startime", "val");
- //var endtime = getval(".endtime","val");
-
- var alltime = getalltime();
- var allcar = getallcar();
- if (allcar == false) {
- return false;
- }
- var allticket = gettickettype();
- var sellday = getval(".sellday", "val");
- var all = getdata(id, startime, alltime, allcar, allticket, sellday);
- console.log(all);
-
- // $.getJSON("./st-xm/Api/run_bus_update.php?" + all, function (data) {
- // if (data.errcode == 0) {
- // window.location.href = "./carList.html";
- // } else {
- // alert(data.errinfo);
- // $('.storage').html('保存');
- // }
- // })
- $.ajax({
- url: "./st-xm/Api/run_bus_update.php?" + all,
- type: 'get',
- dataType: 'json',
- success: function (data) {
- if (data.code == '0') {
- swal({
- title: '修改成功',
- type: 'success',
- timer: 20000,
- confirmButtonText: 'OK'
- }).then(
- function () { window.location.href = "./carList.html"; },
- function (dismiss) {
- window.location.href = "./carList.html";
- }
- )
- } else {
- swal(
- '修改失败',
- data.info,
- 'error'
- );
- $('.storage').html('保存');
- }
- },
- error: function (e) {
- console.log(e);
- }
- })
- // if(/week=\s+/.test(week)){
- // console.log("weektrue");
- // }else{
- // alert("bitian") ;
- // return;
- // }
-
- //console.log(week);
- //console.log(startime);
- //console.log(endtime);
- //console.log($(".add-line").html());
- //console.log(allcar);
- //console.log(allticket);
-
- //location.href="st-xm/Api/run_bus_new_save.php?"+all;
-
- })
-
- // alert(1)
- var runid = 'runid=' + window.location.search.replace(/[^0-9]/ig, "")
- var url = './st-xm/Api/runEditControll.php?method=getRunInfo&user_id=1&run_id=' + window.location.search.replace(/[^0-9]/ig, "");
- $.getJSON(url, function (data) {
- console.log(url);
- console.log(data)
- $('.addtime').css('display', 'block');
- base_cost = data.base_cost;
- var ticket1 = $(".adult").outerHTML();
- $(".adult").remove();
- var linehtml = $(".add-line").outerHTML();
- $(".add-line").remove();
- $(".sellday").val(data.sellday)
-
- if (data.line) {
- var linename = linehtml.replace(/linename|alineid/g, function (match) {
- switch (match) {
- case "linename":
- return data.line.name;
- case "alineid":
- return data.line.lineid;
- }
- });
- $(".replaceline").append(linename)
- }
-
- $(".startime").val(data.time)
-
- //addweek(data.week);
-
- // $.each(data.hascartype,function(i,v){
- // var cartype = [];
- // $.each(v,function(i,v){
- // if(v.sel==1){
- // var acar = additemall("option",v.cartype,{"value":v.id,selected:"true"})
- // }else{
- // var acar = additemall("option",v.cartype,{"value":v.id})
- // }
-
- // cartype.push(acar)
- // })
- // var acartype = addcar.replace("cartype",cartype.join());
- // $(".car-type").append(acartype);
-
- // });
- var allcartype = $(".car-item").outerHTML();
- var ahtml = [];
- $.each(data.hascar, function (i, v) {
- car_no = v.carnum; //保存当前车号
- var acar = addcar.replace(/num|cartype|supplier_list|cost_type|cost-price|selseat|del|删除/g, function (match) {
- switch (match) {
- case "num":
- have_car_no = v.carnum; //将已有的最大车号保存起来 update by fuhc 2016-07-28
- return v.carnum;
- case "cartype":
- return (function (seat, id) {
-
- var html = [];
- $.each(seat, function (i, v) {
- if (id == v.id) {
- var str = "<option selected value = " + v.id + ">" + v.cartype + "</option>"
- }
- // else{
- // var str = "<option value = "+v.id+">"+v.cartype+"</option>"
- // }
- html.push(str);
- })
- return html.join("");
- })(data.cartype, v.id);
- case "supplier_list":
- var str = '';
- for (var i = 0; i < data.supplier_list.length; i++) {
- if (v.cost_motorcade_id == data.supplier_list[i].supplier_id) {
- str += "<option selected value = " + data.supplier_list[i].supplier_id + ">" + data.supplier_list[i].bus_team + "</option>";
- } else {
- str += "<option value = " + data.supplier_list[i].supplier_id + ">" + data.supplier_list[i].bus_team + "</option>";
- }
- }
- if (v.send_bus_res_id == 0) {
- str = '<select class="supplier-list" data-send-bus-res-id="0" onchange="auto_update_cost(this)" >' + str + '</select>';
- } else {
- str = '<select class="supplier-list" data-send-bus-res-id="' + setJsonHtml(v) + '" onchange="auto_update_cost(this)" disabled>' + str + '</select>';
- }
-
-
- return str;
- case "cost_type":
- var str = '';
- for (var i = 0; i < data.cost_type.length; i++) {
- if (v.cost_type == data.cost_type[i].type_id) {
- str += "<option selected value = " + data.cost_type[i].type_id + ">" + data.cost_type[i].type_name + "</option>";
- } else {
- str += "<option value = " + data.cost_type[i].type_id + ">" + data.cost_type[i].type_name + "</option>";
- }
- }
- if (v.send_bus_res_id == 0) {
- str = '<select class="cost-type" onchange="auto_update_cost(this)" >' + str + '</select>';
- } else {
- str = '<select class="cost-type" onchange="auto_update_cost(this)" disabled>' + str + '</select>';
- }
- return str;
- case "cost-price":
- var str = '<input class="cost_price" type="text" value="' + v.cost_price + '">元';
- if (v.send_bus_res_id != 0) {
- str = '<input class="cost_price" type="text" value="' + v.cost_price + '" readonly>元';
- }
- return str;
- case "selseat":
- return v.selectseat == "156" ? "<option value='156' selected>可选</option><option value='157'>不可选</option>" : "<option value='156'>可选</option><option value='157' selected>不可选</option>"
- case "del":
- return "";
- case "删除":
- return "";
- }
- })
- ahtml.push(acar);
- });
- $(".car-type").html(ahtml.join(""));
-
- $(".car-select .del").on("click", function () {
- $(this).parent().remove();
- });
-
- var linehtml = [];
-
- var tickethtml = [];
-
- $(".add-cartype").on("click", function () {
- //将车号++
- car_no++;
- $("car-erro").html("");
- var cartype = [];
- //artype.push("<i>0</i>");
- $.each(data.cartype, function (i, v) {
- var acar = additemall("option", v.cartype, {
- "value": v.id
- })
- cartype.push(acar)
- })
- //artype.push("<option value='156' selected>可选</option><option value='157'>不可选</option>");
-
- var acartype = addcar.replace(/cartype|supplier_list|cost_type|cost-price|num|selseat/g, function (match) {
- switch (match) {
- case "cartype":
- return cartype.join("");
- case "num":
- // 先保证能添加车辆 返回0
- // return "0";
- return car_no;
- case "supplier_list":
- var str = '';
- for (var i = 0; i < data.supplier_list.length; i++) {
- str += "<option value = " + data.supplier_list[i].supplier_id + ">" + data.supplier_list[i].bus_team + "</option>";
- }
- str = '<select class="supplier-list" data-send-bus-res-id="0" onchange="auto_update_cost(this)">' + str + '</select>';
- return str;
- case "cost_type":
- var str = '';
- for (var i = 0; i < data.cost_type.length; i++) {
- str += "<option value = " + data.cost_type[i].type_id + ">" + data.cost_type[i].type_name + "</option>";
- }
- str = '<select class="cost-type" onchange="auto_update_cost(this)" >' + str + '</select>';
- return str;
- case "cost-price":
- var str = '<input class="cost_price" type="text" value="0">元';
- return str;
- case "selseat":
- return "<option value='156' selected>可选</option><option value='157'>不可选</option>";
- }
- ;
- });
- var tmp = acartype.replace(/disabled/g, "");
- console.log(tmp);
- $(".car-type").append(tmp);
-
- $(".car-select .del").unbind();
- $(".car-select .del").on("click", function () {
- $(this).parent().remove();
- });
-
- })
- line_distance = data.line_distance;
- $("#disp_line_distance").html(line_distance + "公里");
- $.each(data.station, function (i, v) {
- var td1 = addTd(addTime(v.DATE_TIME));
- var td2 = additemall("td", v.SITES, {
- alineid: v.STATION_RES_ID
- });
-
- // if(i==0){var td3= addTd('<select style="width: 50px" disabled><option value="108">上</option></select>')}
- // else{var td3=addTd(addUpdownType(v.UP_DOWN_TYPE))};
- var td3 = addTd(addUpdownType(v.UP_DOWN_TYPE));
- var td4 = addTd(addMouth(v.TICKET_GATE, v.CHECKPORT));
- linehtml.push(addItem("tr", "aline", td1.concat(td2, td3, td4)))
- })
-
- $.each(data.ticket, function (i, v) {
- if (v.SEAT == "普通座") {
- var seatid = 72;
- } else if (v.SEAT == "贵宾座") {
- var seatid = 73;
- } else if (v.SEAT == "儿童特票座") {
- var seatid = 74;
- }
- ;
- if (v.CROWD == "成人") {
- var crowdid = 159;
- } else if (v.CROWD == "儿童") {
- var crowdid = 160;
- } else if (v.CROWD == "老人") {
- var crowdid = 161;
- } else if (v.CROWD == "军残") {
- var crowdid = 162;
- } else {
- var crowdid = 0;
- }
- ;
-
- //var html = [];
-
- var atciket = ticket1.replace(/checked="checked"|SID|EID|START_AREA|END_AREA|SEAT|CROWD|PRICE|MAX_COUNT|PROD_ID|aseatid|acrowdid/g, function (match) {
- switch (match) {
- case 'checked="checked"':
- return v.sel == 1 ? 'checked="checked"' : "";
- case "SID":
- return v.SID;
- case "EID":
- return v.EID;
- case "aseatid":
- return seatid;
- case "acrowdid":
- return crowdid;
- case "START_AREA":
- return v.START_AREA;
- case "END_AREA":
- return v.END_AREA;
- case "SEAT":
- return v.SEAT;
- case "CROWD":
- return v.CROWD;
- case "MAX_COUNT":
- return v.MAX_COUNT;
- case "PROD_ID":
- return v.PROD_ID;
- case "PRICE":
- return v.PRICE;
- }
- })
-
- tickethtml.push(atciket)
-
- })
-
- $(".replace-lineinfo").html(linehtml).attr("lineid", data.station[1].PROD_ID);
-
- $(".able-ticket").html(tickethtml.join());
-
- $(".ticket_sel").on("click", function () {
- $(".ticket-erro").html("");
- })
-
- var hourinfo = [];
- $.each($('.hour'), function (i, v) {
- var val = $('.hour').eq(i).val();
- if (val < 10) {
-
- val = "0" + val;
- }
- var arr = [i, val]
- hourinfo.push(arr)
- })
- var minuteinfo = [];
- $.each($('.minute'), function (i, v) {
- var val = $('.minute').eq(i).val()
- if (val < 10) {
-
- val = "0" + val;
- }
- var arr = [i, val]
- minuteinfo.push(arr)
- })
-
- $(".hour").on("change", function () {
- var index = $(this).parent().parent().index();
- var max = $(".hour").length;
- var dangvalue = $(this).val();
-
- for (var i = 0; i < hourinfo.length; i++) {
- if (index == hourinfo[i][0]) { //获得下标
- var nextindex = hourinfo[i][0] + 1;
- var myaddvalue = dangvalue - hourinfo[i][1];
- console.log('myaddvalue=====' + myaddvalue);
- for (var t = nextindex; t < max; t++) {
- var myvalue = hourinfo[t][1]; //获得下一个input值
- var addvalue = myaddvalue + parseInt(myvalue);
-
- if (addvalue > 23) {
- addvalue -= 24
- }
- {
- $(".hour").eq(t).find("option").removeAttr("selected");
- $(".hour").eq(t).find("option").eq(addvalue).attr("selected", "true")
-
- hourinfo[t][1] = addvalue;
- }
-
- }
- // if(myaddvalue<0){
- // hourinfo[i][1]=myaddvalue;
- // }else{
- // for(var t = nextindex;t<max;t++){
- // var myvalue = hourinfo[t][1];//获得下一个input值
- // var addvalue = myaddvalue+parseInt(myvalue);
- //
- // if(addvalue>23){addvalue-=24}{
- // $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addvalue).attr("selected","true")
- //
- // hourinfo[t][1]=addvalue;
- // }
- //
- // }
- // }
- }
-
- }
- hourinfo[index][1] = dangvalue;
-
- })
-
- $(".minute").on("change", function () {
- var index = $(this).parent().parent().index();
- var max = $(".minute").length;
- var dangvalue = parseInt($(this).val());
-
- for (var i = 0; i < minuteinfo.length; i++) {
- if (index == minuteinfo[i][0]) { //获得下标
- var nextindex = parseInt(minuteinfo[i][0]) + 1;
- var addnum = dangvalue - parseInt(minuteinfo[i][1]);
- for (var t = nextindex; t < max; t++) {
- var myhourvalue = hourinfo[t][1];
- var myminutevalue = minuteinfo[t][1];
-
- var addvalue = addnum + parseInt(myminutevalue);
-
- if (addvalue >= 60) {
- addvalue -= 60;
- var addhour = parseInt(hourinfo[t][1]) + 1;
- }
- if (typeof addhour == "undefined") {
- $(".minute").eq(t).find("option").removeAttr("selected");
- $(".minute").eq(t).find("option").eq(addvalue).attr("selected", "true")
-
- minuteinfo[t][1] = addvalue;
-
- } else {
- $(".minute").eq(t).find("option").removeAttr("selected");
- $(".minute").eq(t).find("option").eq(addvalue).attr("selected", "true")
-
- minuteinfo[t][1] = addvalue;
-
- $(".hour").eq(t).find("option").removeAttr("selected");
- $(".hour").eq(t).find("option").eq(addhour).attr("selected", "true");
- hourinfo[t][1] = addhour;
- }
- }
- // if(addnum<0){minuteinfo[i][1]=addnum}
- // else{
- // for(var t = nextindex;t<max;t++){
- // var myhourvalue = hourinfo[t][1];
- // var myminutevalue = minuteinfo[t][1];
- //
- // var addvalue = addnum+parseInt(myminutevalue);
- //
- // if(addvalue>=60){addvalue-=60; var addhour = parseInt(hourinfo[t][1])+1;}
- // if(typeof addhour=="undefined"){
- // $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true")
- //
- // minuteinfo[t][1]=addvalue;
- //
- //
- // }else{
- // $(".minute").eq(t).find("option").removeAttr("selected");$(".minute").eq(t).find("option").eq(addvalue).attr("selected","true")
- //
- // minuteinfo[t][1]=addvalue;
- //
- // $(".hour").eq(t).find("option").removeAttr("selected");$(".hour").eq(t).find("option").eq(addhour).attr("selected","true");
- // hourinfo[t][1]=addhour;
- // }
- // }
- // }
-
- }
- }
- minuteinfo[index][1] = dangvalue;
- })
- })
-
- $('.date-picker').datepicker({
- autoclose: true
- });
-
- $('.allweek').on('change', function () {
-
- if ($(this).is(":checked")) {
- for (var i = 0; i < $(".week").length; i++) {
- $(".week").eq(i).click()
- }
- } else {
- for (var i = 0; i < $(".week").length; i++) {
- $(".week").eq(i).removeAttr("checked");
- }
- }
- })
-
- // $(".storage").on("click",function(){
- // var lineid = 'lineid='+$(".add-line").attr('dataid');
- // var time = 'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val();
- // var pass = [];
- // (function(){
- // var line =[];
- // for(var i = 0;i<$(".aline").length;i++){
- // var aline = [];
-
- // aline.push("time="+$(".aline").eq(i).find(".hour").val()+":"+$(".aline").eq(i).find(".minute").val());
- // aline.push("site="+$(".aline").find("td").eq(1).html());
- // aline.push("updown="+$(".aline").find(".updown").val());
- // aline.push("mouth="+$(".aline").find(".mouth").val());
- // line.push(aline.join(""));
-
- // }
-
- // })()
-
- // url = 'lineid='+$(".add-line").attr('dataid')+'time='+$("#id-date-picker-1").val()+'-'+$("#id-date-picker-2").val()
-
- // })
-
- })
-
- function addItem(label, classname, cent) {
-
- var html = ['<' + label + ' class=' + classname + '>'];
- html.push(cent);
- html.push('</' + label + '>');
-
- return html.join("")
-
- }
-
- function addLi(html) {
- var li = ['<li>'];
- li.push(html);
- li.push('</li>');
- li = li.join("");
- return li
- }
-
- function addTime(time) {
- var time = time.split(":");
- var newHour = parseInt(time[0]),
- newMinute = parseInt(time[1]);
- var html = ['<select class="hour">'];
- for (var i = 0; i < 24; i++) {
- if (i == newHour) {
- if (i < 10) {
- html.push('<option selected value=' + i + '>0' + i + '</option>')
- } else {
- html.push('<option selected value=' + i + '>' + i + '</option>')
- }
- } else {
- if (i < 10) {
- html.push('<option value=' + i + '>0' + i + '</option>')
- } else {
- html.push('<option value=' + i + '>' + i + '</option>')
- }
- }
- }
- html.push('</select style="width: 50px">:<select class="minute">')
- for (var t = 0; t < 60; t++) {
- if (t == newMinute) {
- if (t < 10) {
- html.push('<option selected value=' + t + '>0' + t + '</option>')
- } else {
- html.push('<option selected value=' + t + '>' + t + '</option>')
- }
- } else {
- if (t < 10) {
- html.push('<option value=' + t + '>0' + t + '</option>')
- } else {
- html.push('<option value=' + t + '>' + t + '</option>')
- }
- }
- }
- html.push('</select>');
- html = html.join("")
- return html
- }
-
- function addUpdownType(type) {
- var typeid = null;
- var alltypeid = [108, 109, 110, 114]
- if (type == 108) {
- typeid = "仅上客"
- } else if (type == 109) {
- typeid = "同时上下客"
- } else if (type == 110) {
- typeid = "仅下客"
- } else if (type == 114) {
- typeid = "不停靠"
- }
- var html = ['<select style="width: 100px" class="updown">'],
- alltype = ['仅上客', '同时上下客', '仅下客', '不停靠']
- for (var i = 0; i < 4; i++) {
- if (typeid == alltype[i]) {
- html.push('<option selected value=' + alltypeid[i] + '>' + alltype[i] + '</option>')
- } else {
- html.push('<option value = ' + alltypeid[i] + '>' + alltype[i] + '</option>')
- }
- }
- html.push('</select>');
- html = html.join("");
- return html;
- }
-
- function addMouth(maxNum, num) {
- var html = ['<select class="mouth" style="width: 55px">'];
- for (var i = 0; i < maxNum.length; i++) {
- for (var n in maxNum[i]) {
- if (n == num) {
- html.push('<option selected value = ' + n + '>' + maxNum[i][n] + '</option>')
- } else {
- html.push('<option value=' + n + '>' + maxNum[i][n] + '</option>')
- }
-
- }
-
- }
- ;
- html.push("</select>");
- if (maxNum <= 0) {
- html = ['-'];
- }
- html = html.join("")
- return html;
- }
-
- function addTd(html) {
- var td = ['<td>'];
- td.push(html);
- td.push('</td>');
- td = td.join("")
- return td;
- }
-
- function addTr(html) {
- var tr = ['<tr>'];
- tr.push(html)
- tr.push('</tr>');
-
- tr = tr.join("")
-
- return tr;
-
- }
-
- jQuery.fn.outerHTML = function (s) {
- return (s) ? this.before(s).remove() : $("<Hill_man>").append(this.eq(0).clone()).html();
- }
-
- function additemall(lable, cen, attr) {
- var html = ['<' + lable + ' ' + (function (attr) {
- if (typeof(attr) == "undefined") {
- return ""
- } else {
- var arr = [];
- for (i in attr) {
- arr.push(i + '="' + attr[i] + '"')
- }
- ;
- return arr.join(" ")
- }
- })(attr) + '>'];
- html.push(cen);
- html.push('</' + lable + '>');
-
- return html.join("")
- }
-
- function getdata() {
- var val = [];
- Array.prototype.push.apply(val, arguments);
- return val.join("&");
- }
-
- function getval(dom, value) {
- var val = null;
- if (value == "val" || value == "value") {
- val = $(dom).eq(0).val()
- } else if (value == "html") {
- val = $(dom).eq(0).html()
- } else {
- val = $(dom).eq(0).attr(value);
- var name = value;
- return name + "=" + val;
- }
- var name = $(dom).eq(0).attr("name");
- return name + "=" + val
- }
-
- //html存入json
- function setJsonHtml(data) {
- if (typeof(data) == "object") {
- var jsonArrayFinal = JSON.stringify(data);
- jsonArrayFinal = jsonArrayFinal.replace(/ /g, '');
- jsonArrayFinal = jsonArrayFinal.replace(/"/g, '"');
- return jsonArrayFinal;
- }
- }
-
- //取出html存入的json
- function getJsonHtml(data) {
- if (data) {
- var data_info = JSON.parse(data);
- return data_info;
- }
- }
|