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.
 
 
 
 

171 lines
4.3 KiB

  1. /**
  2. * Created by luocj on 2016/7/26.
  3. */
  4. var cur = "";
  5. var pagesize = 10;
  6. // 模糊搜索
  7. $("#text1").click(function(e){
  8. e.stopPropagation();
  9. $(".xiala").removeClass("hide");
  10. });
  11. $(document).click(function(){
  12. if(!$(".xiala").hasClass("hide")){
  13. $(".xiala").addClass("hide");
  14. }
  15. });
  16. function myFunction() {
  17. var text1 = $("#text1").val();
  18. $.ajax({
  19. url:'./st-xm/Model/line/searchLine.php',
  20. type: "post",
  21. data: {lineName:text1,currpage:cur},
  22. dataType: "json",
  23. success: function (data) {
  24. if(data.code == 0){
  25. createHtml(data.lineList)
  26. }
  27. },
  28. fail: function (data) {
  29. // 此处放失败后执行的代码
  30. }
  31. });
  32. }
  33. //筛选列表
  34. function createHtml(data){
  35. var temp ="";
  36. for (var i = 0; i < data.length; i++) {
  37. temp +='<div class="xuanxiang">'+data[i].line+'</div>'
  38. }
  39. $(".xiala").html(temp);
  40. $(".xuanxiang").click(function(){
  41. var line = $(this).text();
  42. $("#text1").val(line);
  43. })
  44. }
  45. //遍历列表
  46. function createHtml_list(data){
  47. var temp ="";
  48. for (var i = 0; i < data.length; i++) {
  49. temp += '<tr class="list_info" id="list_info'+i+'">'
  50. + '<td class="list_middle"><p>'+data[i].lineName+" "+data[i].prodName+'</p></td>'
  51. + '<td class="list_middle">'+data[i].startArea+'</td>'
  52. + '<td class="list_middle">'+data[i].endArea+'</td>'
  53. + '<td class="list_middle">'
  54. + '<a target="_Blank" href="./sell_manage.html?lineNameJC='+data[i].lineName+'&lineName='+data[i].prodName+'&lineNameId='+data[i].prod_id+'" >票种管理</a>'
  55. + '</td>'
  56. + '</tr>'
  57. }
  58. $("#list").html(temp);
  59. //temp=temp.replace('[操作]',str);
  60. }
  61. // 每页显示的数据个数
  62. var pagesize = 10;
  63. var tttHTML = '';
  64. window.onload = function() {
  65. var cur = "";
  66. var currpage = getPar("currpage");
  67. var text1 = '';
  68. var data = ''
  69. if (!currpage) {
  70. cur = 1;
  71. text1 = $('#text1').val();
  72. data = '{type:text1:' + text1 + ',currpage:' + cur + '}';
  73. searchInfo(cur,text1);
  74. }
  75. else {
  76. cur = currpage;
  77. text1 = getPar('text1');
  78. $('#text1').val(text1);
  79. data = '{type:"text1":' + text1 + 'currpage:' + cur + '}';
  80. tttHTML = $('#list').html();
  81. searchInfo(cur, text1);
  82. }
  83. }
  84. // 得到url上的参数
  85. function getPar(par){
  86. var local_url = document.location.href;
  87. local_url = decodeURI(local_url);
  88. var get = local_url.indexOf(par +"=");
  89. if(get == -1){
  90. return false;
  91. }
  92. var get_par = local_url.slice(par.length + get + 1);
  93. var nextPar = get_par.indexOf("&");
  94. if(nextPar != -1){
  95. get_par = get_par.slice(0, nextPar);
  96. }
  97. return get_par;
  98. }
  99. //查询相关信息
  100. function searchInfo(cur,text1){
  101. if(!cur){
  102. cur = 1;
  103. }
  104. if(!text1){
  105. text1 = $('#text1').val();
  106. }
  107. $.ajax({
  108. url:'./st-xm/Model/line/getLineList.php', //请求地址
  109. type: "get", //请求方式
  110. // data: data, //请求参数
  111. data:{
  112. lineName:text1,
  113. currpage:cur,
  114. pagesize:pagesize
  115. },
  116. async:false,
  117. dataType: "json",
  118. success: function (data) {
  119. if(data.code == 0){
  120. console.log(data);
  121. var sum = data.totalNum;
  122. var tag = "test";
  123. var sendurl = './query_line.html?text1='+text1;
  124. getPager(sendurl, sum, cur, pagesize,tag,'currpage');
  125. createHtml_list(data.list);
  126. document.getElementById("sum").innerHTML = "共"+sum+"条数据";
  127. }else if(data.code == -1){
  128. alert('没有相关数据');
  129. var sum = data.totalNum;
  130. var tag = "test";
  131. var sendurl = './query_line.html?text1='+text1;
  132. getPager(sendurl, sum, cur, pagesize,tag,'currpage');
  133. createHtml_list(data.list);
  134. document.getElementById("sum").innerHTML = "共0条数据";
  135. }
  136. },
  137. fail: function (data) {
  138. // 此处放失败后执行的代码
  139. }
  140. });
  141. if(cur!=1){
  142. var text1 = getPar('text1');
  143. $('#text1').val(text1);
  144. }
  145. }