dataOverview.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. "content.dataid": wx.getStorageSync('userMsg').userid,
  21. "content.username": wx.getStorageSync('userMsg').name,
  22. })
  23. }
  24. },
  25. data: {
  26. "content": {
  27. dateType: "本年",
  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. value: "去年"
  46. }, ],
  47. },
  48. methods: {
  49. getList() {
  50. let content = this.data.content;
  51. const {
  52. dataid,
  53. type,
  54. username,
  55. isleave
  56. } = getCurrentPages()[getCurrentPages().length - 1].data;
  57. content.dataid = dataid;
  58. content.type = type;
  59. content.username = username;
  60. content.where.isleave = isleave;
  61. _Http.basic({
  62. "id": 20231015170504,
  63. content
  64. }).then(res => {
  65. console.log("客户数据概况", res)
  66. if (res.code != '1') return wx.showToast({
  67. title: res.msg,
  68. icon: "none"
  69. })
  70. const getMapText = getApp().globalData.Language.getMapText;
  71. let list = [{
  72. title: '客户总数',
  73. value: res.data.total,
  74. tips: getMapText('客户总数:包含医院管理、公海客户数量'),
  75. link: true
  76. },
  77. {
  78. title: '公海客户数',
  79. value: res.data.customerpoolqty,
  80. tips: '',
  81. link: true
  82. },
  83. {
  84. title: '成交客户数',
  85. value: res.data.tradedCustomers,
  86. tips: getMapText('成交客户:已成交、多次成交状态的客户数量'),
  87. link: true
  88. },
  89. {
  90. title: '参与项目客户数',
  91. value: res.data.participateProject,
  92. tips: getMapText('参与项目客户数:参与有下订单的项目的关联客户数'),
  93. link: true
  94. },
  95. ]
  96. try {
  97. list = list.concat(res.data.data.map(v => {
  98. return {
  99. title: v.value,
  100. value: v.qty,
  101. tips: v.value == '无分类客户' ? getMapText('统计没有客户分类信息的客户数量') : "",
  102. link: true
  103. }
  104. }))
  105. } catch (error) {
  106. }
  107. this.setData({
  108. list,
  109. content
  110. })
  111. this.onCancel()
  112. })
  113. },
  114. showTips(e) {
  115. const {
  116. tips
  117. } = e.currentTarget.dataset;
  118. wx.showModal({
  119. content: tips,
  120. showCancel: false,
  121. confirmText: getApp().globalData.Language.getMapText('确定'),
  122. })
  123. },
  124. toDetail(e) {
  125. const {
  126. item
  127. } = e.currentTarget.dataset,
  128. content = this.data.content;
  129. content.typemx = item.title;
  130. wx.navigateTo({
  131. url: '/salesPanel/dataOverview/OverviewAndDetails/Client?content=' + JSON.stringify(content),
  132. })
  133. },
  134. openDateType() {
  135. this.setData({
  136. detaShow: true
  137. })
  138. },
  139. dateOnSelect(event) {
  140. const {
  141. value
  142. } = event.detail;
  143. if (this.data.content.dateType == value) return this.onCancel();
  144. this.setData({
  145. "content.dateType": value,
  146. dates: this.data.dates.map(item => {
  147. item.color = item.value == value ? "#3874F6" : "";
  148. item.loading = item.value == value ? true : false;
  149. return item
  150. }),
  151. })
  152. this.getList(true)
  153. },
  154. onCancel() {
  155. this.setData({
  156. actionShow: false,
  157. detaShow: false,
  158. list: this.data.list.map(item => {
  159. item.loading = false;
  160. return item
  161. }),
  162. dates: this.data.dates.map(item => {
  163. item.loading = false;
  164. return item
  165. })
  166. })
  167. },
  168. }
  169. })