paymentMethod.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!-- 支付占比分析分析 -->
  2. <template>
  3. <view class="revenue-box">
  4. <view class="revenue-line revenue">
  5. <PieChart v-if="chartData.series[0].data.length" :chartData="chartData" :title="`路段(${title})`"/>
  6. <view class="empty" v-else>
  7. <u-empty></u-empty>
  8. </view>
  9. </view>
  10. <view class="revenue-line revenue">
  11. <PieChart v-if="chartData1.series[0].data.length" :chartData="chartData1" :title="`停车场(${title})`"/>
  12. <view class="empty" v-else>
  13. <u-empty></u-empty>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import PieChart from '@/components/pieChart.vue'
  20. export default {
  21. components: {
  22. PieChart
  23. },
  24. props: {
  25. title: {
  26. type: String,
  27. default: ''
  28. }
  29. },
  30. data() {
  31. return {
  32. reportType: '',
  33. queryDate: '',
  34. paySourceList: [],
  35. chartData: {
  36. series: [{
  37. data: []
  38. }]
  39. },
  40. chartData1: {
  41. series: [{
  42. data: []
  43. }]
  44. }
  45. }
  46. },
  47. created() {
  48. this.getDict()
  49. },
  50. methods: {
  51. getData({ reportType, queryDate }) {
  52. this.reportType = reportType
  53. this.queryDate = queryDate
  54. this.getPaymentWaysData()
  55. },
  56. getDict() {
  57. uni.$u.api.getDictApi({ type: 'pay_source'}).then(res => {
  58. if (res.code === 200) {
  59. this.paySourceList = res.data
  60. }
  61. })
  62. },
  63. getPaymentWaysData() {
  64. uni.$u.api.operationalAnalysisApi.getPaymentWaysDataApi({
  65. reportType: this.reportType,
  66. queryDate: this.queryDate
  67. }).then(res => {
  68. if (res.code === 200) {
  69. if (res.data.itemList && res.data.itemList.length) {
  70. let list = res.data.itemList.map(item => {
  71. return {
  72. name: this.getDictLabel(item.paySource),
  73. value: item.amt
  74. }
  75. })
  76. this.chartData.series[0].data = list
  77. } else {
  78. this.chartData.series[0].data = []
  79. }
  80. }
  81. })
  82. uni.$u.api.operationalAnalysisApi.getParkingPaymentWaysDataApi({
  83. reportType: this.reportType,
  84. queryDate: this.queryDate
  85. }).then(res => {
  86. if (res.code === 200) {
  87. if (res.data.itemList && res.data.itemList.length) {
  88. let list = res.data.itemList.map(item => {
  89. return {
  90. name: this.getDictLabel(item.paySource),
  91. value: item.amt
  92. }
  93. })
  94. this.chartData1.series[0].data = list
  95. } else {
  96. this.chartData1.series[0].data = []
  97. }
  98. }
  99. })
  100. },
  101. getDictLabel(value) {
  102. let name
  103. this.paySourceList.forEach(item => {
  104. if (item.dictValue == value) {
  105. name = item.dictLabel
  106. }
  107. })
  108. if (!name) name = '其他'
  109. return name
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .revenue {
  116. background-color: #fff;
  117. border-radius: 5px;
  118. margin-bottom: 10px;
  119. .empty {
  120. padding: 15px;
  121. }
  122. }
  123. </style>