team-inner.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**新增 修改弹框中的列表渲染及分页操作**/
  2. var innerPage = 1;
  3. // 新增修改 组织人员 列表渲染 ajax请求
  4. function getTeamInnerList(queryParam = {}, innerPage = 1) {
  5. queryParam.page = innerPage;
  6. queryParam.limit = 5; // 每页显示条数
  7. queryParam.start = (queryParam.page - 1) * queryParam.limit;
  8. ajaxRequest(TEAM_INNERLIST, "POST", queryParam, function(result) {
  9. let data = result.RESULT;
  10. let items = '';
  11. if (result.totalCount > 0) {
  12. data.forEach(function(item, key) {
  13. if (item.pd) {
  14. items += "<tr class='selected'>" + "<td class='status checked' data-username='" + item.username + "' data-phone='" + item.phone + "'></td>" + "<td>" + item.username + "</td>" + "<td>" + item.phone + "</td>" + "</tr>"
  15. } else {
  16. items += "<tr>" + "<td class='status' data-username='" + item.username + "' data-phone='" + item.phone + "'></td>" + "<td>" + item.username + "</td>" + "<td>" + item.phone + "</td>" + "</tr>"
  17. }
  18. })
  19. $('#dataList2').html(items);
  20. $('#dataList3').html(items);
  21. } else {
  22. $('#dataList2').html('');
  23. $('#dataList3').html('');
  24. }
  25. console.log(result)
  26. totalPages = result.totalCount / result.limit;
  27. totalPages = Math.ceil(totalPages);
  28. $('#totalPage2,#totalPage3').html(totalPages); // 总共多少页
  29. $('#dataTotal2,#dataTotal3').html(result.totalCount); // 总共多少条数据
  30. $('#currentPage2,#currentPage3').val(innerPage); // 当前页面
  31. let pageFrom = (innerPage - 1) * result.limit + 1; // 开始
  32. let pageTo = result.page * result.limit; // 结束
  33. pageTo = pageTo > result.totalCount ? result.totalCount : pageTo;
  34. $('#pageFrom2,#pageFrom3').html(pageFrom);
  35. $('#pageTo2,#pageTo3').html(pageTo);
  36. // 无数据时
  37. if (!result.totalCount) {
  38. $('.pager2.has-data').hide()
  39. $('.pager2.no-data').show()
  40. } else {
  41. $('.pager2.has-data').show()
  42. $('.pager2.no-data').hide()
  43. }
  44. if (innerPage < totalPages) {
  45. $('#nextPageButton2,#lastPageButton2').removeClass('disabled');
  46. $('#nextPageButton3,#lastPageButton3').removeClass('disabled');
  47. } else {
  48. $('#nextPageButton2,#lastPageButton2').addClass('disabled');
  49. $('#nextPageButton3,#lastPageButton3').addClass('disabled');
  50. }
  51. if (innerPage === 1) {
  52. $('#firstPageButton2,#prevPageButton2').addClass('disabled');
  53. $('#firstPageButton3,#prevPageButton3').addClass('disabled');
  54. } else {
  55. $('#firstPageButton2,#prevPageButton2').removeClass('disabled');
  56. $('#firstPageButton3,#prevPageButton3').removeClass('disabled');
  57. }
  58. }, function(errorMsg) {
  59. alert("请求数据失败!");
  60. }, 3)
  61. };
  62. // // 分页操作
  63. // $('#firstPageButton2').on('click', function() {
  64. // innerPage = 1;
  65. // getTeamInnerList({}, 1);
  66. // });
  67. // $('#lastPageButton2').on('click', function() {
  68. // innerPage = totalPages;
  69. // getTeamInnerList({}, innerPage);
  70. // });
  71. // $('#prevPageButton2').on('click', function() {
  72. // innerPage -= 1;
  73. // getTeamInnerList({}, innerPage);
  74. // });
  75. // $('#nextPageButton2').on('click', function() {
  76. // innerPage += 1;
  77. // getTeamInnerList({}, innerPage);
  78. // })
  79. // // 分页刷新按钮
  80. // $('.pg-refresh2').click(resetForm);
  81. // // 重置表单
  82. // function resetForm() {
  83. // innerPage = 1;
  84. // getTeamInnerList();
  85. // }
  86. // 新增修改弹框分页操作
  87. $('#firstPageButton2,#firstPageButton3').on('click', function() {
  88. innerPage = 1;
  89. getTeamInnerList({}, 1);
  90. });
  91. $('#lastPageButton2,#lastPageButton3').on('click', function() {
  92. innerPage = totalPages;
  93. getTeamInnerList({}, innerPage);
  94. });
  95. $('#prevPageButton2,#prevPageButton3').on('click', function() {
  96. innerPage -= 1;
  97. getTeamInnerList({}, innerPage);
  98. });
  99. $('#nextPageButton2,#nextPageButton3').on('click', function() {
  100. innerPage += 1;
  101. getTeamInnerList({}, innerPage);
  102. })
  103. // 新增分页刷新按钮
  104. $('.pg-refresh2').click(resetForm);
  105. function resetForm() {
  106. innerPage = 1;
  107. getTeamInnerList();
  108. }
  109. // 修改分页刷新
  110. $('.pg-refresh3').click(resetForm);
  111. function resetForm() {
  112. let dataId = $('.pure-table #dataList tr').find('.checked').data('id');
  113. innerPage = 1;
  114. getTeamInnerList({ 'dwid': dataId });
  115. }