人民医院前端

Hardware.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="wrapper">
  3. <view class="contentbox">
  4. <view class="titlebox">{{titlebox}}</view>
  5. <view id="echartbox"></view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import * as echarts from '@/components/echarts/echarts.min.js'; // 引入 echarts
  11. export default {
  12. data() {
  13. return {
  14. titlebox: "硬件服务TOP20"
  15. }
  16. },
  17. onLoad(option) {
  18. if (option.waretype == 0) {
  19. uni.setNavigationBarTitle({
  20. title: '软件服务'
  21. })
  22. this.titlebox = "软件服务TOP20"
  23. }
  24. this.getListData(option)
  25. },
  26. onReady() {
  27. this.chart = echarts.init(document.getElementById('echartbox'))
  28. // this.chartData()
  29. },
  30. methods: {
  31. getListData(option){
  32. const params={
  33. starttime: option.starttime,
  34. endtime: option.endtime,
  35. type: option.waretype
  36. }
  37. this.$http.get("FaultRepair/DayReportDetail", params).then((response) => {
  38. if (response.state == "success") {
  39. var rowData = []
  40. var colData1 = []
  41. var colData2 = []
  42. var colData3 = []
  43. if (response.data.length > 0) {
  44. response.data.forEach((item, index) => {
  45. if(item.deptname){
  46. rowData.push(item.deptname)
  47. }
  48. if(Number(item.finish)!=0){
  49. colData1.push(Number(item.finish))
  50. }
  51. if(Number(item.unfinish)!=0){
  52. colData2.push(Number(item.unfinish))
  53. }
  54. if(Number(item.fx)!=0){
  55. colData3.push(Number(item.fx))
  56. }
  57. this.chartData(rowData, colData1, colData2, colData3)
  58. })
  59. } else {
  60. rowData = ['科室名称', '科室名称', '科室名称']
  61. colData1 = [0, 0, 0]
  62. colData2 = [0, 0, 0]
  63. colData3 = [0, 0, 0]
  64. this.chartData(rowData, colData1, colData2, colData3)
  65. }
  66. }
  67. })
  68. },
  69. //图表
  70. chartData(rowd, cold1, cold2, cold3) {
  71. this.chart.setOption({
  72. tooltip: {
  73. trigger: 'axis',
  74. axisPointer: {
  75. type: 'shadow'
  76. }
  77. },
  78. legend: {
  79. x:'left',
  80. y:'left',
  81. data:['完成量','未完成量','返修量'],
  82. selectedMode:false
  83. },
  84. color:["#7b9df2","#8ebb75","#dabe4f"],
  85. grid: {
  86. left: '1%',
  87. right: '1%',
  88. bottom: '3%',
  89. containLabel: true
  90. },
  91. xAxis: {
  92. axisLine: false,
  93. type: 'value'
  94. },
  95. yAxis: {
  96. type: 'category',
  97. data: rowd
  98. },
  99. series: [{
  100. name: '完成量',
  101. type: 'bar',
  102. stack: 'total',
  103. label: {
  104. show: true
  105. },
  106. data: cold1
  107. },
  108. {
  109. name: '未完成量',
  110. type: 'bar',
  111. stack: 'total',
  112. label: {
  113. show: true
  114. },
  115. data: cold2
  116. },
  117. {
  118. name: '返修量',
  119. type: 'bar',
  120. stack: 'total',
  121. label: {
  122. show: true
  123. },
  124. data: cold3
  125. },
  126. ]
  127. })
  128. },
  129. }
  130. }
  131. </script>
  132. <style scoped>
  133. .contentbox {
  134. padding: 10px 10px;
  135. background-color: #f2f2f2;
  136. }
  137. .titlebox {
  138. margin-bottom: 15px;
  139. margin-left: 5px;
  140. }
  141. .wrapper {
  142. padding: 10px 10px;
  143. background-color: #fff;
  144. }
  145. #echartbox {
  146. width: 100%;
  147. height: 800rpx;
  148. }
  149. </style>