|
@@ -3,13 +3,14 @@
|
|
<div class="default-width">
|
|
<div class="default-width">
|
|
<div class="py-3" style="z-index: 998; background-color: #fff">
|
|
<div class="py-3" style="z-index: 998; background-color: #fff">
|
|
<div class="stickyBox">
|
|
<div class="stickyBox">
|
|
- <headSearch
|
|
|
|
- @handleJobClick="val => dealParams(val, 'positionId')"
|
|
|
|
- @handleSearch="val => dealParams(val, 'content')"
|
|
|
|
|
|
+ <headSearch
|
|
|
|
+ v-model="headSearchText"
|
|
|
|
+ text="中国"
|
|
|
|
+ @handleSearch="val => handleMounted('content', val)"
|
|
></headSearch>
|
|
></headSearch>
|
|
</div>
|
|
</div>
|
|
- <cityFilter class="mx-5 mb-3" ref="cityFilterRef" @updateCheckedInput="handleMounted"></cityFilter>
|
|
|
|
- <conditionFilter class="mx-5 mb-3" ref="conditionFilterRef" @conditionFilterChange="handleMounted"></conditionFilter>
|
|
|
|
|
|
+ <cityFilter class="mx-5 mb-3" ref="cityFilterRef" @change="handleMounted"></cityFilter>
|
|
|
|
+ <conditionFilter class="mx-5 mb-3" ref="conditionFilterRef" @change="handleMounted"></conditionFilter>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex mt-3">
|
|
<div class="d-flex mt-3">
|
|
<div class="mr-3" style="min-width: 884px;">
|
|
<div class="mr-3" style="min-width: 884px;">
|
|
@@ -37,7 +38,7 @@ import PositionLongStrip from '@/components/PositionLongStrip/item.vue'
|
|
import Empty from '@/components/Empty'
|
|
import Empty from '@/components/Empty'
|
|
import { getJobAdvertisedSearch } from '@/api/position'
|
|
import { getJobAdvertisedSearch } from '@/api/position'
|
|
import CtPagination from '@/components/CtPagination'
|
|
import CtPagination from '@/components/CtPagination'
|
|
-import { provide, reactive, ref, nextTick } from 'vue'
|
|
|
|
|
|
+import { provide, reactive, ref } from 'vue'
|
|
import { dealDictObjData } from '@/views/recruit/position/components/dict'
|
|
import { dealDictObjData } from '@/views/recruit/position/components/dict'
|
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
@@ -48,15 +49,39 @@ const cityFilterRef = ref(); const conditionFilterRef = ref()
|
|
const pageInfo = { pageNo: 1, pageSize: 20}
|
|
const pageInfo = { pageNo: 1, pageSize: 20}
|
|
const items = ref([])
|
|
const items = ref([])
|
|
const total = ref(0)
|
|
const total = ref(0)
|
|
-const routeQuery = (route?.query && route.query && Object.keys(route?.query).length) ? route.query : null
|
|
|
|
|
|
+// const routeQuery = (route?.query && route.query && Object.keys(route?.query).length) ? route.query : null
|
|
|
|
+let routeQuery = (route?.query && route.query && Object.keys(route?.query).length) ? reactive(route.query) : reactive({})
|
|
provide('routeQuery', routeQuery)
|
|
provide('routeQuery', routeQuery)
|
|
|
|
|
|
-let pageReqVO = reactive({
|
|
|
|
- ...pageInfo
|
|
|
|
-})
|
|
|
|
|
|
+const headSearchText = ref(routeQuery?.content || '')
|
|
|
|
+// let pageReqVO = reactive({
|
|
|
|
+// ...pageInfo
|
|
|
|
+// })
|
|
|
|
|
|
// 职位搜索
|
|
// 职位搜索
|
|
-const getPositionList = async () => {
|
|
|
|
|
|
+const getData = async () => {
|
|
|
|
+ const pageReqVO = { ...pageInfo }
|
|
|
|
+ // route.query参数
|
|
|
|
+ if (routeQuery && Object.keys(routeQuery).length) {
|
|
|
|
+ const passingStrings = ['content'] // 传递字符串
|
|
|
|
+ Object.keys(routeQuery).forEach(key => {
|
|
|
|
+ if (key === 'city') { // 工作地区id集合,示例值([])
|
|
|
|
+ const city = routeQuery[key]
|
|
|
|
+ const areaIds = []
|
|
|
|
+ const levelCountArr = city.split('__')
|
|
|
|
+ levelCountArr?.forEach(levelIds => {
|
|
|
|
+ const idArr = levelIds.split('_')
|
|
|
|
+ if (idArr?.length) {
|
|
|
|
+ idArr.forEach(idItem => areaIds.push(idItem))
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ pageReqVO.areaIds = areaIds
|
|
|
|
+ }
|
|
|
|
+ else if (passingStrings.includes(key)) pageReqVO[key] = routeQuery[key] // 传给后端字符串
|
|
|
|
+ else pageReqVO[key] = routeQuery[key].split('_') // 传给后端Arr
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ // console.log('pageReqVO', pageReqVO)
|
|
const { list, total: number } = await getJobAdvertisedSearch(pageReqVO)
|
|
const { list, total: number } = await getJobAdvertisedSearch(pageReqVO)
|
|
items.value = list.map(e => {
|
|
items.value = list.map(e => {
|
|
e.job = { ...e.job, ...dealDictObjData({}, e.job) }
|
|
e.job = { ...e.job, ...dealDictObjData({}, e.job) }
|
|
@@ -65,76 +90,50 @@ const getPositionList = async () => {
|
|
})
|
|
})
|
|
total.value = number
|
|
total.value = number
|
|
}
|
|
}
|
|
|
|
+getData()
|
|
|
|
|
|
-const removeEmptyStringsAndReturnNew = (obj) => {
|
|
|
|
- const result = {}
|
|
|
|
- Object.keys(obj).forEach(function(key) {
|
|
|
|
- if (obj[key]) {
|
|
|
|
- result[key] = obj[key]
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- return result
|
|
|
|
-}
|
|
|
|
-const updateRouteQuery = (val, key) => {
|
|
|
|
- const queryObj = { cityFilter: {}, conditionFilter: {} }
|
|
|
|
- if (cityFilterRef.value?.getQuery) {
|
|
|
|
- queryObj.cityFilter = removeEmptyStringsAndReturnNew(cityFilterRef.value?.getQuery())
|
|
|
|
- }
|
|
|
|
- if (conditionFilterRef.value?.getQuery) {
|
|
|
|
- const objData = conditionFilterRef.value?.getQuery()
|
|
|
|
- if (val && key) objData[key] = val
|
|
|
|
- queryObj.conditionFilter = removeEmptyStringsAndReturnNew(objData)
|
|
|
|
- }
|
|
|
|
- let queryArr = []
|
|
|
|
- if (queryObj) {
|
|
|
|
- Object.keys(queryObj)?.forEach(_k => {
|
|
|
|
- const newObj = queryObj[_k]
|
|
|
|
- if (newObj) {
|
|
|
|
- const arr = Object.keys(newObj).map(itemKey => {
|
|
|
|
- return `${itemKey}=${newObj[itemKey]}`
|
|
|
|
- })
|
|
|
|
- if (arr?.length) queryArr = [ ...queryArr, ...arr]
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- const str = queryArr?.join('&')
|
|
|
|
- if (str) router.push(`${route.path}?${str}`)
|
|
|
|
- handleSearchPosition(val, key)
|
|
|
|
|
|
+// 刷新路由
|
|
|
|
+const updateRouter = () => {
|
|
|
|
+ const str = Object.keys(routeQuery).length ? Object.keys(routeQuery).reduce((res, _key) => {
|
|
|
|
+ if (routeQuery[_key] !== '') res += `${res ? '&' : ''}${_key}=${routeQuery[_key]}`
|
|
|
|
+ return res
|
|
|
|
+ }, '') : ''
|
|
|
|
+ // console.log('route.path', str)
|
|
|
|
+ // const str1 = "city=1__140000__140300__140321_140322_140303&jobType=1_3_0"
|
|
|
|
+ router.push(`${route.path}?${str}`)
|
|
|
|
+ // router.push(`${route.path}?${str1}`)
|
|
|
|
+ getData()
|
|
}
|
|
}
|
|
|
|
|
|
-const handleMounted = (key, val) => {
|
|
|
|
- nextTick(() => {
|
|
|
|
- updateRouteQuery(key, val)
|
|
|
|
- })
|
|
|
|
|
|
+const handleMounted = (key, val) => { // val为字符串,数组的话用_下划线分隔
|
|
|
|
+ routeQuery[key] = val
|
|
|
|
+ // console.log('routeQuery', key, val)
|
|
|
|
+ updateRouter()
|
|
}
|
|
}
|
|
|
|
|
|
-// 职位搜索
|
|
|
|
-const handleSearchPosition = () => {
|
|
|
|
- const conditionParams = conditionFilterRef.value?.params
|
|
|
|
- const cityParams = cityFilterRef.value?.getQuery
|
|
|
|
- pageReqVO = { ...pageReqVO, ...conditionParams, ...cityParams, content: pageReqVO.content }
|
|
|
|
- getPositionList()
|
|
|
|
-}
|
|
|
|
|
|
+// // 职位搜索
|
|
|
|
+// const handleSearchPosition = () => {
|
|
|
|
+// // const conditionParams = conditionFilterRef.value?.params
|
|
|
|
+// // const cityParams = cityFilterRef.value?.getQuery
|
|
|
|
+// // pageReqVO = { ...pageReqVO, ...conditionParams, ...cityParams, content: pageReqVO.content }
|
|
|
|
+// pageReqVO = { ...pageReqVO }
|
|
|
|
+// getData()
|
|
|
|
+// }
|
|
|
|
|
|
-// 职位类型、关键字
|
|
|
|
-const dealParams = (val, key) => {
|
|
|
|
- pageReqVO[key] = val
|
|
|
|
- handleMounted(val, key)
|
|
|
|
-}
|
|
|
|
|
|
|
|
-// 刷新后有参数则进行搜索
|
|
|
|
-if (routeQuery) {
|
|
|
|
- for (let i in routeQuery) {
|
|
|
|
- if (routeQuery[i].indexOf('_') !== -1) pageReqVO[i] = routeQuery[i].split('_')
|
|
|
|
- else pageReqVO[i] = routeQuery[i]
|
|
|
|
- }
|
|
|
|
- if (routeQuery.content) handleMounted(routeQuery.content, 'content')
|
|
|
|
- getPositionList()
|
|
|
|
-} else getPositionList()
|
|
|
|
|
|
+// // 刷新后有参数则进行搜索
|
|
|
|
+// if (routeQuery) {
|
|
|
|
+// for (let i in routeQuery) {
|
|
|
|
+// if (routeQuery[i].indexOf('_') !== -1) pageReqVO[i] = routeQuery[i].split('_')
|
|
|
|
+// else pageReqVO[i] = routeQuery[i]
|
|
|
|
+// }
|
|
|
|
+// if (routeQuery.content) handleMounted(routeQuery.content, 'content')
|
|
|
|
+// getData()
|
|
|
|
+// } else getData()
|
|
|
|
|
|
// 分页
|
|
// 分页
|
|
const handleChangePage = (index) => {
|
|
const handleChangePage = (index) => {
|
|
pageInfo.pageNo = index
|
|
pageInfo.pageNo = index
|
|
- getPositionList()
|
|
|
|
|
|
+ getData()
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|