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.
 
 
 
 

308 lines
9.2 KiB

  1. //每页显示的数据个数
  2. var pagesize = 10;
  3. var tttHTML = '';
  4. window.onload = function(){
  5. var cur = "";
  6. var currpage = getPar("currpage");
  7. var select_sale_style = '';
  8. var select_user_style = '';
  9. var select_sale_shop = '';
  10. var keywords = '';
  11. var data = '';
  12. if(!currpage){
  13. cur = 1;
  14. select_sale_style = $('#select_sale_style').val();
  15. select_user_style = $('#select_user_style').val();
  16. select_sale_shop = $('#select_sale_shop').val();
  17. keywords = $('#keywords').val();
  18. data = '{type:"sale_channel",select_sale_style:'+select_sale_style+',select_user_style:'+select_user_style+',select_sale_shop:'+select_sale_shop+',keywords:'+keywords+',currpage:'+cur+'}';
  19. }else{
  20. cur = currpage;
  21. select_sale_style = getPar('select_sale_style');
  22. $('#select_sale_style').val(select_sale_style);
  23. select_user_style = getPar('select_user_style');
  24. $('#select_user_style').val(select_user_style);
  25. select_sale_shop = getPar('select_sale_shop');
  26. $('#select_sale_shop').val(select_sale_shop);
  27. keywords = getPar('keywords');
  28. $('#keywords').val(keywords);
  29. data = '{type:"sale_channel",select_sale_style:'+select_sale_style+',select_user_style:'+select_user_style+',select_sale_shop:'+select_sale_shop+',keywords:'+keywords+',currpage:'+cur+'}';
  30. }
  31. tttHTML = $('#list').html();
  32. searchInfo(cur,select_sale_style,select_user_style,select_sale_shop,keywords,data);
  33. }
  34. //得到url上的参数
  35. function getPar(par){
  36. var local_url = document.location.href;
  37. local_url = decodeURI(local_url);
  38. var get = local_url.indexOf(par +"=");
  39. if(get == -1){
  40. return false;
  41. }
  42. var get_par = local_url.slice(par.length + get + 1);
  43. var nextPar = get_par.indexOf("&");
  44. if(nextPar != -1){
  45. get_par = get_par.slice(0, nextPar);
  46. }
  47. return get_par;
  48. }
  49. //查询相关信息
  50. function searchInfo(cur,select_sale_style,select_user_style,select_sale_shop,keywords,data){
  51. if(!cur){
  52. cur = 1;
  53. }
  54. if(!select_sale_style||!select_user_style||!select_sale_shop||!keywords){
  55. select_sale_style = $('#select_sale_style').val();
  56. select_user_style = $('#select_user_style').val();
  57. select_sale_shop = $('#select_sale_shop').val();
  58. keywords = $('#keywords').val();
  59. }
  60. $.ajax({
  61. url:'./st-xm/control.php', //请求地址
  62. type: "post", //请求方式
  63. // data: data, //请求参数
  64. data:{
  65. type:"sale_channel",
  66. select_sale_style:select_sale_style,
  67. select_user_style:select_user_style,
  68. select_sale_shop:select_sale_shop,
  69. keywords:keywords,
  70. currpage:cur,
  71. pagesize:pagesize
  72. },
  73. async:false,
  74. dataType: "json",
  75. success: function (date1) {
  76. console.log(date1);
  77. if(date1.code == 0){
  78. console.log(date1.info);
  79. // alert('订单提交成功!订单号:' + date.order_id);
  80. // location.href = '/order_list.html';
  81. var sum = date1.totalNum;
  82. var tag = "test";
  83. var sendurl = './sale_channel.html?select_sale_style='+select_sale_style+'&select_user_style='+select_user_style+'&select_sale_shop='+select_sale_shop+'&keywords='+keywords;
  84. getPager(sendurl, sum, cur, pagesize,tag,'currpage');
  85. reloadInfo(date1);
  86. }else if(date1.code == -1){
  87. alert('没有相关数据');
  88. var sum = date1.totalNum;
  89. var tag = "test";
  90. var sendurl = './sale_channel.html?select_sale_style='+select_sale_style+'&select_user_style='+select_user_style+'&select_sale_shop='+select_sale_shop+'&keywords='+keywords;
  91. getPager(sendurl, sum, cur, pagesize,tag,'currpage');
  92. reloadInfo(date1);
  93. }
  94. },
  95. fail: function (date) {
  96. // 此处放失败后执行的代码
  97. }
  98. });
  99. if(cur!=1){
  100. var select_sale_style = getPar('select_sale_style');
  101. $('#select_sale_style').val(select_sale_style);
  102. var select_user_style = getPar('select_user_style');
  103. $('#select_user_style').val(select_user_style);
  104. var select_sale_shop = getPar('select_sale_shop');
  105. $('#select_sale_shop').val(select_sale_shop);
  106. var keywords = getPar('keywords');
  107. $('#keywords').val(keywords);
  108. }
  109. }
  110. //复选框判断
  111. function select_checked(index) {
  112. //index=0最上面的全选 index=1表示的是下面所有的
  113. var cur_check = $('.ace_check')[0];
  114. var checkList = $('.ace_check');
  115. var checkCount = checkList.length - 1;
  116. var true_count = 0;
  117. for (var i = 1; i < checkList.length; i++) {
  118. if (index == '0') {
  119. checkList[i].checked = cur_check.checked;
  120. } else {
  121. if (checkList[i].checked == false) {
  122. cur_check.checked = false
  123. } else {
  124. true_count = true_count + 1;
  125. }
  126. }
  127. }
  128. //判断下面是否选中完
  129. if (checkCount == true_count) {
  130. cur_check.checked = true;
  131. }
  132. }
  133. //加载数据
  134. function reloadInfo(data){
  135. var list = data.list;
  136. console.log(tttHTML)
  137. var newHTML='';
  138. for(var i=0;i<list.length;i++){
  139. var tempHTML=tttHTML;
  140. tempHTML=tempHTML.replace('[渠道性质]',list[i].CHAN_QUALITY);
  141. tempHTML=tempHTML.replace('[渠道分类]',list[i].CHAN_TYPE);
  142. tempHTML=tempHTML.replace('[渠道名称]',list[i].CHAN_NAME);
  143. tempHTML=tempHTML.replace('[所属区域]',list[i].AREA_ID);
  144. tempHTML=tempHTML.replace('[联系人]',list[i].LINKMAN);
  145. tempHTML=tempHTML.replace('[负责业务人员]',list[i].RESMAN);
  146. tempHTML=tempHTML.replace('[销售方式]',list[i].SELA_TYPE);
  147. tempHTML=tempHTML.replace('[账号状态]',list[i].STATUS);
  148. tempHTML=tempHTML.replace('[userid_style]','userid_style'+list[i].CUST_ID);
  149. tempHTML=tempHTML.replace('[oneCheck]','oneCheck'+list[i].CUST_ID);
  150. tempHTML=tempHTML.replace('[oneCheckName]',list[i].CUST_ID);
  151. if(list[i].STATUS=='待审核'){
  152. var str = '<a target="_Blank" onclick="open_new_path(this)" go_path="change_channel.html?org_id=' +list[i].CUST_ID + '&channel_style='+list[i].CHAN_QUALITY+'">管理</a>';
  153. tempHTML=tempHTML.replace('[操作]',str);
  154. }else if(list[i].STATUS=='启用'){
  155. var str = '<a target="_Blank" onclick="open_new_path(this)" go_path="change_channel.html?org_id=' +list[i].CUST_ID + '&channel_style='+list[i].CHAN_QUALITY+'">管理</a>'+'<a id ="start_or_stop'+list[i].CUST_ID+'" onclick="startOrStop(this.innerHTML,'+list[i].CUST_ID+')" style="margin-left: 20px;cursor:pointer;">停用</a>';
  156. tempHTML=tempHTML.replace('[操作]',str);
  157. }else{
  158. var str = '<a target="_Blank" onclick="open_new_path(this)" go_path="change_channel.html?org_id=' +list[i].CUST_ID + '&channel_style='+list[i].CHAN_QUALITY+'">管理</a>'+'<a id ="start_or_stop'+list[i].CUST_ID+'" onclick="startOrStop(this.innerHTML,'+list[i].CUST_ID+')" style="margin-left: 20px;cursor:pointer;">启用</a>';
  159. tempHTML=tempHTML.replace('[操作]',str);
  160. }
  161. newHTML+=tempHTML;
  162. }
  163. $('#list').html(newHTML);
  164. }
  165. //停用 启用按钮
  166. function startOrStop(status,orgid){
  167. if(status=='停用'){
  168. $.ajax({
  169. url:'./st-xm/control.php', //请求地址
  170. type: "post", //请求方式
  171. // data: data, //请求参数
  172. data:{
  173. type:"sale_stop",
  174. prod_id:orgid
  175. },
  176. async:false,
  177. dataType: "json",
  178. success: function (date1) {
  179. if(date1.code==0){
  180. //改变按钮状态
  181. $('#start_or_stop'+orgid).html('启用');
  182. //改变账号状态
  183. $('#userid_style'+orgid).html('停用');
  184. }
  185. },
  186. fail: function (date) {
  187. alert('停用失败');
  188. }
  189. });
  190. }else{
  191. $.ajax({
  192. url:'./st-xm/control.php', //请求地址
  193. type: "post", //请求方式
  194. // data: data, //请求参数
  195. data:{
  196. type:"sale_start",
  197. prod_id:orgid
  198. },
  199. async:false,
  200. dataType: "json",
  201. success: function (date1) {
  202. if(date1.code==0){
  203. //改变按钮状态
  204. $('#start_or_stop'+orgid).html('停用');
  205. //改变账号状态
  206. $('#userid_style'+orgid).html('启用');
  207. }
  208. },
  209. fail: function (date) {
  210. alert('启用失败');
  211. }
  212. });
  213. }
  214. }
  215. //新增销售渠道
  216. function addChannel(){
  217. // window.location.href='./channel_manager.html';
  218. // window.open('./channel_manager.html');
  219. $.cookie("path_url",cookie_path+"channel_manager.html",{domain:domain_path});
  220. window.open(system_path);
  221. }
  222. //停用选中项
  223. function stopSelect(){
  224. var ary = new Array();
  225. $('.ace_check').each(function(index, item) {
  226. if (this.checked && index != 0) {
  227. ary.push($(this).attr('name'));
  228. }
  229. });
  230. if (ary.length <= 0) {
  231. alert('请勾选!!!');
  232. return;
  233. }
  234. var pro_str = ary.join(',');
  235. //记录选中的未审核的个数
  236. var n = 0;
  237. $.ajax({
  238. url:'./st-xm/control.php', //请求地址
  239. type: "post", //请求方式
  240. // data: data, //请求参数
  241. data:{
  242. type:"sale_stop",
  243. prod_id:pro_str
  244. },
  245. async:false,
  246. dataType: "json",
  247. success: function (date1) {
  248. if(date1.code == 0){
  249. $('.ace_check').each(function(index, item) {
  250. if (this.checked && index != 0) {
  251. var stopid = $(this).attr('name');
  252. if($('#userid_style'+stopid).html() != "待审核"){
  253. //改变按钮状态
  254. $('#start_or_stop'+stopid).html('启用');
  255. //改变账号状态
  256. $('#userid_style'+stopid).html('停用');
  257. }else{
  258. n++;
  259. }
  260. }
  261. });
  262. if(n != 0){
  263. alert('所选有'+n+'条记录未通过审核,无法修改状态!');
  264. }
  265. }
  266. },
  267. fail: function (date) {
  268. alert('停用失败');
  269. }
  270. });
  271. }