trafficFlow.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!-- 车流量分析 -->
  2. <template>
  3. <view class="revenue">
  4. <view class="revenue-line">
  5. <LineChart v-if="chartData.series[0].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: false
  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. }
  61. }
  62. },
  63. methods: {
  64. getData({ reportType, queryDate }) {
  65. uni.$u.api.operationalAnalysisApi.getTrafficFlowDataApi({ reportType, queryDate }).then(res => {
  66. if (res.code === 200) {
  67. if (res.data.itemList && res.data.itemList.length) {
  68. this.chartData.categories = res.data.itemList.map(item => {
  69. return item.statisTime
  70. })
  71. this.chartData.series[0].data = res.data.itemList.map(item => {
  72. return item.vehicleCount
  73. })
  74. } else {
  75. this.chartData.categories = []
  76. this.chartData.series[0].data = []
  77. }
  78. }
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .revenue {
  86. background-color: #fff;
  87. border-radius: 5px;
  88. .empty {
  89. padding: 15px;
  90. }
  91. }
  92. </style>