dataOverview.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. _Http.basic({
  50. "id": 20231015170504,
  51. content
  52. }).then(res => {
  53. console.log("客户数据概况", res)
  54. if (res.code != '1') return wx.showToast({
  55. title: res.msg,
  56. icon: "none"
  57. })
  58. const getMapText = getApp().globalData.Language.getMapText;
  59. let list = [{
  60. title: '客户总数',
  61. value: res.data.total,
  62. tips: getMapText('客户总数:包含我的客户、公海客户数量'),
  63. link: true
  64. },
  65. {
  66. title: '公海客户数',
  67. value: res.data.customerpoolqty,
  68. tips: '',
  69. link: true
  70. },
  71. {
  72. title: '成交客户数',
  73. value: res.data.tradedCustomers,
  74. tips: getMapText('成交客户:已成交、多次成交状态的客户数量'),
  75. link: true
  76. },
  77. {
  78. title: '参与项目客户数',
  79. value: res.data.participateProject,
  80. tips: getMapText('参与项目客户数:参与有下订单的项目的关联客户数'),
  81. link: true
  82. },
  83. ]
  84. try {
  85. list = list.concat(res.data.data.map(v => {
  86. return {
  87. title: v.value,
  88. value: v.qty,
  89. tips: v.value == '无分类客户' ? getMapText('统计没有客户分类信息的客户数量') : "",
  90. link: true
  91. }
  92. }))
  93. } catch (error) {
  94. }
  95. this.setData({
  96. list,
  97. content
  98. })
  99. this.onCancel()
  100. })
  101. },
  102. showTips(e) {
  103. const {
  104. tips
  105. } = e.currentTarget.dataset;
  106. wx.showModal({
  107. content: tips,
  108. showCancel: false,
  109. confirmText: getApp().globalData.Language.getMapText('确定'),
  110. })
  111. },
  112. toDetail(e) {
  113. const {
  114. item
  115. } = e.currentTarget.dataset;
  116. },
  117. openDateType() {
  118. this.setData({
  119. detaShow: true
  120. })
  121. },
  122. dateOnSelect(event) {
  123. const {
  124. value
  125. } = event.detail;
  126. if (this.data.content.dateType == value) return this.onCancel();
  127. this.setData({
  128. "content.dateType": value,
  129. dates: this.data.dates.map(item => {
  130. item.color = item.value == value ? "#3874F6" : "";
  131. item.loading = item.value == value ? true : false;
  132. return item
  133. }),
  134. })
  135. this.getList(true)
  136. },
  137. onCancel() {
  138. this.setData({
  139. actionShow: false,
  140. detaShow: false,
  141. list: this.data.list.map(item => {
  142. item.loading = false;
  143. return item
  144. }),
  145. dates: this.data.dates.map(item => {
  146. item.loading = false;
  147. return item
  148. })
  149. })
  150. },
  151. }
  152. })