condition.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. }
  68. return e
  69. })
  70. items.value = items.value.concat(list)
  71. total.value = data.total
  72. if (items.value.length === +data.total) {
  73. more.value = 'noMore'
  74. return
  75. }
  76. } catch {
  77. query.value.pageNo--
  78. more.value = 'more'
  79. }
  80. }
  81. const checkValue = (obj) => {
  82. return Object.values(obj).some(value => {
  83. return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
  84. })
  85. }
  86. const handleSearch = (key, value) => {
  87. query.value.pageNo = 1
  88. params.value[key] = value
  89. if (!checkValue(params.value)) {
  90. uni.showToast({
  91. title: '请至少选择一个查询条件',
  92. icon: 'none',
  93. duration: 2000
  94. })
  95. more.value = 'noMore'
  96. items.value = []
  97. total.value = 0
  98. return
  99. }
  100. items.value = []
  101. total.value = 0
  102. getTalentList()
  103. }
  104. // 加载更多
  105. const loadingMore = () => {
  106. if (more.value === 'noMore') return
  107. more.value = 'loading'
  108. query.value.pageNo++
  109. getTalentList()
  110. }
  111. </script>
  112. <style scoped lang="scss">
  113. .noJobId {
  114. text-align: center;
  115. line-height: 60vh;
  116. color: #666;
  117. }
  118. .box {
  119. height: 100vh;
  120. overflow: hidden;
  121. box-sizing: border-box;
  122. display: flex;
  123. flex-direction: column;
  124. }
  125. .scrollBox{
  126. flex: 1;
  127. padding-bottom: 100px;
  128. box-sizing: border-box;
  129. height: 0 !important;
  130. }
  131. .stickFilter {
  132. z-index: 1;
  133. position: sticky;
  134. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  135. top: 110rpx;
  136. background-color: #fff;
  137. }
  138. </style>