orderAmountTrend.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <moduleEnclosure title="近30日订单金额趋势">
  3. <div class="all-container">
  4. <div id="orderEcharts2" style="width: 100%; height: 100%"></div>
  5. </div>
  6. </moduleEnclosure>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. import moduleEnclosure from '@/components/moduleEnclosure.vue';
  11. import { getOrderTrend } from '@/api/bigView.js';
  12. import { csize } from '@/utils/const.js';
  13. export default {
  14. components: {
  15. moduleEnclosure,
  16. },
  17. data() {
  18. return {
  19. };
  20. },
  21. async mounted() {
  22. getOrderTrend().then(res => {
  23. this.initEcharts(res.data);
  24. })
  25. },
  26. beforeUnmount() {
  27. },
  28. methods: {
  29. getDate() {
  30. const today = new Date();
  31. const dates = [];
  32. for (let i = 0; i < 30; i++) {
  33. const d = new Date();
  34. d.setDate(today.getDate() - i);
  35. dates.unshift(d.toISOString().split('T')[0].slice(5, 11));
  36. }
  37. return dates;
  38. },
  39. initEcharts(data) {
  40. var chartDom = document.getElementById('orderEcharts2');
  41. var myChart = echarts.init(chartDom);
  42. var option;
  43. option = {
  44. title: {
  45. text: ''
  46. },
  47. tooltip: {
  48. confine: true,
  49. trigger: 'axis',
  50. transitionDuration: 0,
  51. backgroundColor: '#092a66',
  52. borderColor: '#0462b5',
  53. borderRadius: 8,
  54. borderWidth: 2,
  55. padding: [5, 10],
  56. axisPointer: {
  57. type: 'line',
  58. lineStyle: {
  59. type: 'dashed',
  60. color: '#8AB1DC',
  61. },
  62. },
  63. textStyle: {
  64. color: '#ffffff'
  65. }
  66. },
  67. legend: {
  68. icon: 'circle',
  69. itemWidth: 8,
  70. itemHeight: 8,
  71. itemGap: 10,
  72. top: '16',
  73. right: '10',
  74. textStyle: {
  75. color: '#A9BBCC'
  76. },
  77. data: ['新增销售金额', '新增辅材金额', '新增配件金额', '新增增值金额'],
  78. },
  79. grid: {
  80. x: csize(40),
  81. y: csize(40),
  82. x2: csize(20),
  83. y2: csize(20),
  84. },
  85. toolbox: {
  86. // feature: {
  87. // saveAsImage: {}
  88. // }
  89. },
  90. xAxis: {
  91. type: 'category',
  92. boundaryGap: false,
  93. axisLabel: {
  94. fontSize: csize(12),
  95. },
  96. axisLine: {
  97. lineStyle: {
  98. color: '#8AB1DC', // x轴文字颜色
  99. }
  100. },
  101. splitLine: {
  102. show: true,
  103. lineStyle: {
  104. color: '#364D95', // x轴辅助线颜色
  105. }
  106. },
  107. data: this.getDate()
  108. },
  109. yAxis: {
  110. type: 'value',
  111. name: "(元)",
  112. nameTextStyle: {
  113. color: "#aaa",
  114. nameLocation: "start",
  115. align: 'right'
  116. },
  117. axisLabel: {
  118. fontSize: csize(12),
  119. },
  120. axisLine: {
  121. lineStyle: {
  122. color: '#8AB1DC', // y轴文字颜色
  123. }
  124. },
  125. splitLine: {
  126. show: true,
  127. lineStyle: {
  128. color: '#364D95', // y轴辅助线颜色
  129. }
  130. }
  131. },
  132. series: [
  133. {
  134. name: '新增销售金额',
  135. type: 'line',
  136. stack: 'Total',
  137. itemStyle: {
  138. normal: {
  139. color: '#FDFE02',
  140. },
  141. },
  142. data: data.map(o => o.sxddje)
  143. },
  144. {
  145. name: '新增辅材金额',
  146. type: 'line',
  147. stack: 'Total',
  148. itemStyle: {
  149. normal: {
  150. color: '#44E28F',
  151. },
  152. },
  153. data: data.map(o => o.fcddje)
  154. },
  155. {
  156. name: '新增配件金额',
  157. type: 'line',
  158. stack: 'Total',
  159. itemStyle: {
  160. normal: {
  161. color: '#41C5E2',
  162. },
  163. },
  164. data: data.map(o => o.pjddje)
  165. },
  166. {
  167. name: '新增增值金额',
  168. type: 'line',
  169. stack: 'Total',
  170. itemStyle: {
  171. normal: {
  172. color: '#D73A79',
  173. },
  174. },
  175. data: data.map(o => o.zzddje)
  176. }
  177. ]
  178. };
  179. option && myChart.setOption(option);
  180. }
  181. },
  182. };
  183. </script>
  184. <style scoped lang="scss">
  185. .all-container {
  186. width: 100%;
  187. height: 100%;
  188. box-sizing: border-box;
  189. padding-top: 16px;
  190. }
  191. </style>