operatDoctorList.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { mapGetters } from 'vuex'
  2. import { debounce } from '@/utils'
  3. export default {
  4. data() {
  5. return {
  6. loadingMore: false,
  7. finished: true,
  8. isRequest: true,
  9. listQuery: {
  10. authUserId: '',
  11. doctorType: 1,
  12. doctorName: '',
  13. pageNum: 1,
  14. pageSize: 12,
  15. },
  16. list: [],
  17. total: 0,
  18. }
  19. },
  20. computed: {
  21. ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
  22. },
  23. mounted() {
  24. this.fetchList()
  25. },
  26. methods: {
  27. fetchList: debounce(async function () {
  28. try {
  29. this.loadingMore = true
  30. this.listQuery.authUserId = this.authUserId
  31. const res = await this.$http.api.fetchDoctorList(this.listQuery)
  32. this.list = [...this.list, ...res.data.list]
  33. this.finished = !res.data.hasNextPage
  34. this.listQuery.pageNum += 1
  35. this.total = res.data.total
  36. } catch (error) {
  37. console.log(error)
  38. } finally {
  39. this.isRequest = false
  40. this.loadingMore = false
  41. }
  42. }, 400),
  43. // 搜索
  44. onSearch() {
  45. this.list = []
  46. this.listQuery.pageNum = 1
  47. this.fetchList()
  48. },
  49. // 医师详情
  50. toDetail(item) {
  51. const url = `${this.routePrefix}/approve/personnel/operate/detail?id=${item.doctorId}`
  52. this.$router.push(url)
  53. },
  54. // 加载更多
  55. onLoadMore() {
  56. this.fetchList()
  57. },
  58. },
  59. }