tollCollectorPerformance.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!-- 收费员业绩 -->
  2. <template>
  3. <view class="performance">
  4. <template v-if="type === 'table'">
  5. <TableRanking :loading="loading" :title="title" :tableTh="tableTh" :tableData="tableData" @pageChange="pageChange"/>
  6. </template>
  7. <template v-else>
  8. <LineChart v-if="chartData.series[0].data.length" :chartData="chartData" :title="title"/>
  9. <view class="empty" v-else>
  10. <u-empty></u-empty>
  11. </view>
  12. </template>
  13. </view>
  14. </template>
  15. <script>
  16. import TableRanking from '@/components/tableRanking.vue'
  17. import LineChart from '@/components/lineChart.vue'
  18. export default {
  19. components: {
  20. TableRanking,
  21. LineChart
  22. },
  23. props: {
  24. type: {
  25. type: String,
  26. default: 'table'
  27. },
  28. title: {
  29. type: String,
  30. default: ''
  31. },
  32. tableTh: {
  33. type: Array,
  34. default: () => [
  35. { width: 100, field: '工号', key: 'payeeNo' },
  36. { width: 100, field: '姓名', key: 'payeeName' },
  37. { width: 100, field: '收益(元)', key: 'amt' }
  38. ]
  39. },
  40. },
  41. data() {
  42. return {
  43. chartData: {
  44. categories: [],
  45. series: [{
  46. name: '',
  47. data: []
  48. }]
  49. },
  50. tableData: {
  51. current: 1,
  52. total: 0,
  53. list: []
  54. },
  55. reportType: '',
  56. queryDate: '',
  57. loading: false
  58. }
  59. },
  60. methods: {
  61. getData({ reportType, queryDate }) {
  62. this.reportType = reportType
  63. this.queryDate = queryDate
  64. if (this.type === 'table') {
  65. this.tableData.current = 1
  66. this.getTableData()
  67. } else {
  68. this.getChartData()
  69. }
  70. },
  71. getTableData() {
  72. this.loading = true
  73. uni.$u.api.operationalAnalysisApi.getTollCollectorPerformanceApi({
  74. pageNum: this.tableData.current,
  75. pageSize: 10,
  76. reportType: this.reportType,
  77. queryDate: this.queryDate
  78. }).then(res => {
  79. if (res.code === 200) {
  80. this.tableData.list = res.rows
  81. this.tableData.total = res.total
  82. }
  83. this.loading = false
  84. }).catch(() => {
  85. this.loading = false
  86. })
  87. },
  88. getChartData() {
  89. uni.$u.api.operationalAnalysisApi.getTollCollectorPerformanceApi({
  90. reportType: this.reportType,
  91. queryDate: this.queryDate
  92. }).then(res => {
  93. if (res.code === 200) {
  94. if (res.rows && res.rows.length) {
  95. this.chartData.categories = res.rows.map(item => {
  96. return item.payeeName
  97. })
  98. this.chartData.series[0].data = res.rows.map(item => {
  99. return item.amt
  100. })
  101. } else {
  102. this.chartData.categories = []
  103. this.chartData.series[0].data = []
  104. }
  105. }
  106. })
  107. },
  108. pageChange(current) {
  109. this.tableData.current = current
  110. this.getTableData()
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .performance {
  117. background-color: #fff;
  118. border-radius: 5px;
  119. .empty {
  120. padding: 15px;
  121. }
  122. }
  123. </style>