sectionAnalysis.vue 4.0 KB

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