lifanagju_citu 11 місяців тому
батько
коміт
6963c1f2bd

+ 1 - 8
src/components/industryTypeCard/index.vue

@@ -36,7 +36,6 @@
 <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'])
@@ -59,24 +58,18 @@ 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) => {

+ 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>