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. this.setData({
  18. "content.dataid": wx.getStorageSync('userMsg').userid,
  19. "content.username": wx.getStorageSync('userMsg').name,
  20. })
  21. }
  22. },
  23. data: {
  24. "content": {
  25. unwriteoffamounttype: "订单",
  26. where: {}
  27. },
  28. pages: {
  29. pageNumber: 1,
  30. pageTotal: 1,
  31. pageSize: 20
  32. },
  33. list: []
  34. },
  35. methods: {
  36. async getList(init = false) {
  37. if (init.detail != undefined) init = init.detail;
  38. let content = this.data.content,
  39. pages = this.data.pages;
  40. const {
  41. dataid,
  42. type,
  43. username,
  44. isleave
  45. } = getCurrentPages()[getCurrentPages().length - 1].data;
  46. if (content.dataid != dataid || content.type != type || isleave != isleave) init = true
  47. content.dataid = dataid;
  48. content.type = type;
  49. content.username = username;
  50. content.where.isleave = isleave;
  51. if (init) {
  52. pages.pageNumber = 1;
  53. pages.pageTotal = 1;
  54. }
  55. if (pages.pageNumber <= pages.pageTotal) _Http.basic({
  56. "id": 20231016163904,
  57. content: Object.assign(content, pages)
  58. }).then(res => {
  59. console.log("出货未开票分析", res)
  60. this.selectComponent('#ListBox').automaticSetHei();
  61. this.selectComponent('#ListBox').RefreshToComplete();
  62. if (res.code != '1') return wx.showToast({
  63. title: res.data,
  64. icon: "none"
  65. })
  66. res.data = res.data.map(v => {
  67. v.zerotothree = CNY(v.zerotothree)
  68. v.threetosix = CNY(v.threetosix)
  69. v.sixtotwelve = CNY(v.sixtotwelve)
  70. v.twelveup = CNY(v.twelveup)
  71. v.total = CNY(v.total)
  72. return v
  73. })
  74. pages.pageNumber++;
  75. pages.pageTotal = res.pageTotal;
  76. this.setData({
  77. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  78. pages
  79. })
  80. if (init) this.initChart(res.data[0].Trend)
  81. })
  82. },
  83. toDetail(e) {
  84. let content = this.data.content;
  85. content.sys_enterpriseid = e.currentTarget.dataset.item.sys_enterpriseid;
  86. content.enterprisename = e.currentTarget.dataset.item.enterprisename;
  87. wx.navigateTo({
  88. url: '/salesPanel/AnalysisOfUninvoicedShipments/detail?content=' + JSON.stringify(content)
  89. })
  90. },
  91. initChart(data) {
  92. let dividend = wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000;
  93. let option = {
  94. tooltip: {
  95. trigger: 'axis',
  96. confine: true, // Ensure tooltip stays within the chart area
  97. formatter: function (params) {
  98. let tooltipText = '';
  99. params.forEach((item, index) => {
  100. tooltipText += `${index==0?item.axisValue+'\n':''}${item.marker}${item.seriesName}: ${item.value}\n`;
  101. });
  102. return tooltipText;
  103. },
  104. textStyle: {
  105. fontSize: 10,
  106. }
  107. },
  108. xAxis: {
  109. max: 'dataMax'
  110. },
  111. yAxis: {
  112. type: 'category',
  113. data: data.map(v => getApp().globalData.Language.getMapText(v.key)),
  114. inverse: true,
  115. animationDuration: 300,
  116. animationDurationUpdate: 300
  117. },
  118. series: [{
  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. })