condition.vue 4.0 KB

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