team-inner.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. $('#firstPageButton3').on('click', function() {
  81. innerPage = 1;
  82. getTeamInnerList(getSearchParamObj2(), 1);
  83. });
  84. $('#lastPageButton3').on('click', function() {
  85. innerPage = totalPages;
  86. getTeamInnerList(getSearchParamObj2(), innerPage);
  87. });
  88. $('#prevPageButton3').on('click', function() {
  89. innerPage -= 1;
  90. getTeamInnerList(getSearchParamObj2(), innerPage);
  91. });
  92. $('#nextPageButton3').on('click', function() {
  93. innerPage += 1;
  94. getTeamInnerList(getSearchParamObj2(), innerPage);
  95. })
  96. // 新增分页刷新按钮
  97. $('.pg-refresh2').click(resetForm);
  98. function resetForm() {
  99. innerPage = 1;
  100. getTeamInnerList();
  101. }
  102. // 修改分页刷新
  103. $('.pg-refresh3').click(resetForm);
  104. function resetForm() {
  105. let dataId = $('.pure-table #dataList tr').find('.checked').data('id');
  106. innerPage = 1;
  107. getTeamInnerList({ 'dwid': dataId });
  108. }
  109. // 拼接搜索条件
  110. function getSearchParamObj2() {
  111. let dataId = $('.pure-table #dataList tr').find('.checked').data('id');
  112. let queryParam = {};
  113. queryParam.dwid = dataId;
  114. return queryParam;
  115. }