paymentMethod.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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="`路段`"/>
  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 PieChart from '@/components/pieChart.vue'
  15. export default {
  16. components: {
  17. PieChart
  18. },
  19. props: {
  20. title: {
  21. type: String,
  22. default: ''
  23. }
  24. },
  25. data() {
  26. return {
  27. reportType: '',
  28. queryDate: '',
  29. loading: false,
  30. paySourceList: [],
  31. chartData: {
  32. series: [{
  33. data: []
  34. }]
  35. }
  36. }
  37. },
  38. created() {
  39. this.getDict()
  40. },
  41. methods: {
  42. getData({ reportType, queryDate }) {
  43. this.reportType = reportType
  44. this.queryDate = queryDate
  45. this.getPaymentWaysData()
  46. },
  47. getDict() {
  48. uni.$u.api.getDictApi({ type: 'pay_source'}).then(res => {
  49. if (res.code === 200) {
  50. this.paySourceList = res.data
  51. }
  52. })
  53. },
  54. getPaymentWaysData() {
  55. this.loading = true
  56. uni.$u.api.operationalAnalysisApi.getPaymentWaysDataApi({
  57. reportType: this.reportType,
  58. queryDate: this.queryDate
  59. }).then(res => {
  60. if (res.code === 200) {
  61. if (res.data.itemList && res.data.itemList.length) {
  62. let list = res.data.itemList.map(item => {
  63. return {
  64. name: this.getDictLabel(item.paySource),
  65. value: item.amt
  66. }
  67. })
  68. this.chartData.series[0].data = list
  69. } else {
  70. this.chartData.series[0].data = []
  71. }
  72. this.loading = false
  73. }
  74. })
  75. },
  76. getDictLabel(value) {
  77. let name
  78. this.paySourceList.forEach(item => {
  79. if (item.dictValue == value) {
  80. name = item.dictLabel
  81. }
  82. })
  83. if (!name) name = '其他'
  84. return name
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .revenue {
  91. background-color: #fff;
  92. border-radius: 5px;
  93. margin-bottom: 10px;
  94. .empty {
  95. padding: 15px;
  96. }
  97. }
  98. </style>