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.
 
 
 
 

252 lines
5.8 KiB

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