recommend.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="box defaultBgc">
  3. <view style="padding: 10px 15px 10px 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" :scroll-y="true" @scrolltolower="loadingMore" 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 more = ref('more')
  32. const total = ref(0)
  33. // 根据职位id获取推荐人才列表
  34. const getRecommendList = async () => {
  35. try {
  36. more.value = 'loading'
  37. const { data } = await getPersonRecommendPage(query.value)
  38. if (!data.list.length) {
  39. more.value = 'noMore'
  40. return
  41. }
  42. const list = dealDictArrayData([], data.list)
  43. items.value = items.value.concat(list)
  44. total.value = data.total
  45. if (items.value.length === +data.total) {
  46. more.value = 'noMore'
  47. return
  48. }
  49. } catch {
  50. query.value.pageNo--
  51. more.value = 'more'
  52. }
  53. }
  54. // 选择招聘中职位
  55. const handleChangeJob = (e) => {
  56. query.value.pageNo = 1
  57. items.value = []
  58. total.value = 0
  59. if (e) getRecommendList()
  60. }
  61. // 加载更多
  62. const loadingMore = () => {
  63. if (more.value === 'noMore') return
  64. more.value = 'loading'
  65. query.value.pageNo++
  66. getRecommendList()
  67. }
  68. </script>
  69. <style scoped lang="scss">
  70. .noJobId {
  71. text-align: center;
  72. line-height: 60vh;
  73. color: #666;
  74. }
  75. .box {
  76. height: 100vh;
  77. overflow: hidden;
  78. box-sizing: border-box;
  79. display: flex;
  80. flex-direction: column;
  81. }
  82. .scrollBox{
  83. flex: 1;
  84. padding-bottom: 100px;
  85. box-sizing: border-box;
  86. height: 0 !important;
  87. }
  88. </style>