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