condition.vue 4.7 KB

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