Kaynağa Gözat

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

Xiao_123 11 ay önce
ebeveyn
işleme
8f70fccb73

+ 10 - 11
src/components/industryTypeCard/index.vue

@@ -36,11 +36,14 @@
 <script setup>
 import { getDict } from '@/hooks/web/useDictionaries'
 import { ref } from 'vue'
-import { useRoute } from 'vue-router'
 import Snackbar from '@/plugins/snackbar'
 defineOptions({ name:'common-components-industryTypeCard'})
 const emits = defineEmits(['handleClickIndustry'])
 const props = defineProps({
+  limit: { // 限制最大可选择数量, 不限制传false或者0
+    type: [Number, Boolean],
+    default: 3
+  },
   select: {
     type: Array,
     default: () => []
@@ -55,33 +58,29 @@ const props = defineProps({
   }
 })
 
-const route = useRoute()
-const routeQuery = route?.query
-
 let items = ref()
 let idChecked = ref([])
 let currentSelect = ref([])
 
 // 回显
 if (props.currentData.length) currentSelect.value = props.currentData
-if (props.select.length) idChecked.value = props.select.map(e => Number(e))
+if (props.select.length) idChecked.value = props.select.map(e => e + '') // 数据中的id是字符串
 
 getDict('industryTreeData', null, 'industryTreeData').then(({ data }) => {
   data = data?.length && data || []
   items.value = data
 })
-if (routeQuery && routeQuery.industryIds) {
-  idChecked.value = routeQuery.industryIds.split('_')
-}
 
 // 设置选中ids
 const handleClick = (val) => {
-  const obj = idChecked.value.includes(val.id)
-  if (!obj) {
-    if (props.showSelect && currentSelect.value.length === 3) return Snackbar.warning('最多可选三个行业')
+  const isExist = idChecked.value.includes(val.id)
+  if (!isExist) {
+    // 添加
+    if (props.limit === idChecked.value.length) return Snackbar.warning(`最多可选${props.limit}个行业`)
     currentSelect.value.push(val)
     idChecked.value.push(val.id)
   } else {
+    // 删除
     currentSelect.value = currentSelect.value.filter(e => e.id !== val.id)
     idChecked.value = idChecked.value.filter(e => e !== val.id)
   }

+ 0 - 32
src/views/recruit/position/components/conditionFilter.vue

@@ -19,8 +19,6 @@ import payScope from './conditionFilter/payScope.vue'
 import educationType from './conditionFilter/educationType.vue'
 import scale from './conditionFilter/scale.vue'
 import financingStatus from './conditionFilter/financingStatus.vue'
-// import { reactive, defineExpose } from 'vue'
-// import { useRoute } from 'vue-router'
 defineOptions({name: 'retrieval-components-conditionFilter'})
 const emits = defineEmits(['change'])
 
@@ -28,34 +26,4 @@ const inputChange = (key, arr) => {
   const str = arr.length ? arr.join('_') : ''
   emits('change', key, str)
 }
-// const route = useRoute()
-
-// const removeEmptyStringsAndReturnNew = (obj) => {
-//   const result = {}
-//   Object.keys(obj).forEach(function(key) {
-//     if (obj[key]) {
-//       result[key] = obj[key]
-//     }
-//   })
-//   return result
-// }
- 
-// const params = reactive({})
-// let query = reactive({})
-
-// if (route.query?.content) {
-//   query['content'] = route.query.content
-//   emits('change')
-// }
-
-// const inputChange = (key, { values }) => {
-//   params[key] = values
-//   query[key] = Array.isArray(values) ? values.join('_') : values
-//   query = removeEmptyStringsAndReturnNew(query)
-//   emits('change', query.value)
-// }
-// const getQuery = () => {
-//   return query
-// }
-// defineExpose({ getQuery, params })
 </script>

+ 24 - 14
src/views/recruit/position/components/conditionFilter/companyIndustry.vue

@@ -1,30 +1,40 @@
 <template>
   <commonStyle :btnTitle="title" :close-on-content-click="false">
-    <industryTypeCard @handleClickIndustry="handleIndustry"></industryTypeCard>
+    <industryTypeCard :select="selectedItems" @handleClickIndustry="handle"></industryTypeCard>
   </commonStyle>
 </template>
 
 <script setup>
 import commonStyle from './commonStyle.vue'
 import industryTypeCard from '@/components/industryTypeCard'
+import { inject, ref } from 'vue'
 defineOptions({name: 'conditionFilter-company-industry'})
-import { ref } from 'vue'
-import { useRoute } from 'vue-router'
-
-const route = useRoute()
-const routeQuery = route?.query
-
 const emits = defineEmits(['inputChange'])
+const query = inject('routeQuery')
+const props = defineProps({
+  positionIndexPage: { // 职位检索
+    type: Boolean,
+    default: false
+  }
+})
+
 const title = ref('行业类型')
-if (routeQuery && routeQuery.industryIds) {
-  const arr = routeQuery.industryIds.split('_')
-  title.value = `行业类型(${arr.length})`
-  emits('inputChange', { values: arr, isEmit: true })
+const selectedItems = ref([])
+
+if (query && query.industryIds) {
+  const str = query.industryIds.split(',')[0]
+  const arr = str.split('_')
+  if (arr?.length) {
+    selectedItems.value = arr
+    title.value = selectedItems.value.length ? `行业类型(${selectedItems.value.length})` : '行业类型'
+  }
 }
 
-const handleIndustry = (val) => {
-  title.value = val.length ? `行业类型(${val.length})` : '行业类型'
-  emits('inputChange', { values: val, isEmit: true })
+const handle = (arr) => {
+  selectedItems.value = arr
+  title.value = selectedItems.value.length ? `行业类型(${selectedItems.value.length})` : '行业类型'
+  if (props.positionIndexPage) emits('inputChange', selectedItems.value)
+  else emits('inputChange', { values: selectedItems.value, isEmit: true })
 }
 </script>
 

+ 0 - 2
src/views/recruit/position/components/conditionFilter/expType.vue

@@ -57,7 +57,6 @@ const handle = (val) => {
   if (props.isSingle) {
     // 单选
     selectedItems.value = obj ? [] : [val]
-    // title.value = (obj || val === '2') ? '工作经验' : '工作经验(1)'
   } else {
     // 多选 
     if (obj) {
@@ -70,7 +69,6 @@ const handle = (val) => {
       // 当经验不限已存在时还选中其它项,把经验不限给清掉
       if (val !== '2' && selectedItems.value.find(k => k === '2')) selectedItems.value = selectedItems.value.filter(i => i !== '2')
     }
-    // title.value = val === '2' ? '工作经验' : (selectedItems.value.length ? `工作经验(${selectedItems.value.length})` : '工作经验')
   }
   title.value = selectedItems.value.length ? `工作经验(${selectedItems.value.length})` : '工作经验'
   if (props.positionIndexPage) emits('inputChange', selectedItems.value)

+ 6 - 31
src/views/recruit/position/index.vue

@@ -49,14 +49,10 @@ const cityFilterRef = ref(); const conditionFilterRef = ref()
 const pageInfo = { pageNo: 1, pageSize: 20}
 const items = ref([])
 const total = ref(0)
-// 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)
 
 const headSearchText = ref(routeQuery?.content || '')
-// let pageReqVO = reactive({
-//   ...pageInfo
-// })
 
 // 职位搜索
 const getData = async () => {
@@ -81,7 +77,7 @@ const getData = async () => {
       else pageReqVO[key] = routeQuery[key].split('_') // 传给后端Arr
     })
   }
-  // console.log('pageReqVO', pageReqVO)
+  // console.log('getData参数pageReqVO', pageReqVO)
   const { list, total: number } = await getJobAdvertisedSearch(pageReqVO)
   items.value = list.map(e => {
     e.job = { ...e.job, ...dealDictObjData({}, e.job) }
@@ -90,47 +86,26 @@ const getData = async () => {
   })
   total.value = number
 }
-getData()
 
-// 刷新路由
+// 页面刷新
+if (routeQuery && Object.keys(routeQuery).length) getData() 
+
+// 参数改变后刷新路由,触发数据刷新
 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 handleQueryChange = (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 }
-//   pageReqVO = { ...pageReqVO }
-//   getData()
-// }
-
-
-// // 刷新后有参数则进行搜索
-// 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) handleQueryChange(routeQuery.content, 'content')
-//   getData()
-// } else getData()
-
 // 分页
 const handleChangePage = (index) => {
   pageInfo.pageNo = index