dataOverview.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. content = this.data.content;
  109. content.typemx = item.title;
  110. wx.navigateTo({
  111. url: '/salesPanel/dataOverview/OverviewAndDetails/Costs?content=' + JSON.stringify(content),
  112. })
  113. },
  114. openDateType() {
  115. this.setData({
  116. detaShow: true
  117. })
  118. },
  119. dateOnSelect(event) {
  120. const {
  121. value
  122. } = event.detail;
  123. if (this.data.content.dateType == value) return this.onCancel();
  124. this.setData({
  125. "content.dateType": value,
  126. dates: this.data.dates.map(item => {
  127. item.color = item.value == value ? "#3874F6" : "";
  128. item.loading = item.value == value ? true : false;
  129. return item
  130. }),
  131. })
  132. this.getList(true)
  133. },
  134. onCancel() {
  135. this.setData({
  136. actionShow: false,
  137. detaShow: false,
  138. list: this.data.list.map(item => {
  139. item.loading = false;
  140. return item
  141. }),
  142. dates: this.data.dates.map(item => {
  143. item.loading = false;
  144. return item
  145. })
  146. })
  147. },
  148. }
  149. })