sourceOfPayment.vue 2.4 KB

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