followUp.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. let dateTypes = [];
  10. if (this.data.mode == "联系人") {
  11. dateTypes = ["全部", "本年", "本季", "本月"]
  12. } else {
  13. dateTypes = ["全部", "本年"]
  14. }
  15. this.setData({
  16. dateTypes
  17. })
  18. }
  19. },
  20. properties: {
  21. mode: {
  22. type: String
  23. }
  24. },
  25. data: {
  26. dateTypes: [],
  27. showList: false,
  28. list: [],
  29. dateType: "本年", //联系人用
  30. "isAll": 0, //客户和项目用 1全部 0本年 99时间范围
  31. "content": {
  32. "nocache": true,
  33. "pageNumber": 1,
  34. "pageTotal": 1,
  35. "total": null,
  36. "where": {
  37. begdate: "",
  38. enddate: "",
  39. }
  40. }
  41. },
  42. methods: {
  43. getList(id, init) {
  44. let content = this.data.content;
  45. if (init) {
  46. content.pageNumber = 1;
  47. content.total = null;
  48. }
  49. if (!this.data.showList && content.total != null) return;
  50. if (content.pageNumber > content.pageTotal) return;
  51. const types = {
  52. 联系人: {
  53. id: 20240605110904,
  54. idName: "sys_phonebookid"
  55. },
  56. 客户: {
  57. id: 20230713103904,
  58. idName: "sa_customersid"
  59. },
  60. 项目: {
  61. id: 20230715111804,
  62. idName: "sa_projectid"
  63. }
  64. },
  65. mode = this.data.mode;
  66. content[types[mode].idName] = id;
  67. if (mode == "联系人") {
  68. content.dateType = this.data.dateType;
  69. } else {
  70. content.isAll = this.data.isAll;
  71. }
  72. _Http.basic({
  73. "id": types[mode].id,
  74. content
  75. }).then(res => {
  76. console.log(this.data.mode + "跟进", res)
  77. if (res.code != '1') return wx.showToast({
  78. title: res.data,
  79. icon: "none"
  80. })
  81. content.pageNumber = res.pageNumber + 1;
  82. content.pageSize = res.pageSize;
  83. content.pageTotal = res.pageTotal;
  84. content.total = res.total;
  85. try {
  86. res.data = res.data.map(item => {
  87. try {
  88. if (!item.followname.length) item.followname = ' --'
  89. } catch (error) {
  90. item.followname = ' --'
  91. }
  92. item.cons = item.content.split(';').filter(v => v).map(v => {
  93. let arr = v.split(':')
  94. return {
  95. label: arr[0] || "--",
  96. value: arr[1] || "--"
  97. }
  98. })
  99. return item
  100. })
  101. } catch (error) {
  102. console.log("error", error)
  103. }
  104. this.setData({
  105. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  106. content,
  107. id: id,
  108. });
  109. this.selectComponent("#TimeRange").onCancel()
  110. })
  111. },
  112. changeDate({
  113. detail
  114. }) {
  115. console.log(detail)
  116. this.setData({
  117. dateType: detail.dateType,
  118. isAll: detail.isAll,
  119. "content.where.begdate": detail.begdate || "",
  120. "content.where.enddate": detail.enddate || ""
  121. })
  122. this.getList(this.data.id, true)
  123. },
  124. shrinkChange({
  125. detail
  126. }) {
  127. this.setData({
  128. showList: detail
  129. })
  130. },
  131. viewInstructions() {
  132. getApp().globalData.Language.modeBoxPrompts('定义:每次平均跟进天数;若没有跟进次数,则跟进频率-0天/次;若有跟进次数,则按跟进频率=(首次跟进时间到当前时间的天数-节假日天数)÷跟进次数')
  133. }
  134. }
  135. })