workOrderTrend.vue 5.0 KB

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