index.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. import * as echarts from '../ec-canvas/echarts';
  8. Component({
  9. properties: {
  10. },
  11. options: {
  12. addGlobalClass: true
  13. },
  14. lifetimes: {
  15. attached: function () {
  16. getApp().globalData.Language.getLanguagePackage(this)
  17. }
  18. },
  19. data: {
  20. "content": {
  21. dataid: wx.getStorageSync('userMsg').userid,
  22. username: wx.getStorageSync('userMsg').name,
  23. unwriteoffamounttype: "订单",
  24. where: {}
  25. },
  26. pages: {
  27. pageNumber: 1,
  28. pageTotal: 1,
  29. pageSize: 20
  30. },
  31. list: []
  32. },
  33. methods: {
  34. async getList(init = false) {
  35. if (init.detail != undefined) init = init.detail;
  36. let content = this.data.content,
  37. pages = this.data.pages;
  38. const {
  39. dataid,
  40. type,
  41. username,
  42. isleave
  43. } = getCurrentPages()[getCurrentPages().length - 1].data;
  44. if (content.dataid != dataid || content.type != type || isleave != isleave) init = true
  45. content.dataid = dataid;
  46. content.type = type;
  47. content.username = username;
  48. content.where.isleave = isleave;
  49. if (init) {
  50. pages.pageNumber = 1;
  51. pages.pageTotal = 1;
  52. }
  53. if (pages.pageNumber <= pages.pageTotal) _Http.basic({
  54. "id": 20231016163904,
  55. content: Object.assign(content, pages)
  56. }).then(res => {
  57. console.log("出货未开票分析", res)
  58. this.selectComponent('#ListBox').RefreshToComplete();
  59. if (res.code != '1') return wx.showToast({
  60. title: res.data,
  61. icon: "none"
  62. })
  63. res.data = res.data.map(v => {
  64. v.zerotothree = CNY(v.zerotothree)
  65. v.threetosix = CNY(v.threetosix)
  66. v.sixtotwelve = CNY(v.sixtotwelve)
  67. v.twelveup = CNY(v.twelveup)
  68. v.total = CNY(v.total)
  69. return v
  70. })
  71. pages.pageNumber++;
  72. pages.pageTotal = res.pageTotal;
  73. this.setData({
  74. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  75. pages
  76. })
  77. if (init) this.initChart(res.data[0].Trend)
  78. })
  79. },
  80. toDetail(e) {
  81. let content = this.data.content;
  82. content.sys_enterpriseid = e.currentTarget.dataset.item.sys_enterpriseid;
  83. content.enterprisename = e.currentTarget.dataset.item.enterprisename;
  84. wx.navigateTo({
  85. url: '/salesPanel/AnalysisOfUninvoicedShipments/detail?content=' + JSON.stringify(content)
  86. })
  87. },
  88. initChart(data) {
  89. console.log(123)
  90. let dividend = wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000;
  91. let option = {
  92. tooltip: {
  93. trigger: 'axis',
  94. confine: true, // Ensure tooltip stays within the chart area
  95. formatter: function (params) {
  96. let tooltipText = '';
  97. params.forEach((item, index) => {
  98. tooltipText += `${index==0?item.axisValue+'\n':''}${item.marker}${item.seriesName}: ${item.value}\n`;
  99. });
  100. return tooltipText;
  101. },
  102. textStyle: {
  103. fontSize: 10,
  104. }
  105. },
  106. xAxis: {
  107. max: 'dataMax'
  108. },
  109. yAxis: {
  110. type: 'category',
  111. data: data.map(v => getApp().globalData.Language.getMapText(v.key)),
  112. inverse: true,
  113. animationDuration: 300,
  114. animationDurationUpdate: 300,
  115. max: 3 // only the largest 3 bars will be displayed
  116. },
  117. series: [{
  118. realtimeSort: true,
  119. name: getApp().globalData.Language.getMapText('出货未开票金额') + '(' + getApp().globalData.Language.getMapText('万元') + ')',
  120. type: 'bar',
  121. data: data.map(v => (v.value / dividend).toFixed(2)),
  122. label: {
  123. show: true,
  124. valueAnimation: true
  125. }
  126. }],
  127. legend: {
  128. show: true
  129. },
  130. grid: {
  131. top: '10%',
  132. left: '3%',
  133. right: '4%',
  134. bottom: '3%',
  135. containLabel: true
  136. },
  137. animationDuration: 0,
  138. animationDurationUpdate: 3000,
  139. animationEasing: 'linear',
  140. animationEasingUpdate: 'linear'
  141. };
  142. this.chartComponent = this.selectComponent('#mychart');
  143. this.chartComponent.init((canvas, width, height, dpr) => {
  144. const chart = echarts.init(canvas, null, {
  145. width,
  146. height,
  147. devicePixelRatio: dpr
  148. });
  149. chart.setOption(option);
  150. return chart;
  151. });
  152. },
  153. showExplain(e) {
  154. const {
  155. name
  156. } = e.currentTarget.dataset;
  157. getApp().globalData.Language.modeBoxPrompts(getApp().globalData.Language.getMapText('统计到当前查询时间为止的') + name + "(" + getApp().globalData.Language.getMapText('审核状态') + ")")
  158. },
  159. }
  160. })