index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <el-row class="mianBox">
  3. <el-row class="headerBox">
  4. <el-col class="title">
  5. <img src="../../../assets/image/arrow.png" alt="" />
  6. 停车场统计
  7. </el-col>
  8. </el-row>
  9. <el-row class="carNumber">
  10. <el-col class="carLot">
  11. <el-col>
  12. <img src="../../../assets/image/car2.png" alt="" />
  13. </el-col>
  14. <el-col class="carNumbderLot">
  15. <span class="green">{{resList && resList.totalNum || 0}}</span>
  16. <span>车位总数</span>
  17. </el-col>
  18. </el-col>
  19. <el-col class="carLot">
  20. <el-col>
  21. <img src="../../../assets/image/car1.png" alt="" />
  22. </el-col>
  23. <el-col class="carNumbderLot">
  24. <span class="yellow">{{resList && resList.tiatlFreeNum || 0}}</span>
  25. <span>空闲车位总数</span>
  26. </el-col>
  27. </el-col>
  28. </el-row>
  29. <el-row class="carLine">
  30. <div ref="echartD" style="width:100%;height:100%;"></div>
  31. </el-row>
  32. </el-row>
  33. </template>
  34. <script>
  35. import * as echarts from "echarts";
  36. import echartsGet from './echart'
  37. import { parkingLotApi2 } from "@/plugins/api"
  38. export default {
  39. props:['resInfo', 'websocket'],
  40. data() {
  41. return {
  42. resList: [],
  43. resList2: [],
  44. };
  45. },
  46. watch: {
  47. "$store.state.windowWidth"() {
  48. echarts.init(this.$refs.echartD).resize();
  49. },
  50. resInfo(){
  51. this.getData()
  52. },
  53. websocket(){
  54. this.getData()
  55. }
  56. },
  57. mounted(){
  58. this.getData()
  59. },
  60. methods:{
  61. async getData(){
  62. if(this.websocket.data){
  63. this.resList=this.websocket.data
  64. }else{
  65. this.resList=this.resInfo
  66. }
  67. var myDate = new Date();
  68. let tYear = myDate.getFullYear();
  69. let tMonth = myDate.getMonth() + 1;
  70. let lastDay= new Date(tYear,tMonth,0).getDate()
  71. this.month = tMonth
  72. let day = myDate.getDate(); //获取当前日(1-31)
  73. let hours = myDate.getHours(); //获取当前小时数(0-23)
  74. let minutes = myDate.getMinutes(); //获取当前分钟数(0-59)
  75. let seconds = myDate.getSeconds(); //获取当前秒数(0-59)
  76. // this.year = tYear + '年'
  77. if(tMonth<10){
  78. tMonth = '0' + tMonth
  79. this.monthParameter = tMonth
  80. }else{
  81. this.monthParameter = tMonth
  82. }
  83. if(day<10){
  84. day = '0' + day
  85. }else{
  86. day = day
  87. }
  88. if(minutes<10){
  89. minutes = '0' + minutes
  90. }else{
  91. minutes = minutes
  92. }
  93. if(seconds<10){
  94. seconds = '0' + seconds
  95. }else{
  96. seconds = seconds
  97. }
  98. let startTime = tYear + '-' + tMonth + '-' + day + ' ' + "00:00:00"
  99. let endTime = tYear + '-' + tMonth + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
  100. parkingLotApi2({startTime:startTime,endTime:endTime}).then(res =>{
  101. echarts.init(this.$refs.echartD).setOption(echartsGet(res.data))
  102. })
  103. },
  104. resize() {
  105. echarts.init(this.$refs.echartD).resize();
  106. },
  107. }
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .mianBox {
  112. background: url("../../../assets/image/view2.png") no-repeat;
  113. background-size: 100% 100%;
  114. font-family: Impact Regular, Impact Regular-Regular;
  115. .carLine {
  116. flex: 1;
  117. width: 100%;
  118. }
  119. .carNumber {
  120. height: 90px;
  121. padding: 10px 0;
  122. width: 100%;
  123. display: flex;
  124. align-items: center;
  125. justify-content: space-between;
  126. & > .el-col {
  127. flex: 1;
  128. height: 100%;
  129. }
  130. .carLot {
  131. display: flex;
  132. justify-content: center;
  133. .el-col {
  134. width: auto;
  135. }
  136. .carNumbderLot {
  137. display: flex;
  138. flex-direction: column;
  139. justify-content: space-around;
  140. margin-left: 10px;
  141. span {
  142. display: block;
  143. }
  144. & span:first-child{
  145. font-size: 28px;
  146. }
  147. & span:last-child{
  148. font-size: 16px;
  149. color: #DEF1FF;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. </style>