workOrderTrend.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <moduleEnclosure title="近30天工单趋势">
  3. <template v-slot:rightce>
  4. <div class="tabbar">
  5. <div :class="tabIndex == index?'tab active':'tab'" v-for="(item,index) in tabs" :key="index" @click="tabIndex = index">{{item}}</div>
  6. </div>
  7. </template>
  8. <div id="main2" style="width: 100%; height: 100%">
  9. </div>
  10. </moduleEnclosure>
  11. </template>
  12. <script>
  13. import moduleEnclosure from '@/components/moduleEnclosure.vue';
  14. import * as echarts from 'echarts';
  15. import { getQuery11 } from '@/api/bigView.js';
  16. import { csize } from '@/utils/const.js';
  17. let myChart3;
  18. export default {
  19. components: {
  20. moduleEnclosure,
  21. },
  22. data() {
  23. return {
  24. tabs: ['安装','维修','回收'],
  25. tabIndex: 0,
  26. myChart2: null,
  27. };
  28. },
  29. mounted() {
  30. this.timeId = getQuery11((res) => {
  31. this.init_myChart2(res.data);
  32. }, 30000);
  33. },
  34. beforeUnmount() {
  35. this.timeId();
  36. },
  37. methods: {
  38. init_myChart2(value) {
  39. var times = value.map((item) => {
  40. var str1 = item.ddate.split(' ')[0];
  41. return str1.slice(5);
  42. });
  43. var data1 = value.map((item) => {
  44. return item.completeMachine;
  45. });
  46. var data2 = value.map((item) => {
  47. return item.completeOrder;
  48. });
  49. if (myChart3) {
  50. myChart3.dispose();
  51. }
  52. myChart3 = new echarts.init(document.getElementById('main2'));
  53. myChart3.setOption({
  54. tooltip: {
  55. trigger: 'axis',
  56. formatter: function (params) {
  57. var res = '';
  58. for (var i = 0, l = params.length; i < l; i++) {
  59. res +=
  60. '' + params[i].seriesName + ' : ' + params[i].value + '<br>';
  61. }
  62. return `<div style="color:#fff;">${res}</div>`;
  63. },
  64. transitionDuration: 0,
  65. backgroundColor: '#092a66',
  66. borderColor: '#0462b5',
  67. borderRadius: 8,
  68. borderWidth: 2,
  69. padding: [5, 10],
  70. axisPointer: {
  71. type: 'line',
  72. lineStyle: {
  73. type: 'dashed',
  74. color: '#8AB1DC',
  75. },
  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. fontSize: csize(16),
  88. color: '#8AB1DC',
  89. },
  90. },
  91. grid: {
  92. x: csize(65),
  93. y: csize(50),
  94. x2: csize(30),
  95. y2: csize(30),
  96. containLabel: false,
  97. },
  98. xAxis: [
  99. {
  100. type: 'category',
  101. boundaryGap: false,
  102. axisLabel: {
  103. interval: Math.floor(times.length / 10),
  104. showMinLabel: true, //是否显示最小 tick 的 label
  105. showMaxLabel: true, //是否显示最大 tick 的 label
  106. fontSize: csize(12),
  107. },
  108. axisLine: {
  109. show: false,
  110. lineStyle: {
  111. color: '#8AB1DC',
  112. },
  113. },
  114. axisTick: {
  115. show: false,
  116. },
  117. data: times,
  118. },
  119. ],
  120. yAxis: [
  121. {
  122. type: 'value',
  123. name: '单',
  124. nameTextStyle: {
  125. fontSize: csize(16),
  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(137, 189, 27, 0.3)',
  171. },
  172. {
  173. offset: 0.8,
  174. color: 'rgba(137, 189, 27, 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: '#1cc840',
  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(0, 136, 212, 0.3)',
  211. },
  212. {
  213. offset: 0.8,
  214. color: 'rgba(0, 136, 212, 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: '#43bbfb',
  226. },
  227. },
  228. data: data2,
  229. },
  230. ],
  231. });
  232. },
  233. },
  234. };
  235. </script>
  236. <style scoped lang="scss">
  237. .tabbar{
  238. display: flex;
  239. .tab{
  240. width: 50px;
  241. color: #ffffff;
  242. border: 1px solid #254280;
  243. font-size: 12px;
  244. font-weight: bold;
  245. padding: 2px 0;
  246. margin-right: 14px;
  247. text-align: center;
  248. cursor: pointer;
  249. }
  250. .active{
  251. border: 1px solid #153781;
  252. color: #1a8dc8;
  253. }
  254. }
  255. #main2{
  256. }
  257. </style>