trafficFlow.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!-- 车流量分析 -->
  2. <template>
  3. <view class="revenue">
  4. <view class="revenue-line">
  5. <LineChart v-if="chartData.series[0].data.length || chartData.series[1].data.length" :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: false
  43. },
  44. dataLabel: false,
  45. padding: [10, 0, 10, 0],
  46. extra: {
  47. column: {
  48. width: 20
  49. }
  50. }
  51. }
  52. }
  53. }
  54. },
  55. data() {
  56. return {
  57. chartData: {
  58. categories: [],
  59. series: [{
  60. name: '路段',
  61. data: []
  62. }, {
  63. name: '停车场',
  64. data: []
  65. }]
  66. }
  67. }
  68. },
  69. methods: {
  70. getData({ reportType, queryDate }) {
  71. this.chartData.categories = []
  72. this.chartData.series[0].data = []
  73. this.chartData.series[1].data = []
  74. uni.$u.api.operationalAnalysisApi.getTrafficFlowDataApi({ reportType, queryDate }).then(res => {
  75. if (res.code === 200) {
  76. if (res.data.itemList && res.data.itemList.length) {
  77. this.chartData.categories = res.data.itemList.map(item => {
  78. return item.statisTime
  79. })
  80. this.chartData.series[0].data = res.data.itemList.map(item => {
  81. return item.vehicleCount
  82. })
  83. }
  84. }
  85. })
  86. uni.$u.api.operationalAnalysisApi.getParkingTrafficFlowDataApi({ reportType, queryDate }).then(res => {
  87. if (res.code === 200) {
  88. if (res.data.itemList && res.data.itemList.length) {
  89. this.chartData.categories = res.data.itemList.map(item => {
  90. return item.statisTime
  91. })
  92. this.chartData.series[1].data = res.data.itemList.map(item => {
  93. return item.vehicleCount
  94. })
  95. }
  96. }
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .revenue {
  104. background-color: #fff;
  105. border-radius: 5px;
  106. .empty {
  107. padding: 15px;
  108. }
  109. }
  110. </style>