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.
 
 
 
 

280 lines
6.2 KiB

  1. //一个页面的线路条数
  2. var pagesize = 10;
  3. //当前页数
  4. var currpage = 1;
  5. var car_number = "";
  6. var brand_id = 0;
  7. //删除刷新页
  8. var delete_page = 1;
  9. var line_type = "255";
  10. //总页数
  11. var totalpage = "";
  12. var listHTML = '';
  13. $(document).ready(function(){
  14. listHTML = $('#list').html();
  15. car_list_baseinfo();
  16. selectOnePage(1);
  17. });
  18. //加载配置信息
  19. function car_list_baseinfo(){
  20. $.ajax({
  21. url:base_api+'carManager/index.php', //请求地址
  22. data:{tp:"carControl_brandList"},
  23. type: "post", //请求方式
  24. dataType: "json",
  25. success: function (data) {
  26. console.log(data);
  27. if(data.code == 0){
  28. get_baseinfo(data.data);
  29. }else{
  30. ZZAlertInfo(data.info);
  31. }
  32. }
  33. });
  34. }
  35. //替换加载配置信息
  36. function get_baseinfo(data){
  37. var temp = '<option value="0">请选择</option>';
  38. for(var i=0,j=data.length;i<j;i++){
  39. temp += '<option value="'+data[i].res_id+'">'+data[i].res_name+'</option>';
  40. }
  41. $("#brand").html(temp);
  42. }
  43. //加载线路列表
  44. function selectOnePage(page){
  45. car_number = $("#car_number").val();
  46. brand_id = $("#brand").val();
  47. $.ajax({
  48. url:base_api+'carManager/index.php', //请求地址
  49. data:{
  50. tp:"carControl_carList",
  51. page_size:pagesize,
  52. current_page:page,
  53. car_number:car_number,
  54. brand_id:brand_id,
  55. },
  56. type: "post", //请求方式
  57. dataType: "json",
  58. async:false,
  59. success: function (data) {
  60. if(data.code == 0){
  61. console.log(data);
  62. totalpage = data.page.total_page;
  63. reloadData(data.data);
  64. if (totalpage == 0) {
  65. $('.pageDiv').hide();
  66. } else{
  67. createPage(currpage,totalpage);
  68. $('.pageDiv').show();
  69. }
  70. }else{
  71. ZZAlertInfo(data.info);
  72. }
  73. }
  74. });
  75. }
  76. //加载线路列表
  77. function delete_update(page){
  78. car_number = $("#car_number").val();
  79. brand_id = $("#brand").val();
  80. $.ajax({
  81. url:base_api+'carManager/index.php', //请求地址
  82. data:{
  83. tp:"carControl_carList",
  84. page_size:pagesize,
  85. current_page:page,
  86. car_number:car_number,
  87. brand_id:brand_id,
  88. },
  89. type: "post", //请求方式
  90. dataType: "json",
  91. async:false,
  92. success: function (data) {
  93. console.log(data);
  94. if(data.code == 0){
  95. totalpage = data.page.total_page;
  96. reloadData(data.data);
  97. }else{
  98. ZZAlertInfo(data.info);
  99. }
  100. }
  101. });
  102. }
  103. //替换加载列表
  104. function get_linelist(data){
  105. var temp = '';
  106. for(var i=0,j=data.length;i<j;i++){
  107. temp += '<option value="'+data[i].supplier_id+'">'+data[i].supplier_name+'</option>';
  108. }
  109. $("#yunying_company").html(temp);
  110. }
  111. //加载线路列表数据
  112. function reloadData(data){
  113. var list = data;
  114. var newHTML='';
  115. for(var i=0;i<list.length;i++){
  116. var tempHTML=listHTML;
  117. tempHTML=tempHTML.replace('[车牌号]','<a style="" onclick="open_new_path(this)" go_path="web/busManager/reviseCar.html?bus_id='+list[i].bus_id+'">'+ list[i].bus_no+ '</a>');
  118. tempHTML=tempHTML.replace('[品牌]',list[i].bus_brand);
  119. tempHTML=tempHTML.replace('[车座]',list[i].seat_desc);
  120. tempHTML=tempHTML.replace('[运营公司]',list[i].company);
  121. tempHTML=tempHTML.replace('[状态]',list[i].bus_state);
  122. tempHTML=tempHTML.replace('[userid_style]','userid_style'+list[i].line_id);
  123. tempHTML=tempHTML.replace('[oneCheckName]',list[i].bus_id);
  124. var str = '<a style="" onclick="open_new_path(this)" go_path="web/busManager/reviseCar.html?bus_id='+list[i].bus_id+'">修改</a>';
  125. tempHTML=tempHTML.replace('[操作]',str);
  126. newHTML+=tempHTML;
  127. }
  128. $('#list').html(newHTML);
  129. }
  130. //创建分页控件
  131. function createPage(currpage,totalpage){
  132. $(".pageDiv").createPage({
  133. pageCount:totalpage,//总页数
  134. current:currpage,//当前页
  135. turndown:'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  136. backFn:function(p){
  137. delete_page = p;
  138. $.ajax({
  139. url:base_api+'carManager/index.php', //请求地址
  140. data:{
  141. tp:"carControl_carList",
  142. page_size:pagesize,
  143. current_page:p,
  144. car_number:car_number,
  145. brand_id:brand_id,
  146. },
  147. type: "post",
  148. dataType: "json",
  149. async:false,
  150. success: function (data) {
  151. if(data.code == "0"){
  152. console.log(data);
  153. totalpage = data.page.total_page;
  154. reloadData(data.data);
  155. }else{
  156. ZZAlertInfo(data.info);
  157. }
  158. }
  159. });
  160. }
  161. });
  162. }
  163. //查询
  164. function searchInfo(){
  165. selectOnePage(1);
  166. }
  167. //复选框判断
  168. function select_checked(index) {
  169. //index=0最上面的全选 index=1表示的是下面所有的
  170. var cur_check = $('.ace_check')[0];
  171. var checkList = $('.ace_check');
  172. var checkCount = checkList.length - 1;
  173. var true_count = 0;
  174. for (var i = 1; i < checkList.length; i++) {
  175. if (index == '0') {
  176. checkList[i].checked = cur_check.checked;
  177. } else {
  178. if (checkList[i].checked == false) {
  179. cur_check.checked = false
  180. } else {
  181. true_count = true_count + 1;
  182. }
  183. }
  184. }
  185. //判断下面是否选中完
  186. if (checkCount == true_count) {
  187. cur_check.checked = true;
  188. }
  189. }
  190. //得到url上的参数
  191. function getPar(par){
  192. var local_url = document.location.href;
  193. local_url = decodeURI(local_url);
  194. var get = local_url.indexOf(par +"=");
  195. if(get == -1){
  196. return false;
  197. }
  198. var get_par = local_url.slice(par.length + get + 1);
  199. var nextPar = get_par.indexOf("&");
  200. if(nextPar != -1){
  201. get_par = get_par.slice(0, nextPar);
  202. }
  203. return get_par;
  204. }
  205. //删除选中项
  206. function deleteSelect() {
  207. var ary = new Array();
  208. $('.ace_check').each(function(index, item) {
  209. if(this.checked && index != 0) {
  210. ary.push($(this).attr('name'));
  211. }
  212. });
  213. if(ary.length <= 0) {
  214. ZZAlertInfo('请勾选!!!');
  215. return;
  216. }
  217. var pro_str = ary.join(',');
  218. ZZConfirm("确定删除车辆信息吗?",function(ok){
  219. var data = {
  220. tp: "carControl_deleteCar",
  221. bus_id: pro_str
  222. }
  223. $.ajax({
  224. url: base_api+'carManager/index.php', //请求地址
  225. type: "post", //请求方式
  226. data: data,
  227. async: false,
  228. dataType: "json",
  229. success: function(data) {
  230. console.log(data);
  231. if(data.code == 0) {
  232. delete_update(delete_page);
  233. }
  234. }
  235. });
  236. },function(cancel){},function(close){});
  237. }
  238. function add_car(){
  239. window.location.href = "addCar.html";
  240. }