smodule100.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="module-main">
  3. <div class="module-box">
  4. <div class="header">
  5. <div class="rhombus" />
  6. <span class="title">医废周数据分析</span>
  7. </div>
  8. <echarts v-if="!loading" :data="echartdata" class="echarts" />
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import Vue from 'vue';
  14. import Component from 'vue-class-component';
  15. import Echarts from '@/common/components/echarts.vue';
  16. import api from '../../api';
  17. @Component({
  18. components: {
  19. Echarts,
  20. },
  21. props: {
  22. data: {
  23. type: Object,
  24. default: null,
  25. },
  26. },
  27. })
  28. export default class Smodule100 extends Vue {
  29. loading = true;
  30. echartdata = {
  31. tooltip: {
  32. trigger: 'axis',
  33. axisPointer: {
  34. type: 'cross',
  35. crossStyle: {
  36. color: '#999',
  37. },
  38. },
  39. },
  40. color: ['#B24038', '#FFF000', '#709FA6', '#C8856B', '#9DC5B0'], // , '#7D9D85'
  41. legend: {
  42. data: [],
  43. textStyle: {
  44. color: '#88B1D0',
  45. fontSize: 10,
  46. },
  47. },
  48. xAxis: [
  49. {
  50. type: 'category',
  51. data: [],
  52. rotate: 45,
  53. axisLabel: {
  54. textStyle: {
  55. color: '#fff',
  56. },
  57. },
  58. splitLine: {
  59. show: false, // 去掉网格线
  60. },
  61. splitArea: {
  62. show: false,
  63. },
  64. },
  65. ],
  66. yAxis: [
  67. {
  68. type: 'value',
  69. interval: 50,
  70. axisLabel: {
  71. textStyle: {
  72. color: '#fff',
  73. },
  74. },
  75. splitLine: {
  76. show: false, // 去掉网格线
  77. },
  78. splitArea: {
  79. show: false,
  80. },
  81. },
  82. ],
  83. series: [
  84. ],
  85. };
  86. created() {
  87. this.getWeekCateRecord();
  88. setInterval(() => {
  89. this.getWeekCateRecord();
  90. }, 5000 * 60);
  91. }
  92. getWeekCateRecord() {
  93. this.loading = true;
  94. api.getWeekCateRecord().then((res) => {
  95. this.echartdata.xAxis[0].data = res.data.date;
  96. this.echartdata.legend.data = res.data.cate;
  97. const lists = res.data.list;
  98. const series = [];
  99. lists.forEach((e) => {
  100. series.push(
  101. {
  102. name: e.title,
  103. type: 'bar',
  104. data: e.list,
  105. },
  106. );
  107. });
  108. this.echartdata.series = series;
  109. this.loading = false;
  110. }).catch(() => {}).finally(() => {
  111. this.loading = false;
  112. });
  113. }
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .module-box{
  118. width: 100%;
  119. height: 100%;
  120. position: relative;
  121. }
  122. .module-box .header{
  123. width: 97%;
  124. height: 40px;
  125. line-height: 40px;
  126. padding-left: 3%;
  127. }
  128. .module-box .header .rhombus{
  129. width: 14px;
  130. height: 14px;
  131. background: #2D59BC;
  132. display: inline-block;
  133. clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  134. }
  135. .module-box .header .title{
  136. color: #FFFFFF;
  137. font-size: 15px;
  138. font-weight: 500;
  139. margin-left: 2%;
  140. }
  141. .module-box .echarts{
  142. width: 100%;
  143. height: auto;
  144. position: absolute;
  145. top: 40px;
  146. left: 0;
  147. right: 0;
  148. bottom: 0;
  149. }
  150. </style>