dataOverview.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. })
  26. }
  27. },
  28. data: {
  29. "content": {
  30. dateType: "本年",
  31. dataid: wx.getStorageSync('userMsg').userid,
  32. username: wx.getStorageSync('userMsg').name,
  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. },
  51. methods: {
  52. getList() {
  53. let content = this.data.content;
  54. const {
  55. dataid,
  56. type,
  57. username,
  58. isleave
  59. } = getCurrentPages()[getCurrentPages().length - 1].data;
  60. content.dataid = dataid;
  61. content.type = type;
  62. content.username = username;
  63. content.where.isleave = isleave;
  64. _Http.basic({
  65. "id": 2024062609373902,
  66. content
  67. }).then(res => {
  68. console.log("营销费用数据概况", res)
  69. if (res.code != '1') return wx.showToast({
  70. title: res.msg,
  71. icon: "none"
  72. })
  73. const getMapText = getApp().globalData.Language.getMapText;
  74. let list = [{
  75. title: '营销费用总金额',
  76. value: CNY(res.data.amount),
  77. tips: "",
  78. link: true
  79. },
  80. {
  81. title: '营销费用总数量',
  82. value: res.data.count,
  83. tips: '',
  84. link: true
  85. }
  86. ]
  87. this.setData({
  88. list,
  89. content
  90. })
  91. this.onCancel()
  92. })
  93. },
  94. showTips(e) {
  95. const {
  96. tips
  97. } = e.currentTarget.dataset;
  98. wx.showModal({
  99. content: tips,
  100. showCancel: false,
  101. confirmText: getApp().globalData.Language.getMapText('确定'),
  102. })
  103. },
  104. toDetail(e) {
  105. const {
  106. item
  107. } = e.currentTarget.dataset;
  108. },
  109. openDateType() {
  110. this.setData({
  111. detaShow: true
  112. })
  113. },
  114. dateOnSelect(event) {
  115. const {
  116. value
  117. } = event.detail;
  118. if (this.data.content.dateType == value) return this.onCancel();
  119. this.setData({
  120. "content.dateType": value,
  121. dates: this.data.dates.map(item => {
  122. item.color = item.value == value ? "#3874F6" : "";
  123. item.loading = item.value == value ? true : false;
  124. return item
  125. }),
  126. })
  127. this.getList(true)
  128. },
  129. onCancel() {
  130. this.setData({
  131. actionShow: false,
  132. detaShow: false,
  133. list: this.data.list.map(item => {
  134. item.loading = false;
  135. return item
  136. }),
  137. dates: this.data.dates.map(item => {
  138. item.loading = false;
  139. return item
  140. })
  141. })
  142. },
  143. }
  144. })