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.
 
 
 
 

249 lines
5.6 KiB

  1. var currpage = 1;
  2. var pagesize = 10;
  3. //查询参数
  4. var supplier_name = '';
  5. var sale_style = '';
  6. var sale_status = '';
  7. var listHTML = '';
  8. window.onload = function(){
  9. listHTML = $('#list').html();
  10. selectOnePage(1);
  11. }
  12. //选中页码
  13. function selectOnePage(page){
  14. supplier_name = $('#supplier_name').val();
  15. sale_style = $('#select_supplier').val();
  16. sale_status = $('#select_status').val();
  17. currpage=page;
  18. var urlstr = base_path+'control.php';
  19. var data = {
  20. type:'supply_list_get',
  21. is_disabled : sale_status,
  22. product_type : sale_style,
  23. supplier_name : supplier_name,
  24. current : page,
  25. pagesize : 10
  26. };
  27. console.log(data);
  28. $.ajax({
  29. url:urlstr, //请求地址
  30. data:data,
  31. type: "post",
  32. dataType: "json",
  33. async:false,
  34. success: function (data) {
  35. if(data.code == "0"){
  36. console.log(data);
  37. totalpage = data.total_page;
  38. reloadData(data);
  39. if (totalpage == 0) {
  40. $('.pageDiv').hide();
  41. } else{
  42. createPage(currpage,totalpage);
  43. $('.pageDiv').show();
  44. }
  45. }else{
  46. alert(data.info);
  47. }
  48. }
  49. });
  50. }
  51. //加载数据
  52. function reloadData(data){
  53. var list = data.list;
  54. var newHTML='';
  55. for(var i=0;i<list.length;i++){
  56. var tempHTML=listHTML;
  57. tempHTML=tempHTML.replace('[名称]',list[i].supplier_name);
  58. tempHTML=tempHTML.replace('[区域]',list[i].area_name);
  59. tempHTML=tempHTML.replace('[类型]',list[i].product_type);
  60. tempHTML=tempHTML.replace('[状态]',list[i].is_disabled);
  61. tempHTML=tempHTML.replace('[oneCheck]','oneCheck'+list[i].id);
  62. tempHTML=tempHTML.replace('[oneCheckName]',list[i].id);
  63. tempHTML=tempHTML.replace('[userid_style]','userid_style'+list[i].id);
  64. 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>';
  65. tempHTML=tempHTML.replace('[操作]',str);
  66. newHTML+=tempHTML;
  67. }
  68. $('#list').html(newHTML);
  69. }
  70. //创建分页控件
  71. function createPage(currpage,totalpage){
  72. $(".pageDiv").createPage({
  73. pageCount:totalpage,//总页数
  74. current:currpage,//当前页
  75. turndown:'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  76. backFn:function(p){
  77. var urlstr = base_path+'control.php';
  78. var data = {
  79. type:'supply_list_get',
  80. is_disabled : sale_status,
  81. product_type : sale_style,
  82. supplier_name : supplier_name,
  83. current : p,
  84. pagesize : 10
  85. };
  86. console.log(data);
  87. $.ajax({
  88. url:urlstr, //请求地址
  89. data:data,
  90. type: "post",
  91. dataType: "json",
  92. async:false,
  93. success: function (data) {
  94. if(data.code == "0"){
  95. console.log(data);
  96. totalpage = data.total_page;
  97. reloadData(data);
  98. }else{
  99. alert(data.info);
  100. }
  101. }
  102. });
  103. }
  104. });
  105. }
  106. //查询
  107. function searchInfo(){
  108. selectOnePage(1);
  109. }
  110. //添加供应商
  111. function addSelect(){
  112. window.location.href = './add_supplier.html';
  113. }
  114. //停用选中项
  115. function stopSelect() {
  116. var ary = new Array();
  117. $('.ace_check').each(function(index, item) {
  118. if(this.checked && index != 0) {
  119. ary.push($(this).attr('name'));
  120. }
  121. });
  122. if(ary.length <= 0) {
  123. alert('请勾选!!!');
  124. return;
  125. }
  126. var pro_str = ary.join(',');
  127. var data = {
  128. type: "supply_list_statu",
  129. supply_id: pro_str,
  130. play: 'stop'
  131. }
  132. console.log(data);
  133. $.ajax({
  134. url: base_path+'control.php', //请求地址
  135. type: "post", //请求方式
  136. data: data,
  137. async: false,
  138. dataType: "json",
  139. success: function(data) {
  140. if(data.code == 0) {
  141. $('.ace_check').each(function(index, item) {
  142. if(this.checked && index != 0) {
  143. var stopid = $(this).attr('name');
  144. $('#userid_style' + stopid).html('关闭');
  145. }
  146. });
  147. alert('停用成功!');
  148. }
  149. }
  150. });
  151. }
  152. //启用选中项
  153. function startSelect() {
  154. var ary = new Array();
  155. $('.ace_check').each(function(index, item) {
  156. if(this.checked && index != 0) {
  157. ary.push($(this).attr('name'));
  158. }
  159. });
  160. if(ary.length <= 0) {
  161. alert('请勾选!!!');
  162. return;
  163. }
  164. var pro_str = ary.join(',');
  165. var data = {
  166. type: "supply_list_statu",
  167. supply_id: pro_str,
  168. play: 'start'
  169. }
  170. console.log(data);
  171. $.ajax({
  172. url: base_path+'control.php', //请求地址
  173. type: "post", //请求方式
  174. data: data,
  175. async: false,
  176. dataType: "json",
  177. success: function(data) {
  178. if(data.code == 0) {
  179. $('.ace_check').each(function(index, item) {
  180. if(this.checked && index != 0) {
  181. var stopid = $(this).attr('name');
  182. $('#userid_style' + stopid).html('正常');
  183. }
  184. });
  185. alert('启用成功!');
  186. }
  187. }
  188. });
  189. }
  190. //复选框判断
  191. function select_checked(index) {
  192. //index=0最上面的全选 index=1表示的是下面所有的
  193. var cur_check = $('.ace_check')[0];
  194. var checkList = $('.ace_check');
  195. var checkCount = checkList.length - 1;
  196. var true_count = 0;
  197. for (var i = 1; i < checkList.length; i++) {
  198. if (index == '0') {
  199. checkList[i].checked = cur_check.checked;
  200. } else {
  201. if (checkList[i].checked == false) {
  202. cur_check.checked = false
  203. } else {
  204. true_count = true_count + 1;
  205. }
  206. }
  207. }
  208. //判断下面是否选中完
  209. if (checkCount == true_count) {
  210. cur_check.checked = true;
  211. }
  212. }
  213. //得到url上的参数
  214. function getPar(par){
  215. var local_url = document.location.href;
  216. local_url = decodeURI(local_url);
  217. var get = local_url.indexOf(par +"=");
  218. if(get == -1){
  219. return false;
  220. }
  221. var get_par = local_url.slice(par.length + get + 1);
  222. var nextPar = get_par.indexOf("&");
  223. if(nextPar != -1){
  224. get_par = get_par.slice(0, nextPar);
  225. }
  226. return get_par;
  227. }