team-inner.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**新增 修改弹框中的列表渲染及分页操作**/
  2. var innerPage = 1;
  3. // 新增修改 组织人员 列表渲染 ajax请求
  4. function getTeamInnerList(queryParam = {}, innerPage = 1) {
  5. queryParam.page = innerPage;
  6. queryParam.limit = 1; // 每页显示条数
  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. items += "<tr>" + "<td class='status' data-username='" + item.username + "' data-phone='" + item.phone + "'></td>" + "<td>" + item.username + "</td>" + "<td>" + item.phone + "</td>" + "</tr>"
  14. })
  15. $('#dataList2').html(items);
  16. $('#dataList3').html(items);
  17. } else {
  18. $('#dataList2').html('');
  19. $('#dataList3').html('');
  20. }
  21. console.log(result)
  22. totalPages = result.totalCount / result.limit;
  23. totalPages = Math.ceil(totalPages);
  24. $('#totalPage2').html(totalPages); // 总共多少页
  25. $('#dataTotal2').html(result.totalCount); // 总共多少条数据
  26. $('#currentPage2').val(innerPage); // 当前页面
  27. let pageFrom = (innerPage - 1) * result.limit + 1; // 开始
  28. let pageTo = result.page * result.limit; // 结束
  29. pageTo = pageTo > result.totalCount ? result.totalCount : pageTo;
  30. $('#pageFrom2').html(pageFrom);
  31. $('#pageTo2').html(pageTo);
  32. // 无数据时
  33. if (!result.totalCount) {
  34. $('.pager2.has-data').hide()
  35. $('.pager2.no-data').show()
  36. } else {
  37. $('.pager2.has-data').show()
  38. $('.pager2.no-data').hide()
  39. }
  40. if (innerPage < totalPages) {
  41. $('#nextPageButton2,#lastPageButton2').removeClass('disabled');
  42. } else {
  43. $('#nextPageButton2,#lastPageButton2').addClass('disabled');
  44. }
  45. if (innerPage === 1) {
  46. $('#firstPageButton2,#prevPageButton2').addClass('disabled');
  47. } else {
  48. $('#firstPageButton2,#prevPageButton2').removeClass('disabled');
  49. }
  50. }, function(errorMsg) {
  51. alert("请求数据失败!");
  52. }, 3)
  53. };
  54. // 分页操作
  55. $('#firstPageButton2').on('click', function() {
  56. innerPage = 1;
  57. getTeamInnerList({}, 1);
  58. });
  59. $('#lastPageButton2').on('click', function() {
  60. innerPage = totalPages;
  61. getTeamInnerList({}, innerPage);
  62. });
  63. $('#prevPageButton2').on('click', function() {
  64. innerPage -= 1;
  65. getTeamInnerList({}, innerPage);
  66. });
  67. $('#nextPageButton2').on('click', function() {
  68. innerPage += 1;
  69. getTeamInnerList({}, innerPage);
  70. })
  71. // 分页刷新按钮
  72. $('.pg-refresh2').click(resetForm);
  73. // 重置表单
  74. function resetForm() {
  75. innerPage = 1;
  76. getTeamInnerList();
  77. }