sectionAnalysis.vue 3.8 KB

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