condition.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="box defaultBgc">
  3. <view style="background-color: #fff;">
  4. <uni-search-bar
  5. v-model="params.content"
  6. radius="5"
  7. placeholder="输入关键字"
  8. cancelButton="none"
  9. :focus="false"
  10. @clear="handleSearch('content', null)"
  11. @confirm="handleSearch('content', params.content)"
  12. ></uni-search-bar>
  13. <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
  14. </view>
  15. <scroll-view class="scrollBox" :scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  16. <TalentItem v-if="items?.length" :items="items" :showLastWorkExp="false" />
  17. <uni-load-more v-if="items.length" :status="more" />
  18. <view v-else class="noJobId">请选择条件搜索人才</view>
  19. </scroll-view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import { ref, nextTick } from 'vue'
  24. import TalentItem from './talentItem.vue'
  25. import FilterList from '@/components/FilterList'
  26. import { getPersonConditionSearchPage } from '@/api/search'
  27. import { dealDictArrayData } from '@/utils/position'
  28. import { timesTampChange, getTimeDifferenceInChinese } from '@/utils/date'
  29. const query = ref({
  30. pageNo: 1,
  31. pageSize: 10
  32. })
  33. const params = ref({
  34. content: null,
  35. positionIds: [],
  36. areaIds: [],
  37. expType: '',
  38. eduType: ''
  39. })
  40. const items = ref([])
  41. const more = ref('more')
  42. const total = ref(0)
  43. const filterList = ref([
  44. { label: '职位', dictType: 'positionTreeData',key: 'positionId', map: { text: 'nameCn', value: 'id' } },
  45. { label: '城市', multiple: true, dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
  46. { label: '最高学历', dictType: 'menduner_education_type', key: 'eduType' },
  47. { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  48. ])
  49. // 根据条件搜索人才
  50. const getTalentList = async () => {
  51. try {
  52. more.value = 'loading'
  53. const { data } = await getPersonConditionSearchPage(Object.assign(query.value, params.value))
  54. if (!data.list.length) {
  55. more.value = 'noMore'
  56. items.value = []
  57. total.value = 0
  58. return
  59. }
  60. const list = dealDictArrayData([], data.list).map(e => {
  61. if (e.workList?.length) {
  62. e.workList.forEach(exp => {
  63. exp.startTimeStr = exp.startTime ? timesTampChange(exp.startTime, 'Y-M') : '未填写工作时间'
  64. exp.endTimeStr = exp.startTime ? exp.endTime ? timesTampChange(exp.endTime, 'Y-M') : '至今' : ''
  65. exp.year = exp.endTimeStr ? getTimeDifferenceInChinese(exp.startTime, exp.endTime) : ''
  66. })
  67. e.workList = e.workList.splice(0, 2)
  68. }
  69. return e
  70. })
  71. items.value = items.value.concat(list)
  72. total.value = data.total
  73. if (items.value.length === +data.total) {
  74. more.value = 'noMore'
  75. return
  76. }
  77. } catch {
  78. query.value.pageNo--
  79. more.value = 'more'
  80. }
  81. }
  82. const checkValue = (obj) => {
  83. return Object.values(obj).some(value => {
  84. return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
  85. })
  86. }
  87. const handleSearch = (key, value) => {
  88. query.value.pageNo = 1
  89. params.value[key] = value
  90. if (!checkValue(params.value)) {
  91. uni.showToast({
  92. title: '请至少选择一个查询条件',
  93. icon: 'none',
  94. duration: 2000
  95. })
  96. more.value = 'noMore'
  97. items.value = []
  98. total.value = 0
  99. return
  100. }
  101. items.value = []
  102. total.value = 0
  103. getTalentList()
  104. }
  105. // 加载更多
  106. const loadingMore = () => {
  107. if (more.value === 'noMore') return
  108. more.value = 'loading'
  109. query.value.pageNo++
  110. getTalentList()
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. .noJobId {
  115. text-align: center;
  116. line-height: 60vh;
  117. color: #666;
  118. }
  119. .box {
  120. height: 100vh;
  121. overflow: hidden;
  122. box-sizing: border-box;
  123. display: flex;
  124. flex-direction: column;
  125. }
  126. .scrollBox{
  127. flex: 1;
  128. padding-bottom: 100px;
  129. box-sizing: border-box;
  130. height: 0 !important;
  131. }
  132. .stickFilter {
  133. z-index: 1;
  134. position: sticky;
  135. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  136. top: 110rpx;
  137. background-color: #fff;
  138. }
  139. </style>