|
- //一个页面的线路条数
- var pagesize = 10;
- //当前页数
- var currpage = 1;
-
- var car_number = "";
-
- var brand_id = 0;
-
- //删除刷新页
- var delete_page = 1;
-
- var line_type = "255";
- //总页数
- var totalpage = "";
-
- var listHTML = '';
-
- $(document).ready(function(){
- listHTML = $('#list').html();
- car_list_baseinfo();
- selectOnePage(1);
- });
-
-
- //加载配置信息
-
- function car_list_baseinfo(){
- $.ajax({
- url:base_api+'carManager/index.php', //请求地址
- data:{tp:"carControl_brandList"},
- type: "post", //请求方式
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- get_baseinfo(data.data);
- }else{
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
-
- //替换加载配置信息
-
- function get_baseinfo(data){
- var temp = '<option value="0">请选择</option>';
- for(var i=0,j=data.length;i<j;i++){
- temp += '<option value="'+data[i].res_id+'">'+data[i].res_name+'</option>';
- }
- $("#brand").html(temp);
- }
-
- //加载线路列表
-
- function selectOnePage(page){
-
- car_number = $("#car_number").val();
- brand_id = $("#brand").val();
- $.ajax({
- url:base_api+'carManager/index.php', //请求地址
- data:{
- tp:"carControl_carList",
- page_size:pagesize,
- current_page:page,
- car_number:car_number,
- brand_id:brand_id,
- },
- type: "post", //请求方式
- dataType: "json",
- async:false,
- success: function (data) {
- if(data.code == 0){
- console.log(data);
- totalpage = data.page.total_page;
- reloadData(data.data);
- if (totalpage == 0) {
- $('.pageDiv').hide();
- } else{
- createPage(currpage,totalpage);
- $('.pageDiv').show();
- }
- }else{
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
-
- //加载线路列表
-
- function delete_update(page){
-
- car_number = $("#car_number").val();
- brand_id = $("#brand").val();
- $.ajax({
- url:base_api+'carManager/index.php', //请求地址
- data:{
- tp:"carControl_carList",
- page_size:pagesize,
- current_page:page,
- car_number:car_number,
- brand_id:brand_id,
- },
- type: "post", //请求方式
- dataType: "json",
- async:false,
- success: function (data) {
- console.log(data);
- if(data.code == 0){
-
- totalpage = data.page.total_page;
- reloadData(data.data);
-
- }else{
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
-
- //替换加载列表
-
- function get_linelist(data){
- var temp = '';
- for(var i=0,j=data.length;i<j;i++){
- temp += '<option value="'+data[i].supplier_id+'">'+data[i].supplier_name+'</option>';
- }
- $("#yunying_company").html(temp);
- }
-
- //加载线路列表数据
- function reloadData(data){
-
- var list = data;
- var newHTML='';
- for(var i=0;i<list.length;i++){
- var tempHTML=listHTML;
- 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>');
- tempHTML=tempHTML.replace('[品牌]',list[i].bus_brand);
- tempHTML=tempHTML.replace('[车座]',list[i].seat_desc);
- tempHTML=tempHTML.replace('[运营公司]',list[i].company);
- tempHTML=tempHTML.replace('[状态]',list[i].bus_state);
- tempHTML=tempHTML.replace('[userid_style]','userid_style'+list[i].line_id);
- tempHTML=tempHTML.replace('[oneCheckName]',list[i].bus_id);
- var str = '<a style="" onclick="open_new_path(this)" go_path="web/busManager/reviseCar.html?bus_id='+list[i].bus_id+'">修改</a>';
- tempHTML=tempHTML.replace('[操作]',str);
- newHTML+=tempHTML;
- }
- $('#list').html(newHTML);
- }
-
- //创建分页控件
- function createPage(currpage,totalpage){
- $(".pageDiv").createPage({
- pageCount:totalpage,//总页数
- current:currpage,//当前页
- turndown:'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
- backFn:function(p){
- delete_page = p;
- $.ajax({
- url:base_api+'carManager/index.php', //请求地址
- data:{
- tp:"carControl_carList",
- page_size:pagesize,
- current_page:p,
- car_number:car_number,
- brand_id:brand_id,
- },
- type: "post",
- dataType: "json",
- async:false,
- success: function (data) {
- if(data.code == "0"){
- console.log(data);
- totalpage = data.page.total_page;
- reloadData(data.data);
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
- });
- }
-
- //查询
- function searchInfo(){
- selectOnePage(1);
- }
-
- //复选框判断
- function select_checked(index) {
- //index=0最上面的全选 index=1表示的是下面所有的
- var cur_check = $('.ace_check')[0];
- var checkList = $('.ace_check');
- var checkCount = checkList.length - 1;
- var true_count = 0;
- for (var i = 1; i < checkList.length; i++) {
- if (index == '0') {
- checkList[i].checked = cur_check.checked;
- } else {
- if (checkList[i].checked == false) {
- cur_check.checked = false
- } else {
- true_count = true_count + 1;
- }
- }
- }
- //判断下面是否选中完
- if (checkCount == true_count) {
- cur_check.checked = true;
- }
- }
-
- //得到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 deleteSelect() {
-
- var ary = new Array();
- $('.ace_check').each(function(index, item) {
- if(this.checked && index != 0) {
- ary.push($(this).attr('name'));
- }
- });
- if(ary.length <= 0) {
- ZZAlertInfo('请勾选!!!');
- return;
- }
- var pro_str = ary.join(',');
- ZZConfirm("确定删除车辆信息吗?",function(ok){
- var data = {
- tp: "carControl_deleteCar",
- bus_id: pro_str
- }
-
- $.ajax({
- url: base_api+'carManager/index.php', //请求地址
- type: "post", //请求方式
- data: data,
- async: false,
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- delete_update(delete_page);
-
- }
- }
- });
-
- },function(cancel){},function(close){});
-
- }
-
- function add_car(){
- window.location.href = "addCar.html";
- }
-
|