|
- var lineNameJC = getPar("lineNameJC")
- var temp1 = getPar("prod_id");
- var line_name = getPar("lineName");
- var ind;
- var prod_id;
- var cus_price;
- var prod_price;
- var cus_price_id;
- var prod_price_id;
- var ticket_type;
- var end_area_id;
- var start_area_id;
- window.onload = function() {
- var index = '<span>线路名称:</span>'
- +'<span>'+lineNameJC+'</span>'
- +'<span>'+line_name+'</span>'
- $("#lineName").html(index);
-
- $.ajax({
- url:'./st-xm/control.php',
- type: "post",
- data: {type:"linemanager_tickets",id:temp1},
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- console.log(data);
- createHtml_list(data.list);
- }
- },
- fail: function (data) {
- // 此处放失败后执行的代码
- }
- });
- }
-
- //遍历列表
- function createHtml_list(data){
- var temp ="";
-
- for (var i = 0; i < data.length; i++){
- if(data[i].cus_price==null){
-
- temp += '<tr class="list_info" id="list_info'+i+'">'
- + '<td class="list_middle"><p>'+data[i].start_area_name+'</p></td>'
- + '<td class="list_middle">'+data[i].end_area_name+'</td>'
- + '<td class="list_middle">'+data[i].seat_name+'</td>'
- + '<td class="list_middle">'+data[i].ticket_type_name+'</td>'
- +'<td class="list_middle"><input class="" value="" placeholder="请填写零售价" style="width: 98px;text-align:right;" id="cus_price'+i+'"> 元</td>'
- +'<td class="list_middle"><input class="" value="" placeholder="请填写分销价" style="width: 98px;text-align:right;" id="prod_price'+i+'"> 元</td>'
- +'<td class="list_middle"><a><div id="save'+i+'" style="display:inline-block;cursor: pointer;"'
- +'start_area_id="'+data[i].start_area_id+'" end_area_id="'+data[i].end_area_id+'" ticket_type="'+data[i].ticket_type+'" prodId="'+data[i].prod_id+'" ind="'+i+'" class="save" >保存</div></a><a><div class="quxiao" style="display:inline-block;margin-left:12px;cursor: pointer;">取消</div></a></td>'
- + '</tr>'
- }else{
- temp += '<tr class="list_info" id="list_info'+i+'">'
- + '<td class="list_middle"><p>'+data[i].start_area_name+'</p></td>'
- + '<td class="list_middle">'+data[i].end_area_name+'</td>'
- + '<td class="list_middle">'+data[i].seat_name+'</td>'
- + '<td class="list_middle">'+data[i].ticket_type_name+'</td>'
- +'<td class="list_middle"><input value="'+data[i].cus_price+'" placeholder="请填写零售价" class="r_input" readonly="true" style="width: 98px;text-align:right;" id="cus_price'+i+'"> 元</td>'
- +'<td class="list_middle"><input value="'+data[i].prod_price+'" placeholder="请填写分销价" class="r_input" readonly="true" style="width: 98px;text-align:right;" id="prod_price'+i+'"> 元</td>'
- +'<td class="list_middle"><a><div id="save'+i+'" style="display:inline-block;cursor: pointer;"'
- +'start_area_id="'+data[i].start_area_id+'" end_area_id="'+data[i].end_area_id+'" ticket_type="'+data[i].ticket_type+'" prodId="'+data[i].prod_id+'" ind="'+i+'" class="save" >修改</div></a><a><div class="quxiao" style="display:inline-block;margin-left:12px;cursor: pointer;">取消</div></a></td>'
- + '</tr>'
- }
-
- }
- $("#list").html(temp);
- $(".save").click(function(){
- ind = $(this).attr("ind");
- prod_id = $(this).attr("prodId");
- ticket_type = $(this).attr("ticket_type");
- start_area_id = $(this).attr("start_area_id");
- end_area_id = $(this).attr("end_area_id");
- cus_price = $("#cus_price"+ind).val();
- prod_price = $("#prod_price"+ind).val();
- cus_price_id = "prod_price"+ind;
- prod_price_id = "cus_price"+ind;
- if($(this).text()=="保存"){
- goSave();
- // $(this).text("保存");
- // $("#cus_price"+ind).removeAttr("readonly");
- // $("#prod_price"+ind).removeAttr("readonly");
- // $("#cus_price"+ind).removeClass("r_input");
- // $("#prod_price"+ind).removeClass("r_input");
-
-
- }else if($(this).text()=="修改"){
-
- $(this).text("确定");
- $("#cus_price"+ind).removeAttr("readonly");
- $("#prod_price"+ind).removeAttr("readonly");
- $("#cus_price"+ind).removeClass("r_input");
- $("#prod_price"+ind).removeClass("r_input");
-
- }else if($(this).text()=="确定"){
- goAmenda();
- }
-
-
- })
- $(".quxiao").click(function(){
- $("#"+cus_price_id).attr("readonly","true");
- $("#"+prod_price_id).attr("readonly","true");
- $("#cus_price"+ind).addClass("r_input");
- $("#prod_price"+ind).addClass("r_input");
- $("#save"+ind).text("修改");
- })
- }
-
- function goSave(){
-
- $.ajax({
- url:'./st-xm/control.php',
- type: "post",
- data: {type:"linemanager_addticket",
- line_id:temp1,
- c_price:cus_price,
- p_price:prod_price,
- ticket_type:ticket_type,
- start_area_id:start_area_id,
- end_area_id:end_area_id
- },
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- $("#"+cus_price_id).attr("readonly","true");
- $("#"+prod_price_id).attr("readonly","true");
- $("#cus_price"+ind).addClass("r_input");
- $("#prod_price"+ind).addClass("r_input");
- $("#save"+ind).text("修改");
- alert('保存成功');
-
- }else{
- alert('保存失败!')
- }
- },
- fail: function (data) {
- alert("请检查网络!");
- // 此处放失败后执行的代码
- }
- });
-
-
-
- }
-
-
- function goAmenda(){
-
- var r=confirm("请确认是否修改价格?")
- if (r==true)
- {
- $.ajax({
- url:'./st-xm/control.php',
- type: "post",
- data: {type:"linemanager_updateticket",
- line_id:temp1,
- c_price:cus_price,
- p_price:prod_price,
- ticket_type:ticket_type,
- start_area_id:start_area_id,
- end_area_id:end_area_id
- },
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- $("#"+cus_price_id).attr("readonly","true");
- $("#"+prod_price_id).attr("readonly","true");
- $("#cus_price"+ind).addClass("r_input");
- $("#prod_price"+ind).addClass("r_input");
- $("#save"+ind).text("修改");
- alert('保存成功');
-
- }else{
- alert('保存失败!')
- }
- },
- fail: function (data) {
- alert("请检查网络!");
- // 此处放失败后执行的代码
- }
- });
- }
- else
- {
- return;
- }
-
-
- }
-
-
- //得到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;
- }
|