orderTrend.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. methods: {
  28. getDate() {
  29. const today = new Date()
  30. const dates = []
  31. for (let i = 0; i < 30; i++) {
  32. const d = new Date()
  33. d.setDate(today.getDate() - i)
  34. dates.unshift(d.toISOString().split('T')[0].slice(5, 11))
  35. }
  36. return dates
  37. },
  38. initEcharts(data) {
  39. var times = this.getDate()
  40. var data1 = data.map(item => {
  41. return item.sxdds || 0
  42. })
  43. var data2 = data.map(item => {
  44. return item.fcdds || 0
  45. })
  46. var data3 = data.map(item => {
  47. return item.pjdds || 0
  48. })
  49. var data4 = data.map(item => {
  50. return item.zzdds || 0
  51. })
  52. if (myChart4) {
  53. myChart4.dispose()
  54. }
  55. myChart4 = new echarts.init(document.getElementById('orderEcharts1'))
  56. myChart4.setOption({
  57. tooltip: {
  58. confine: true,
  59. trigger: 'axis',
  60. transitionDuration: 0,
  61. backgroundColor: '#092a66',
  62. borderColor: '#0462b5',
  63. borderRadius: 8,
  64. borderWidth: 2,
  65. padding: [5, 10],
  66. axisPointer: {
  67. type: 'line',
  68. lineStyle: {
  69. type: 'dashed',
  70. color: '#8AB1DC'
  71. }
  72. },
  73. textStyle: {
  74. color: '#ffffff'
  75. }
  76. },
  77. legend: {
  78. icon: 'circle',
  79. itemWidth: 8,
  80. itemHeight: 8,
  81. itemGap: 10,
  82. top: '16',
  83. right: '10',
  84. data: ['新增辅材单', '新增配件单'],
  85. textStyle: {
  86. color: '#A9BBCC'
  87. }
  88. },
  89. grid: {
  90. x: csize(40),
  91. y: csize(50),
  92. x2: csize(20),
  93. y2: csize(20)
  94. },
  95. xAxis: [
  96. {
  97. type: 'category',
  98. boundaryGap: false,
  99. axisLabel: {
  100. interval: Math.floor(times.length / 10),
  101. showMinLabel: true, //是否显示最小 tick 的 label
  102. showMaxLabel: true, //是否显示最大 tick 的 label
  103. fontSize: csize(12)
  104. },
  105. axisLine: {
  106. show: false,
  107. lineStyle: {
  108. color: '#8AB1DC'
  109. }
  110. },
  111. axisTick: {
  112. show: false
  113. },
  114. data: times
  115. }
  116. ],
  117. yAxis: [
  118. {
  119. type: 'value',
  120. minInterval: 1,
  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: 'rgba(256, 256, 256, 0.1)'
  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>