sectionAnalysis.vue 3.8 KB

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