var urlstr = base_api+'index.php'; var currpage = 1; var pagesize = 10; //查询参数 var supplier_name = ''; var sale_style = ''; var sale_status = ''; var listHTML = ''; //权限控制 var user_type = getStorage("user_type"); window.onload = function(){ listHTML = $('#list').html(); selectOnePage(1); } //选中页码 function selectOnePage(page){ supplier_name = $('#supplier_name').val(); sale_style = $('#select_supplier').val(); sale_status = $('#select_status').val(); currpage=page; var data = { tp : 'supply_supplier_getSupplierList', is_disabled : sale_status, product_type : sale_style, supplier_name : supplier_name, current : page, pagesize : 10 }; console.log(data); $.ajax({ url:urlstr, //请求地址 data:data, type: "post", dataType: "json", async:false, success: function (data) { if(data.code == "0"){ console.log(data); totalpage = data.total_page; reloadData(data); if (totalpage == 0) { $('.pageDiv').hide(); } else{ createPage(currpage,totalpage); $('.pageDiv').show(); } }else{ ZZAlertInfo(data.info); } } }); } //加载数据 function reloadData(data){ var list = data.list; var newHTML=''; for(var i=0;i修改'+'账号管理'; 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){ var data = { tp : 'supply_supplier_getSupplierList', is_disabled : sale_status, product_type : sale_style, supplier_name : supplier_name, current : p, pagesize : 10 }; console.log(data); $.ajax({ url:urlstr, //请求地址 data:data, type: "post", dataType: "json", async:false, success: function (data) { if(data.code == "0"){ console.log(data); totalpage = data.total_page; reloadData(data); }else{ ZZAlertInfo(data.info); } } }); } }); } //查询 function searchInfo(){ selectOnePage(1); } //添加供应商 function addSelect(){ window.location.href = './add_supplier.html'; } //停用选中项 function stopSelect() { 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(','); var data = { tp : "supply_supplier_updateStatus", supply_id: pro_str, play: 'stop' } console.log(data); $.ajax({ url: urlstr, //请求地址 type: "post", //请求方式 data: data, async: false, dataType: "json", success: function(data) { if(data.code == 0) { $('.ace_check').each(function(index, item) { if(this.checked && index != 0) { var stopid = $(this).attr('name'); $('#userid_style' + stopid).html('关闭'); } }); ZZAlertInfo('停用成功!'); } } }); } //启用选中项 function startSelect() { 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(','); var data = { tp : "supply_supplier_updateStatus", supply_id: pro_str, play: 'start' } console.log(data); $.ajax({ url: urlstr, //请求地址 type: "post", //请求方式 data: data, async: false, dataType: "json", success: function(data) { if(data.code == 0) { //由于批量操作时,后台待审核的suppl $('.ace_check').each(function(index, item) { if(this.checked && index != 0) { var stopid = $(this).attr('name'); $('#userid_style' + stopid).html('正常'); } }); ZZAlertInfo('启用成功!'); } } }); } //复选框判断 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; }