serve.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. lifetimes: {
  7. attached: function () {
  8. getApp().globalData.Language.getLanguagePackage(this)
  9. }
  10. },
  11. properties: {
  12. mode: {
  13. type: String
  14. }
  15. },
  16. data: {
  17. dateTypes: ["全部", "本年"],
  18. showList: false,
  19. list: [],
  20. dateType: "本年", //联系人用
  21. "isAll": 0, //客户和项目用 1全部 0本年 99时间范围
  22. "content": {
  23. "nocache": true,
  24. "pageNumber": 1,
  25. "pageTotal": 1,
  26. "total": null,
  27. "where": {
  28. begdate: "",
  29. enddate: "",
  30. }
  31. }
  32. },
  33. methods: {
  34. getList(id, init) {
  35. let content = this.data.content;
  36. if (init) {
  37. content.pageNumber = 1;
  38. content.total = null;
  39. }
  40. if (!this.data.showList && content.total != null) return;
  41. if (content.pageNumber > content.pageTotal) return;
  42. const types = {
  43. 客户: {
  44. id: 20230713104404,
  45. idName: "sa_customersid"
  46. },
  47. 项目: {
  48. id: 20230716151004,
  49. idName: "sa_projectid"
  50. }
  51. },
  52. mode = this.data.mode;
  53. content[types[mode].idName] = id;
  54. content.isAll = this.data.isAll;
  55. _Http.basic({
  56. "id": types[mode].id,
  57. content
  58. }).then(res => {
  59. console.log(this.data.mode + "服务", res)
  60. if (res.code != '1') return wx.showToast({
  61. title: res.data,
  62. icon: "none"
  63. })
  64. content.pageNumber = res.pageNumber + 1;
  65. content.pageSize = res.pageSize;
  66. content.pageTotal = res.pageTotal;
  67. content.total = res.total;
  68. this.setData({
  69. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  70. content,
  71. id: id,
  72. });
  73. this.selectComponent("#TimeRange").onCancel()
  74. })
  75. },
  76. changeDate({
  77. detail
  78. }) {
  79. this.setData({
  80. dateType: detail.dateType,
  81. isAll: detail.isAll,
  82. "content.where.begdate": detail.begdate || "",
  83. "content.where.enddate": detail.enddate || ""
  84. })
  85. this.getList(this.data.id, true)
  86. },
  87. shrinkChange({
  88. detail
  89. }) {
  90. this.setData({
  91. showList: detail
  92. })
  93. }
  94. }
  95. })