123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <template>
- <view class="box defaultBgc">
- <view>
- <uni-search-bar
- v-model="params.content"
- radius="5"
- placeholder="输入关键字"
- cancelButton="none"
- bgColor="#fff"
- :focus="false"
- @clear="handleSearch('content', null)"
- @confirm="handleSearch('content', params.content)"
- ></uni-search-bar>
- <view style="padding: 0 10px;">
- <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
- </view>
- </view>
-
- <scroll-view class="scrollBox" :scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
- <TalentItem v-if="items?.length" :items="items" :showLastWorkExp="false" />
- <uni-load-more v-if="items.length" :status="more" />
- <view v-else class="noJobId">请选择条件搜索人才</view>
- </scroll-view>
- </view>
- </template>
- <script setup>
- import { ref } from 'vue'
- import TalentItem from './talentItem.vue'
- import FilterList from '@/components/FilterList'
- import { getPersonConditionSearchPage } from '@/api/search'
- import { dealDictArrayData } from '@/utils/position'
- import { timesTampChange, getTimeDifferenceInChinese } from '@/utils/date'
- // defineProps({ navbarHeight: [Number, String] })
- const query = ref({
- pageNo: 1,
- pageSize: 10
- })
- const params = ref({
- content: null,
- positionIds: [],
- areaIds: [],
- expType: '',
- eduType: ''
- })
- const items = ref([])
- const more = ref('more')
- const total = ref(0)
- const filterList = ref([
- { label: '职位', dictType: 'positionTreeData',key: 'positionId', map: { text: 'nameCn', value: 'id' } },
- { label: '城市', multiple: true, dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
- { label: '最高学历', dictType: 'menduner_education_type', key: 'eduType' },
- { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
- ])
- // 根据条件搜索人才
- const getTalentList = async () => {
- try {
- more.value = 'loading'
- const { data } = await getPersonConditionSearchPage(Object.assign(query.value, params.value))
- if (!data.list.length) {
- more.value = 'noMore'
- items.value = []
- total.value = 0
- return
- }
- const list = dealDictArrayData([], data.list).map(e => {
- if (e.workList?.length) {
- e.workList.forEach(exp => {
- exp.startTimeStr = exp.startTime ? timesTampChange(exp.startTime, 'Y-M') : '未填写工作时间'
- exp.endTimeStr = exp.startTime ? exp.endTime ? timesTampChange(exp.endTime, 'Y-M') : '至今' : ''
- exp.year = exp.endTimeStr ? getTimeDifferenceInChinese(exp.startTime, exp.endTime) : ''
- })
- e.workList = e.workList.splice(0, 2)
- }
- return e
- })
- items.value = items.value.concat(list)
- total.value = data.total
- if (items.value.length === +data.total) {
- more.value = 'noMore'
- return
- }
- } catch {
- query.value.pageNo--
- more.value = 'more'
- }
- }
- const checkValue = (obj) => {
- return Object.values(obj).some(value => {
- return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
- })
- }
- const handleSearch = (key, value) => {
- query.value.pageNo = 1
- params.value[key] = value
- if (!checkValue(params.value)) {
- uni.showToast({
- title: '请至少选择一个查询条件',
- icon: 'none',
- duration: 2000
- })
- more.value = 'noMore'
- items.value = []
- total.value = 0
- return
- }
- items.value = []
- total.value = 0
- getTalentList()
- }
- // 加载更多
- const loadingMore = () => {
- if (more.value === 'noMore') return
- more.value = 'loading'
- query.value.pageNo++
- getTalentList()
- }
- </script>
- <style scoped lang="scss">
- .noJobId {
- text-align: center;
- line-height: 60vh;
- color: #666;
- }
- .box {
- height: 100vh;
- overflow: hidden;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- }
- .scrollBox{
- flex: 1;
- padding-bottom: 100px;
- box-sizing: border-box;
- height: 0 !important;
- }
- // .stick {
- // z-index: 1;
- // position: sticky;
- // background-color: #fff;
- // }
- </style>
|