revenueAnalysis.vue 3.2 KB

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