index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div>
  3. <SearchBoxVue :data="searchData" @search="handleSearch" />
  4. <TableBoxVue :loading="loading" :data="tableData" style="margin-top: -40px;" />
  5. <pagination
  6. :auto-scroll="false"
  7. :total="paginationData.total"
  8. :page="paginationData.page"
  9. :limit="paginationData.limit"
  10. @pagination="handlePagination"
  11. />
  12. </div>
  13. </template>
  14. <script>
  15. import SearchBoxVue from './components/SearchBox.vue'
  16. import TableBoxVue from './components/TableBox.vue'
  17. import { feedbackList } from '@/api/admin'
  18. import { dateFormat } from '@/filters/index'
  19. export default {
  20. components: {
  21. SearchBoxVue,
  22. TableBoxVue
  23. },
  24. data() {
  25. return {
  26. loading: false,
  27. searchData: {
  28. type_id: '',
  29. dep_id: '',
  30. user_name: '',
  31. start_time: '',
  32. end_time: ''
  33. },
  34. tableData: [],
  35. paginationData: {
  36. total: 0,
  37. page: 1,
  38. limit: 10
  39. }
  40. }
  41. },
  42. created() {
  43. this.getList()
  44. },
  45. methods: {
  46. getList() {
  47. const { type_id, dep_id, user_name, start_time, end_time } = this.searchData
  48. const { page, limit } = this.paginationData
  49. const params = {
  50. type_id,
  51. user_name,
  52. dep_id,
  53. page,
  54. page_size: limit
  55. }
  56. params.start_time = start_time ? dateFormat(start_time, 'YYYYMMDD') : ''
  57. params.end_time = end_time ? dateFormat(end_time, 'YYYYMMDD') : ''
  58. this.loading = true
  59. feedbackList(params).then(res => {
  60. const { p } = res
  61. this.paginationData.total = p.count
  62. this.tableData = p.list
  63. }).catch(error => {
  64. console.log(error)
  65. }).finally(() => {
  66. this.loading = false
  67. })
  68. },
  69. handlePagination(param) {
  70. this.paginationData.page = param.page
  71. this.paginationData.limit = param.limit
  72. this.getList()
  73. },
  74. handleSearch() {
  75. this.paginationData.page = 1
  76. this.getList()
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. </style>