sectionAnalysis.vue 2.8 KB

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