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.
 
 
 
 

183 lines
4.3 KiB

  1. var prod_id = '';
  2. var listHTML = '';
  3. var stopListHTML = '';
  4. //停用启用的html
  5. var html_stop = '';
  6. var html_start = '';
  7. var urlstr = base_api + 'index.php'
  8. window.onload = function(){
  9. prod_id = getPar('prod_id');
  10. listHTML = $('#list_info').html();
  11. stopListHTML = $('#list_info_no').html();
  12. html_stop = $('#html_stop').html();
  13. html_start = $('#html_start').html();
  14. var data = {
  15. tp:'supply_dataInfo_execUser',
  16. supplier_id:prod_id,
  17. operate:'list'
  18. }
  19. console.log(data);
  20. $.ajax({
  21. url: urlstr, //请求地址
  22. type: "post", //请求方式
  23. data: data,
  24. async: false,
  25. dataType: "json",
  26. success: function(data) {
  27. if(data.code == 0) {
  28. console.log(data);
  29. reloadData(data);
  30. }else{
  31. console.log(data.info);
  32. }
  33. }
  34. });
  35. }
  36. //填充数据
  37. function reloadData(data){
  38. var list = data.list;
  39. var newHTML='';
  40. for(var i=0;i<list.length;i++){
  41. var tempHTML = '';
  42. if (list[i].status == '停用') {
  43. tempHTML = listHTML;
  44. } else{
  45. tempHTML = stopListHTML;
  46. }
  47. tempHTML=tempHTML.replace('[姓名]',list[i].true_name);
  48. tempHTML=tempHTML.replace('[id]',list[i].id);
  49. newHTML+=tempHTML;
  50. }
  51. $('#list_info').html(newHTML);
  52. }
  53. //添加账号
  54. function addAccount(){
  55. window.location.href = './add_account.html?prod_id='+prod_id;
  56. }
  57. //修改
  58. function changeDidClicked(obj){
  59. var user_id = $(obj).closest('.acoont_info').attr('id');
  60. window.location.href = './change_account.html?user_id='+user_id+'&prod_id='+prod_id;
  61. }
  62. //停用
  63. function stopDidClicked(obj){
  64. var user_id = $(obj).closest('.acoont_info').attr('id');
  65. var data = {
  66. tp:'supply_dataInfo_execUser',
  67. user_id:user_id,
  68. operate:'stop'
  69. }
  70. console.log('停用参数');
  71. console.log(data);
  72. $.ajax({
  73. url:urlstr, //请求地址
  74. type: "post", //请求方式
  75. data: data,
  76. async: false,
  77. dataType: "json",
  78. success: function(data) {
  79. if(data.code == 0) {
  80. console.log(data);
  81. $(obj).parent().html(html_start);
  82. }else{
  83. console.log(data.info);
  84. }
  85. }
  86. });
  87. // $(obj).closest('.acoont_info').find('.btns').removeClass('btn-primary');
  88. // $(obj).closest('.acoont_info').find('.btns').addClass('btn_stop');
  89. // $(obj).closest('.acoont_info').find('.stop_info_btn').addClass('ui_hide');
  90. // $(obj).closest('.acoont_info').find('.start_info_btn').removeClass('ui_hide');
  91. // $(obj).closest('.acoont_info').find('.change_info_btn').removeAttr('onclick');
  92. // $(obj).closest('.acoont_info').find('.del_info_btn').removeAttr('onclick');
  93. }
  94. //启用
  95. function startDidClicked(obj){
  96. var user_id = $(obj).closest('.acoont_info').attr('id');
  97. var data = {
  98. tp:'supply_dataInfo_execUser',
  99. user_id:user_id,
  100. operate:'start'
  101. }
  102. console.log('启用参数');
  103. console.log(data);
  104. $.ajax({
  105. url: urlstr, //请求地址
  106. type: "post", //请求方式
  107. data: data,
  108. async: false,
  109. dataType: "json",
  110. success: function(data) {
  111. if(data.code == 0) {
  112. console.log(data);
  113. $(obj).parent().html(html_stop);
  114. }else{
  115. console.log(data.info);
  116. }
  117. }
  118. });
  119. // $(obj).closest('.acoont_info').find('.btns').addClass('btn-primary');
  120. // $(obj).closest('.acoont_info').find('.btns').removeClass('btn_stop');
  121. // $(obj).closest('.acoont_info').find('.stop_info_btn').removeClass('ui_hide');
  122. // $(obj).closest('.acoont_info').find('.start_info_btn').addClass('ui_hide');
  123. // $(obj).closest('.acoont_info').find('.change_info_btn').attr('onclick','changeDidClicked(this);');
  124. // $(obj).closest('.acoont_info').find('.del_info_btn').attr('onclick','delDidClicked(this);');
  125. }
  126. //删除
  127. function delDidClicked(obj){
  128. //调用删除接口
  129. var user_id = $(obj).closest('.acoont_info').attr('id');
  130. var data = {
  131. tp:'supply_dataInfo_execUser',
  132. user_id:user_id,
  133. operate:'delete'
  134. }
  135. console.log('删除参数');
  136. console.log(data);
  137. $.ajax({
  138. url: urlstr, //请求地址
  139. type: "post", //请求方式
  140. data: data,
  141. async: false,
  142. dataType: "json",
  143. success: function(data) {
  144. if(data.code == 0) {
  145. console.log(data);
  146. $(obj).closest('.acoont_info').remove();
  147. }else{
  148. console.log(data.info);
  149. }
  150. }
  151. });
  152. }
  153. //得到url上的参数
  154. function getPar(par){
  155. var local_url = document.location.href;
  156. local_url = decodeURI(local_url);
  157. var get = local_url.indexOf(par +"=");
  158. if(get == -1){
  159. return false;
  160. }
  161. var get_par = local_url.slice(par.length + get + 1);
  162. var nextPar = get_par.indexOf("&");
  163. if(nextPar != -1){
  164. get_par = get_par.slice(0, nextPar);
  165. }
  166. return get_par;
  167. }