index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. list: [],
  5. loading: false,
  6. content: {
  7. nocache: true,
  8. pageNumber: 1,
  9. pageSize: 20,
  10. pageTotal: 1,
  11. total: null,
  12. where: {
  13. condition: "",
  14. tablefilter: {
  15. taskname: null,
  16. name: null,
  17. year: null,
  18. status: null,
  19. createby: null
  20. }
  21. }
  22. }
  23. },
  24. onLoad() {
  25. this.getList(true);
  26. },
  27. onShow() {
  28. if (this.data._loaded) {
  29. this.getList(true);
  30. }
  31. this.setData({ _loaded: true });
  32. },
  33. onPullDownRefresh() {
  34. this.getList(true);
  35. wx.stopPullDownRefresh();
  36. },
  37. onReachBottom() {
  38. if (this.data.content.pageNumber <= this.data.content.pageTotal) {
  39. this.getList(false);
  40. }
  41. },
  42. onSearch(e) {
  43. const keyword = typeof e.detail === 'string' ? e.detail : (e.detail.value || "");
  44. this.setData({
  45. "content.where.condition": keyword,
  46. "content.pageNumber": 1
  47. });
  48. this.getList(true);
  49. },
  50. getList(init) {
  51. if (init.detail != undefined) init = init.detail;
  52. let content = this.data.content;
  53. if (init) {
  54. content.pageNumber = 1;
  55. this.setData({ loading: true });
  56. }
  57. if (content.pageNumber > content.pageTotal) return;
  58. _Http.basic({
  59. "id": "2026041309474202",
  60. content
  61. }).then(res => {
  62. this.setData({ loading: false });
  63. console.log("合同任务列表", res);
  64. this.selectComponent('#ListBox').RefreshToComplete();
  65. if (res.msg !== '成功') return wx.showToast({
  66. title: res.msg,
  67. icon: "none"
  68. });
  69. this.setData({
  70. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  71. "content.pageNumber": res.pageNumber + 1,
  72. "content.pageSize": res.pageSize,
  73. "content.pageTotal": res.pageTotal,
  74. "content.total": res.total
  75. });
  76. }).catch(() => {
  77. this.setData({ loading: false });
  78. this.selectComponent('#ListBox').RefreshToComplete();
  79. wx.showToast({ title: '加载失败', icon: 'none' });
  80. });
  81. },
  82. goToCreate() {
  83. wx.navigateTo({
  84. url: '/CRM/contract/create'
  85. });
  86. }
  87. });