You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB

  1. import { getDict } from '@/utils/dictionary'
  2. export default {
  3. data() {
  4. return {
  5. page: 1,
  6. total: 10,
  7. pageSize: 10,
  8. tableData: [],
  9. searchInfo: {}
  10. }
  11. },
  12. methods: {
  13. filterDict(value, type) {
  14. const rowLabel = this[type + 'Options'] && this[type + 'Options'].filter(item => item.value === value)
  15. return rowLabel && rowLabel[0] && rowLabel[0].label
  16. },
  17. async getDict(type) {
  18. const dicts = await getDict(type)
  19. this[type + 'Options'] = dicts
  20. return dicts
  21. },
  22. handleSizeChange(val) {
  23. this.pageSize = val
  24. this.getTableData()
  25. },
  26. handleCurrentChange(val) {
  27. this.page = val
  28. this.getTableData()
  29. },
  30. async getTableData(page = this.page, pageSize = this.pageSize) {
  31. const table = await this.listApi({ page, pageSize, ...this.searchInfo })
  32. if (table.code === 0) {
  33. this.tableData = table.data.list
  34. this.total = table.data.total
  35. this.page = table.data.page
  36. this.pageSize = table.data.pageSize
  37. }
  38. }
  39. }
  40. }