orderTrend.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <moduleEnclosure title="近30日订单趋势">
  3. <div id="orderEcharts1" style="width: 100%; height: 100%"></div>
  4. </moduleEnclosure>
  5. </template>
  6. <script>
  7. import moduleEnclosure from '@/components/moduleEnclosure.vue';
  8. import * as echarts from 'echarts';
  9. import { getOrderTrend } from '@/api/bigView.js';
  10. import { csize } from '@/utils/const.js';
  11. let myChart4;
  12. export default {
  13. components: {
  14. moduleEnclosure,
  15. },
  16. data() {
  17. return {
  18. myChart2: null,
  19. };
  20. },
  21. 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 times = this.getDate();
  41. var data1 = data.map((item) => {
  42. return item.sxdds || 0;
  43. });
  44. var data2 = data.map((item) => {
  45. return item.fcdds || 0;
  46. });
  47. var data3 = data.map((item) => {
  48. return item.pjdds || 0;
  49. });
  50. var data4 = data.map((item) => {
  51. return item.zzdds || 0;
  52. });
  53. if (myChart4) {
  54. myChart4.dispose();
  55. }
  56. myChart4 = new echarts.init(document.getElementById('orderEcharts1'));
  57. myChart4.setOption({
  58. tooltip : {
  59. confine: true,
  60. trigger: 'axis',
  61. transitionDuration: 0,
  62. backgroundColor: '#092a66',
  63. borderColor: '#0462b5',
  64. borderRadius: 8,
  65. borderWidth: 2,
  66. padding: [5, 10],
  67. axisPointer: {
  68. type: 'line',
  69. lineStyle: {
  70. type: 'dashed',
  71. color: '#8AB1DC',
  72. },
  73. },
  74. textStyle: {
  75. color: '#ffffff'
  76. }
  77. },
  78. legend: {
  79. icon: 'circle',
  80. itemWidth: 8,
  81. itemHeight: 8,
  82. itemGap: 10,
  83. top: '16',
  84. right: '10',
  85. data: ['新增销售单', '新增辅材单', '新增配件单', '新增增值单'],
  86. textStyle: {
  87. color: '#A9BBCC',
  88. },
  89. },
  90. grid: {
  91. x: csize(50),
  92. y: csize(50),
  93. x2: csize(20),
  94. y2: csize(20),
  95. },
  96. xAxis: [
  97. {
  98. type: 'category',
  99. boundaryGap: false,
  100. axisLabel: {
  101. interval: Math.floor(times.length / 10),
  102. showMinLabel: true, //是否显示最小 tick 的 label
  103. showMaxLabel: true, //是否显示最大 tick 的 label
  104. fontSize: csize(12),
  105. },
  106. axisLine: {
  107. show: false,
  108. lineStyle: {
  109. color: '#8AB1DC',
  110. },
  111. },
  112. axisTick: {
  113. show: false,
  114. },
  115. data: times,
  116. },
  117. ],
  118. yAxis: [
  119. {
  120. type: 'value',
  121. name: '(单/台)',
  122. nameTextStyle: {
  123. color: "#aaa",
  124. nameLocation: "start",
  125. // align: 'right'
  126. },
  127. axisLine: {
  128. show: false,
  129. lineStyle: {
  130. color: '#8AB1DC',
  131. },
  132. },
  133. axisLabel: {
  134. margin: 10,
  135. textStyle: {
  136. fontSize: csize(12),
  137. },
  138. },
  139. splitLine: {
  140. lineStyle: {
  141. color: '#364D95',
  142. },
  143. },
  144. axisTick: {
  145. show: false,
  146. },
  147. },
  148. ],
  149. series: [
  150. {
  151. name: '新增销售单',
  152. type: 'line',
  153. smooth: true,
  154. showSymbol: false,
  155. lineStyle: {
  156. normal: {
  157. width: 2,
  158. },
  159. },
  160. areaStyle: {
  161. normal: {
  162. color: new echarts.graphic.LinearGradient(
  163. 0,
  164. 0,
  165. 0,
  166. 1,
  167. [
  168. {
  169. offset: 0,
  170. color: 'rgba(253, 173, 96, 0.3)',
  171. },
  172. {
  173. offset: 0.8,
  174. color: 'rgba(253, 173, 96, 0)',
  175. },
  176. ],
  177. false
  178. ),
  179. shadowColor: 'rgba(0, 0, 0, 0.1)',
  180. shadowBlur: 10,
  181. },
  182. },
  183. itemStyle: {
  184. normal: {
  185. color: '#FDAD60',
  186. },
  187. },
  188. data: data1,
  189. },
  190. {
  191. name: '新增辅材单',
  192. type: 'line',
  193. smooth: true,
  194. showSymbol: false,
  195. lineStyle: {
  196. normal: {
  197. width: 2,
  198. },
  199. },
  200. areaStyle: {
  201. normal: {
  202. color: new echarts.graphic.LinearGradient(
  203. 0,
  204. 0,
  205. 0,
  206. 1,
  207. [
  208. {
  209. offset: 0,
  210. color: 'rgba(68, 226, 143, 0.3)',
  211. },
  212. {
  213. offset: 0.8,
  214. color: 'rgba(68, 226, 143, 0)',
  215. },
  216. ],
  217. false
  218. ),
  219. shadowColor: 'rgba(0, 0, 0, 0.1)',
  220. shadowBlur: 10,
  221. },
  222. },
  223. itemStyle: {
  224. normal: {
  225. color: '#44E28F',
  226. },
  227. },
  228. data: data2,
  229. },
  230. {
  231. name: '新增配件单',
  232. type: 'line',
  233. smooth: true,
  234. showSymbol: false,
  235. lineStyle: {
  236. normal: {
  237. width: 2,
  238. },
  239. },
  240. areaStyle: {
  241. normal: {
  242. color: new echarts.graphic.LinearGradient(
  243. 0,
  244. 0,
  245. 0,
  246. 1,
  247. [
  248. {
  249. offset: 0,
  250. color: 'rgba(160, 61, 239, 0.3)',
  251. },
  252. {
  253. offset: 0.8,
  254. color: 'rgba(160, 61, 239, 0)',
  255. },
  256. ],
  257. false
  258. ),
  259. shadowColor: 'rgba(0, 0, 0, 0.1)',
  260. shadowBlur: 10,
  261. },
  262. },
  263. itemStyle: {
  264. normal: {
  265. color: '#A03DEF',
  266. },
  267. },
  268. data: data3,
  269. },
  270. {
  271. name: '新增增值单',
  272. type: 'line',
  273. smooth: true,
  274. showSymbol: false,
  275. lineStyle: {
  276. normal: {
  277. width: 2,
  278. },
  279. },
  280. areaStyle: {
  281. normal: {
  282. color: new echarts.graphic.LinearGradient(
  283. 0,
  284. 0,
  285. 0,
  286. 1,
  287. [
  288. {
  289. offset: 0,
  290. color: 'rgba(65, 197, 226, 0.3)',
  291. },
  292. {
  293. offset: 0.8,
  294. color: 'rgba(65, 197, 226, 0)',
  295. },
  296. ],
  297. false
  298. ),
  299. shadowColor: 'rgba(0, 0, 0, 0.1)',
  300. shadowBlur: 10,
  301. },
  302. },
  303. itemStyle: {
  304. normal: {
  305. color: '#41C5E2',
  306. },
  307. },
  308. data: data4,
  309. },
  310. ],
  311. });
  312. },
  313. },
  314. };
  315. </script>
  316. <style></style>