trafficFlow.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. xAxis: {
  28. rotateLabel: false,
  29. labelCount: 6
  30. },
  31. yAxis: {
  32. showTitle: true,
  33. splitNumber: 5,
  34. data: [{
  35. title: '辆',
  36. titleOffsetY: -5
  37. }]
  38. },
  39. legend: {
  40. show: true
  41. },
  42. dataLabel: false,
  43. extra: {
  44. column: {
  45. width: 20
  46. }
  47. }
  48. }
  49. }
  50. }
  51. },
  52. data() {
  53. return {
  54. chartData: {
  55. categories: [],
  56. series: [{
  57. name: '路段',
  58. data: []
  59. }, {
  60. name: '停车场',
  61. data: []
  62. }]
  63. }
  64. }
  65. },
  66. methods: {
  67. getData({ reportType, queryDate }) {
  68. this.chartData.categories = []
  69. this.chartData.series[0].data = []
  70. this.chartData.series[1].data = []
  71. uni.$u.api.operationalAnalysisApi.getTrafficFlowDataApi({ reportType, queryDate }).then(res => {
  72. if (res.code === 200) {
  73. if (res.data.itemList && res.data.itemList.length) {
  74. this.chartData.categories = res.data.itemList.map(item => {
  75. return item.statisTime
  76. })
  77. this.chartData.series[0].data = res.data.itemList.map(item => {
  78. return item.vehicleCount
  79. })
  80. }
  81. }
  82. })
  83. uni.$u.api.operationalAnalysisApi.getParkingTrafficFlowDataApi({ reportType, queryDate }).then(res => {
  84. if (res.code === 200) {
  85. if (res.data.itemList && res.data.itemList.length) {
  86. this.chartData.categories = res.data.itemList.map(item => {
  87. return item.statisTime
  88. })
  89. this.chartData.series[1].data = res.data.itemList.map(item => {
  90. return item.vehicleCount
  91. })
  92. }
  93. }
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .revenue {
  101. background-color: #fff;
  102. border-radius: 5px;
  103. .empty {
  104. padding: 15px;
  105. }
  106. }
  107. </style>