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.
 
 
 
 

247 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:'channel_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. $.ajax({
  28. url:urlstr, //请求地址
  29. data:data,
  30. type: "post",
  31. dataType: "json",
  32. async:false,
  33. success: function (data) {
  34. if(data.code == "0"){
  35. console.log(data);
  36. totalpage = data.total_page;
  37. reloadData(data);
  38. if (totalpage == 0) {
  39. $('.pageDiv').hide();
  40. } else{
  41. createPage(currpage,totalpage);
  42. $('.pageDiv').show();
  43. }
  44. }else{
  45. alert(data.info);
  46. }
  47. }
  48. });
  49. }
  50. //加载数据
  51. function reloadData(data){
  52. var list = data.list;
  53. var newHTML='';
  54. for(var i=0;i<list.length;i++){
  55. var tempHTML=listHTML;
  56. tempHTML=tempHTML.replace('[名称]',list[i].supplier_name);
  57. tempHTML=tempHTML.replace('[区域]',list[i].area_name);
  58. tempHTML=tempHTML.replace('[经营性质]',list[i].manage_type);
  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="amend_channel.html?iprod_id=' +list[i].id +'">修改</a>'+'<a style="padding-left:20px" target="_Blank" href="./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:'channel_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. $.ajax({
  87. url:urlstr, //请求地址
  88. data:data,
  89. type: "post",
  90. dataType: "json",
  91. async:false,
  92. success: function (data) {
  93. if(data.code == "0"){
  94. console.log(data);
  95. totalpage = data.total_page;
  96. reloadData(data);
  97. }else{
  98. alert(data.info);
  99. }
  100. }
  101. });
  102. }
  103. });
  104. }
  105. //查询
  106. function searchInfo(){
  107. selectOnePage(1);
  108. }
  109. //添加供应商
  110. function addSelect(){
  111. window.location.href = './add_channel.html';
  112. }
  113. //停用选中项
  114. function stopSelect() {
  115. var ary = new Array();
  116. $('.ace_check').each(function(index, item) {
  117. if(this.checked && index != 0) {
  118. ary.push($(this).attr('name'));
  119. }
  120. });
  121. if(ary.length <= 0) {
  122. alert('请勾选!!!');
  123. return;
  124. }
  125. var pro_str = ary.join(',');
  126. var data = {
  127. type: "channel_list_statu",
  128. channel_id: pro_str,
  129. play: 'stop'
  130. }
  131. console.log(data);
  132. $.ajax({
  133. url: base_path+'control.php', //请求地址
  134. type: "post", //请求方式
  135. data: data,
  136. async: false,
  137. dataType: "json",
  138. success: function(data) {
  139. if(data.code == 0) {
  140. $('.ace_check').each(function(index, item) {
  141. if(this.checked && index != 0) {
  142. var stopid = $(this).attr('name');
  143. $('#userid_style' + stopid).html('关闭');
  144. }
  145. });
  146. alert('停用成功!');
  147. }
  148. }
  149. });
  150. }
  151. //启用选中项
  152. function startSelect() {
  153. var ary = new Array();
  154. $('.ace_check').each(function(index, item) {
  155. if(this.checked && index != 0) {
  156. ary.push($(this).attr('name'));
  157. }
  158. });
  159. if(ary.length <= 0) {
  160. alert('请勾选!!!');
  161. return;
  162. }
  163. var pro_str = ary.join(',');
  164. var data = {
  165. type: "channel_list_statu",
  166. channel_id: pro_str,
  167. play: 'start'
  168. }
  169. console.log(data);
  170. $.ajax({
  171. url: base_path+'control.php', //请求地址
  172. type: "post", //请求方式
  173. data: data,
  174. async: false,
  175. dataType: "json",
  176. success: function(data) {
  177. if(data.code == 0) {
  178. $('.ace_check').each(function(index, item) {
  179. if(this.checked && index != 0) {
  180. var stopid = $(this).attr('name');
  181. $('#userid_style' + stopid).html('正常');
  182. }
  183. });
  184. alert('启用成功!');
  185. }
  186. }
  187. });
  188. }
  189. //复选框判断
  190. function select_checked(index) {
  191. //index=0最上面的全选 index=1表示的是下面所有的
  192. var cur_check = $('.ace_check')[0];
  193. var checkList = $('.ace_check');
  194. var checkCount = checkList.length - 1;
  195. var true_count = 0;
  196. for (var i = 1; i < checkList.length; i++) {
  197. if (index == '0') {
  198. checkList[i].checked = cur_check.checked;
  199. } else {
  200. if (checkList[i].checked == false) {
  201. cur_check.checked = false
  202. } else {
  203. true_count = true_count + 1;
  204. }
  205. }
  206. }
  207. //判断下面是否选中完
  208. if (checkCount == true_count) {
  209. cur_check.checked = true;
  210. }
  211. }
  212. //得到url上的参数
  213. function getPar(par){
  214. var local_url = document.location.href;
  215. local_url = decodeURI(local_url);
  216. var get = local_url.indexOf(par +"=");
  217. if(get == -1){
  218. return false;
  219. }
  220. var get_par = local_url.slice(par.length + get + 1);
  221. var nextPar = get_par.indexOf("&");
  222. if(nextPar != -1){
  223. get_par = get_par.slice(0, nextPar);
  224. }
  225. return get_par;
  226. }