condition.vue 3.9 KB

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