dataOverview.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../../utils/currency"),
  3. CNY = (value, symbol = "", precision = 2) => currency(value, {
  4. symbol,
  5. precision
  6. }).format();
  7. Component({
  8. options: {
  9. addGlobalClass: true,
  10. },
  11. properties: {
  12. update: {
  13. type: Function
  14. }
  15. },
  16. lifetimes: {
  17. attached: function () {
  18. getApp().globalData.Language.getLanguagePackage(this)
  19. this.setData({
  20. dates: this.data.dates.map(v => {
  21. v.name = getApp().globalData.Language.getMapText(v.value);
  22. v.color = v.value == this.data.content.dateType ? "#3874F6" : "";
  23. return v
  24. }),
  25. "content.dataid": wx.getStorageSync('userMsg').userid,
  26. "content.username": wx.getStorageSync('userMsg').name,
  27. })
  28. }
  29. },
  30. data: {
  31. "content": {
  32. dateType: "本年",
  33. type: 0,
  34. "where": {
  35. isleave: "1"
  36. }
  37. },
  38. detaShow: false,
  39. dates: [{
  40. value: "全部"
  41. }, {
  42. value: "本年"
  43. }, {
  44. value: "本季"
  45. }, {
  46. value: "本月"
  47. }, {
  48. value: "上月"
  49. }, {
  50. value: "去年"
  51. }, ],
  52. },
  53. methods: {
  54. getList() {
  55. let content = this.data.content;
  56. const {
  57. dataid,
  58. type,
  59. username,
  60. isleave
  61. } = getCurrentPages()[getCurrentPages().length - 1].data;
  62. content.dataid = dataid;
  63. content.type = type;
  64. content.username = username;
  65. content.where.isleave = isleave;
  66. _Http.basic({
  67. "id": 2024062609373902,
  68. content
  69. }).then(res => {
  70. console.log("营销费用数据概况", res)
  71. if (res.code != '1') return wx.showToast({
  72. title: res.msg,
  73. icon: "none"
  74. })
  75. const getMapText = getApp().globalData.Language.getMapText;
  76. let list = [{
  77. title: '营销费用总金额',
  78. value: CNY(res.data.amount),
  79. tips: "",
  80. link: true
  81. },
  82. {
  83. title: '营销费用总数量',
  84. value: res.data.count,
  85. tips: '',
  86. link: true
  87. }
  88. ]
  89. this.setData({
  90. list,
  91. content
  92. })
  93. this.onCancel()
  94. })
  95. },
  96. showTips(e) {
  97. const {
  98. tips
  99. } = e.currentTarget.dataset;
  100. wx.showModal({
  101. content: tips,
  102. showCancel: false,
  103. confirmText: getApp().globalData.Language.getMapText('确定'),
  104. })
  105. },
  106. toDetail(e) {
  107. const {
  108. item
  109. } = e.currentTarget.dataset,
  110. content = this.data.content;
  111. content.typemx = item.title;
  112. wx.navigateTo({
  113. url: '/salesPanel/dataOverview/OverviewAndDetails/Costs?content=' + JSON.stringify(content),
  114. })
  115. },
  116. openDateType() {
  117. this.setData({
  118. detaShow: true
  119. })
  120. },
  121. dateOnSelect(event) {
  122. const {
  123. value
  124. } = event.detail;
  125. if (this.data.content.dateType == value) return this.onCancel();
  126. this.setData({
  127. "content.dateType": value,
  128. dates: this.data.dates.map(item => {
  129. item.color = item.value == value ? "#3874F6" : "";
  130. item.loading = item.value == value ? true : false;
  131. return item
  132. }),
  133. })
  134. this.getList(true)
  135. },
  136. onCancel() {
  137. this.setData({
  138. actionShow: false,
  139. detaShow: false,
  140. list: this.data.list.map(item => {
  141. item.loading = false;
  142. return item
  143. }),
  144. dates: this.data.dates.map(item => {
  145. item.loading = false;
  146. return item
  147. })
  148. })
  149. },
  150. }
  151. })