paymentMethod.vue 1.8 KB

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