arrearsAnalysis.vue 2.3 KB

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