trafficFlow.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!-- 车流量分析 -->
  2. <template>
  3. <view class="revenue">
  4. <view class="revenue-line">
  5. <LineChart v-if="hasData" :chartData="chartData" :title="title" :opts="opts" />
  6. <view class="empty" v-else>
  7. <u-empty></u-empty>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import LineChart from '@/components/lineChart.vue'
  14. export default {
  15. components: {
  16. LineChart
  17. },
  18. props: {
  19. title: {
  20. type: String,
  21. default: ''
  22. },
  23. opts: {
  24. type: Object,
  25. default: () => {
  26. return {
  27. enableScroll: true,
  28. xAxis: {
  29. rotateLabel: true,
  30. scrollShow: true,
  31. itemCount: 8
  32. },
  33. yAxis: {
  34. showTitle: true,
  35. splitNumber: 5,
  36. data: [{
  37. title: '辆',
  38. titleOffsetY: -3
  39. }]
  40. },
  41. legend: {
  42. show: true
  43. },
  44. dataLabel: false,
  45. padding: [20, 10, 10, 10],
  46. extra: {
  47. column: {
  48. width: 20
  49. }
  50. }
  51. }
  52. }
  53. }
  54. },
  55. data() {
  56. return {
  57. chartData: {
  58. categories: [],
  59. series: []
  60. },
  61. reportType: '',
  62. queryDate: '',
  63. hasData: false
  64. }
  65. },
  66. methods: {
  67. getData({
  68. reportType,
  69. queryDate
  70. }) {
  71. this.chartData.categories = []
  72. this.chartData.series = []
  73. this.reportType = reportType
  74. this.queryDate = queryDate
  75. this.hasData = false;
  76. this.getRoadData({ reportType, queryDate });
  77. },
  78. getRoadData({ reportType, queryDate }) {
  79. uni.$u.api.operationalAnalysisApi.getTrafficFlowDataApi({
  80. reportType,
  81. queryDate
  82. }).then(res => {
  83. if (res.code === 200) {
  84. if (res.data.itemList && res.data.itemList.length) {
  85. this.chartData.series[0] = {
  86. name: '路段',
  87. data: []
  88. }
  89. this.chartData.categories = res.data.itemList.map(item => {
  90. return item.statisTime
  91. })
  92. this.chartData.series[0].data = res.data.itemList.map(item => {
  93. return item.vehicleCount
  94. })
  95. }
  96. }
  97. this.getParkingData({ reportType, queryDate });
  98. })
  99. },
  100. getParkingData({ reportType, queryDate }) {
  101. uni.$u.api.operationalAnalysisApi.getParkingTrafficFlowDataApi({
  102. reportType,
  103. queryDate
  104. }).then(res => {
  105. if (res.code === 200) {
  106. if (res.data.itemList && res.data.itemList.length) {
  107. if (this.chartData.series.length) {
  108. this.chartData.series[1] = {
  109. name: '停车场',
  110. data: []
  111. }
  112. this.chartData.series[1].data = res.data.itemList.map(item => {
  113. return item.vehicleCount
  114. })
  115. } else {
  116. this.chartData.series[0] = {
  117. name: '停车场',
  118. data: []
  119. }
  120. this.chartData.series[0].data = res.data.itemList.map(item => {
  121. return item.vehicleCount
  122. })
  123. }
  124. if (!this.chartData.categories.length) {
  125. this.chartData.categories = res.data.itemList.map(item => {
  126. return item.statisTime
  127. })
  128. }
  129. this.hasData = true
  130. } else if (this.chartData.series.length === 1) {
  131. this.hasData = true
  132. } else if (!this.chartData.series.length) {
  133. this.hasData = false
  134. }
  135. }
  136. })
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .revenue {
  143. background-color: #fff;
  144. border-radius: 5px;
  145. .empty {
  146. padding: 15px;
  147. }
  148. }
  149. </style>