workOrderTrend.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <moduleEnclosure title="近30天工单趋势">
  3. <template v-slot:rightce>
  4. <el-tabs v-model="tabCurrent" type="card" @tab-click="changeTab">
  5. <el-tab-pane v-for="(item, index) in tabList" :key="index" :label="item" :name="item"></el-tab-pane>
  6. </el-tabs>
  7. </template>
  8. <div class="all-container">
  9. <div id="workorderEcharts1" style="width: 100%; height: 100%"></div>
  10. </div>
  11. </moduleEnclosure>
  12. </template>
  13. <script>
  14. import vScrollView from 'v-scroll-view'
  15. import moduleEnclosure from '@/components/moduleEnclosure.vue';
  16. import * as echarts from 'echarts';
  17. import { getWorkorderTrend } from '@/api/bigView.js';
  18. import { csize } from '@/utils/const.js';
  19. export default {
  20. components: {
  21. moduleEnclosure,
  22. vScrollView
  23. },
  24. data() {
  25. return {
  26. tabList: [],
  27. tabCurrent: '',
  28. tableData: [],
  29. };
  30. },
  31. mounted() {
  32. this.dingshishuaxin()
  33. },
  34. beforeUnmount() {
  35. this.mouseenter();
  36. },
  37. watch: {
  38. tabCurrent() {
  39. this.mouseenter();
  40. this.dingshishuaxin()
  41. }
  42. },
  43. methods: {
  44. mouseenter() {
  45. if (this.TimeId) {
  46. clearTimeout(this.TimeId)
  47. }
  48. },
  49. dingshishuaxin() {
  50. this.initData();
  51. this.TimeId = setTimeout(() => {
  52. this.setbiuaoji()
  53. }, 3000)
  54. },
  55. getDate() {
  56. const today = new Date();
  57. const dates = [];
  58. for (let i = 0; i < 30; i++) {
  59. const d = new Date();
  60. d.setDate(today.getDate() - i);
  61. dates.unshift(d.toISOString().split('T')[0].slice(5, 11));
  62. }
  63. return dates;
  64. },
  65. setbiuaoji() {
  66. var index = this.tabList.indexOf(this.tabCurrent)
  67. if (index >= (this.tabList.length - 1)) {
  68. this.tabCurrent = this.tabList[0]
  69. } else {
  70. this.tabCurrent = this.tabList[index + 1]
  71. }
  72. },
  73. changeTab(item) {
  74. this.tabCurrent = item.name;
  75. this.initEcharts();
  76. },
  77. initData() {
  78. getWorkorderTrend().then(res => {
  79. this.tabList = res.data.map(o => o.lx);
  80. if (this.tabCurrent == "") {
  81. this.setbiuaoji()
  82. }
  83. this.tableData = res.data;
  84. this.initEcharts();
  85. })
  86. },
  87. initEcharts() {
  88. var chartDom = document.getElementById('workorderEcharts1');
  89. var myChart = echarts.init(chartDom);
  90. var option;
  91. option = {
  92. title: {
  93. text: ''
  94. },
  95. tooltip: {
  96. confine: true,
  97. trigger: 'axis',
  98. transitionDuration: 0,
  99. backgroundColor: '#092a66',
  100. borderColor: '#0462b5',
  101. borderRadius: 8,
  102. borderWidth: 2,
  103. padding: [5, 10],
  104. axisPointer: {
  105. type: 'line',
  106. lineStyle: {
  107. type: 'dashed',
  108. color: '#8AB1DC',
  109. },
  110. },
  111. textStyle: {
  112. color: '#ffffff'
  113. }
  114. },
  115. legend: {
  116. icon: 'circle',
  117. itemWidth: 8,
  118. itemHeight: 8,
  119. itemGap: 10,
  120. top: '16',
  121. right: '10',
  122. data: ['已完工', '未完工'],
  123. textStyle: {
  124. color: '#A9BBCC'
  125. },
  126. },
  127. // grid: {
  128. // left: '3%',
  129. // right: '4%',
  130. // bottom: '3%',
  131. // containLabel: true
  132. // },
  133. toolbox: {
  134. // feature: {
  135. // saveAsImage: {}
  136. // }
  137. },
  138. grid: {
  139. x: csize(40),
  140. y: csize(50),
  141. x2: csize(20),
  142. y2: csize(20),
  143. },
  144. xAxis: {
  145. type: 'category',
  146. boundaryGap: false,
  147. axisLabel: {
  148. fontSize: csize(12),
  149. },
  150. axisLine: {
  151. lineStyle: {
  152. color: '#8AB1DC', // x轴文字颜色
  153. }
  154. },
  155. splitLine: {
  156. show: true,
  157. lineStyle: {
  158. color: '#364D95', // x轴辅助线颜色
  159. }
  160. },
  161. data: this.getDate()
  162. },
  163. yAxis: {
  164. type: 'value',
  165. name: "(单/台)",
  166. nameTextStyle: {
  167. color: "#aaa",
  168. nameLocation: "start",
  169. // align: 'right'
  170. },
  171. axisLabel: {
  172. fontSize: csize(12),
  173. },
  174. axisLine: {
  175. lineStyle: {
  176. color: '#8AB1DC', // y轴文字颜色
  177. }
  178. },
  179. splitLine: {
  180. show: true,
  181. lineStyle: {
  182. color: '#364D95', // y轴辅助线颜色
  183. }
  184. }
  185. },
  186. series: [
  187. {
  188. name: '已完工',
  189. type: 'line',
  190. stack: 'Total',
  191. itemStyle: {
  192. normal: {
  193. color: '#44E28F',
  194. },
  195. },
  196. data: this.tableData.find(o => o.lx == this.tabCurrent).unitNum
  197. },
  198. {
  199. name: '未完工',
  200. type: 'line',
  201. stack: 'Total',
  202. itemStyle: {
  203. normal: {
  204. color: '#D73A79',
  205. },
  206. },
  207. data: this.tableData.find(o => o.lx == this.tabCurrent).unitNumWwg
  208. },
  209. ]
  210. };
  211. option && myChart.setOption(option);
  212. }
  213. },
  214. };
  215. </script>
  216. <style scoped lang="scss">
  217. ::v-deep .el-tabs {
  218. width: 100%;
  219. .el-tabs__header {
  220. margin-bottom: 0;
  221. border-bottom: none;
  222. }
  223. .el-tabs__nav {
  224. border: none;
  225. }
  226. .el-tabs__nav-prev {
  227. line-height: 30px;
  228. }
  229. .el-tabs__nav-next {
  230. line-height: 30px;
  231. }
  232. .el-tabs__item {
  233. width: 50px;
  234. height: 30px;
  235. line-height: 30px;
  236. color: #ffffff;
  237. border: 1px solid #254280 !important;
  238. font-size: 12px;
  239. font-weight: bold;
  240. margin-right: 10px;
  241. padding: 0 !important;
  242. text-align: center;
  243. &:last-child {
  244. margin-right: 0;
  245. }
  246. &.is-active {
  247. border: 1px solid #153781 !important;
  248. color: #1a8dc8;
  249. }
  250. }
  251. }
  252. .all-container {
  253. width: 100%;
  254. height: 100%;
  255. box-sizing: border-box;
  256. padding-top: 16px;
  257. }
  258. </style>