dataOverview.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true,
  5. },
  6. properties: {
  7. update: {
  8. type: Function
  9. }
  10. },
  11. lifetimes: {
  12. attached: function () {
  13. getApp().globalData.Language.getLanguagePackage(this)
  14. this.setData({
  15. dates: this.data.dates.map(v => {
  16. v.name = getApp().globalData.Language.getMapText(v.value);
  17. v.color = v.value == this.data.content.dateType ? "#3874F6" : "";
  18. return v
  19. })
  20. })
  21. }
  22. },
  23. data: {
  24. "content": {
  25. dateType: "本年",
  26. dataid: wx.getStorageSync('userMsg').userid,
  27. username: wx.getStorageSync('userMsg').name,
  28. type: 0,
  29. "where": {
  30. isleave: "1"
  31. }
  32. },
  33. detaShow: false,
  34. dates: [{
  35. value: "全部"
  36. }, {
  37. value: "本年"
  38. }, {
  39. value: "本季"
  40. }, {
  41. value: "本月"
  42. }, {
  43. value: "去年"
  44. }, ],
  45. },
  46. methods: {
  47. getList() {
  48. let content = this.data.content;
  49. const {
  50. dataid,
  51. type,
  52. username,
  53. isleave
  54. } = getCurrentPages()[getCurrentPages().length - 1].data;
  55. content.dataid = dataid;
  56. content.type = type;
  57. content.username = username;
  58. content.where.isleave = isleave;
  59. _Http.basic({
  60. "id": 20231015170504,
  61. content
  62. }).then(res => {
  63. console.log("客户数据概况", res)
  64. if (res.code != '1') return wx.showToast({
  65. title: res.msg,
  66. icon: "none"
  67. })
  68. const getMapText = getApp().globalData.Language.getMapText;
  69. let list = [{
  70. title: '客户总数',
  71. value: res.data.total,
  72. tips: getMapText('客户总数:包含我的客户、公海客户数量'),
  73. link: true
  74. },
  75. {
  76. title: '公海客户数',
  77. value: res.data.customerpoolqty,
  78. tips: '',
  79. link: true
  80. },
  81. {
  82. title: '成交客户数',
  83. value: res.data.tradedCustomers,
  84. tips: getMapText('成交客户:已成交、多次成交状态的客户数量'),
  85. link: true
  86. },
  87. {
  88. title: '参与项目客户数',
  89. value: res.data.participateProject,
  90. tips: getMapText('参与项目客户数:参与有下订单的项目的关联客户数'),
  91. link: true
  92. },
  93. ]
  94. try {
  95. list = list.concat(res.data.data.map(v => {
  96. return {
  97. title: v.value,
  98. value: v.qty,
  99. tips: v.value == '无分类客户' ? getMapText('统计没有客户分类信息的客户数量') : "",
  100. link: true
  101. }
  102. }))
  103. } catch (error) {
  104. }
  105. this.setData({
  106. list,
  107. content
  108. })
  109. this.onCancel()
  110. })
  111. },
  112. showTips(e) {
  113. const {
  114. tips
  115. } = e.currentTarget.dataset;
  116. wx.showModal({
  117. content: tips,
  118. showCancel: false,
  119. confirmText: getApp().globalData.Language.getMapText('确定'),
  120. })
  121. },
  122. toDetail(e) {
  123. const {
  124. item
  125. } = e.currentTarget.dataset;
  126. },
  127. openDateType() {
  128. this.setData({
  129. detaShow: true
  130. })
  131. },
  132. dateOnSelect(event) {
  133. const {
  134. value
  135. } = event.detail;
  136. if (this.data.content.dateType == value) return this.onCancel();
  137. this.setData({
  138. "content.dateType": value,
  139. dates: this.data.dates.map(item => {
  140. item.color = item.value == value ? "#3874F6" : "";
  141. item.loading = item.value == value ? true : false;
  142. return item
  143. }),
  144. })
  145. this.getList(true)
  146. },
  147. onCancel() {
  148. this.setData({
  149. actionShow: false,
  150. detaShow: false,
  151. list: this.data.list.map(item => {
  152. item.loading = false;
  153. return item
  154. }),
  155. dates: this.data.dates.map(item => {
  156. item.loading = false;
  157. return item
  158. })
  159. })
  160. },
  161. }
  162. })