tollCollectorPerformance.vue 2.5 KB

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