sectionAnalysis.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. this.getRoadTrafficFlowData()
  102. },
  103. getRevenueTrendsData() {
  104. uni.$u.api.operationalAnalysisApi.getRevenueTrendsDataApi({
  105. reportType: this.reportType,
  106. queryDate: this.queryDate
  107. }).then(res => {
  108. if (res.code === 200) {
  109. if (res.data.itemList && res.data.itemList.length) {
  110. this.revenueTrendsData.categories = res.data.itemList.map(item => {
  111. return item.roadName
  112. })
  113. this.revenueTrendsData.series[0].data = res.data.itemList.map(item => {
  114. return item.amt
  115. })
  116. } else {
  117. this.revenueTrendsData.categories = []
  118. this.revenueTrendsData.series[0].data = []
  119. }
  120. console.log(this.revenueTrendsData)
  121. }
  122. })
  123. },
  124. getRoadTrafficFlowData() {
  125. uni.$u.api.operationalAnalysisApi.getRoadTrafficFlowDataApi({
  126. reportType: this.reportType,
  127. queryDate: this.queryDate
  128. }).then(res => {
  129. if (res.code === 200) {
  130. if (res.data.itemList && res.data.itemList.length) {
  131. this.trafficFlowData.categories = res.data.itemList.map(item => {
  132. return item.roadName
  133. })
  134. this.trafficFlowData.series[0].data = res.data.itemList.map(item => {
  135. return item.vehicleCount
  136. })
  137. } else {
  138. this.trafficFlowData.categories = []
  139. this.trafficFlowData.series[0].data = []
  140. }
  141. console.log(this.trafficFlowData)
  142. }
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .section {
  150. &-part {
  151. background-color: #fff;
  152. border-radius: 5px;
  153. margin-bottom: 10px;
  154. &-title {
  155. padding: 15px;
  156. text {
  157. color: #f00;
  158. margin-right: 5px;
  159. }
  160. }
  161. }
  162. }
  163. </style>