Xiao_123 11 kuukautta sitten
vanhempi
commit
36c0c7ba1f

+ 15 - 15
src/components/industryTypeCard/index.vue

@@ -35,8 +35,8 @@
 
 <script setup>
 import { getDict } from '@/hooks/web/useDictionaries'
-import { reactive, ref } from 'vue';
-import { useRoute } from 'vue-router';
+import { ref } from 'vue'
+import { useRoute } from 'vue-router'
 import Snackbar from '@/plugins/snackbar'
 defineOptions({ name:'common-components-industryTypeCard'})
 const emits = defineEmits(['handleClickIndustry'])
@@ -59,33 +59,33 @@ const route = useRoute()
 const routeQuery = route?.query
 
 let items = ref()
-let idChecked = reactive([])
-let currentSelect = reactive([])
+let idChecked = ref([])
+let currentSelect = ref([])
 
 // 回显
-if (props.currentData.length) currentSelect = props.currentData
-if (props.select.length) idChecked = props.select.map(e => Number(e))
+if (props.currentData.length) currentSelect.value = props.currentData
+if (props.select.length) idChecked.value = props.select.map(e => Number(e))
 
 getDict('industryTreeData', null, 'industryTreeData').then(({ data }) => {
   data = data?.length && data || []
   items.value = data
 })
 if (routeQuery && routeQuery.industryIds) {
-  idChecked = routeQuery.industryIds.split('_').map(e => Number(e))
+  idChecked.value = routeQuery.industryIds.split('_')
 }
 
 // 设置选中ids
 const handleClick = (val) => {
-  const findIndex = idChecked?.length ? idChecked.findIndex(j => j === val.id) : -1
-  if (findIndex === -1) {
-    if (props.showSelect && currentSelect.length === 3) return Snackbar.warning('最多可选三个行业')
-    currentSelect.push(val)
-    idChecked.push(val.id) // 添加
+  const obj = idChecked.value.includes(val.id)
+  if (!obj) {
+    if (props.showSelect && currentSelect.value.length === 3) return Snackbar.warning('最多可选三个行业')
+    currentSelect.value.push(val)
+    idChecked.value.push(val.id)
   } else {
-    currentSelect.splice(findIndex, 1)
-    idChecked.splice(findIndex, 1) // 删除  
+    currentSelect.value = currentSelect.value.filter(e => e.id !== val.id)
+    idChecked.value = idChecked.value.filter(e => e !== val.id)
   }
-  emits('handleClickIndustry', idChecked, currentSelect)
+  emits('handleClickIndustry', idChecked.value, currentSelect.value)
 }
 </script>
 

+ 2 - 1
src/components/jobTypeCard/index.vue

@@ -150,7 +150,8 @@ const handleMouseOver = (val, index) => { // 鼠标移入
   rightObj.data = val
   // 回显
   if (routeQuery && routeQuery.positionId) {
-    selectItems.value = routeQuery.positionId.split('_').map(e => Number(e))
+    if (props.isSingle) selectItems.value = [routeQuery.positionId]
+    else selectItems.value = routeQuery.positionId.split('_')
   }
   rightObj.show = true
 }

+ 1 - 1
src/views/recruit/position/components/conditionFilter.vue

@@ -45,7 +45,7 @@ if (route.query?.content) {
 
 const inputChange = (key, { values, isEmit}) => {
   params[key] = values
-  query[key] = values.join('_')
+  query[key] = Array.isArray(values) ? values.join('_') : values
   query = removeEmptyStringsAndReturnNew(query)
   if (isEmit) emits('conditionFilterChange', query.value)
 }

+ 6 - 6
src/views/recruit/position/components/conditionFilter/positionType.vue

@@ -1,6 +1,6 @@
 <template>
-  <commonStyle :btnTitle="title" :close-on-content-click="false">
-    <jobTypeCard @handleJobClick="handleClick"></jobTypeCard>
+  <commonStyle :btnTitle="title">
+    <jobTypeCard :isSingle="true" @handleJobClick="handleClick"></jobTypeCard>
   </commonStyle>
 </template>
 
@@ -15,16 +15,16 @@ const emits = defineEmits(['inputChange'])
 const title = ref('职位类型')
 
 const handleClick = (val) => {
-  title.value = val.length ? `职位类型(${val.length})` : '职位类型'
-  emits('inputChange', { values: val, isEmit: true })
+  title.value = val.length ? `职位类型(1)` : '职位类型'
+  emits('inputChange', { values: val.length ? val[0] : '', isEmit: true })
 }
 
 const route = useRoute()
 const routeQuery = route?.query
 
 if (routeQuery && routeQuery.positionId) {
-  const arr = routeQuery.positionId.split('_')
-  title.value = `职位类型(${arr.length})`
+  const arr = routeQuery.positionId
+  title.value = `职位类型(1)`
   if (arr.length) emits('inputChange', { values: arr, isEmit: true })
 }
 </script>

+ 12 - 9
src/views/recruit/position/index.vue

@@ -9,8 +9,8 @@
           @handleSearch="val => dealParams(val, 'content')"
         ></headSearch>
       </div>
-      <cityFilter class="mx-5 mb-3" ref="cityFilterRef" @updateCheckedInput="updateRouteQuery('cityFilterRef')"></cityFilter>
-      <conditionFilter class="mx-5 mb-3" ref="conditionFilterRef" @conditionFilterChange="updateRouteQuery('conditionFilterRef')"></conditionFilter>
+      <cityFilter class="mx-5 mb-3" ref="cityFilterRef" @updateCheckedInput="handleMounted"></cityFilter>
+      <conditionFilter class="mx-5 mb-3" ref="conditionFilterRef" @conditionFilterChange="handleMounted"></conditionFilter>
     </v-card>
     <div class="d-flex mt-3">
       <div class="mr-3" style="min-width: 884px;">
@@ -38,7 +38,7 @@ import PositionLongStrip from '@/components/PositionLongStrip/item.vue'
 import Empty from '@/components/Empty'
 import { getJobAdvertisedSearch } from '@/api/position'
 import CtPagination from '@/components/CtPagination'
-import { provide, reactive, ref } from 'vue'
+import { provide, reactive, ref, nextTick } from 'vue'
 import { dealDictData } from '@/views/recruit/position/components/dict'
 
 import { useRoute, useRouter } from 'vue-router'
@@ -76,9 +76,7 @@ const removeEmptyStringsAndReturnNew = (obj) => {
   })
   return result
 }
-
-const updateRouteQuery = (ref, val, key) => {
-  ref
+const updateRouteQuery = (val, key) => {
   const queryObj = { cityFilter: {}, conditionFilter: {} }
   if (cityFilterRef.value?.getQuery) {
     queryObj.cityFilter = removeEmptyStringsAndReturnNew(cityFilterRef.value?.getQuery())
@@ -105,6 +103,12 @@ const updateRouteQuery = (ref, val, key) => {
   handleSearchPosition(val, key)
 }
 
+const handleMounted = (key, val) => {
+  nextTick(() => {
+    updateRouteQuery(key, val)
+  })
+}
+
 // 职位搜索
 const handleSearchPosition = () => {
   const conditionParams = conditionFilterRef.value?.params
@@ -116,8 +120,7 @@ const handleSearchPosition = () => {
 // 职位类型、关键字
 const dealParams = (val, key) => {
   pageReqVO[key] = val
-  updateRouteQuery('cityFilterRef')
-  updateRouteQuery('conditionFilterRef', val, key)
+  handleMounted(val, key)
 }
 
 // 刷新后有参数则进行搜索
@@ -126,7 +129,7 @@ if (routeQuery) {
     if (routeQuery[i].indexOf('_') !== -1) pageReqVO[i] = routeQuery[i].split('_')
     else pageReqVO[i] = routeQuery[i]
   }
-  if (routeQuery.content) updateRouteQuery('conditionFilterRef', routeQuery.content, 'content')
+  if (routeQuery.content) handleMounted(routeQuery.content, 'content')
   getPositionList()
 } else getPositionList()