recommend.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view>
  3. <view style="padding: 0 15px;">
  4. <uni-data-select
  5. v-model="query.jobId"
  6. :clear="false"
  7. :localdata="jobList"
  8. @change="handleChangeJob"
  9. placeholder="招聘中职位"
  10. ></uni-data-select>
  11. </view>
  12. <scroll-view class="scrollBox defaultBgc" :scroll-y="true" :scroll-top="scrollTop" @scrolltolower="loadingMore" @scroll="onScroll" style="position:relative;">
  13. <TalentItem v-if="query.jobId && (items?.length || more !== 'loading')" :items="items" />
  14. <uni-load-more v-if="query.jobId" :status="more" />
  15. <view v-else class="noJobId">请选择要推荐人才的职位</view>
  16. </scroll-view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref, nextTick } from 'vue'
  21. import TalentItem from './talentItem.vue'
  22. import { getPersonRecommendPage } from '@/api/search'
  23. import { dealDictArrayData } from '@/utils/position'
  24. defineProps({ jobList: Array })
  25. const query = ref({
  26. pageNo: 1,
  27. paeSize: 20,
  28. jobId: null
  29. })
  30. const items = ref([])
  31. const scrollTop = ref(0)
  32. const old = ref({
  33. scrollTop: 0
  34. })
  35. const more = ref('more')
  36. const total = ref(0)
  37. // 根据职位id获取推荐人才列表
  38. const getRecommendList = async () => {
  39. try {
  40. more.value = 'loading'
  41. const { data } = await getPersonRecommendPage(query.value)
  42. scrollTop.value = old.value.scrollTop
  43. nextTick(() => {
  44. scrollTop.value = 0
  45. })
  46. if (!data.list.length) {
  47. more.value = 'noMore'
  48. return
  49. }
  50. const list = dealDictArrayData([], data.list).map(e => {
  51. e.areaName = e.area?.str ?? ''
  52. e.regName = e.reg?.str ?? ''
  53. return e
  54. })
  55. items.value = items.value.concat(list)
  56. total.value = data.total
  57. if (items.value.length === +data.total) {
  58. more.value = 'noMore'
  59. return
  60. }
  61. } catch {
  62. query.value.pageNo--
  63. more.value = 'more'
  64. }
  65. }
  66. // 选择招聘中职位
  67. const handleChangeJob = (e) => {
  68. query.value.pageNo = 1
  69. items.value = []
  70. if (e) getRecommendList()
  71. }
  72. // 加载更多
  73. const loadingMore = () => {
  74. more.value = 'loading'
  75. query.value.pageNo++
  76. getRecommendList()
  77. }
  78. const onScroll = (e) =>{
  79. old.value.scrollTop = e.detail.scrollTop
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .noJobId {
  84. text-align: center;
  85. line-height: 60vh;
  86. color: #666;
  87. }
  88. .scrollBox{
  89. padding-bottom: 24rpx;
  90. box-sizing: border-box;
  91. margin-top: 10px;
  92. min-height: 80vh;
  93. }
  94. </style>