page.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. export default {
  2. data () {
  3. return {
  4. tableLoading: true,
  5. totalCount: 0,
  6. page: 1,
  7. page_size: 20
  8. }
  9. },
  10. computed: {
  11. vheight () {
  12. return document.body.clientHeight - 280
  13. }
  14. },
  15. methods: {
  16. async init () {
  17. Object.keys(this.searchForm).map(key => {
  18. if (this.searchForm[key] === '') {
  19. this.searchForm[key] = undefined
  20. }
  21. })
  22. this.tableLoading = true
  23. const api = (/^\/v1/.test(this.tableUrl) ? '' : '/api/auth') + this.tableUrl
  24. const { code, data } = await this.$fetch(api, {
  25. page: this.page,
  26. page_size: this.page_size,
  27. ...this.searchForm
  28. }, 'get')
  29. this.tableLoading = false
  30. if (this.tableData && (data.data || data.list) && code === 200) {
  31. this.tableData = data.data || data.list
  32. this.totalCount = Number(data.total)
  33. if (this.tableUrl === '/v1/user/song/list') {
  34. this.user_song_name = data.user_song_name
  35. }
  36. if (this.tableUrl === '/v1/user/record/price/List') {
  37. this.total_price = data.total_price
  38. }
  39. }
  40. },
  41. handleCurrentChange (page) {
  42. this.page = page
  43. this.init()
  44. },
  45. handleSizeChange (page_size) {
  46. this.page_size = page_size
  47. this.handleCurrentChange(1)
  48. //this.searchSubmit()
  49. },
  50. async searchSubmit () {
  51. this.page = 1
  52. await this.init()
  53. },
  54. searchReset (obj = {}) {
  55. Object.keys(this.searchForm).forEach(item => {
  56. this.searchForm[item] = undefined
  57. })
  58. Object.keys(obj).forEach(item => {
  59. this.searchForm[item] = obj[item]
  60. })
  61. this.searchSubmit()
  62. }
  63. }
  64. }