|
-
-
- var currpage = 1;
- var pagesize = 10;
-
- //查询参数
- var supplier_name = '';
- var sale_style = '';
- var sale_status = '';
-
- var listHTML = '';
-
- 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 urlstr = base_path+'control.php';
- var data = {
- type:'supply_list_get',
- 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{
- alert(data.info);
- }
-
- }
- });
- }
-
- //加载数据
- function reloadData(data){
- var list = data.list;
- var newHTML='';
- for(var i=0;i<list.length;i++){
- var tempHTML=listHTML;
- tempHTML=tempHTML.replace('[名称]',list[i].supplier_name);
- tempHTML=tempHTML.replace('[区域]',list[i].area_name);
- tempHTML=tempHTML.replace('[类型]',list[i].product_type);
- tempHTML=tempHTML.replace('[状态]',list[i].is_disabled);
- tempHTML=tempHTML.replace('[oneCheck]','oneCheck'+list[i].id);
- tempHTML=tempHTML.replace('[oneCheckName]',list[i].id);
- tempHTML=tempHTML.replace('[userid_style]','userid_style'+list[i].id);
- var str = '<a target="_Blank" onclick="open_new_path(this)" go_path="change_supplier.html?prod_id=' +list[i].id +'">修改</a>'+'<a style="padding-left:20px" target="_Blank" onclick="open_new_path(this)" go_path="account_list.html?iprod_id=' +list[i].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){
- var urlstr = base_path+'control.php';
- var data = {
- type:'supply_list_get',
- 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{
- alert(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) {
- alert('请勾选!!!');
- return;
- }
- var pro_str = ary.join(',');
- var data = {
- type: "supply_list_statu",
- supply_id: pro_str,
- play: 'stop'
- }
- console.log(data);
- $.ajax({
- url: base_path+'control.php', //请求地址
- 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('关闭');
- }
- });
- alert('停用成功!');
- }
- }
- });
- }
-
- //启用选中项
- 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) {
- alert('请勾选!!!');
- return;
- }
- var pro_str = ary.join(',');
- var data = {
- type: "supply_list_statu",
- supply_id: pro_str,
- play: 'start'
- }
- console.log(data);
- $.ajax({
- url: base_path+'control.php', //请求地址
- 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('正常');
- }
- });
- alert('启用成功!');
- }
- }
- });
- }
-
-
-
- //复选框判断
- 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;
- }
|