var HTML = ''; //记录添加的 tr id var n = 0; //记录途径顺序 var m = 1; var prod_id; var stationId; window.onload = function(){ $('#tr_replace').hide(); initdata(); } //根据用户输入检索 function lineListSearch(listId){ $.ajax({ url:'./st-xm/Model/linemanager/stationListSearch.php', //请求地址 type: "post", //请求方式 // data: data, //请求参数 data:{ stationName:listId }, async:false, dataType: "json", success: function (data) { console.log(data); if(data.code == 0){ $('#line_name_search').show(); var line_list = document.getElementById("line_name_search"); var list = data.list; var htmlStr = ""; for (var i=0;i'+list[i].res_name+''; } line_list.innerHTML = htmlStr; } }, fail: function (data) { } }); } //选中一个站点 function click_select(id,name){ $('#line_list').val(name); $('#line_name_search').hide(); $('#station_select').val(id); } function initdata(){ prod_id = getPar("prod_id"); $.ajax({ url:'./st-xm/control.php', type: "post", data: {type:"linemanager_datainfo",id: prod_id}, dataType: "json", success: function (data) { console.log(data); if(data.code == 0){ createHtml(data); }else if(data.code == -1){ alert("请检查网络!!!") } }, fail: function (data) { // 此处放失败后执行的代码 } }); } //拼接数据 function createHtml(data){ $("#line_no").text(data.cominfo.linecode); $("#line_name").text(data.cominfo.linename); if((data.cominfo.bus_type==255)||(data.cominfo.bus_type==0)){ $("#bar_style_z").attr("checked","checked"); }else if(data.cominfo.bus_type==256){ $("#bar_style_c").attr("checked","checked"); } var temp = ""; var alltemp = ""; var y var index = ""; var ind = ""; for(var i=0,j=data.list.length;i' + '' + ''+m+'' + ''+data.list[i].station_res_name+'' + '' + '' + '' + '' + '分' + '' + '' + '公里' + '' + '' + '' + '' + '' + '' + '' + '删除' + '' m++; } $("#line_list_info").append(temp); for(var i=0;i'+data.list[i].poi_name[j].area_name_list+'' } $("#select_poi"+(i+1)).append(temp1); if(i==0){ $("#time_out"+(i+1)).attr("readonly","true") } } for(var i=0;i'+data.list[i].checkport_res[j].checkport_res_name+'' } $("#teller_station"+(i+1)).append(temp2); } } } //得到url上的参数 function getPar(par){ var local_url = document.location.href; local_url = decodeURI(local_url); var get = local_url.indexOf(par +"="); if(get == -1){ return false; } var get_par = local_url.slice(par.length + get + 1); var nextPar = get_par.indexOf("&"); if(nextPar != -1){ get_par = get_par.slice(0, nextPar); } return get_par; } //添加一条线路 function addOneLine(){ var line_list = $('#line_list').val(); if (line_list == "") { alert('未选择站点信息!'); return; } var stationId = $('#station_select').val(); var poiAry = ''; var checkPortAry = ''; var poiIdAry = ''; var checkPortIdAry = ''; var ifHasCheckport = ''; //站点id对应每一条站点信息 // var stationId = ''; //请求站点相关的数据 $.ajax({ url:'./st-xm/Model/linemanager/stationInfo.php', //请求地址 type: "post", data:{stationId:stationId}, async:false, dataType: "json", success: function (data) { console.log(data); if(data.code == 0){ //(poi) var poiListStr = data.list.parent_area_name_list; //得到截取后返回的数组(poi) poiAry = intercept(poiListStr); //(poi)id var poiListIdStr = data.list.parent_area_id_list; //得到截取后返回的数组(poi) poiIdAry = intercept(poiListIdStr); ifHasCheckport = data.list.checkport_res_name; if (data.list.checkport_res_id != 0) { //检票口数组 checkPortAry = data.list.checkport_res_name.split(','); //检票口id数组 checkPortIdAry = data.list.checkport_res_id.split(','); } //站点proid stationId = data.list.res_id; } }, fail: function (data) { } }); //tbody var line = document.getElementById('line_list_info'); //tr var tr = document.createElement("tr"); tr.id = m; var newHtml = ''; var tempHTML = $('#tr_replace').html(); tempHTML = tempHTML.replace('[途径顺序]',m); tempHTML = tempHTML.replace('[orderid]','orderid'+m); tempHTML = tempHTML.replace('[站点]',$('#line_list').val()); tempHTML = tempHTML.replace('[station_type_td]','station_type_td'+m); tempHTML = tempHTML.replace('[select_poi]','select_poi'+m); tempHTML = tempHTML.replace('[teller]','teller'+m); tempHTML = tempHTML.replace('[teller_station]','teller_station'+m); tempHTML = tempHTML.replace('[stationid]','stationid'+m); tempHTML = tempHTML.replace('[timeid]','timeid'+m); tempHTML = tempHTML.replace('[updown]','updown'+m); tempHTML = tempHTML.replace('[del]',m); tempHTML = tempHTML.replace('time_out','time_out'+m); tempHTML = tempHTML.replace('distance','distance'+m); tempHTML = tempHTML.replace('[station_type]','station_type'+m); tempHTML = tempHTML.replace('[hideid]','hideid'+m); tempHTML = tempHTML.replace('[hideid_id]',stationId); line.appendChild(tr); var str = '删除'; tempHTML = tempHTML.replace('[删除]',str); tr.innerHTML = tempHTML; //替换poi var poiHTML = ''; for (var i = poiAry.length-1; i>=0;i --) { var tempHTML1 = ''; tempHTML1 = tempHTML1.replace('请选择',poiAry[i]); tempHTML1 = tempHTML1.replace('0',poiIdAry[i]); poiHTML += tempHTML1; } $('#select_poi'+m).html(poiHTML); //替换检票口 if (ifHasCheckport=='') { $('#teller'+m).html('-'); }else{ var checkportHTML = ''; for (var i = 0; i 1){ // for (var i = 0 ; i